aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Data
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')
-rw-r--r--OpenSim/Data/AssetDataBase.cs2
-rw-r--r--OpenSim/Data/DBGuids.cs2
-rw-r--r--OpenSim/Data/IAssetData.cs2
-rw-r--r--OpenSim/Data/IAvatarData.cs2
-rw-r--r--OpenSim/Data/IEstateDataStore.cs16
-rw-r--r--OpenSim/Data/IGridUserData.cs2
-rw-r--r--OpenSim/Data/IGroupsData.cs2
-rw-r--r--OpenSim/Data/IHGTravelingData.cs2
-rw-r--r--OpenSim/Data/IMuteListData.cs44
-rw-r--r--OpenSim/Data/IOfflineIMData.cs2
-rw-r--r--OpenSim/Data/IPresenceData.cs2
-rw-r--r--OpenSim/Data/IProfilesData.cs2
-rw-r--r--OpenSim/Data/IRegionData.cs2
-rw-r--r--OpenSim/Data/IUserAccountData.cs1
-rw-r--r--OpenSim/Data/IXGroupData.cs6
-rw-r--r--OpenSim/Data/Migration.cs26
-rw-r--r--OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs112
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs58
-rw-r--r--OpenSim/Data/MySQL/MySQLAvatarData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs26
-rw-r--r--OpenSim/Data/MySQL/MySQLFSAssetData.cs397
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs60
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs184
-rw-r--r--OpenSim/Data/MySQL/MySQLGroupsData.cs23
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs26
-rw-r--r--OpenSim/Data/MySQL/MySQLMigrations.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLMuteListData.cs67
-rw-r--r--OpenSim/Data/MySQL/MySQLOfflineIMData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs78
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs710
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs40
-rw-r--r--OpenSim/Data/MySQL/MySQLUserProfilesData.cs588
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs113
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs16
-rw-r--r--OpenSim/Data/MySQL/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/MySQL/Resources/AgentPrefs.migrations2
-rw-r--r--OpenSim/Data/MySQL/Resources/AssetStore.migrations76
-rw-r--r--OpenSim/Data/MySQL/Resources/AuthStore.migrations37
-rw-r--r--OpenSim/Data/MySQL/Resources/Avatar.migrations23
-rw-r--r--OpenSim/Data/MySQL/Resources/EstateStore.migrations80
-rw-r--r--OpenSim/Data/MySQL/Resources/FSAssetStore.migrations2
-rw-r--r--OpenSim/Data/MySQL/Resources/FriendsStore.migrations36
-rw-r--r--OpenSim/Data/MySQL/Resources/GridStore.migrations141
-rw-r--r--OpenSim/Data/MySQL/Resources/GridUserStore.migrations2
-rw-r--r--OpenSim/Data/MySQL/Resources/HGTravelStore.migrations2
-rw-r--r--OpenSim/Data/MySQL/Resources/IM_Store.migrations46
-rw-r--r--OpenSim/Data/MySQL/Resources/InventoryStore.migrations143
-rw-r--r--OpenSim/Data/MySQL/Resources/LogStore.migrations2
-rw-r--r--OpenSim/Data/MySQL/Resources/MuteListStore.migrations16
-rw-r--r--OpenSim/Data/MySQL/Resources/Presence.migrations37
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations1183
-rw-r--r--OpenSim/Data/MySQL/Resources/UserAccount.migrations56
-rw-r--r--OpenSim/Data/MySQL/Resources/UserProfiles.migrations28
-rw-r--r--OpenSim/Data/MySQL/Resources/UserStore.migrations168
-rw-r--r--OpenSim/Data/MySQL/Resources/XAssetStore.migrations4
-rw-r--r--OpenSim/Data/MySQL/Resources/XMute.migrations16
-rw-r--r--OpenSim/Data/MySQL/Resources/os_groups_Store.migrations14
-rwxr-xr-x[-rw-r--r--]OpenSim/Data/Null/NullEstateData.cs6
-rw-r--r--OpenSim/Data/Null/NullFriendsData.cs10
-rw-r--r--OpenSim/Data/Null/NullPresenceData.cs8
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs20
-rw-r--r--OpenSim/Data/Null/NullSimulationData.cs22
-rw-r--r--OpenSim/Data/Null/NullUserAccountData.cs37
-rw-r--r--OpenSim/Data/Null/Properties/AssemblyInfo.cs2
-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
-rw-r--r--OpenSim/Data/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/SQLite/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/SQLite/Resources/AgentPrefs.migrations2
-rw-r--r--OpenSim/Data/SQLite/Resources/AssetStore.migrations71
-rw-r--r--OpenSim/Data/SQLite/Resources/EstateStore.migrations68
-rw-r--r--OpenSim/Data/SQLite/Resources/InventoryStore.migrations92
-rw-r--r--OpenSim/Data/SQLite/Resources/RegionStore.migrations549
-rw-r--r--OpenSim/Data/SQLite/Resources/UserAccount.migrations8
-rw-r--r--OpenSim/Data/SQLite/Resources/UserProfiles.migrations2
-rw-r--r--OpenSim/Data/SQLite/Resources/UserStore.migrations169
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs12
-rw-r--r--OpenSim/Data/SQLite/SQLiteAuthenticationData.cs6
-rw-r--r--OpenSim/Data/SQLite/SQLiteEstateData.cs12
-rw-r--r--OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs4
-rw-r--r--OpenSim/Data/SQLite/SQLiteGridUserData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteHGTravelData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteInventoryStore.cs916
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs158
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserAccountData.cs7
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserProfilesData.cs165
-rw-r--r--OpenSim/Data/SQLite/SQLiteUtils.cs6
-rw-r--r--OpenSim/Data/SQLite/SQLiteXInventoryData.cs14
-rw-r--r--OpenSim/Data/Tests/AssetTests.cs24
-rw-r--r--OpenSim/Data/Tests/BasicDataServiceTest.cs14
-rw-r--r--OpenSim/Data/Tests/DefaultTestConns.cs10
-rw-r--r--OpenSim/Data/Tests/EstateTests.cs18
-rw-r--r--OpenSim/Data/Tests/InventoryTests.cs33
-rw-r--r--OpenSim/Data/Tests/PropertyScrambler.cs2
-rw-r--r--OpenSim/Data/Tests/RegionTests.cs161
-rw-r--r--OpenSim/Data/Tests/Resources/TestDataConnections.ini4
125 files changed, 3885 insertions, 5111 deletions
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs
index 1bb432c..9593a25 100644
--- a/OpenSim/Data/AssetDataBase.cs
+++ b/OpenSim/Data/AssetDataBase.cs
@@ -37,7 +37,7 @@ namespace OpenSim.Data
37 public abstract class AssetDataBase : IAssetDataPlugin 37 public abstract class AssetDataBase : IAssetDataPlugin
38 { 38 {
39 public abstract AssetBase GetAsset(UUID uuid); 39 public abstract AssetBase GetAsset(UUID uuid);
40 public abstract void StoreAsset(AssetBase asset); 40 public abstract bool StoreAsset(AssetBase asset);
41 public abstract bool[] AssetsExist(UUID[] uuids); 41 public abstract bool[] AssetsExist(UUID[] uuids);
42 42
43 public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count); 43 public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
diff --git a/OpenSim/Data/DBGuids.cs b/OpenSim/Data/DBGuids.cs
index ad1c19c..1a2bf41 100644
--- a/OpenSim/Data/DBGuids.cs
+++ b/OpenSim/Data/DBGuids.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Data
38 /// <summary>This function converts a value returned from the database in one of the 38 /// <summary>This function converts a value returned from the database in one of the
39 /// supported formats into a UUID. This function is not actually DBMS-specific right 39 /// supported formats into a UUID. This function is not actually DBMS-specific right
40 /// now 40 /// now
41 /// 41 ///
42 /// </summary> 42 /// </summary>
43 /// <param name="id"></param> 43 /// <param name="id"></param>
44 /// <returns></returns> 44 /// <returns></returns>
diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs
index a41e310..febab5d 100644
--- a/OpenSim/Data/IAssetData.cs
+++ b/OpenSim/Data/IAssetData.cs
@@ -34,7 +34,7 @@ namespace OpenSim.Data
34 public interface IAssetDataPlugin : IPlugin 34 public interface IAssetDataPlugin : IPlugin
35 { 35 {
36 AssetBase GetAsset(UUID uuid); 36 AssetBase GetAsset(UUID uuid);
37 void StoreAsset(AssetBase asset); 37 bool StoreAsset(AssetBase asset);
38 bool[] AssetsExist(UUID[] uuids); 38 bool[] AssetsExist(UUID[] uuids);
39 List<AssetMetadata> FetchAssetMetadataSet(int start, int count); 39 List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
40 void Initialise(string connect); 40 void Initialise(string connect);
diff --git a/OpenSim/Data/IAvatarData.cs b/OpenSim/Data/IAvatarData.cs
index 0a18e21..b3f12c1 100644
--- a/OpenSim/Data/IAvatarData.cs
+++ b/OpenSim/Data/IAvatarData.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Data
39 public Dictionary<string, string> Data; 39 public Dictionary<string, string> Data;
40 } 40 }
41 41
42 public interface IAvatarData 42 public interface IAvatarData
43 { 43 {
44 AvatarBaseData[] Get(string field, string val); 44 AvatarBaseData[] Get(string field, string val);
45 bool Store(AvatarBaseData data); 45 bool Store(AvatarBaseData data);
diff --git a/OpenSim/Data/IEstateDataStore.cs b/OpenSim/Data/IEstateDataStore.cs
index f9070ea..6b30db2 100644
--- a/OpenSim/Data/IEstateDataStore.cs
+++ b/OpenSim/Data/IEstateDataStore.cs
@@ -46,14 +46,14 @@ namespace OpenSim.Data
46 /// <param name="create">If true, then an estate is created if one is not found.</param> 46 /// <param name="create">If true, then an estate is created if one is not found.</param>
47 /// <returns></returns> 47 /// <returns></returns>
48 EstateSettings LoadEstateSettings(UUID regionID, bool create); 48 EstateSettings LoadEstateSettings(UUID regionID, bool create);
49 49
50 /// <summary> 50 /// <summary>
51 /// Load estate settings for an estate ID. 51 /// Load estate settings for an estate ID.
52 /// </summary> 52 /// </summary>
53 /// <param name="estateID"></param> 53 /// <param name="estateID"></param>
54 /// <returns></returns> 54 /// <returns></returns>
55 EstateSettings LoadEstateSettings(int estateID); 55 EstateSettings LoadEstateSettings(int estateID);
56 56
57 /// <summary> 57 /// <summary>
58 /// Create a new estate. 58 /// Create a new estate.
59 /// </summary> 59 /// </summary>
@@ -67,7 +67,7 @@ namespace OpenSim.Data
67 /// </summary> 67 /// </summary>
68 /// <returns>An empty list if no estates were found.</returns> 68 /// <returns>An empty list if no estates were found.</returns>
69 List<EstateSettings> LoadEstateSettingsAll(); 69 List<EstateSettings> LoadEstateSettingsAll();
70 70
71 /// <summary> 71 /// <summary>
72 /// Store estate settings. 72 /// Store estate settings.
73 /// </summary> 73 /// </summary>
@@ -75,7 +75,7 @@ namespace OpenSim.Data
75 /// This is also called by EstateSettings.Save()</remarks> 75 /// This is also called by EstateSettings.Save()</remarks>
76 /// <param name="es"></param> 76 /// <param name="es"></param>
77 void StoreEstateSettings(EstateSettings es); 77 void StoreEstateSettings(EstateSettings es);
78 78
79 /// <summary> 79 /// <summary>
80 /// Get estate IDs. 80 /// Get estate IDs.
81 /// </summary> 81 /// </summary>
@@ -88,13 +88,13 @@ namespace OpenSim.Data
88 /// </summary> 88 /// </summary>
89 /// <returns>An empty list if no estates were found.</returns> 89 /// <returns>An empty list if no estates were found.</returns>
90 List<int> GetEstatesByOwner(UUID ownerID); 90 List<int> GetEstatesByOwner(UUID ownerID);
91 91
92 /// <summary> 92 /// <summary>
93 /// Get the IDs of all estates. 93 /// Get the IDs of all estates.
94 /// </summary> 94 /// </summary>
95 /// <returns>An empty list if no estates were found.</returns> 95 /// <returns>An empty list if no estates were found.</returns>
96 List<int> GetEstatesAll(); 96 List<int> GetEstatesAll();
97 97
98 /// <summary> 98 /// <summary>
99 /// Link a region to an estate. 99 /// Link a region to an estate.
100 /// </summary> 100 /// </summary>
@@ -102,14 +102,14 @@ namespace OpenSim.Data
102 /// <param name="estateID"></param> 102 /// <param name="estateID"></param>
103 /// <returns>true if the link succeeded, false otherwise</returns> 103 /// <returns>true if the link succeeded, false otherwise</returns>
104 bool LinkRegion(UUID regionID, int estateID); 104 bool LinkRegion(UUID regionID, int estateID);
105 105
106 /// <summary> 106 /// <summary>
107 /// Get the UUIDs of all the regions in an estate. 107 /// Get the UUIDs of all the regions in an estate.
108 /// </summary> 108 /// </summary>
109 /// <param name="estateID"></param> 109 /// <param name="estateID"></param>
110 /// <returns></returns> 110 /// <returns></returns>
111 List<UUID> GetRegions(int estateID); 111 List<UUID> GetRegions(int estateID);
112 112
113 /// <summary> 113 /// <summary>
114 /// Delete an estate 114 /// Delete an estate
115 /// </summary> 115 /// </summary>
diff --git a/OpenSim/Data/IGridUserData.cs b/OpenSim/Data/IGridUserData.cs
index 9afa477..1b2ea87 100644
--- a/OpenSim/Data/IGridUserData.cs
+++ b/OpenSim/Data/IGridUserData.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Data
47 /// <summary> 47 /// <summary>
48 /// An interface for connecting to the user grid datastore 48 /// An interface for connecting to the user grid datastore
49 /// </summary> 49 /// </summary>
50 public interface IGridUserData 50 public interface IGridUserData
51 { 51 {
52 GridUserData Get(string userID); 52 GridUserData Get(string userID);
53 GridUserData[] GetAll(string query); 53 GridUserData[] GetAll(string query);
diff --git a/OpenSim/Data/IGroupsData.cs b/OpenSim/Data/IGroupsData.cs
index c11e649..bd059e0 100644
--- a/OpenSim/Data/IGroupsData.cs
+++ b/OpenSim/Data/IGroupsData.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Data
81 } 81 }
82 82
83 83
84 public interface IGroupsData 84 public interface IGroupsData
85 { 85 {
86 // groups table 86 // groups table
87 bool StoreGroup(GroupData data); 87 bool StoreGroup(GroupData data);
diff --git a/OpenSim/Data/IHGTravelingData.cs b/OpenSim/Data/IHGTravelingData.cs
index 452af7b..5e4894e 100644
--- a/OpenSim/Data/IHGTravelingData.cs
+++ b/OpenSim/Data/IHGTravelingData.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Data
48 /// <summary> 48 /// <summary>
49 /// An interface for connecting to the user grid datastore 49 /// An interface for connecting to the user grid datastore
50 /// </summary> 50 /// </summary>
51 public interface IHGTravelingData 51 public interface IHGTravelingData
52 { 52 {
53 HGTravelingData Get(UUID sessionID); 53 HGTravelingData Get(UUID sessionID);
54 HGTravelingData[] GetSessions(UUID userID); 54 HGTravelingData[] GetSessions(UUID userID);
diff --git a/OpenSim/Data/IMuteListData.cs b/OpenSim/Data/IMuteListData.cs
new file mode 100644
index 0000000..b0235b2
--- /dev/null
+++ b/OpenSim/Data/IMuteListData.cs
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Data
34{
35 /// <summary>
36 /// An interface for connecting to the Mute List datastore
37 /// </summary>
38 public interface IMuteListData
39 {
40 bool Store(MuteData data);
41 MuteData[] Get(UUID agentID);
42 bool Delete(UUID agentID, UUID muteID, string muteName);
43 }
44}
diff --git a/OpenSim/Data/IOfflineIMData.cs b/OpenSim/Data/IOfflineIMData.cs
index 58501a3..a0f4d69 100644
--- a/OpenSim/Data/IOfflineIMData.cs
+++ b/OpenSim/Data/IOfflineIMData.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Data
39 } 39 }
40 40
41 41
42 public interface IOfflineIMData 42 public interface IOfflineIMData
43 { 43 {
44 OfflineIMData[] Get(string field, string val); 44 OfflineIMData[] Get(string field, string val);
45 long GetCount(string field, string key); 45 long GetCount(string field, string key);
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
index 9ec48b0..4086245 100644
--- a/OpenSim/Data/IPresenceData.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Data
44 /// <summary> 44 /// <summary>
45 /// An interface for connecting to the presence datastore 45 /// An interface for connecting to the presence datastore
46 /// </summary> 46 /// </summary>
47 public interface IPresenceData 47 public interface IPresenceData
48 { 48 {
49 bool Store(PresenceData data); 49 bool Store(PresenceData data);
50 50
diff --git a/OpenSim/Data/IProfilesData.cs b/OpenSim/Data/IProfilesData.cs
index 7fb075d..a4a32a9 100644
--- a/OpenSim/Data/IProfilesData.cs
+++ b/OpenSim/Data/IProfilesData.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Data
48 bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); 48 bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result);
49 bool UpdateAvatarInterests(UserProfileProperties up, ref string result); 49 bool UpdateAvatarInterests(UserProfileProperties up, ref string result);
50 bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); 50 bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result);
51 bool UpdateUserPreferences(ref UserPreferences pref, ref string result); 51 bool UpdateUserPreferences(ref UserPreferences pref, ref string result);
52 bool GetUserPreferences(ref UserPreferences pref, ref string result); 52 bool GetUserPreferences(ref UserPreferences pref, ref string result);
53 bool GetUserAppData(ref UserAppData props, ref string result); 53 bool GetUserAppData(ref UserAppData props, ref string result);
54 bool SetUserAppData(UserAppData props, ref string result); 54 bool SetUserAppData(UserAppData props, ref string result);
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs
index ca9b327..c8e38a4 100644
--- a/OpenSim/Data/IRegionData.cs
+++ b/OpenSim/Data/IRegionData.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Data
67 /// <summary> 67 /// <summary>
68 /// An interface for connecting to the authentication datastore 68 /// An interface for connecting to the authentication datastore
69 /// </summary> 69 /// </summary>
70 public interface IRegionData 70 public interface IRegionData
71 { 71 {
72 RegionData Get(UUID regionID, UUID ScopeID); 72 RegionData Get(UUID regionID, UUID ScopeID);
73 List<RegionData> Get(string regionName, UUID ScopeID); 73 List<RegionData> Get(string regionName, UUID ScopeID);
diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs
index 906ba6c..bc7eda7 100644
--- a/OpenSim/Data/IUserAccountData.cs
+++ b/OpenSim/Data/IUserAccountData.cs
@@ -50,5 +50,6 @@ namespace OpenSim.Data
50 bool Store(UserAccountData data); 50 bool Store(UserAccountData data);
51 bool Delete(string field, string val); 51 bool Delete(string field, string val);
52 UserAccountData[] GetUsers(UUID scopeID, string query); 52 UserAccountData[] GetUsers(UUID scopeID, string query);
53 UserAccountData[] GetUsersWhere(UUID scopeID, string where);
53 } 54 }
54} 55}
diff --git a/OpenSim/Data/IXGroupData.cs b/OpenSim/Data/IXGroupData.cs
index e5821ef..82073fe 100644
--- a/OpenSim/Data/IXGroupData.cs
+++ b/OpenSim/Data/IXGroupData.cs
@@ -38,12 +38,12 @@ namespace OpenSim.Data
38 public UUID ownerRoleID; 38 public UUID ownerRoleID;
39 public string name; 39 public string name;
40 public string charter; 40 public string charter;
41 public bool showInList; 41 public bool showInList;
42 public UUID insigniaID; 42 public UUID insigniaID;
43 public int membershipFee; 43 public int membershipFee;
44 public bool openEnrollment; 44 public bool openEnrollment;
45 public bool allowPublish; 45 public bool allowPublish;
46 public bool maturePublish; 46 public bool maturePublish;
47 public UUID founderID; 47 public UUID founderID;
48 public ulong everyonePowers; 48 public ulong everyonePowers;
49 public ulong ownersPowers; 49 public ulong ownersPowers;
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs
index d606470..e54bf55 100644
--- a/OpenSim/Data/Migration.cs
+++ b/OpenSim/Data/Migration.cs
@@ -80,10 +80,10 @@ namespace OpenSim.Data
80 80
81 /// <summary>Have the parameterless constructor just so we can specify it as a generic parameter with the new() constraint. 81 /// <summary>Have the parameterless constructor just so we can specify it as a generic parameter with the new() constraint.
82 /// Currently this is only used in the tests. A Migration instance created this way must be then 82 /// Currently this is only used in the tests. A Migration instance created this way must be then
83 /// initialized with Initialize(). Regular creation should be through the parameterized constructors. 83 /// initialized with Initialize(). Regular creation should be through the parameterized constructors.
84 /// </summary> 84 /// </summary>
85 public Migration() 85 public Migration()
86 { 86 {
87 } 87 }
88 88
89 public Migration(DbConnection conn, Assembly assem, string subtype, string type) 89 public Migration(DbConnection conn, Assembly assem, string subtype, string type)
@@ -91,7 +91,7 @@ namespace OpenSim.Data
91 Initialize(conn, assem, type, subtype); 91 Initialize(conn, assem, type, subtype);
92 } 92 }
93 93
94 public Migration(DbConnection conn, Assembly assem, string type) 94 public Migration(DbConnection conn, Assembly assem, string type)
95 { 95 {
96 Initialize(conn, assem, type, ""); 96 Initialize(conn, assem, type, "");
97 } 97 }
@@ -191,7 +191,7 @@ namespace OpenSim.Data
191 int newversion = kvp.Key; 191 int newversion = kvp.Key;
192 // we need to up the command timeout to infinite as we might be doing long migrations. 192 // we need to up the command timeout to infinite as we might be doing long migrations.
193 193
194 /* [AlexRa 01-May-10]: We can't always just run any SQL in a single batch (= ExecuteNonQuery()). Things like 194 /* [AlexRa 01-May-10]: We can't always just run any SQL in a single batch (= ExecuteNonQuery()). Things like
195 * stored proc definitions might have to be sent to the server each in a separate batch. 195 * stored proc definitions might have to be sent to the server each in a separate batch.
196 * This is certainly so for MS SQL; not sure how the MySQL connector sorts out the mess 196 * This is certainly so for MS SQL; not sure how the MySQL connector sorts out the mess
197 * with 'delimiter @@'/'delimiter ;' around procs. So each "script" this code executes now is not 197 * with 'delimiter @@'/'delimiter ;' around procs. So each "script" this code executes now is not
@@ -276,7 +276,7 @@ namespace OpenSim.Data
276 private delegate void FlushProc(); 276 private delegate void FlushProc();
277 277
278 /// <summary>Scans for migration resources in either old-style "scattered" (one file per version) 278 /// <summary>Scans for migration resources in either old-style "scattered" (one file per version)
279 /// or new-style "integrated" format (single file with ":VERSION nnn" sections). 279 /// or new-style "integrated" format (single file with ":VERSION nnn" sections).
280 /// In the new-style migrations it also recognizes ':GO' separators for parts of the SQL script 280 /// In the new-style migrations it also recognizes ':GO' separators for parts of the SQL script
281 /// that must be sent to the server separately. The old-style migrations are loaded each in one piece 281 /// that must be sent to the server separately. The old-style migrations are loaded each in one piece
282 /// and don't support the ':GO' feature. 282 /// and don't support the ':GO' feature.
@@ -301,12 +301,12 @@ namespace OpenSim.Data
301 { 301 {
302 /* The filename should be '<StoreName>.migrations[.NNN]' where NNN 302 /* The filename should be '<StoreName>.migrations[.NNN]' where NNN
303 * is the last version number defined in the file. If the '.NNN' part is recognized, the code can skip 303 * is the last version number defined in the file. If the '.NNN' part is recognized, the code can skip
304 * the file without looking inside if we have a higher version already. Without the suffix we read 304 * the file without looking inside if we have a higher version already. Without the suffix we read
305 * the file anyway and use the version numbers inside. Any unrecognized suffix (such as '.sql') 305 * the file anyway and use the version numbers inside. Any unrecognized suffix (such as '.sql')
306 * is valid but ignored. 306 * is valid but ignored.
307 * 307 *
308 * NOTE that we expect only one 'merged' migration file. If there are several, we take the last one. 308 * NOTE that we expect only one 'merged' migration file. If there are several, we take the last one.
309 * If you are numbering them, leave only the latest one in the project or at least make sure they numbered 309 * If you are numbering them, leave only the latest one in the project or at least make sure they numbered
310 * to come up in the correct order (e.g. 'SomeStore.migrations.001' rather than 'SomeStore.migrations.1') 310 * to come up in the correct order (e.g. 'SomeStore.migrations.001' rather than 'SomeStore.migrations.1')
311 */ 311 */
312 312
@@ -351,7 +351,7 @@ namespace OpenSim.Data
351 if (sLine.Trim().Equals(":GO", StringComparison.InvariantCultureIgnoreCase)) 351 if (sLine.Trim().Equals(":GO", StringComparison.InvariantCultureIgnoreCase))
352 { 352 {
353 if (sb.Length == 0) continue; 353 if (sb.Length == 0) continue;
354 if (nVersion > after) 354 if (nVersion > after)
355 script.Add(sb.ToString()); 355 script.Add(sb.ToString());
356 sb.Length = 0; 356 sb.Length = 0;
357 continue; 357 continue;
@@ -405,10 +405,10 @@ scan_old_style:
405 } 405 }
406 } 406 }
407 } 407 }
408 408
409 if (migrations.Count < 1) 409 if (migrations.Count < 1)
410 m_log.DebugFormat("[MIGRATIONS]: {0} data tables already up to date at revision {1}", _type, after); 410 m_log.DebugFormat("[MIGRATIONS]: {0} data tables already up to date at revision {1}", _type, after);
411 411
412 return migrations; 412 return migrations;
413 } 413 }
414 } 414 }
diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs
index ed0ab98..17f1374 100644
--- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs
+++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 5d8da17..8569c90 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL
75 dbcon.Open(); 75 dbcon.Open();
76 Migration m = new Migration(dbcon, Assembly, "AssetStore"); 76 Migration m = new Migration(dbcon, Assembly, "AssetStore");
77 m.Update(); 77 m.Update();
78 dbcon.Close();
78 } 79 }
79 } 80 }
80 81
@@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL
144 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); 145 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
145 } 146 }
146 } 147 }
148 dbcon.Close();
147 } 149 }
148 150
149 return asset; 151 return asset;
@@ -154,65 +156,62 @@ namespace OpenSim.Data.MySQL
154 /// </summary> 156 /// </summary>
155 /// <param name="asset">Asset UUID to create</param> 157 /// <param name="asset">Asset UUID to create</param>
156 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 158 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
157 override public void StoreAsset(AssetBase asset) 159 override public bool StoreAsset(AssetBase asset)
158 { 160 {
161 string assetName = asset.Name;
162 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
163 {
164 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
165 m_log.WarnFormat(
166 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
167 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
168 }
169
170 string assetDescription = asset.Description;
171 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
172 {
173 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
174 m_log.WarnFormat(
175 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
176 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
177 }
178
159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 179 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
160 { 180 {
161 dbcon.Open(); 181 dbcon.Open();
162
163 using (MySqlCommand cmd = 182 using (MySqlCommand cmd =
164 new MySqlCommand( 183 new MySqlCommand(
165 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 184 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
166 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", 185 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
167 dbcon)) 186 dbcon))
168 { 187 {
169 string assetName = asset.Name;
170 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
171 {
172 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
173 m_log.WarnFormat(
174 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
175 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
176 }
177
178 string assetDescription = asset.Description;
179 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
180 {
181 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
182 m_log.WarnFormat(
183 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
184 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
185 }
186
187 try 188 try
188 { 189 {
189 using (cmd) 190 // create unix epoch time
190 { 191 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
191 // create unix epoch time 192 cmd.Parameters.AddWithValue("?id", asset.ID);
192 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 193 cmd.Parameters.AddWithValue("?name", assetName);
193 cmd.Parameters.AddWithValue("?id", asset.ID); 194 cmd.Parameters.AddWithValue("?description", assetDescription);
194 cmd.Parameters.AddWithValue("?name", assetName); 195 cmd.Parameters.AddWithValue("?assetType", asset.Type);
195 cmd.Parameters.AddWithValue("?description", assetDescription); 196 cmd.Parameters.AddWithValue("?local", asset.Local);
196 cmd.Parameters.AddWithValue("?assetType", asset.Type); 197 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
197 cmd.Parameters.AddWithValue("?local", asset.Local); 198 cmd.Parameters.AddWithValue("?create_time", now);
198 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 199 cmd.Parameters.AddWithValue("?access_time", now);
199 cmd.Parameters.AddWithValue("?create_time", now); 200 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
200 cmd.Parameters.AddWithValue("?access_time", now); 201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
201 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); 202 cmd.Parameters.AddWithValue("?data", asset.Data);
202 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 203 cmd.ExecuteNonQuery();
203 cmd.Parameters.AddWithValue("?data", asset.Data); 204 dbcon.Close();
204 cmd.ExecuteNonQuery(); 205 return true;
205 }
206 } 206 }
207 catch (Exception e) 207 catch (Exception e)
208 { 208 {
209 m_log.Error( 209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
210 string.Format( 210 asset.FullID, asset.Name, e.Message);
211 "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", 211 dbcon.Close();
212 asset.FullID, asset.Name) 212 return false;
213 , e);
214 } 213 }
215 } 214 }
216 } 215 }
217 } 216 }
218 217
@@ -227,24 +226,22 @@ namespace OpenSim.Data.MySQL
227 { 226 {
228 try 227 try
229 { 228 {
230 using (cmd) 229 // create unix epoch time
231 { 230 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
232 // create unix epoch time 231 cmd.Parameters.AddWithValue("?id", asset.ID);
233 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 232 cmd.Parameters.AddWithValue("?access_time", now);
234 cmd.Parameters.AddWithValue("?id", asset.ID); 233 cmd.ExecuteNonQuery();
235 cmd.Parameters.AddWithValue("?access_time", now);
236 cmd.ExecuteNonQuery();
237 }
238 } 234 }
239 catch (Exception e) 235 catch (Exception e)
240 { 236 {
241 m_log.Error( 237 m_log.Error(
242 string.Format( 238 string.Format(
243 "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", 239 "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
244 asset.FullID, asset.Name), 240 asset.FullID, asset.Name),
245 e); 241 e);
246 } 242 }
247 } 243 }
244 dbcon.Close();
248 } 245 }
249 } 246 }
250 247
@@ -277,6 +274,7 @@ namespace OpenSim.Data.MySQL
277 } 274 }
278 } 275 }
279 } 276 }
277 dbcon.Close();
280 } 278 }
281 279
282 bool[] results = new bool[uuids.Length]; 280 bool[] results = new bool[uuids.Length];
@@ -336,11 +334,12 @@ namespace OpenSim.Data.MySQL
336 { 334 {
337 m_log.Error( 335 m_log.Error(
338 string.Format( 336 string.Format(
339 "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", 337 "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
340 start, count), 338 start, count),
341 e); 339 e);
342 } 340 }
343 } 341 }
342 dbcon.Close();
344 } 343 }
345 344
346 return retList; 345 return retList;
@@ -357,6 +356,7 @@ namespace OpenSim.Data.MySQL
357 cmd.Parameters.AddWithValue("?id", id); 356 cmd.Parameters.AddWithValue("?id", id);
358 cmd.ExecuteNonQuery(); 357 cmd.ExecuteNonQuery();
359 } 358 }
359 dbcon.Close();
360 } 360 }
361 361
362 return true; 362 return true;
@@ -364,4 +364,4 @@ namespace OpenSim.Data.MySQL
364 364
365 #endregion 365 #endregion
366 } 366 }
367} \ No newline at end of file 367}
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 7627497..fef582e 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -59,6 +59,7 @@ namespace OpenSim.Data.MySQL
59 dbcon.Open(); 59 dbcon.Open();
60 Migration m = new Migration(dbcon, Assembly, "AuthStore"); 60 Migration m = new Migration(dbcon, Assembly, "AuthStore");
61 m.Update(); 61 m.Update();
62 dbcon.Close();
62 } 63 }
63 } 64 }
64 65
@@ -76,27 +77,30 @@ namespace OpenSim.Data.MySQL
76 { 77 {
77 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 78 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
78 79
79 IDataReader result = cmd.ExecuteReader(); 80 using(IDataReader result = cmd.ExecuteReader())
80
81 if (result.Read())
82 { 81 {
83 ret.PrincipalID = principalID; 82 if(result.Read())
84
85 CheckColumnNames(result);
86
87 foreach (string s in m_ColumnNames)
88 { 83 {
89 if (s == "UUID") 84 ret.PrincipalID = principalID;
90 continue; 85
91 86 CheckColumnNames(result);
92 ret.Data[s] = result[s].ToString(); 87
88 foreach(string s in m_ColumnNames)
89 {
90 if(s == "UUID")
91 continue;
92
93 ret.Data[s] = result[s].ToString();
94 }
95
96 dbcon.Close();
97 return ret;
98 }
99 else
100 {
101 dbcon.Close();
102 return null;
93 } 103 }
94
95 return ret;
96 }
97 else
98 {
99 return null;
100 } 104 }
101 } 105 }
102 } 106 }
@@ -132,25 +136,25 @@ namespace OpenSim.Data.MySQL
132 if (!first) 136 if (!first)
133 update += ", "; 137 update += ", ";
134 update += "`" + field + "` = ?"+field; 138 update += "`" + field + "` = ?"+field;
135 139
136 first = false; 140 first = false;
137 141
138 cmd.Parameters.AddWithValue("?"+field, data.Data[field]); 142 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
139 } 143 }
140 144
141 update += " where UUID = ?principalID"; 145 update += " where UUID = ?principalID";
142 146
143 cmd.CommandText = update; 147 cmd.CommandText = update;
144 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); 148 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
145 149
146 if (ExecuteNonQuery(cmd) < 1) 150 if (ExecuteNonQuery(cmd) < 1)
147 { 151 {
148 string insert = "insert into `" + m_Realm + "` (`UUID`, `" + 152 string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
149 String.Join("`, `", fields) + 153 String.Join("`, `", fields) +
150 "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; 154 "`) values (?principalID, ?" + String.Join(", ?", fields) + ")";
151 155
152 cmd.CommandText = insert; 156 cmd.CommandText = insert;
153 157
154 if (ExecuteNonQuery(cmd) < 1) 158 if (ExecuteNonQuery(cmd) < 1)
155 return false; 159 return false;
156 } 160 }
@@ -166,7 +170,7 @@ namespace OpenSim.Data.MySQL
166 { 170 {
167 cmd.Parameters.AddWithValue("?"+item, value); 171 cmd.Parameters.AddWithValue("?"+item, value);
168 cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); 172 cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
169 173
170 if (ExecuteNonQuery(cmd) > 0) 174 if (ExecuteNonQuery(cmd) > 0)
171 return true; 175 return true;
172 } 176 }
@@ -186,7 +190,7 @@ namespace OpenSim.Data.MySQL
186 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 190 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
187 cmd.Parameters.AddWithValue("?token", token); 191 cmd.Parameters.AddWithValue("?token", token);
188 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); 192 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
189 193
190 if (ExecuteNonQuery(cmd) > 0) 194 if (ExecuteNonQuery(cmd) > 0)
191 return true; 195 return true;
192 } 196 }
diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs
index 6a2f5d8..63e8020 100644
--- a/OpenSim/Data/MySQL/MySQLAvatarData.cs
+++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Data.MySQL
57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); 57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm);
58 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 58 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
59 cmd.Parameters.AddWithValue("?Name", name); 59 cmd.Parameters.AddWithValue("?Name", name);
60 60
61 if (ExecuteNonQuery(cmd) > 0) 61 if (ExecuteNonQuery(cmd) > 0)
62 return true; 62 return true;
63 } 63 }
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index fe1487b..eeedf02 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL
82 82
83 Migration m = new Migration(dbcon, Assembly, "EstateStore"); 83 Migration m = new Migration(dbcon, Assembly, "EstateStore");
84 m.Update(); 84 m.Update();
85 dbcon.Close();
85 86
86 Type t = typeof(EstateSettings); 87 Type t = typeof(EstateSettings);
87 m_Fields = t.GetFields(BindingFlags.NonPublic | 88 m_Fields = t.GetFields(BindingFlags.NonPublic |
@@ -143,7 +144,6 @@ namespace OpenSim.Data.MySQL
143 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 144 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
144 { 145 {
145 dbcon.Open(); 146 dbcon.Open();
146
147 cmd.Connection = dbcon; 147 cmd.Connection = dbcon;
148 148
149 bool found = false; 149 bool found = false;
@@ -171,6 +171,8 @@ namespace OpenSim.Data.MySQL
171 } 171 }
172 } 172 }
173 } 173 }
174 dbcon.Close();
175 cmd.Connection = null;
174 176
175 if (!found && create) 177 if (!found && create)
176 { 178 {
@@ -231,6 +233,7 @@ namespace OpenSim.Data.MySQL
231 233
232 es.Save(); 234 es.Save();
233 } 235 }
236 dbcon.Close();
234 } 237 }
235 } 238 }
236 239
@@ -263,6 +266,7 @@ namespace OpenSim.Data.MySQL
263 266
264 cmd.ExecuteNonQuery(); 267 cmd.ExecuteNonQuery();
265 } 268 }
269 dbcon.Close();
266 } 270 }
267 271
268 SaveBanList(es); 272 SaveBanList(es);
@@ -300,6 +304,7 @@ namespace OpenSim.Data.MySQL
300 } 304 }
301 } 305 }
302 } 306 }
307 dbcon.Close();
303 } 308 }
304 } 309 }
305 310
@@ -329,6 +334,7 @@ namespace OpenSim.Data.MySQL
329 cmd.Parameters.Clear(); 334 cmd.Parameters.Clear();
330 } 335 }
331 } 336 }
337 dbcon.Close();
332 } 338 }
333 } 339 }
334 340
@@ -358,6 +364,7 @@ namespace OpenSim.Data.MySQL
358 cmd.Parameters.Clear(); 364 cmd.Parameters.Clear();
359 } 365 }
360 } 366 }
367 dbcon.Close();
361 } 368 }
362 } 369 }
363 370
@@ -383,6 +390,7 @@ namespace OpenSim.Data.MySQL
383 } 390 }
384 } 391 }
385 } 392 }
393 dbcon.Close();
386 } 394 }
387 395
388 return uuids.ToArray(); 396 return uuids.ToArray();
@@ -403,19 +411,19 @@ namespace OpenSim.Data.MySQL
403 return e; 411 return e;
404 } 412 }
405 } 413 }
406 414
407 public List<EstateSettings> LoadEstateSettingsAll() 415 public List<EstateSettings> LoadEstateSettingsAll()
408 { 416 {
409 List<EstateSettings> allEstateSettings = new List<EstateSettings>(); 417 List<EstateSettings> allEstateSettings = new List<EstateSettings>();
410 418
411 List<int> allEstateIds = GetEstatesAll(); 419 List<int> allEstateIds = GetEstatesAll();
412 420
413 foreach (int estateId in allEstateIds) 421 foreach (int estateId in allEstateIds)
414 allEstateSettings.Add(LoadEstateSettings(estateId)); 422 allEstateSettings.Add(LoadEstateSettings(estateId));
415 423
416 return allEstateSettings; 424 return allEstateSettings;
417 } 425 }
418 426
419 public List<int> GetEstatesAll() 427 public List<int> GetEstatesAll()
420 { 428 {
421 List<int> result = new List<int>(); 429 List<int> result = new List<int>();
@@ -437,11 +445,10 @@ namespace OpenSim.Data.MySQL
437 reader.Close(); 445 reader.Close();
438 } 446 }
439 } 447 }
440
441 dbcon.Close(); 448 dbcon.Close();
442 } 449 }
443 450
444 return result; 451 return result;
445 } 452 }
446 453
447 public List<int> GetEstates(string search) 454 public List<int> GetEstates(string search)
@@ -466,7 +473,6 @@ namespace OpenSim.Data.MySQL
466 reader.Close(); 473 reader.Close();
467 } 474 }
468 } 475 }
469
470 dbcon.Close(); 476 dbcon.Close();
471 } 477 }
472 478
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
index 19e23b5..6c48607 100644
--- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
@@ -41,10 +41,8 @@ namespace OpenSim.Data.MySQL
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 protected MySqlConnection m_Connection = null;
45 protected string m_ConnectionString; 44 protected string m_ConnectionString;
46 protected string m_Table; 45 protected string m_Table;
47 protected Object m_connLock = new Object();
48 46
49 /// <summary> 47 /// <summary>
50 /// Number of days that must pass before we update the access time on an asset when it has been fetched 48 /// Number of days that must pass before we update the access time on an asset when it has been fetched
@@ -56,7 +54,7 @@ namespace OpenSim.Data.MySQL
56 { 54 {
57 get { return GetType().Assembly; } 55 get { return GetType().Assembly; }
58 } 56 }
59 57
60 public MySQLFSAssetData() 58 public MySQLFSAssetData()
61 { 59 {
62 } 60 }
@@ -75,10 +73,13 @@ namespace OpenSim.Data.MySQL
75 73
76 try 74 try
77 { 75 {
78 OpenDatabase(); 76 using (MySqlConnection conn = new MySqlConnection(m_ConnectionString))
79 77 {
80 Migration m = new Migration(m_Connection, Assembly, "FSAssetStore"); 78 conn.Open();
81 m.Update(); 79 Migration m = new Migration(conn, Assembly, "FSAssetStore");
80 m.Update();
81 conn.Close();
82 }
82 } 83 }
83 catch (MySqlException e) 84 catch (MySqlException e)
84 { 85 {
@@ -100,70 +101,37 @@ namespace OpenSim.Data.MySQL
100 101
101 #endregion 102 #endregion
102 103
103 private bool OpenDatabase() 104 private bool ExecuteNonQuery(MySqlCommand cmd)
104 { 105 {
105 try 106 using (MySqlConnection conn = new MySqlConnection(m_ConnectionString))
106 {
107 m_Connection = new MySqlConnection(m_ConnectionString);
108
109 m_Connection.Open();
110 }
111 catch (MySqlException e)
112 { 107 {
113 m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", 108 try
114 e.Message.ToString());
115
116 return false;
117 }
118
119 return true;
120 }
121
122 private IDataReader ExecuteReader(MySqlCommand c)
123 {
124 IDataReader r = null;
125 MySqlConnection connection = (MySqlConnection) ((ICloneable)m_Connection).Clone();
126 connection.Open();
127 c.Connection = connection;
128
129 r = c.ExecuteReader();
130
131 return r;
132 }
133
134 private void ExecuteNonQuery(MySqlCommand c)
135 {
136 lock (m_connLock)
137 {
138 bool errorSeen = false;
139
140 while (true)
141 { 109 {
142 try 110 conn.Open();
143 { 111 }
144 c.ExecuteNonQuery(); 112 catch (MySqlException e)
145 } 113 {
146 catch (MySqlException) 114 m_log.ErrorFormat("[FSASSETS]: Database open failed with {0}", e.ToString());
147 { 115 return false;
148 System.Threading.Thread.Sleep(500); 116 }
149
150 m_Connection.Close();
151 m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone();
152 m_Connection.Open();
153 c.Connection = m_Connection;
154
155 if (!errorSeen)
156 {
157 errorSeen = true;
158 continue;
159 }
160 m_log.ErrorFormat("[FSASSETS] MySQL command: {0}", c.CommandText);
161 throw;
162 }
163 117
164 break; 118 cmd.Connection = conn;
119 try
120 {
121 cmd.ExecuteNonQuery();
122 }
123 catch (MySqlException e)
124 {
125 cmd.Connection = null;
126 conn.Close();
127 m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString());
128 return false;
165 } 129 }
130 conn.Close();
131 cmd.Connection = null;
166 } 132 }
133
134 return true;
167 } 135 }
168 136
169 #region IFSAssetDataPlugin Members 137 #region IFSAssetDataPlugin Members
@@ -172,63 +140,79 @@ namespace OpenSim.Data.MySQL
172 { 140 {
173 hash = String.Empty; 141 hash = String.Empty;
174 142
175 MySqlCommand cmd = new MySqlCommand();
176
177 cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, access_time, asset_flags from {0} where id = ?id", m_Table);
178 cmd.Parameters.AddWithValue("?id", id);
179
180 IDataReader reader = ExecuteReader(cmd);
181
182 if (!reader.Read())
183 {
184 reader.Close();
185 FreeCommand(cmd);
186 return null;
187 }
188
189 AssetMetadata meta = new AssetMetadata(); 143 AssetMetadata meta = new AssetMetadata();
190 144
191 hash = reader["hash"].ToString(); 145 using (MySqlConnection conn = new MySqlConnection(m_ConnectionString))
146 {
147 try
148 {
149 conn.Open();
150 }
151 catch (MySqlException e)
152 {
153 m_log.ErrorFormat("[FSASSETS]: Database open failed with {0}", e.ToString());
154 return null;
155 }
192 156
193 meta.ID = id; 157 using (MySqlCommand cmd = conn.CreateCommand())
194 meta.FullID = new UUID(id); 158 {
159 cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, asset_flags, access_time from {0} where id = ?id", m_Table);
160 cmd.Parameters.AddWithValue("?id", id);
195 161
196 meta.Name = reader["name"].ToString(); 162 using (IDataReader reader = cmd.ExecuteReader())
197 meta.Description = reader["description"].ToString(); 163 {
198 meta.Type = (sbyte)Convert.ToInt32(reader["type"]); 164 if (!reader.Read())
199 meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); 165 return null;
200 meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"]));
201 meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]);
202 166
203 int AccessTime = Convert.ToInt32(reader["access_time"]); 167 hash = reader["hash"].ToString();
204 168
205 reader.Close(); 169 meta.ID = id;
170 meta.FullID = new UUID(id);
206 171
207 UpdateAccessTime(AccessTime, cmd); 172 meta.Name = reader["name"].ToString();
173 meta.Description = reader["description"].ToString();
174 meta.Type = (sbyte)Convert.ToInt32(reader["type"]);
175 meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type);
176 meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"]));
177 meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]);
208 178
209 FreeCommand(cmd); 179 int AccessTime = Convert.ToInt32(reader["access_time"]);
180 UpdateAccessTime(id, AccessTime);
181 }
182 }
183 conn.Close();
184 }
210 185
211 return meta; 186 return meta;
212 } 187 }
213 188
214 private void UpdateAccessTime(int AccessTime, MySqlCommand cmd) 189 private void UpdateAccessTime(string AssetID, int AccessTime)
215 { 190 {
216 // Reduce DB work by only updating access time if asset hasn't recently been accessed 191 // Reduce DB work by only updating access time if asset hasn't recently been accessed
217 // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" 192 // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates"
218 if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) 193 if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
219 return; 194 return;
220 195
221 cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); 196 using (MySqlConnection conn = new MySqlConnection(m_ConnectionString))
222 197 {
223 cmd.ExecuteNonQuery(); 198 try
224 } 199 {
200 conn.Open();
201 }
202 catch (MySqlException e)
203 {
204 m_log.ErrorFormat("[FSASSETS]: Database open failed with {0}", e.ToString());
205 return;
206 }
225 207
226 protected void FreeCommand(MySqlCommand cmd) 208 using (MySqlCommand cmd = conn.CreateCommand())
227 { 209 {
228 MySqlConnection c = cmd.Connection; 210 cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table);
229 cmd.Dispose(); 211 cmd.Parameters.AddWithValue("?id", AssetID);
230 c.Close(); 212 cmd.ExecuteNonQuery();
231 c.Dispose(); 213 }
214 conn.Close();
215 }
232 } 216 }
233 217
234 public bool Store(AssetMetadata meta, string hash) 218 public bool Store(AssetMetadata meta, string hash)
@@ -238,37 +222,41 @@ namespace OpenSim.Data.MySQL
238 string oldhash; 222 string oldhash;
239 AssetMetadata existingAsset = Get(meta.ID, out oldhash); 223 AssetMetadata existingAsset = Get(meta.ID, out oldhash);
240 224
241 MySqlCommand cmd = m_Connection.CreateCommand(); 225 using (MySqlCommand cmd = new MySqlCommand())
242
243 cmd.Parameters.AddWithValue("?id", meta.ID);
244 cmd.Parameters.AddWithValue("?name", meta.Name);
245 cmd.Parameters.AddWithValue("?description", meta.Description);
246 cmd.Parameters.AddWithValue("?type", meta.Type.ToString());
247 cmd.Parameters.AddWithValue("?hash", hash);
248 cmd.Parameters.AddWithValue("?asset_flags", meta.Flags);
249
250 if (existingAsset == null)
251 { 226 {
252 cmd.CommandText = String.Format("insert into {0} (id, name, description, type, hash, asset_flags, create_time, access_time) values ( ?id, ?name, ?description, ?type, ?hash, ?asset_flags, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", m_Table); 227 cmd.Parameters.AddWithValue("?id", meta.ID);
228 cmd.Parameters.AddWithValue("?name", meta.Name);
229 cmd.Parameters.AddWithValue("?description", meta.Description);
230// cmd.Parameters.AddWithValue("?type", meta.Type.ToString());
231 cmd.Parameters.AddWithValue("?type", meta.Type);
232 cmd.Parameters.AddWithValue("?hash", hash);
233 cmd.Parameters.AddWithValue("?asset_flags", meta.Flags);
234
235 if (existingAsset == null)
236 {
237 cmd.CommandText = String.Format("insert into {0} (id, name, description, type, hash, asset_flags, create_time, access_time) values ( ?id, ?name, ?description, ?type, ?hash, ?asset_flags, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", m_Table);
253 238
254 ExecuteNonQuery(cmd); 239 ExecuteNonQuery(cmd);
255 240
256 cmd.Dispose(); 241 return true;
242 }
257 243
258 return true; 244 //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table);
259 }
260 245
261 //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); 246 //ExecuteNonQuery(cmd);
262 247
263 //ExecuteNonQuery(cmd); 248 }
264 249
265 cmd.Dispose(); 250// return false;
266 return false; 251 // if the asset already exits
252 // assume it was already correctly stored
253 // or regions will keep retry.
254 return true;
267 } 255 }
268 catch(Exception e) 256 catch(Exception e)
269 { 257 {
270 m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); 258 m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID);
271 m_log.Error(e.ToString()); 259 m_log.Error(e.ToString());
272 return false; 260 return false;
273 } 261 }
274 } 262 }
@@ -283,26 +271,43 @@ namespace OpenSim.Data.MySQL
283 if (uuids.Length == 0) 271 if (uuids.Length == 0)
284 return new bool[0]; 272 return new bool[0];
285 273
274 bool[] results = new bool[uuids.Length];
275 for (int i = 0; i < uuids.Length; i++)
276 results[i] = false;
277
286 HashSet<UUID> exists = new HashSet<UUID>(); 278 HashSet<UUID> exists = new HashSet<UUID>();
287 279
288 string ids = "'" + string.Join("','", uuids) + "'"; 280 string ids = "'" + string.Join("','", uuids) + "'";
289 string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table); 281 string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table);
290 282
291 using (MySqlCommand cmd = m_Connection.CreateCommand()) 283 using (MySqlConnection conn = new MySqlConnection(m_ConnectionString))
292 { 284 {
293 cmd.CommandText = sql; 285 try
286 {
287 conn.Open();
288 }
289 catch (MySqlException e)
290 {
291 m_log.ErrorFormat("[FSASSETS]: Failed to open database: {0}", e.ToString());
292 return results;
293 }
294 294
295 using (MySqlDataReader dbReader = cmd.ExecuteReader()) 295 using (MySqlCommand cmd = conn.CreateCommand())
296 { 296 {
297 while (dbReader.Read()) 297 cmd.CommandText = sql;
298
299 using (MySqlDataReader dbReader = cmd.ExecuteReader())
298 { 300 {
299 UUID id = DBGuid.FromDB(dbReader["ID"]); 301 while (dbReader.Read())
300 exists.Add(id); 302 {
303 UUID id = DBGuid.FromDB(dbReader["ID"]);
304 exists.Add(id);
305 }
301 } 306 }
302 } 307 }
308 conn.Close();
303 } 309 }
304 310
305 bool[] results = new bool[uuids.Length];
306 for (int i = 0; i < uuids.Length; i++) 311 for (int i = 0; i < uuids.Length; i++)
307 results[i] = exists.Contains(uuids[i]); 312 results[i] = exists.Contains(uuids[i]);
308 return results; 313 return results;
@@ -310,27 +315,43 @@ namespace OpenSim.Data.MySQL
310 315
311 public int Count() 316 public int Count()
312 { 317 {
313 MySqlCommand cmd = m_Connection.CreateCommand(); 318 int count = 0;
314 319
315 cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table); 320 using (MySqlConnection conn = new MySqlConnection(m_ConnectionString))
316 321 {
317 IDataReader reader = ExecuteReader(cmd); 322 try
323 {
324 conn.Open();
325 }
326 catch (MySqlException e)
327 {
328 m_log.ErrorFormat("[FSASSETS]: Failed to open database: {0}", e.ToString());
329 return 0;
330 }
318 331
319 reader.Read(); 332 using(MySqlCommand cmd = conn.CreateCommand())
333 {
334 cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table);
320 335
321 int count = Convert.ToInt32(reader["count"]); 336 using (IDataReader reader = cmd.ExecuteReader())
337 {
338 reader.Read();
322 339
323 reader.Close(); 340 count = Convert.ToInt32(reader["count"]);
324 FreeCommand(cmd); 341 }
342 }
343 conn.Close();
344 }
325 345
326 return count; 346 return count;
327 } 347 }
328 348
329 public bool Delete(string id) 349 public bool Delete(string id)
330 { 350 {
331 using (MySqlCommand cmd = m_Connection.CreateCommand()) 351 using(MySqlCommand cmd = new MySqlCommand())
332 { 352 {
333 cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); 353
354 cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table);
334 355
335 cmd.Parameters.AddWithValue("?id", id); 356 cmd.Parameters.AddWithValue("?id", id);
336 357
@@ -342,70 +363,68 @@ namespace OpenSim.Data.MySQL
342 363
343 public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) 364 public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store)
344 { 365 {
345 MySqlConnection importConn; 366 int imported = 0;
346
347 try
348 {
349 importConn = new MySqlConnection(conn);
350 367
351 importConn.Open(); 368 using (MySqlConnection importConn = new MySqlConnection(conn))
352 }
353 catch (MySqlException e)
354 { 369 {
355 m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", 370 try
356 e.Message.ToString()); 371 {
357 372 importConn.Open();
358 return; 373 }
359 } 374 catch (MySqlException e)
375 {
376 m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}",
377 e.Message.ToString());
360 378
361 int imported = 0; 379 return;
380 }
362 381
363 MySqlCommand cmd = importConn.CreateCommand(); 382 using (MySqlCommand cmd = importConn.CreateCommand())
383 {
384 string limit = String.Empty;
385 if (count != -1)
386 {
387 limit = String.Format(" limit {0},{1}", start, count);
388 }
364 389
365 string limit = String.Empty; 390 cmd.CommandText = String.Format("select * from {0}{1}", table, limit);
366 if (count != -1)
367 {
368 limit = String.Format(" limit {0},{1}", start, count);
369 }
370
371 cmd.CommandText = String.Format("select * from {0}{1}", table, limit);
372 391
373 MainConsole.Instance.Output("Querying database"); 392 MainConsole.Instance.Output("Querying database");
374 IDataReader reader = cmd.ExecuteReader(); 393 using (IDataReader reader = cmd.ExecuteReader())
394 {
395 MainConsole.Instance.Output("Reading data");
375 396
376 MainConsole.Instance.Output("Reading data"); 397 while (reader.Read())
398 {
399 if ((imported % 100) == 0)
400 {
401 MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported));
402 }
377 403
378 while (reader.Read()) 404 AssetBase asset = new AssetBase();
379 { 405 AssetMetadata meta = new AssetMetadata();
380 if ((imported % 100) == 0)
381 {
382 MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported));
383 }
384
385 AssetBase asset = new AssetBase();
386 AssetMetadata meta = new AssetMetadata();
387 406
388 meta.ID = reader["id"].ToString(); 407 meta.ID = reader["id"].ToString();
389 meta.FullID = new UUID(meta.ID); 408 meta.FullID = new UUID(meta.ID);
390 409
391 meta.Name = reader["name"].ToString(); 410 meta.Name = reader["name"].ToString();
392 meta.Description = reader["description"].ToString(); 411 meta.Description = reader["description"].ToString();
393 meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]); 412 meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]);
394 meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); 413 meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type);
395 meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); 414 meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"]));
396 415
397 asset.Metadata = meta; 416 asset.Metadata = meta;
398 asset.Data = (byte[])reader["data"]; 417 asset.Data = (byte[])reader["data"];
399 418
400 store(asset, force); 419 store(asset, force);
401 420
402 imported++; 421 imported++;
422 }
423 }
424 }
425 importConn.Close();
403 } 426 }
404 427
405 reader.Close();
406 cmd.Dispose();
407 importConn.Close();
408
409 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); 428 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported));
410 } 429 }
411 430
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index 5820a90..98106f0 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -36,7 +36,7 @@ using MySql.Data.MySqlClient;
36namespace OpenSim.Data.MySQL 36namespace OpenSim.Data.MySQL
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// A database interface class to a user profile storage system 39 /// Common code for a number of database modules
40 /// </summary> 40 /// </summary>
41 public class MySqlFramework 41 public class MySqlFramework
42 { 42 {
@@ -44,30 +44,78 @@ namespace OpenSim.Data.MySQL
44 log4net.LogManager.GetLogger( 44 log4net.LogManager.GetLogger(
45 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 45 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 protected string m_connectionString; 47 protected string m_connectionString = String.Empty;
48 protected MySqlTransaction m_trans = null;
48 49
50 // Constructor using a connection string. Instances constructed
51 // this way will open a new connection for each call.
49 protected MySqlFramework(string connectionString) 52 protected MySqlFramework(string connectionString)
50 { 53 {
51 m_connectionString = connectionString; 54 m_connectionString = connectionString;
52 } 55 }
53 56
57 // Constructor using a connection object. Instances constructed
58 // this way will use the connection object and never create
59 // new connections.
60 protected MySqlFramework(MySqlTransaction trans)
61 {
62 m_trans = trans;
63 }
64
65 //////////////////////////////////////////////////////////////
66 //
67 // All non queries are funneled through one connection
68 // to increase performance a little
69 //
54 protected int ExecuteNonQuery(MySqlCommand cmd) 70 protected int ExecuteNonQuery(MySqlCommand cmd)
55 { 71 {
56 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 72 if (m_trans == null)
73 {
74 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
75 {
76 dbcon.Open();
77 int ret = ExecuteNonQueryWithConnection(cmd, dbcon);
78 dbcon.Close();
79 return ret;
80 }
81 }
82 else
83 {
84 return ExecuteNonQueryWithTransaction(cmd, m_trans);
85 }
86 }
87
88 private int ExecuteNonQueryWithTransaction(MySqlCommand cmd, MySqlTransaction trans)
89 {
90 cmd.Transaction = trans;
91 return ExecuteNonQueryWithConnection(cmd, trans.Connection);
92 }
93
94 private int ExecuteNonQueryWithConnection(MySqlCommand cmd, MySqlConnection dbcon)
95 {
96 try
57 { 97 {
58 dbcon.Open();
59 cmd.Connection = dbcon; 98 cmd.Connection = dbcon;
60 99
61 try 100 try
62 { 101 {
63 return cmd.ExecuteNonQuery(); 102 int ret = cmd.ExecuteNonQuery();
103 cmd.Connection = null;
104 return ret;
64 } 105 }
65 catch (Exception e) 106 catch (Exception e)
66 { 107 {
67 m_log.Error(e.Message, e); 108 m_log.Error(e.Message, e);
109 m_log.Error(Environment.StackTrace.ToString());
110 cmd.Connection = null;
68 return 0; 111 return 0;
69 } 112 }
70 } 113 }
114 catch (Exception e)
115 {
116 m_log.Error(e.Message, e);
117 return 0;
118 }
71 } 119 }
72 } 120 }
73} \ No newline at end of file 121}
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 35fa89f..9bd3c0c 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Data.MySQL
40 public class MySQLGenericTableHandler<T> : MySqlFramework where T: class, new() 40 public class MySQLGenericTableHandler<T> : MySqlFramework where T: class, new()
41 { 41 {
42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 protected Dictionary<string, FieldInfo> m_Fields = 44 protected Dictionary<string, FieldInfo> m_Fields =
45 new Dictionary<string, FieldInfo>(); 45 new Dictionary<string, FieldInfo>();
46 46
@@ -53,14 +53,27 @@ namespace OpenSim.Data.MySQL
53 get { return GetType().Assembly; } 53 get { return GetType().Assembly; }
54 } 54 }
55 55
56 public MySQLGenericTableHandler(MySqlTransaction trans,
57 string realm, string storeName) : base(trans)
58 {
59 m_Realm = realm;
60
61 CommonConstruct(storeName);
62 }
63
56 public MySQLGenericTableHandler(string connectionString, 64 public MySQLGenericTableHandler(string connectionString,
57 string realm, string storeName) : base(connectionString) 65 string realm, string storeName) : base(connectionString)
58 { 66 {
59 m_Realm = realm; 67 m_Realm = realm;
60 m_connectionString = connectionString; 68
61 69 CommonConstruct(storeName);
70 }
71
72 protected void CommonConstruct(string storeName)
73 {
62 if (storeName != String.Empty) 74 if (storeName != String.Empty)
63 { 75 {
76 // We always use a new connection for any Migrations
64 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 77 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
65 { 78 {
66 dbcon.Open(); 79 dbcon.Open();
@@ -111,6 +124,11 @@ namespace OpenSim.Data.MySQL
111 124
112 public virtual T[] Get(string[] fields, string[] keys) 125 public virtual T[] Get(string[] fields, string[] keys)
113 { 126 {
127 return Get(fields, keys, String.Empty);
128 }
129
130 public virtual T[] Get(string[] fields, string[] keys, string options)
131 {
114 if (fields.Length != keys.Length) 132 if (fields.Length != keys.Length)
115 return new T[0]; 133 return new T[0];
116 134
@@ -126,81 +144,107 @@ namespace OpenSim.Data.MySQL
126 144
127 string where = String.Join(" and ", terms.ToArray()); 145 string where = String.Join(" and ", terms.ToArray());
128 146
129 string query = String.Format("select * from {0} where {1}", 147 string query = String.Format("select * from {0} where {1} {2}",
130 m_Realm, where); 148 m_Realm, where, options);
131 149
132 cmd.CommandText = query; 150 cmd.CommandText = query;
133 151
134 return DoQuery(cmd); 152 return DoQuery(cmd);
135 } 153 }
136 } 154 }
137 155
138 protected T[] DoQuery(MySqlCommand cmd) 156 protected T[] DoQuery(MySqlCommand cmd)
139 { 157 {
158 if (m_trans == null)
159 {
160 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
161 {
162 dbcon.Open();
163 T[] ret = DoQueryWithConnection(cmd, dbcon);
164 dbcon.Close();
165 return ret;
166 }
167 }
168 else
169 {
170 return DoQueryWithTransaction(cmd, m_trans);
171 }
172 }
173
174 protected T[] DoQueryWithTransaction(MySqlCommand cmd, MySqlTransaction trans)
175 {
176 cmd.Transaction = trans;
177
178 return DoQueryWithConnection(cmd, trans.Connection);
179 }
180
181 protected T[] DoQueryWithConnection(MySqlCommand cmd, MySqlConnection dbcon)
182 {
140 List<T> result = new List<T>(); 183 List<T> result = new List<T>();
141 184
142 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 185 cmd.Connection = dbcon;
186
187 using (IDataReader reader = cmd.ExecuteReader())
143 { 188 {
144 dbcon.Open(); 189 if (reader == null)
145 cmd.Connection = dbcon; 190 return new T[0];
146 191
147 using (IDataReader reader = cmd.ExecuteReader()) 192 CheckColumnNames(reader);
148 {
149 if (reader == null)
150 return new T[0];
151 193
152 CheckColumnNames(reader); 194 while (reader.Read())
195 {
196 T row = new T();
153 197
154 while (reader.Read()) 198 foreach (string name in m_Fields.Keys)
155 { 199 {
156 T row = new T(); 200 if (reader[name] is DBNull)
157 201 {
158 foreach (string name in m_Fields.Keys) 202 continue;
203 }
204 if (m_Fields[name].FieldType == typeof(bool))
205 {
206 int v = Convert.ToInt32(reader[name]);
207 m_Fields[name].SetValue(row, v != 0 ? true : false);
208 }
209 else if (m_Fields[name].FieldType == typeof(UUID))
159 { 210 {
160 if (reader[name] is DBNull) 211 m_Fields[name].SetValue(row, DBGuid.FromDB(reader[name]));
161 {
162 continue;
163 }
164 if (m_Fields[name].FieldType == typeof(bool))
165 {
166 int v = Convert.ToInt32(reader[name]);
167 m_Fields[name].SetValue(row, v != 0 ? true : false);
168 }
169 else if (m_Fields[name].FieldType == typeof(UUID))
170 {
171 m_Fields[name].SetValue(row, DBGuid.FromDB(reader[name]));
172 }
173 else if (m_Fields[name].FieldType == typeof(int))
174 {
175 int v = Convert.ToInt32(reader[name]);
176 m_Fields[name].SetValue(row, v);
177 }
178 else
179 {
180 m_Fields[name].SetValue(row, reader[name]);
181 }
182 } 212 }
183 213 else if (m_Fields[name].FieldType == typeof(int))
184 if (m_DataField != null)
185 { 214 {
186 Dictionary<string, string> data = 215 int v = Convert.ToInt32(reader[name]);
187 new Dictionary<string, string>(); 216 m_Fields[name].SetValue(row, v);
217 }
218 else if (m_Fields[name].FieldType == typeof(uint))
219 {
220 uint v = Convert.ToUInt32(reader[name]);
221 m_Fields[name].SetValue(row, v);
222 }
223 else
224 {
225 m_Fields[name].SetValue(row, reader[name]);
226 }
227 }
188 228
189 foreach (string col in m_ColumnNames) 229 if (m_DataField != null)
190 { 230 {
191 data[col] = reader[col].ToString(); 231 Dictionary<string, string> data =
192 if (data[col] == null) 232 new Dictionary<string, string>();
193 data[col] = String.Empty;
194 }
195 233
196 m_DataField.SetValue(row, data); 234 foreach (string col in m_ColumnNames)
235 {
236 data[col] = reader[col].ToString();
237 if (data[col] == null)
238 data[col] = String.Empty;
197 } 239 }
198 240
199 result.Add(row); 241 m_DataField.SetValue(row, data);
200 } 242 }
243
244 result.Add(row);
201 } 245 }
202 } 246 }
203 247 cmd.Connection = null;
204 return result.ToArray(); 248 return result.ToArray();
205 } 249 }
206 250
@@ -210,9 +254,9 @@ namespace OpenSim.Data.MySQL
210 { 254 {
211 string query = String.Format("select * from {0} where {1}", 255 string query = String.Format("select * from {0} where {1}",
212 m_Realm, where); 256 m_Realm, where);
213 257
214 cmd.CommandText = query; 258 cmd.CommandText = query;
215 259
216 return DoQuery(cmd); 260 return DoQuery(cmd);
217 } 261 }
218 } 262 }
@@ -231,16 +275,16 @@ namespace OpenSim.Data.MySQL
231 { 275 {
232 names.Add(fi.Name); 276 names.Add(fi.Name);
233 values.Add("?" + fi.Name); 277 values.Add("?" + fi.Name);
234 278
235 // Temporarily return more information about what field is unexpectedly null for 279 // Temporarily return more information about what field is unexpectedly null for
236 // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the 280 // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
237 // InventoryTransferModule or we may be required to substitute a DBNull here. 281 // InventoryTransferModule or we may be required to substitute a DBNull here.
238 if (fi.GetValue(row) == null) 282 if (fi.GetValue(row) == null)
239 throw new NullReferenceException( 283 throw new NullReferenceException(
240 string.Format( 284 string.Format(
241 "[MYSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null", 285 "[MYSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null",
242 fi.Name, row)); 286 fi.Name, row));
243 287
244 cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); 288 cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString());
245 } 289 }
246 290
@@ -352,14 +396,26 @@ namespace OpenSim.Data.MySQL
352 396
353 public object DoQueryScalar(MySqlCommand cmd) 397 public object DoQueryScalar(MySqlCommand cmd)
354 { 398 {
355 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 399 if (m_trans == null)
356 { 400 {
357 dbcon.Open(); 401 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
358 cmd.Connection = dbcon; 402 {
403 dbcon.Open();
404 cmd.Connection = dbcon;
405
406 Object ret = cmd.ExecuteScalar();
407 cmd.Connection = null;
408 dbcon.Close();
409 return ret;
410 }
411 }
412 else
413 {
414 cmd.Connection = m_trans.Connection;
415 cmd.Transaction = m_trans;
359 416
360 return cmd.ExecuteScalar(); 417 return cmd.ExecuteScalar();
361 } 418 }
362 } 419 }
363
364 } 420 }
365} \ No newline at end of file 421}
diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs
index afa499e..4e73ee7 100644
--- a/OpenSim/Data/MySQL/MySQLGroupsData.cs
+++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs
@@ -133,10 +133,10 @@ namespace OpenSim.Data.MySQL
133 133
134 public bool DeleteMember(UUID groupID, string pricipalID) 134 public bool DeleteMember(UUID groupID, string pricipalID)
135 { 135 {
136 return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" }, 136 return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" },
137 new string[] { groupID.ToString(), pricipalID }); 137 new string[] { groupID.ToString(), pricipalID });
138 } 138 }
139 139
140 public int MemberCount(UUID groupID) 140 public int MemberCount(UUID groupID)
141 { 141 {
142 return (int)m_Membership.GetCount("GroupID", groupID.ToString()); 142 return (int)m_Membership.GetCount("GroupID", groupID.ToString());
@@ -168,7 +168,7 @@ namespace OpenSim.Data.MySQL
168 168
169 public bool DeleteRole(UUID groupID, UUID roleID) 169 public bool DeleteRole(UUID groupID, UUID roleID)
170 { 170 {
171 return m_Roles.Delete(new string[] { "GroupID", "RoleID" }, 171 return m_Roles.Delete(new string[] { "GroupID", "RoleID" },
172 new string[] { groupID.ToString(), roleID.ToString() }); 172 new string[] { groupID.ToString(), roleID.ToString() });
173 } 173 }
174 174
@@ -360,7 +360,7 @@ namespace OpenSim.Data.MySQL
360 get { return GetType().Assembly; } 360 get { return GetType().Assembly; }
361 } 361 }
362 362
363 public MySqlGroupsGroupsHandler(string connectionString, string realm, string store) 363 public MySqlGroupsGroupsHandler(string connectionString, string realm, string store)
364 : base(connectionString, realm, store) 364 : base(connectionString, realm, store)
365 { 365 {
366 } 366 }
@@ -375,7 +375,7 @@ namespace OpenSim.Data.MySQL
375 get { return GetType().Assembly; } 375 get { return GetType().Assembly; }
376 } 376 }
377 377
378 public MySqlGroupsMembershipHandler(string connectionString, string realm) 378 public MySqlGroupsMembershipHandler(string connectionString, string realm)
379 : base(connectionString, realm, string.Empty) 379 : base(connectionString, realm, string.Empty)
380 { 380 {
381 } 381 }
@@ -390,7 +390,7 @@ namespace OpenSim.Data.MySQL
390 get { return GetType().Assembly; } 390 get { return GetType().Assembly; }
391 } 391 }
392 392
393 public MySqlGroupsRolesHandler(string connectionString, string realm) 393 public MySqlGroupsRolesHandler(string connectionString, string realm)
394 : base(connectionString, realm, string.Empty) 394 : base(connectionString, realm, string.Empty)
395 { 395 {
396 } 396 }
@@ -405,7 +405,7 @@ namespace OpenSim.Data.MySQL
405 get { return GetType().Assembly; } 405 get { return GetType().Assembly; }
406 } 406 }
407 407
408 public MySqlGroupsRoleMembershipHandler(string connectionString, string realm) 408 public MySqlGroupsRoleMembershipHandler(string connectionString, string realm)
409 : base(connectionString, realm, string.Empty) 409 : base(connectionString, realm, string.Empty)
410 { 410 {
411 } 411 }
@@ -420,7 +420,7 @@ namespace OpenSim.Data.MySQL
420 get { return GetType().Assembly; } 420 get { return GetType().Assembly; }
421 } 421 }
422 422
423 public MySqlGroupsInvitesHandler(string connectionString, string realm) 423 public MySqlGroupsInvitesHandler(string connectionString, string realm)
424 : base(connectionString, realm, string.Empty) 424 : base(connectionString, realm, string.Empty)
425 { 425 {
426 } 426 }
@@ -431,8 +431,7 @@ namespace OpenSim.Data.MySQL
431 431
432 using (MySqlCommand cmd = new MySqlCommand()) 432 using (MySqlCommand cmd = new MySqlCommand())
433 { 433 {
434 cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); 434 cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm);
435 cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
436 435
437 ExecuteNonQuery(cmd); 436 ExecuteNonQuery(cmd);
438 } 437 }
@@ -448,7 +447,7 @@ namespace OpenSim.Data.MySQL
448 get { return GetType().Assembly; } 447 get { return GetType().Assembly; }
449 } 448 }
450 449
451 public MySqlGroupsNoticesHandler(string connectionString, string realm) 450 public MySqlGroupsNoticesHandler(string connectionString, string realm)
452 : base(connectionString, realm, string.Empty) 451 : base(connectionString, realm, string.Empty)
453 { 452 {
454 } 453 }
@@ -476,7 +475,7 @@ namespace OpenSim.Data.MySQL
476 get { return GetType().Assembly; } 475 get { return GetType().Assembly; }
477 } 476 }
478 477
479 public MySqlGroupsPrincipalsHandler(string connectionString, string realm) 478 public MySqlGroupsPrincipalsHandler(string connectionString, string realm)
480 : base(connectionString, realm, string.Empty) 479 : base(connectionString, realm, string.Empty)
481 { 480 {
482 } 481 }
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index e9b10f3..cc787cc 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
78 dbcon.Open(); 78 dbcon.Open();
79 Migration m = new Migration(dbcon, assem, "InventoryStore"); 79 Migration m = new Migration(dbcon, assem, "InventoryStore");
80 m.Update(); 80 m.Update();
81 dbcon.Close();
81 } 82 }
82 } 83 }
83 84
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130 items.Add(item); 131 items.Add(item);
131 } 132 }
132 133
134 dbcon.Close();
133 return items; 135 return items;
134 } 136 }
135 } 137 }
@@ -170,6 +172,7 @@ namespace OpenSim.Data.MySQL
170 while (reader.Read()) 172 while (reader.Read())
171 items.Add(readInventoryFolder(reader)); 173 items.Add(readInventoryFolder(reader));
172 174
175 dbcon.Close();
173 return items; 176 return items;
174 } 177 }
175 } 178 }
@@ -221,6 +224,7 @@ namespace OpenSim.Data.MySQL
221 if (items.Count > 0) 224 if (items.Count > 0)
222 rootFolder = items[0]; 225 rootFolder = items[0];
223 226
227 dbcon.Close();
224 return rootFolder; 228 return rootFolder;
225 } 229 }
226 } 230 }
@@ -261,6 +265,7 @@ namespace OpenSim.Data.MySQL
261 while (reader.Read()) 265 while (reader.Read())
262 items.Add(readInventoryFolder(reader)); 266 items.Add(readInventoryFolder(reader));
263 267
268 dbcon.Close();
264 return items; 269 return items;
265 } 270 }
266 } 271 }
@@ -288,7 +293,7 @@ namespace OpenSim.Data.MySQL
288 // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. 293 // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these.
289 // (DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero) 294 // (DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero)
290 item.CreatorId = reader["creatorID"].ToString(); 295 item.CreatorId = reader["creatorID"].ToString();
291 296
292 // Be a bit safer in parsing these because the 297 // Be a bit safer in parsing these because the
293 // database doesn't enforce them to be not null, and 298 // database doesn't enforce them to be not null, and
294 // the inventory still works if these are weird in the 299 // the inventory still works if these are weird in the
@@ -352,6 +357,7 @@ namespace OpenSim.Data.MySQL
352 if (reader.Read()) 357 if (reader.Read())
353 item = readInventoryItem(reader); 358 item = readInventoryItem(reader);
354 359
360 dbcon.Close();
355 return item; 361 return item;
356 } 362 }
357 } 363 }
@@ -417,6 +423,7 @@ namespace OpenSim.Data.MySQL
417 if (reader.Read()) 423 if (reader.Read())
418 folder = readInventoryFolder(reader); 424 folder = readInventoryFolder(reader);
419 425
426 dbcon.Close();
420 return folder; 427 return folder;
421 } 428 }
422 } 429 }
@@ -453,7 +460,7 @@ namespace OpenSim.Data.MySQL
453 itemName = item.Name.Substring(0, 64); 460 itemName = item.Name.Substring(0, 64);
454 m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length + " to " + itemName.Length + " characters on add item"); 461 m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length + " to " + itemName.Length + " characters on add item");
455 } 462 }
456 463
457 string itemDesc = item.Description; 464 string itemDesc = item.Description;
458 if (item.Description.Length > 128) 465 if (item.Description.Length > 128)
459 { 466 {
@@ -490,10 +497,10 @@ namespace OpenSim.Data.MySQL
490 result.Parameters.AddWithValue("?groupID", item.GroupID); 497 result.Parameters.AddWithValue("?groupID", item.GroupID);
491 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); 498 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
492 result.Parameters.AddWithValue("?flags", item.Flags); 499 result.Parameters.AddWithValue("?flags", item.Flags);
493 500
494 lock (m_dbLock) 501 lock (m_dbLock)
495 result.ExecuteNonQuery(); 502 result.ExecuteNonQuery();
496 503
497 result.Dispose(); 504 result.Dispose();
498 } 505 }
499 506
@@ -504,6 +511,7 @@ namespace OpenSim.Data.MySQL
504 lock (m_dbLock) 511 lock (m_dbLock)
505 result.ExecuteNonQuery(); 512 result.ExecuteNonQuery();
506 } 513 }
514 dbcon.Close();
507 } 515 }
508 } 516 }
509 catch (MySqlException e) 517 catch (MySqlException e)
@@ -540,6 +548,7 @@ namespace OpenSim.Data.MySQL
540 lock (m_dbLock) 548 lock (m_dbLock)
541 cmd.ExecuteNonQuery(); 549 cmd.ExecuteNonQuery();
542 } 550 }
551 dbcon.Close();
543 } 552 }
544 } 553 }
545 catch (MySqlException e) 554 catch (MySqlException e)
@@ -600,6 +609,7 @@ namespace OpenSim.Data.MySQL
600 m_log.Error(e.ToString()); 609 m_log.Error(e.ToString());
601 } 610 }
602 } 611 }
612 dbcon.Close();
603 } 613 }
604 } 614 }
605 615
@@ -630,7 +640,7 @@ namespace OpenSim.Data.MySQL
630 { 640 {
631 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); 641 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
632 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); 642 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
633 643
634 try 644 try
635 { 645 {
636 lock (m_dbLock) 646 lock (m_dbLock)
@@ -643,6 +653,7 @@ namespace OpenSim.Data.MySQL
643 m_log.Error(e.ToString()); 653 m_log.Error(e.ToString());
644 } 654 }
645 } 655 }
656 dbcon.Close();
646 } 657 }
647 } 658 }
648 659
@@ -806,6 +817,7 @@ namespace OpenSim.Data.MySQL
806 lock (m_dbLock) 817 lock (m_dbLock)
807 cmd.ExecuteNonQuery(); 818 cmd.ExecuteNonQuery();
808 } 819 }
820 dbcon.Close();
809 } 821 }
810 } 822 }
811 catch (MySqlException e) 823 catch (MySqlException e)
@@ -833,6 +845,7 @@ namespace OpenSim.Data.MySQL
833 lock (m_dbLock) 845 lock (m_dbLock)
834 cmd.ExecuteNonQuery(); 846 cmd.ExecuteNonQuery();
835 } 847 }
848 dbcon.Close();
836 } 849 }
837 } 850 }
838 catch (MySqlException e) 851 catch (MySqlException e)
@@ -860,7 +873,7 @@ namespace OpenSim.Data.MySQL
860 deleteOneFolder(folderID); 873 deleteOneFolder(folderID);
861 deleteItemsInFolder(folderID); 874 deleteItemsInFolder(folderID);
862 } 875 }
863 876
864 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) 877 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
865 { 878 {
866 lock (m_dbLock) 879 lock (m_dbLock)
@@ -886,6 +899,7 @@ namespace OpenSim.Data.MySQL
886 if (item != null) 899 if (item != null)
887 list.Add(item); 900 list.Add(item);
888 } 901 }
902 dbcon.Close();
889 return list; 903 return list;
890 } 904 }
891 } 905 }
diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs
index 81a0e83..2043dae 100644
--- a/OpenSim/Data/MySQL/MySQLMigrations.cs
+++ b/OpenSim/Data/MySQL/MySQLMigrations.cs
@@ -39,16 +39,16 @@ namespace OpenSim.Data.MySQL
39{ 39{
40 /// <summary>This is a MySQL-customized migration processor. The only difference is in how 40 /// <summary>This is a MySQL-customized migration processor. The only difference is in how
41 /// it executes SQL scripts (using MySqlScript instead of MyCommand) 41 /// it executes SQL scripts (using MySqlScript instead of MyCommand)
42 /// 42 ///
43 /// </summary> 43 /// </summary>
44 public class MySqlMigration : Migration 44 public class MySqlMigration : Migration
45 { 45 {
46 public MySqlMigration() 46 public MySqlMigration()
47 : base() 47 : base()
48 { 48 {
49 } 49 }
50 50
51 public MySqlMigration(DbConnection conn, Assembly assem, string subtype, string type) : 51 public MySqlMigration(DbConnection conn, Assembly assem, string subtype, string type) :
52 base(conn, assem, subtype, type) 52 base(conn, assem, subtype, type)
53 { 53 {
54 } 54 }
diff --git a/OpenSim/Data/MySQL/MySQLMuteListData.cs b/OpenSim/Data/MySQL/MySQLMuteListData.cs
new file mode 100644
index 0000000..a5935a3
--- /dev/null
+++ b/OpenSim/Data/MySQL/MySQLMuteListData.cs
@@ -0,0 +1,67 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using MySql.Data.MySqlClient;
35
36namespace OpenSim.Data.MySQL
37{
38 public class MySqlMuteListData : MySQLGenericTableHandler<MuteData>, IMuteListData
39 {
40 public MySqlMuteListData(string connectionString)
41 : base(connectionString, "MuteList", "MuteListStore")
42 {
43 }
44
45 public MuteData[] Get(UUID agentID)
46 {
47 MuteData[] data = base.Get("AgentID", agentID.ToString());
48 return data;
49 }
50
51 public bool Delete(UUID agentID, UUID muteID, string muteName)
52 {
53 string cmnd ="delete from MuteList where AgentID = ?AgentID and MuteID = ?MuteID and MuteName = ?MuteName";
54
55 using (MySqlCommand cmd = new MySqlCommand(cmnd))
56 {
57 cmd.Parameters.AddWithValue("?AgentID", agentID.ToString());
58 cmd.Parameters.AddWithValue("?MuteID", muteID.ToString());
59 cmd.Parameters.AddWithValue("?MuteName", muteName);
60
61 if (ExecuteNonQuery(cmd) > 0)
62 return true;
63 return false;
64 }
65 }
66 }
67} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs
index bafd204..7608858 100644
--- a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs
+++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Data.MySQL
50 using (MySqlCommand cmd = new MySqlCommand()) 50 using (MySqlCommand cmd = new MySqlCommand())
51 { 51 {
52 cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm); 52 cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm);
53 53
54 ExecuteNonQuery(cmd); 54 ExecuteNonQuery(cmd);
55 } 55 }
56 56
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index 3f90639..70aca5f 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -66,9 +66,9 @@ namespace OpenSim.Data.MySQL
66 using (MySqlCommand cmd = new MySqlCommand()) 66 using (MySqlCommand cmd = new MySqlCommand())
67 { 67 {
68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); 68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm);
69 69
70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
71 71
72 ExecuteNonQuery(cmd); 72 ExecuteNonQuery(cmd);
73 } 73 }
74 } 74 }
@@ -85,10 +85,10 @@ namespace OpenSim.Data.MySQL
85 using (MySqlCommand cmd = new MySqlCommand()) 85 using (MySqlCommand cmd = new MySqlCommand())
86 { 86 {
87 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); 87 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm);
88 88
89 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); 89 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
90 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 90 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
91 91
92 if (ExecuteNonQuery(cmd) == 0) 92 if (ExecuteNonQuery(cmd) == 0)
93 return false; 93 return false;
94 } 94 }
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2ad7590..46df421 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Data.MySQL
60 dbcon.Open(); 60 dbcon.Open();
61 Migration m = new Migration(dbcon, Assembly, "GridStore"); 61 Migration m = new Migration(dbcon, Assembly, "GridStore");
62 m.Update(); 62 m.Update();
63 dbcon.Close();
63 } 64 }
64 } 65 }
65 66
@@ -82,6 +83,7 @@ namespace OpenSim.Data.MySQL
82 83
83 public RegionData Get(int posX, int posY, UUID scopeID) 84 public RegionData Get(int posX, int posY, UUID scopeID)
84 { 85 {
86/* fixed size regions
85 string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; 87 string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY";
86 if (scopeID != UUID.Zero) 88 if (scopeID != UUID.Zero)
87 command += " and ScopeID = ?scopeID"; 89 command += " and ScopeID = ?scopeID";
@@ -98,6 +100,45 @@ namespace OpenSim.Data.MySQL
98 100
99 return ret[0]; 101 return ret[0];
100 } 102 }
103*/
104 // extend database search for maximum region size area
105 string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY";
106 if (scopeID != UUID.Zero)
107 command += " and ScopeID = ?scopeID";
108
109 int startX = posX - (int)Constants.MaximumRegionSize;
110 int startY = posY - (int)Constants.MaximumRegionSize;
111 int endX = posX;
112 int endY = posY;
113
114 List<RegionData> ret;
115 using (MySqlCommand cmd = new MySqlCommand(command))
116 {
117 cmd.Parameters.AddWithValue("?startX", startX.ToString());
118 cmd.Parameters.AddWithValue("?startY", startY.ToString());
119 cmd.Parameters.AddWithValue("?endX", endX.ToString());
120 cmd.Parameters.AddWithValue("?endY", endY.ToString());
121 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
122
123 ret = RunCommand(cmd);
124 }
125
126 if (ret.Count == 0)
127 return null;
128
129 // find the first that contains pos
130 RegionData rg = null;
131 foreach (RegionData r in ret)
132 {
133 if (posX >= r.posX && posX < r.posX + r.sizeX
134 && posY >= r.posY && posY < r.posY + r.sizeY)
135 {
136 rg = r;
137 break;
138 }
139 }
140
141 return rg;
101 } 142 }
102 143
103 public RegionData Get(UUID regionID, UUID scopeID) 144 public RegionData Get(UUID regionID, UUID scopeID)
@@ -121,6 +162,7 @@ namespace OpenSim.Data.MySQL
121 162
122 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) 163 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
123 { 164 {
165/* fix size regions
124 string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY"; 166 string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY";
125 if (scopeID != UUID.Zero) 167 if (scopeID != UUID.Zero)
126 command += " and ScopeID = ?scopeID"; 168 command += " and ScopeID = ?scopeID";
@@ -135,6 +177,38 @@ namespace OpenSim.Data.MySQL
135 177
136 return RunCommand(cmd); 178 return RunCommand(cmd);
137 } 179 }
180 */
181 string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY";
182 if (scopeID != UUID.Zero)
183 command += " and ScopeID = ?scopeID";
184
185 int qstartX = startX - (int)Constants.MaximumRegionSize;
186 int qstartY = startY - (int)Constants.MaximumRegionSize;
187
188 List<RegionData> dbret;
189 using (MySqlCommand cmd = new MySqlCommand(command))
190 {
191 cmd.Parameters.AddWithValue("?startX", qstartX.ToString());
192 cmd.Parameters.AddWithValue("?startY", qstartY.ToString());
193 cmd.Parameters.AddWithValue("?endX", endX.ToString());
194 cmd.Parameters.AddWithValue("?endY", endY.ToString());
195 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
196
197 dbret = RunCommand(cmd);
198 }
199
200 List<RegionData> ret = new List<RegionData>();
201
202 if (dbret.Count == 0)
203 return ret;
204
205 foreach (RegionData r in dbret)
206 {
207 if (r.posX + r.sizeX > startX && r.posX <= endX
208 && r.posY + r.sizeY > startY && r.posY <= endY)
209 ret.Add(r);
210 }
211 return ret;
138 } 212 }
139 213
140 public List<RegionData> RunCommand(MySqlCommand cmd) 214 public List<RegionData> RunCommand(MySqlCommand cmd)
@@ -187,6 +261,8 @@ namespace OpenSim.Data.MySQL
187 retList.Add(ret); 261 retList.Add(ret);
188 } 262 }
189 } 263 }
264 cmd.Connection = null;
265 dbcon.Close();
190 } 266 }
191 267
192 return retList; 268 return retList;
@@ -337,7 +413,7 @@ namespace OpenSim.Data.MySQL
337 using (MySqlCommand cmd = new MySqlCommand(command)) 413 using (MySqlCommand cmd = new MySqlCommand(command))
338 { 414 {
339 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 415 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
340 416
341 return RunCommand(cmd); 417 return RunCommand(cmd);
342 } 418 }
343 } 419 }
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index bb0ab75..e754522 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Data.MySQL
55 /// <summary> 55 /// <summary>
56 /// This lock was being used to serialize database operations when the connection was shared, but this has 56 /// This lock was being used to serialize database operations when the connection was shared, but this has
57 /// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead. 57 /// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead.
58 /// FIXME: However, the locks remain in many places since they are effectively providing a level of 58 /// FIXME: However, the locks remain in many places since they are effectively providing a level of
59 /// transactionality. This should be replaced by more efficient database transactions which would not require 59 /// transactionality. This should be replaced by more efficient database transactions which would not require
60 /// unrelated operations to block each other or unrelated operations on the same tables from blocking each 60 /// unrelated operations to block each other or unrelated operations on the same tables from blocking each
61 /// other. 61 /// other.
@@ -76,7 +76,7 @@ namespace OpenSim.Data.MySQL
76 Initialise(connectionString); 76 Initialise(connectionString);
77 } 77 }
78 78
79 public void Initialise(string connectionString) 79 public virtual void Initialise(string connectionString)
80 { 80 {
81 m_connectionString = connectionString; 81 m_connectionString = connectionString;
82 82
@@ -88,6 +88,7 @@ namespace OpenSim.Data.MySQL
88 // 88 //
89 Migration m = new Migration(dbcon, Assembly, "RegionStore"); 89 Migration m = new Migration(dbcon, Assembly, "RegionStore");
90 m.Update(); 90 m.Update();
91 dbcon.Close();
91 } 92 }
92 } 93 }
93 94
@@ -123,7 +124,7 @@ namespace OpenSim.Data.MySQL
123 124
124 public void Dispose() {} 125 public void Dispose() {}
125 126
126 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 127 public virtual void StoreObject(SceneObjectGroup obj, UUID regionUUID)
127 { 128 {
128 uint flags = obj.RootPart.GetEffectiveObjectFlags(); 129 uint flags = obj.RootPart.GetEffectiveObjectFlags();
129 130
@@ -167,7 +168,7 @@ namespace OpenSim.Data.MySQL
167 "SitTargetOrientY, SitTargetOrientZ, " + 168 "SitTargetOrientY, SitTargetOrientZ, " +
168 "RegionUUID, CreatorID, " + 169 "RegionUUID, CreatorID, " +
169 "OwnerID, GroupID, " + 170 "OwnerID, GroupID, " +
170 "LastOwnerID, SceneGroupID, " + 171 "LastOwnerID, RezzerID, SceneGroupID, " +
171 "PayPrice, PayButton1, " + 172 "PayPrice, PayButton1, " +
172 "PayButton2, PayButton3, " + 173 "PayButton2, PayButton3, " +
173 "PayButton4, LoopedSound, " + 174 "PayButton4, LoopedSound, " +
@@ -183,10 +184,12 @@ namespace OpenSim.Data.MySQL
183 "ParticleSystem, ClickAction, Material, " + 184 "ParticleSystem, ClickAction, Material, " +
184 "CollisionSound, CollisionSoundVolume, " + 185 "CollisionSound, CollisionSoundVolume, " +
185 "PassTouches, " + 186 "PassTouches, " +
186 "LinkNumber, MediaURL, AttachedPosX, " + 187 "PassCollisions, " +
187 "AttachedPosY, AttachedPosZ, KeyframeMotion, " + 188 "LinkNumber, MediaURL, KeyframeMotion, AttachedPosX, " +
189 "AttachedPosY, AttachedPosZ, " +
188 "PhysicsShapeType, Density, GravityModifier, " + 190 "PhysicsShapeType, Density, GravityModifier, " +
189 "Friction, Restitution, DynAttrs " + 191 "Friction, Restitution, Vehicle, PhysInertia, DynAttrs, " +
192 "RotationAxisLocks" +
190 ") values (" + "?UUID, " + 193 ") values (" + "?UUID, " +
191 "?CreationDate, ?Name, ?Text, " + 194 "?CreationDate, ?Name, ?Text, " +
192 "?Description, ?SitName, ?TouchName, " + 195 "?Description, ?SitName, ?TouchName, " +
@@ -205,7 +208,7 @@ namespace OpenSim.Data.MySQL
205 "?SitTargetOrientW, ?SitTargetOrientX, " + 208 "?SitTargetOrientW, ?SitTargetOrientX, " +
206 "?SitTargetOrientY, ?SitTargetOrientZ, " + 209 "?SitTargetOrientY, ?SitTargetOrientZ, " +
207 "?RegionUUID, ?CreatorID, ?OwnerID, " + 210 "?RegionUUID, ?CreatorID, ?OwnerID, " +
208 "?GroupID, ?LastOwnerID, ?SceneGroupID, " + 211 "?GroupID, ?LastOwnerID, ?RezzerID, ?SceneGroupID, " +
209 "?PayPrice, ?PayButton1, ?PayButton2, " + 212 "?PayPrice, ?PayButton1, ?PayButton2, " +
210 "?PayButton3, ?PayButton4, ?LoopedSound, " + 213 "?PayButton3, ?PayButton4, ?LoopedSound, " +
211 "?LoopedSoundGain, ?TextureAnimation, " + 214 "?LoopedSoundGain, ?TextureAnimation, " +
@@ -218,11 +221,12 @@ namespace OpenSim.Data.MySQL
218 "?SaleType, ?ColorR, ?ColorG, " + 221 "?SaleType, ?ColorR, ?ColorG, " +
219 "?ColorB, ?ColorA, ?ParticleSystem, " + 222 "?ColorB, ?ColorA, ?ParticleSystem, " +
220 "?ClickAction, ?Material, ?CollisionSound, " + 223 "?ClickAction, ?Material, ?CollisionSound, " +
221 "?CollisionSoundVolume, ?PassTouches, " + 224 "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " +
222 "?LinkNumber, ?MediaURL, ?AttachedPosX, " + 225 "?LinkNumber, ?MediaURL, ?KeyframeMotion, ?AttachedPosX, " +
223 "?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " + 226 "?AttachedPosY, ?AttachedPosZ, " +
224 "?PhysicsShapeType, ?Density, ?GravityModifier, " + 227 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
225 "?Friction, ?Restitution, ?DynAttrs)"; 228 "?Friction, ?Restitution, ?Vehicle, ?PhysInertia, ?DynAttrs," +
229 "?RotationAxisLocks)";
226 230
227 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 231 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
228 232
@@ -258,14 +262,15 @@ namespace OpenSim.Data.MySQL
258 ExecuteNonQuery(cmd); 262 ExecuteNonQuery(cmd);
259 } 263 }
260 } 264 }
265 dbcon.Close();
261 } 266 }
262 } 267 }
263 } 268 }
264 269
265 public void RemoveObject(UUID obj, UUID regionUUID) 270 public virtual void RemoveObject(UUID obj, UUID regionUUID)
266 { 271 {
267// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); 272// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID);
268 273
269 List<UUID> uuids = new List<UUID>(); 274 List<UUID> uuids = new List<UUID>();
270 275
271 // Formerly, this used to check the region UUID. 276 // Formerly, this used to check the region UUID.
@@ -297,6 +302,7 @@ namespace OpenSim.Data.MySQL
297 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; 302 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
298 ExecuteNonQuery(cmd); 303 ExecuteNonQuery(cmd);
299 } 304 }
305 dbcon.Close();
300 } 306 }
301 } 307 }
302 308
@@ -317,7 +323,8 @@ namespace OpenSim.Data.MySQL
317 /// <param name="uuid">the Item UUID</param> 323 /// <param name="uuid">the Item UUID</param>
318 private void RemoveItems(UUID uuid) 324 private void RemoveItems(UUID uuid)
319 { 325 {
320 lock (m_dbLock) 326 // locked by caller
327// lock (m_dbLock)
321 { 328 {
322 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 329 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
323 { 330 {
@@ -330,6 +337,7 @@ namespace OpenSim.Data.MySQL
330 337
331 ExecuteNonQuery(cmd); 338 ExecuteNonQuery(cmd);
332 } 339 }
340 dbcon.Close();
333 } 341 }
334 } 342 }
335 } 343 }
@@ -368,6 +376,7 @@ namespace OpenSim.Data.MySQL
368 376
369 ExecuteNonQuery(cmd); 377 ExecuteNonQuery(cmd);
370 } 378 }
379 dbcon.Close();
371 } 380 }
372 } 381 }
373 } 382 }
@@ -407,11 +416,12 @@ namespace OpenSim.Data.MySQL
407 416
408 ExecuteNonQuery(cmd); 417 ExecuteNonQuery(cmd);
409 } 418 }
419 dbcon.Close();
410 } 420 }
411 } 421 }
412 } 422 }
413 423
414 public List<SceneObjectGroup> LoadObjects(UUID regionID) 424 public virtual List<SceneObjectGroup> LoadObjects(UUID regionID)
415 { 425 {
416 const int ROWS_PER_QUERY = 5000; 426 const int ROWS_PER_QUERY = 5000;
417 427
@@ -456,6 +466,7 @@ namespace OpenSim.Data.MySQL
456 } 466 }
457 } 467 }
458 } 468 }
469 dbcon.Close();
459 } 470 }
460 } 471 }
461 472
@@ -505,7 +516,7 @@ namespace OpenSim.Data.MySQL
505 #region Prim Inventory Loading 516 #region Prim Inventory Loading
506 517
507 // Instead of attempting to LoadItems on every prim, 518 // Instead of attempting to LoadItems on every prim,
508 // most of which probably have no items... get a 519 // most of which probably have no items... get a
509 // list from DB of all prims which have items and 520 // list from DB of all prims which have items and
510 // LoadItems only on those 521 // LoadItems only on those
511 List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); 522 List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>();
@@ -531,6 +542,7 @@ namespace OpenSim.Data.MySQL
531 } 542 }
532 } 543 }
533 } 544 }
545 dbcon.Close();
534 } 546 }
535 } 547 }
536 548
@@ -576,6 +588,7 @@ namespace OpenSim.Data.MySQL
576 } 588 }
577 } 589 }
578 } 590 }
591 dbcon.Close();
579 } 592 }
580 593
581 prim.Inventory.RestoreInventoryItems(inventory); 594 prim.Inventory.RestoreInventoryItems(inventory);
@@ -590,40 +603,102 @@ namespace OpenSim.Data.MySQL
590 603
591 public void StoreTerrain(TerrainData terrData, UUID regionID) 604 public void StoreTerrain(TerrainData terrData, UUID regionID)
592 { 605 {
593 lock (m_dbLock) 606 Util.FireAndForget(delegate(object x)
594 { 607 {
595 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 608 m_log.Info("[REGION DB]: Storing terrain");
596 {
597 dbcon.Open();
598 609
599 using (MySqlCommand cmd = dbcon.CreateCommand()) 610 int terrainDBRevision;
611 Array terrainDBblob;
612 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
613
614 lock (m_dbLock)
615 {
616 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
600 { 617 {
601 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; 618 dbcon.Open();
602 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
603 619
604 ExecuteNonQuery(cmd); 620 using (MySqlCommand cmd = dbcon.CreateCommand())
621 {
622 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
623 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
605 624
606 int terrainDBRevision; 625 using (MySqlCommand cmd2 = dbcon.CreateCommand())
607 Array terrainDBblob; 626 {
608 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); 627 try
628 {
629 cmd2.CommandText = "insert into terrain (RegionUUID, " +
630 "Revision, Heightfield) values (?RegionUUID, " +
631 "?Revision, ?Heightfield)";
609 632
610 m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}", 633 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
611 LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision); 634 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
635 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
612 636
613 cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" 637 ExecuteNonQuery(cmd);
614 + "values (?RegionUUID, ?Revision, ?Heightfield)"; 638 ExecuteNonQuery(cmd2);
639 }
640 catch (Exception e)
641 {
642 m_log.ErrorFormat(e.ToString());
643 }
644 }
645 }
646 dbcon.Close();
647 }
648 }
649 });
650 }
615 651
616 cmd.Parameters.AddWithValue("Revision", terrainDBRevision); 652 public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
617 cmd.Parameters.AddWithValue("Heightfield", terrainDBblob); 653 {
654 Util.FireAndForget(delegate(object x)
655 {
656 m_log.Info("[REGION DB]: Storing Baked terrain");
618 657
619 ExecuteNonQuery(cmd); 658 int terrainDBRevision;
659 Array terrainDBblob;
660 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
661
662 lock (m_dbLock)
663 {
664 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
665 {
666 dbcon.Open();
667
668 using (MySqlCommand cmd = dbcon.CreateCommand())
669 {
670 cmd.CommandText = "delete from bakedterrain where RegionUUID = ?RegionUUID";
671 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
672
673 using (MySqlCommand cmd2 = dbcon.CreateCommand())
674 {
675 try
676 {
677 cmd2.CommandText = "insert into bakedterrain (RegionUUID, " +
678 "Revision, Heightfield) values (?RegionUUID, " +
679 "?Revision, ?Heightfield)";
680
681 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
682 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
683 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
684
685 ExecuteNonQuery(cmd);
686 ExecuteNonQuery(cmd2);
687 }
688 catch (Exception e)
689 {
690 m_log.ErrorFormat(e.ToString());
691 }
692 }
693 }
694 dbcon.Close();
620 } 695 }
621 } 696 }
622 } 697 });
623 } 698 }
624 699
625 // Legacy region loading 700 // Legacy region loading
626 public double[,] LoadTerrain(UUID regionID) 701 public virtual double[,] LoadTerrain(UUID regionID)
627 { 702 {
628 double[,] ret = null; 703 double[,] ret = null;
629 TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); 704 TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
@@ -636,9 +711,12 @@ namespace OpenSim.Data.MySQL
636 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) 711 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
637 { 712 {
638 TerrainData terrData = null; 713 TerrainData terrData = null;
714 byte[] blob = null;
715 int rev = 0;
639 716
640 lock (m_dbLock) 717 lock (m_dbLock)
641 { 718 {
719
642 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 720 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
643 { 721 {
644 dbcon.Open(); 722 dbcon.Open();
@@ -654,19 +732,64 @@ namespace OpenSim.Data.MySQL
654 { 732 {
655 while (reader.Read()) 733 while (reader.Read())
656 { 734 {
657 int rev = Convert.ToInt32(reader["Revision"]); 735 rev = Convert.ToInt32(reader["Revision"]);
658 byte[] blob = (byte[])reader["Heightfield"]; 736 if ((reader["Heightfield"] != DBNull.Value))
659 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); 737 {
738 blob = (byte[])reader["Heightfield"];
739 }
740 }
741 }
742 }
743 dbcon.Close();
744 }
745 }
746
747 if(blob != null)
748 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
749
750 return terrData;
751 }
752
753 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
754 {
755 TerrainData terrData = null;
756 byte[] blob = null;
757 int rev = 0;
758
759 lock (m_dbLock)
760 {
761 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
762 {
763 dbcon.Open();
764
765 using (MySqlCommand cmd = dbcon.CreateCommand())
766 {
767 cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
768 "from bakedterrain where RegionUUID = ?RegionUUID ";
769 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
770
771 using (IDataReader reader = ExecuteReader(cmd))
772 {
773 while (reader.Read())
774 {
775 rev = Convert.ToInt32(reader["Revision"]);
776 if ((reader["Heightfield"] != DBNull.Value))
777 {
778 blob = (byte[])reader["Heightfield"];
779 }
660 } 780 }
661 } 781 }
662 } 782 }
783 dbcon.Close();
663 } 784 }
664 } 785 }
786 if(blob != null)
787 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
665 788
666 return terrData; 789 return terrData;
667 } 790 }
668 791
669 public void RemoveLandObject(UUID globalID) 792 public virtual void RemoveLandObject(UUID globalID)
670 { 793 {
671 lock (m_dbLock) 794 lock (m_dbLock)
672 { 795 {
@@ -681,11 +804,12 @@ namespace OpenSim.Data.MySQL
681 804
682 ExecuteNonQuery(cmd); 805 ExecuteNonQuery(cmd);
683 } 806 }
807 dbcon.Close();
684 } 808 }
685 } 809 }
686 } 810 }
687 811
688 public void StoreLandObject(ILandObject parcel) 812 public virtual void StoreLandObject(ILandObject parcel)
689 { 813 {
690 lock (m_dbLock) 814 lock (m_dbLock)
691 { 815 {
@@ -705,7 +829,8 @@ namespace OpenSim.Data.MySQL
705 "UserLocationX, UserLocationY, UserLocationZ, " + 829 "UserLocationX, UserLocationY, UserLocationZ, " +
706 "UserLookAtX, UserLookAtY, UserLookAtZ, " + 830 "UserLookAtX, UserLookAtY, UserLookAtZ, " +
707 "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + 831 "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " +
708 "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + 832 "MediaSize, MediaLoop, ObscureMusic, ObscureMedia, " +
833 "SeeAVs, AnyAVSounds, GroupAVSounds) values (" +
709 "?UUID, ?RegionUUID, " + 834 "?UUID, ?RegionUUID, " +
710 "?LocalLandID, ?Bitmap, ?Name, ?Description, " + 835 "?LocalLandID, ?Bitmap, ?Name, ?Description, " +
711 "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + 836 "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " +
@@ -716,7 +841,8 @@ namespace OpenSim.Data.MySQL
716 "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + 841 "?UserLocationX, ?UserLocationY, ?UserLocationZ, " +
717 "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + 842 "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
718 "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ 843 "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+
719 "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; 844 "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia, " +
845 "?SeeAVs, ?AnyAVSounds, ?GroupAVSounds)";
720 846
721 FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); 847 FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID);
722 848
@@ -738,11 +864,12 @@ namespace OpenSim.Data.MySQL
738 cmd.Parameters.Clear(); 864 cmd.Parameters.Clear();
739 } 865 }
740 } 866 }
867 dbcon.Close();
741 } 868 }
742 } 869 }
743 } 870 }
744 871
745 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 872 public virtual RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
746 { 873 {
747 RegionLightShareData nWP = new RegionLightShareData(); 874 RegionLightShareData nWP = new RegionLightShareData();
748 nWP.OnSave += StoreRegionWindlightSettings; 875 nWP.OnSave += StoreRegionWindlightSettings;
@@ -759,90 +886,94 @@ namespace OpenSim.Data.MySQL
759 886
760 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); 887 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
761 888
762 IDataReader result = ExecuteReader(cmd); 889 using(IDataReader result = ExecuteReader(cmd))
763 if (!result.Read())
764 { 890 {
765 //No result, so store our default windlight profile and return it 891 if(!result.Read())
766 nWP.regionID = regionUUID; 892 {
767// StoreRegionWindlightSettings(nWP); 893 //No result, so store our default windlight profile and return it
768 return nWP; 894 nWP.regionID = regionUUID;
769 } 895 // StoreRegionWindlightSettings(nWP);
770 else 896 return nWP;
771 { 897 }
772 nWP.regionID = DBGuid.FromDB(result["region_id"]); 898 else
773 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); 899 {
774 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); 900 nWP.regionID = DBGuid.FromDB(result["region_id"]);
775 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); 901 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
776 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); 902 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
777 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); 903 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
778 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); 904 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
779 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); 905 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
780 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); 906 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
781 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); 907 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
782 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); 908 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
783 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); 909 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
784 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); 910 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
785 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); 911 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
786 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); 912 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
787 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); 913 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
788 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); 914 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
789 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); 915 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
790 UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); 916 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
791 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); 917 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
792 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); 918 UUID.TryParse(result["normal_map_texture"].ToString(),out nWP.normalMapTexture);
793 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); 919 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
794 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); 920 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
795 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); 921 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
796 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); 922 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
797 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); 923 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
798 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); 924 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
799 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); 925 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
800 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); 926 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
801 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); 927 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
802 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); 928 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
803 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); 929 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
804 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); 930 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
805 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); 931 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
806 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); 932 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
807 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); 933 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
808 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); 934 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
809 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); 935 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
810 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); 936 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
811 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); 937 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
812 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); 938 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
813 nWP.eastAngle = Convert.ToSingle(result["east_angle"]); 939 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
814 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); 940 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
815 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); 941 nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
816 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); 942 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
817 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); 943 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
818 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); 944 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
819 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); 945 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
820 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); 946 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
821 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); 947 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
822 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); 948 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
823 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); 949 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
824 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); 950 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
825 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); 951 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
826 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); 952 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
827 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); 953 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
828 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); 954 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
829 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); 955 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
830 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); 956 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
831 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); 957 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
832 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); 958 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
833 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); 959 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
834 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); 960 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
835 nWP.valid = true; 961 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
962 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
963 nWP.valid = true;
964 }
836 } 965 }
837 } 966 }
967 dbcon.Close();
838 } 968 }
839 969
840 return nWP; 970 return nWP;
841 } 971 }
842 972
843 public RegionSettings LoadRegionSettings(UUID regionUUID) 973 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
844 { 974 {
845 RegionSettings rs = null; 975 RegionSettings rs = null;
976 bool needStore = false;
846 977
847 lock (m_dbLock) 978 lock (m_dbLock)
848 { 979 {
@@ -868,19 +999,23 @@ namespace OpenSim.Data.MySQL
868 rs.RegionUUID = regionUUID; 999 rs.RegionUUID = regionUUID;
869 rs.OnSave += StoreRegionSettings; 1000 rs.OnSave += StoreRegionSettings;
870 1001
871 StoreRegionSettings(rs); 1002 needStore = true;
872 } 1003 }
873 } 1004 }
874 } 1005 }
1006 dbcon.Close();
875 } 1007 }
876 } 1008 }
877 1009
1010 if(needStore)
1011 StoreRegionSettings(rs);
1012
878 LoadSpawnPoints(rs); 1013 LoadSpawnPoints(rs);
879 1014
880 return rs; 1015 return rs;
881 } 1016 }
882 1017
883 public void StoreRegionWindlightSettings(RegionLightShareData wl) 1018 public virtual void StoreRegionWindlightSettings(RegionLightShareData wl)
884 { 1019 {
885 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1020 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
886 { 1021 {
@@ -888,31 +1023,32 @@ namespace OpenSim.Data.MySQL
888 1023
889 using (MySqlCommand cmd = dbcon.CreateCommand()) 1024 using (MySqlCommand cmd = dbcon.CreateCommand())
890 { 1025 {
891 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; 1026 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "
892 cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; 1027 + "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "
893 cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; 1028 + "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "
894 cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; 1029 + "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "
895 cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; 1030 + "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "
896 cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; 1031 + "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "
897 cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; 1032 + "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "
898 cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; 1033 + "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "
899 cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; 1034 + "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "
900 cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; 1035 + "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "
901 cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; 1036 + "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "
902 cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; 1037 + "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "
903 cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; 1038 + "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "
904 cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; 1039 + "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "
905 cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; 1040 + "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "
906 cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; 1041 + "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "
907 cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; 1042 + "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "
908 cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; 1043 + "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "
909 cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; 1044 + "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "
910 cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; 1045 + "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "
911 cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; 1046 + "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "
912 cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; 1047 + "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "
913 cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; 1048 + "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "
914 cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; 1049 + "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "
915 cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; 1050 + "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"
1051 ;
916 1052
917 cmd.Parameters.AddWithValue("region_id", wl.regionID); 1053 cmd.Parameters.AddWithValue("region_id", wl.regionID);
918 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); 1054 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
@@ -977,13 +1113,14 @@ namespace OpenSim.Data.MySQL
977 cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); 1113 cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
978 cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); 1114 cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
979 cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); 1115 cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
980 1116
981 ExecuteNonQuery(cmd); 1117 ExecuteNonQuery(cmd);
982 } 1118 }
1119 dbcon.Close();
983 } 1120 }
984 } 1121 }
985 1122
986 public void RemoveRegionWindlightSettings(UUID regionID) 1123 public virtual void RemoveRegionWindlightSettings(UUID regionID)
987 { 1124 {
988 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1125 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
989 { 1126 {
@@ -995,6 +1132,7 @@ namespace OpenSim.Data.MySQL
995 cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); 1132 cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
996 ExecuteNonQuery(cmd); 1133 ExecuteNonQuery(cmd);
997 } 1134 }
1135 dbcon.Close();
998 } 1136 }
999 } 1137 }
1000 1138
@@ -1013,14 +1151,19 @@ namespace OpenSim.Data.MySQL
1013 1151
1014 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); 1152 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1015 1153
1016 IDataReader result = ExecuteReader(cmd); 1154 using(IDataReader result = ExecuteReader(cmd))
1017 if (!result.Read())
1018 { 1155 {
1019 return String.Empty; 1156 if(!result.Read())
1020 } 1157 {
1021 else 1158 dbcon.Close();
1022 { 1159 return String.Empty;
1023 return Convert.ToString(result["llsd_settings"]); 1160 }
1161 else
1162 {
1163 string ret = Convert.ToString(result["llsd_settings"]);
1164 dbcon.Close();
1165 return ret;
1166 }
1024 } 1167 }
1025 } 1168 }
1026 } 1169 }
@@ -1041,6 +1184,7 @@ namespace OpenSim.Data.MySQL
1041 1184
1042 ExecuteNonQuery(cmd); 1185 ExecuteNonQuery(cmd);
1043 } 1186 }
1187 dbcon.Close();
1044 } 1188 }
1045 } 1189 }
1046 1190
@@ -1056,11 +1200,12 @@ namespace OpenSim.Data.MySQL
1056 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); 1200 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1057 ExecuteNonQuery(cmd); 1201 ExecuteNonQuery(cmd);
1058 } 1202 }
1203 dbcon.Close();
1059 } 1204 }
1060 } 1205 }
1061 #endregion 1206 #endregion
1062 1207
1063 public void StoreRegionSettings(RegionSettings rs) 1208 public virtual void StoreRegionSettings(RegionSettings rs)
1064 { 1209 {
1065 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1210 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1066 { 1211 {
@@ -1069,52 +1214,51 @@ namespace OpenSim.Data.MySQL
1069 using (MySqlCommand cmd = dbcon.CreateCommand()) 1214 using (MySqlCommand cmd = dbcon.CreateCommand())
1070 { 1215 {
1071 cmd.CommandText = "replace into regionsettings (regionUUID, " + 1216 cmd.CommandText = "replace into regionsettings (regionUUID, " +
1072 "block_terraform, block_fly, allow_damage, " + 1217 "block_terraform, block_fly, allow_damage, " +
1073 "restrict_pushing, allow_land_resell, " + 1218 "restrict_pushing, allow_land_resell, " +
1074 "allow_land_join_divide, block_show_in_search, " + 1219 "allow_land_join_divide, block_show_in_search, " +
1075 "agent_limit, object_bonus, maturity, " + 1220 "agent_limit, object_bonus, maturity, " +
1076 "disable_scripts, disable_collisions, " + 1221 "disable_scripts, disable_collisions, " +
1077 "disable_physics, terrain_texture_1, " + 1222 "disable_physics, terrain_texture_1, " +
1078 "terrain_texture_2, terrain_texture_3, " + 1223 "terrain_texture_2, terrain_texture_3, " +
1079 "terrain_texture_4, elevation_1_nw, " + 1224 "terrain_texture_4, elevation_1_nw, " +
1080 "elevation_2_nw, elevation_1_ne, " + 1225 "elevation_2_nw, elevation_1_ne, " +
1081 "elevation_2_ne, elevation_1_se, " + 1226 "elevation_2_ne, elevation_1_se, " +
1082 "elevation_2_se, elevation_1_sw, " + 1227 "elevation_2_se, elevation_1_sw, " +
1083 "elevation_2_sw, water_height, " + 1228 "elevation_2_sw, water_height, " +
1084 "terrain_raise_limit, terrain_lower_limit, " + 1229 "terrain_raise_limit, terrain_lower_limit, " +
1085 "use_estate_sun, fixed_sun, sun_position, " + 1230 "use_estate_sun, fixed_sun, sun_position, " +
1086 "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + 1231 "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " +
1087 "sunvectorz, loaded_creation_datetime, " + 1232 "sunvectorz, loaded_creation_datetime, " +
1088 "loaded_creation_id, map_tile_ID, " + 1233 "loaded_creation_id, map_tile_ID, block_search, casino, " +
1089 "TelehubObject, parcel_tile_ID) " + 1234 "TelehubObject, parcel_tile_ID) " +
1090 "values (?RegionUUID, ?BlockTerraform, " + 1235 "values (?RegionUUID, ?BlockTerraform, " +
1091 "?BlockFly, ?AllowDamage, ?RestrictPushing, " + 1236 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
1092 "?AllowLandResell, ?AllowLandJoinDivide, " + 1237 "?AllowLandResell, ?AllowLandJoinDivide, " +
1093 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + 1238 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
1094 "?Maturity, ?DisableScripts, ?DisableCollisions, " + 1239 "?Maturity, ?DisableScripts, ?DisableCollisions, " +
1095 "?DisablePhysics, ?TerrainTexture1, " + 1240 "?DisablePhysics, ?TerrainTexture1, " +
1096 "?TerrainTexture2, ?TerrainTexture3, " + 1241 "?TerrainTexture2, ?TerrainTexture3, " +
1097 "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + 1242 "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
1098 "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + 1243 "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
1099 "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + 1244 "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
1100 "?WaterHeight, ?TerrainRaiseLimit, " + 1245 "?WaterHeight, ?TerrainRaiseLimit, " +
1101 "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + 1246 "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
1102 "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + 1247 "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " +
1103 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + 1248 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1104 "?LoadedCreationDateTime, ?LoadedCreationID, " + 1249 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1105 "?TerrainImageID, " + 1250 "?TerrainImageID, ?block_search, ?casino, " +
1106 "?TelehubObject, ?ParcelImageID)"; 1251 "?TelehubObject, ?ParcelImageID)";
1107 1252
1108 FillRegionSettingsCommand(cmd, rs); 1253 FillRegionSettingsCommand(cmd, rs);
1109
1110 ExecuteNonQuery(cmd); 1254 ExecuteNonQuery(cmd);
1111 } 1255 }
1256 dbcon.Close();
1257 SaveSpawnPoints(rs);
1112 } 1258 }
1113
1114 SaveSpawnPoints(rs);
1115 } 1259 }
1116 1260
1117 public List<LandData> LoadLandObjects(UUID regionUUID) 1261 public virtual List<LandData> LoadLandObjects(UUID regionUUID)
1118 { 1262 {
1119 List<LandData> landData = new List<LandData>(); 1263 List<LandData> landData = new List<LandData>();
1120 1264
@@ -1156,6 +1300,7 @@ namespace OpenSim.Data.MySQL
1156 } 1300 }
1157 } 1301 }
1158 } 1302 }
1303 dbcon.Close();
1159 } 1304 }
1160 } 1305 }
1161 1306
@@ -1170,12 +1315,16 @@ namespace OpenSim.Data.MySQL
1170 { 1315 {
1171 SceneObjectPart prim = new SceneObjectPart(); 1316 SceneObjectPart prim = new SceneObjectPart();
1172 1317
1173 // depending on the MySQL connector version, CHAR(36) may be already converted to Guid! 1318 // depending on the MySQL connector version, CHAR(36) may be already converted to Guid!
1174 prim.UUID = DBGuid.FromDB(row["UUID"]); 1319 prim.UUID = DBGuid.FromDB(row["UUID"]);
1175 prim.CreatorIdentification = (string)row["CreatorID"]; 1320 prim.CreatorIdentification = (string)row["CreatorID"];
1176 prim.OwnerID = DBGuid.FromDB(row["OwnerID"]); 1321 prim.OwnerID = DBGuid.FromDB(row["OwnerID"]);
1177 prim.GroupID = DBGuid.FromDB(row["GroupID"]); 1322 prim.GroupID = DBGuid.FromDB(row["GroupID"]);
1178 prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]); 1323 prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]);
1324 if (row["RezzerID"] != DBNull.Value)
1325 prim.RezzerID = DBGuid.FromDB(row["RezzerID"]);
1326 else
1327 prim.RezzerID = UUID.Zero;
1179 1328
1180 // explicit conversion of integers is required, which sort 1329 // explicit conversion of integers is required, which sort
1181 // of sucks. No idea if there is a shortcut here or not. 1330 // of sucks. No idea if there is a shortcut here or not.
@@ -1294,10 +1443,11 @@ namespace OpenSim.Data.MySQL
1294 1443
1295 prim.CollisionSound = DBGuid.FromDB(row["CollisionSound"]); 1444 prim.CollisionSound = DBGuid.FromDB(row["CollisionSound"]);
1296 prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; 1445 prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"];
1297 1446
1298 prim.PassTouches = ((sbyte)row["PassTouches"] != 0); 1447 prim.PassTouches = ((sbyte)row["PassTouches"] != 0);
1448 prim.PassCollisions = ((sbyte)row["PassCollisions"] != 0);
1299 prim.LinkNum = (int)row["LinkNumber"]; 1449 prim.LinkNum = (int)row["LinkNumber"];
1300 1450
1301 if (!(row["MediaURL"] is System.DBNull)) 1451 if (!(row["MediaURL"] is System.DBNull))
1302 prim.MediaUrl = (string)row["MediaURL"]; 1452 prim.MediaUrl = (string)row["MediaURL"];
1303 1453
@@ -1313,7 +1463,7 @@ namespace OpenSim.Data.MySQL
1313 if (!(row["DynAttrs"] is System.DBNull)) 1463 if (!(row["DynAttrs"] is System.DBNull))
1314 prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); 1464 prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
1315 else 1465 else
1316 prim.DynAttrs = new DAMap(); 1466 prim.DynAttrs = new DAMap();
1317 1467
1318 if (!(row["KeyframeMotion"] is DBNull)) 1468 if (!(row["KeyframeMotion"] is DBNull))
1319 { 1469 {
@@ -1333,7 +1483,22 @@ namespace OpenSim.Data.MySQL
1333 prim.GravityModifier = (float)(double)row["GravityModifier"]; 1483 prim.GravityModifier = (float)(double)row["GravityModifier"];
1334 prim.Friction = (float)(double)row["Friction"]; 1484 prim.Friction = (float)(double)row["Friction"];
1335 prim.Restitution = (float)(double)row["Restitution"]; 1485 prim.Restitution = (float)(double)row["Restitution"];
1336 1486 prim.RotationAxisLocks = (byte)Convert.ToInt32(row["RotationAxisLocks"].ToString());
1487
1488 SOPVehicle vehicle = null;
1489
1490 if (row["Vehicle"].ToString() != String.Empty)
1491 {
1492 vehicle = SOPVehicle.FromXml2(row["Vehicle"].ToString());
1493 if (vehicle != null)
1494 prim.VehicleParams = vehicle;
1495 }
1496
1497 PhysicsInertiaData pdata = null;
1498 if (row["PhysInertia"].ToString() != String.Empty)
1499 pdata = PhysicsInertiaData.FromXml2(row["PhysInertia"].ToString());
1500 prim.PhysicsInertia = pdata;
1501
1337 return prim; 1502 return prim;
1338 } 1503 }
1339 1504
@@ -1344,32 +1509,40 @@ namespace OpenSim.Data.MySQL
1344 /// <returns></returns> 1509 /// <returns></returns>
1345 private static TaskInventoryItem BuildItem(IDataReader row) 1510 private static TaskInventoryItem BuildItem(IDataReader row)
1346 { 1511 {
1347 TaskInventoryItem taskItem = new TaskInventoryItem(); 1512 try
1348 1513 {
1349 taskItem.ItemID = DBGuid.FromDB(row["itemID"]); 1514 TaskInventoryItem taskItem = new TaskInventoryItem();
1350 taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); 1515
1351 taskItem.AssetID = DBGuid.FromDB(row["assetID"]); 1516 taskItem.ItemID = DBGuid.FromDB(row["itemID"]);
1352 taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); 1517 taskItem.ParentPartID = DBGuid.FromDB(row["primID"]);
1353 1518 taskItem.AssetID = DBGuid.FromDB(row["assetID"]);
1354 taskItem.InvType = Convert.ToInt32(row["invType"]); 1519 taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]);
1355 taskItem.Type = Convert.ToInt32(row["assetType"]); 1520
1356 1521 taskItem.InvType = Convert.ToInt32(row["invType"]);
1357 taskItem.Name = (String)row["name"]; 1522 taskItem.Type = Convert.ToInt32(row["assetType"]);
1358 taskItem.Description = (String)row["description"]; 1523
1359 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); 1524 taskItem.Name = (String)row["name"];
1360 taskItem.CreatorIdentification = (String)row["creatorID"]; 1525 taskItem.Description = (String)row["description"];
1361 taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); 1526 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
1362 taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); 1527 taskItem.CreatorIdentification = (String)row["creatorID"];
1363 taskItem.GroupID = DBGuid.FromDB(row["groupID"]); 1528 taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]);
1364 1529 taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]);
1365 taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); 1530 taskItem.GroupID = DBGuid.FromDB(row["groupID"]);
1366 taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); 1531
1367 taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); 1532 taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]);
1368 taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); 1533 taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]);
1369 taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); 1534 taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]);
1370 taskItem.Flags = Convert.ToUInt32(row["flags"]); 1535 taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]);
1371 1536 taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]);
1372 return taskItem; 1537 taskItem.Flags = Convert.ToUInt32(row["flags"]);
1538
1539 return taskItem;
1540 }
1541 catch
1542 {
1543 m_log.ErrorFormat("[MYSQL DB]: Error reading task inventory: itemID was {0}, primID was {1}", row["itemID"].ToString(), row["primID"].ToString());
1544 throw;
1545 }
1373 } 1546 }
1374 1547
1375 private static RegionSettings BuildRegionSettings(IDataReader row) 1548 private static RegionSettings BuildRegionSettings(IDataReader row)
@@ -1417,16 +1590,19 @@ namespace OpenSim.Data.MySQL
1417 newSettings.Covenant = DBGuid.FromDB(row["covenant"]); 1590 newSettings.Covenant = DBGuid.FromDB(row["covenant"]);
1418 newSettings.CovenantChangedDateTime = Convert.ToInt32(row["covenant_datetime"]); 1591 newSettings.CovenantChangedDateTime = Convert.ToInt32(row["covenant_datetime"]);
1419 newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); 1592 newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]);
1420 1593
1421 if (row["loaded_creation_id"] is DBNull) 1594 if (row["loaded_creation_id"] is DBNull)
1422 newSettings.LoadedCreationID = ""; 1595 newSettings.LoadedCreationID = "";
1423 else 1596 else
1424 newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; 1597 newSettings.LoadedCreationID = (String) row["loaded_creation_id"];
1425 1598
1426 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); 1599 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
1427 newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]); 1600 newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]);
1428 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); 1601 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
1429 1602
1603 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
1604 newSettings.Casino = Convert.ToBoolean(row["casino"]);
1605
1430 return newSettings; 1606 return newSettings;
1431 } 1607 }
1432 1608
@@ -1503,6 +1679,13 @@ namespace OpenSim.Data.MySQL
1503 1679
1504 newData.ParcelAccessList = new List<LandAccessEntry>(); 1680 newData.ParcelAccessList = new List<LandAccessEntry>();
1505 1681
1682 if (!(row["SeeAVs"] is System.DBNull))
1683 newData.SeeAVs = Convert.ToInt32(row["SeeAVs"]) != 0 ? true : false;
1684 if (!(row["AnyAVSounds"] is System.DBNull))
1685 newData.AnyAVSounds = Convert.ToInt32(row["AnyAVSounds"]) != 0 ? true : false;
1686 if (!(row["GroupAVSounds"] is System.DBNull))
1687 newData.GroupAVSounds = Convert.ToInt32(row["GroupAVSounds"]) != 0 ? true : false;
1688
1506 return newData; 1689 return newData;
1507 } 1690 }
1508 1691
@@ -1550,6 +1733,7 @@ namespace OpenSim.Data.MySQL
1550 cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); 1733 cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString());
1551 cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); 1734 cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString());
1552 cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); 1735 cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString());
1736 cmd.Parameters.AddWithValue("RezzerID", prim.RezzerID.ToString());
1553 cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); 1737 cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask);
1554 cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); 1738 cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask);
1555 cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); 1739 cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask);
@@ -1654,6 +1838,11 @@ namespace OpenSim.Data.MySQL
1654 else 1838 else
1655 cmd.Parameters.AddWithValue("PassTouches", 0); 1839 cmd.Parameters.AddWithValue("PassTouches", 0);
1656 1840
1841 if (prim.PassCollisions)
1842 cmd.Parameters.AddWithValue("PassCollisions", 1);
1843 else
1844 cmd.Parameters.AddWithValue("PassCollisions", 0);
1845
1657 cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); 1846 cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
1658 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); 1847 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
1659 if (prim.AttachedPos != null) 1848 if (prim.AttachedPos != null)
@@ -1668,6 +1857,16 @@ namespace OpenSim.Data.MySQL
1668 else 1857 else
1669 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); 1858 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
1670 1859
1860 if (prim.PhysicsInertia != null)
1861 cmd.Parameters.AddWithValue("PhysInertia", prim.PhysicsInertia.ToXml2());
1862 else
1863 cmd.Parameters.AddWithValue("PhysInertia", String.Empty);
1864
1865 if (prim.VehicleParams != null)
1866 cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2());
1867 else
1868 cmd.Parameters.AddWithValue("Vehicle", String.Empty);
1869
1671 if (prim.DynAttrs.CountNamespaces > 0) 1870 if (prim.DynAttrs.CountNamespaces > 0)
1672 cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); 1871 cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml());
1673 else 1872 else
@@ -1678,6 +1877,7 @@ namespace OpenSim.Data.MySQL
1678 cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); 1877 cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier);
1679 cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); 1878 cmd.Parameters.AddWithValue("Friction", (double)prim.Friction);
1680 cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution); 1879 cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution);
1880 cmd.Parameters.AddWithValue("RotationAxisLocks", prim.RotationAxisLocks);
1681 } 1881 }
1682 1882
1683 /// <summary> 1883 /// <summary>
@@ -1756,6 +1956,8 @@ namespace OpenSim.Data.MySQL
1756 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); 1956 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
1757 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); 1957 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
1758 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); 1958 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
1959 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
1960 cmd.Parameters.AddWithValue("casino", settings.Casino);
1759 1961
1760 cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); 1962 cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID);
1761 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); 1963 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
@@ -1813,6 +2015,10 @@ namespace OpenSim.Data.MySQL
1813 cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); 2015 cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop);
1814 cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); 2016 cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic);
1815 cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); 2017 cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia);
2018 cmd.Parameters.AddWithValue("SeeAVs", land.SeeAVs ? 1 : 0);
2019 cmd.Parameters.AddWithValue("AnyAVSounds", land.AnyAVSounds ? 1 : 0);
2020 cmd.Parameters.AddWithValue("GroupAVSounds", land.GroupAVSounds ? 1 : 0);
2021
1816 } 2022 }
1817 2023
1818 /// <summary> 2024 /// <summary>
@@ -1869,7 +2075,7 @@ namespace OpenSim.Data.MySQL
1869 2075
1870 s.State = (byte)(int)row["State"]; 2076 s.State = (byte)(int)row["State"];
1871 s.LastAttachPoint = (byte)(int)row["LastAttachPoint"]; 2077 s.LastAttachPoint = (byte)(int)row["LastAttachPoint"];
1872 2078
1873 if (!(row["Media"] is System.DBNull)) 2079 if (!(row["Media"] is System.DBNull))
1874 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); 2080 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]);
1875 2081
@@ -1919,7 +2125,7 @@ namespace OpenSim.Data.MySQL
1919 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); 2125 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
1920 } 2126 }
1921 2127
1922 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 2128 public virtual void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
1923 { 2129 {
1924 lock (m_dbLock) 2130 lock (m_dbLock)
1925 { 2131 {
@@ -1949,20 +2155,53 @@ namespace OpenSim.Data.MySQL
1949 "?flags, ?itemID, ?primID, ?assetID, " + 2155 "?flags, ?itemID, ?primID, ?assetID, " +
1950 "?parentFolderID, ?creatorID, ?ownerID, " + 2156 "?parentFolderID, ?creatorID, ?ownerID, " +
1951 "?groupID, ?lastOwnerID)"; 2157 "?groupID, ?lastOwnerID)";
1952 2158
1953 foreach (TaskInventoryItem item in items) 2159 foreach (TaskInventoryItem item in items)
1954 { 2160 {
1955 cmd.Parameters.Clear(); 2161 cmd.Parameters.Clear();
1956 2162
1957 FillItemCommand(cmd, item); 2163 FillItemCommand(cmd, item);
1958 2164
1959 ExecuteNonQuery(cmd); 2165 ExecuteNonQuery(cmd);
1960 } 2166 }
1961 } 2167 }
2168 dbcon.Close();
1962 } 2169 }
1963 } 2170 }
1964 } 2171 }
1965 2172
2173 public UUID[] GetObjectIDs(UUID regionID)
2174 {
2175 List<UUID> uuids = new List<UUID>();
2176
2177 lock (m_dbLock)
2178 {
2179 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
2180 {
2181 dbcon.Open();
2182
2183 using (MySqlCommand cmd = dbcon.CreateCommand())
2184 {
2185 cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID and SceneGroupID = UUID";
2186 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
2187
2188 using (IDataReader reader = ExecuteReader(cmd))
2189 {
2190 while (reader.Read())
2191 {
2192 UUID id = new UUID(reader["UUID"].ToString());
2193
2194 uuids.Add(id);
2195 }
2196 }
2197 }
2198 dbcon.Close();
2199 }
2200 }
2201
2202 return uuids.ToArray();
2203 }
2204
1966 private void LoadSpawnPoints(RegionSettings rs) 2205 private void LoadSpawnPoints(RegionSettings rs)
1967 { 2206 {
1968 rs.ClearSpawnPoints(); 2207 rs.ClearSpawnPoints();
@@ -1992,6 +2231,7 @@ namespace OpenSim.Data.MySQL
1992 } 2231 }
1993 } 2232 }
1994 } 2233 }
2234 dbcon.Close();
1995 } 2235 }
1996 } 2236 }
1997 } 2237 }
@@ -2026,6 +2266,7 @@ namespace OpenSim.Data.MySQL
2026 cmd.Parameters.Clear(); 2266 cmd.Parameters.Clear();
2027 } 2267 }
2028 } 2268 }
2269 dbcon.Close();
2029 } 2270 }
2030 } 2271 }
2031 } 2272 }
@@ -2045,6 +2286,7 @@ namespace OpenSim.Data.MySQL
2045 2286
2046 cmd.ExecuteNonQuery(); 2287 cmd.ExecuteNonQuery();
2047 } 2288 }
2289 dbcon.Close();
2048 } 2290 }
2049 } 2291 }
2050 2292
@@ -2062,6 +2304,7 @@ namespace OpenSim.Data.MySQL
2062 2304
2063 cmd.ExecuteNonQuery(); 2305 cmd.ExecuteNonQuery();
2064 } 2306 }
2307 dbcon.Close();
2065 } 2308 }
2066 } 2309 }
2067 2310
@@ -2085,6 +2328,7 @@ namespace OpenSim.Data.MySQL
2085 } 2328 }
2086 } 2329 }
2087 } 2330 }
2331 dbcon.Close();
2088 } 2332 }
2089 2333
2090 return ret; 2334 return ret;
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index e964295..59cfe70 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -46,17 +46,21 @@ namespace OpenSim.Data.MySQL
46 { 46 {
47 string[] words = query.Split(new char[] {' '}); 47 string[] words = query.Split(new char[] {' '});
48 48
49 bool valid = false;
50
49 for (int i = 0 ; i < words.Length ; i++) 51 for (int i = 0 ; i < words.Length ; i++)
50 { 52 {
51 if (words[i].Length < 3) 53 if (words[i].Length > 2)
52 { 54 valid = true;
53 if (i != words.Length - 1) 55// if (words[i].Length < 3)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1); 56// {
55 Array.Resize(ref words, words.Length - 1); 57// if (i != words.Length - 1)
56 } 58// Array.Copy(words, i + 1, words, i, words.Length - i - 1);
59// Array.Resize(ref words, words.Length - 1);
60// }
57 } 61 }
58 62
59 if (words.Length == 0) 63 if ((!valid) || words.Length == 0)
60 return new UserAccountData[0]; 64 return new UserAccountData[0];
61 65
62 if (words.Length > 2) 66 if (words.Length > 2)
@@ -66,13 +70,13 @@ namespace OpenSim.Data.MySQL
66 { 70 {
67 if (words.Length == 1) 71 if (words.Length == 1)
68 { 72 {
69 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
70 cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); 74 cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%");
71 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
72 } 76 }
73 else 77 else
74 { 78 {
75 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); 79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm);
76 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); 80 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%");
77 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); 81 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%");
78 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
@@ -81,5 +85,21 @@ namespace OpenSim.Data.MySQL
81 return DoQuery(cmd); 85 return DoQuery(cmd);
82 } 86 }
83 } 87 }
88
89 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
90 {
91 using (MySqlCommand cmd = new MySqlCommand())
92 {
93 if (scopeID != UUID.Zero)
94 {
95 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")";
96 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
97 }
98
99 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm);
100
101 return DoQuery(cmd);
102 }
103 }
84 } 104 }
85} \ No newline at end of file 105}
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index b35595d..16637c3 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -40,39 +40,40 @@ namespace OpenSim.Data.MySQL
40 public class UserProfilesData: IProfilesData 40 public class UserProfilesData: IProfilesData
41 { 41 {
42 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 #region Properites 44 #region Properites
45 string ConnectionString 45 string ConnectionString
46 { 46 {
47 get; set; 47 get; set;
48 } 48 }
49 49
50 protected virtual Assembly Assembly 50 protected virtual Assembly Assembly
51 { 51 {
52 get { return GetType().Assembly; } 52 get { return GetType().Assembly; }
53 } 53 }
54 54
55 #endregion Properties 55 #endregion Properties
56 56
57 #region class Member Functions 57 #region class Member Functions
58 public UserProfilesData(string connectionString) 58 public UserProfilesData(string connectionString)
59 { 59 {
60 ConnectionString = connectionString; 60 ConnectionString = connectionString;
61 Init(); 61 Init();
62 } 62 }
63 63
64 void Init() 64 void Init()
65 { 65 {
66 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 66 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
67 { 67 {
68 dbcon.Open(); 68 dbcon.Open();
69 69
70 Migration m = new Migration(dbcon, Assembly, "UserProfiles"); 70 Migration m = new Migration(dbcon, Assembly, "UserProfiles");
71 m.Update(); 71 m.Update();
72 dbcon.Close();
72 } 73 }
73 } 74 }
74 #endregion Member Functions 75 #endregion Member Functions
75 76
76 #region Classifieds Queries 77 #region Classifieds Queries
77 /// <summary> 78 /// <summary>
78 /// Gets the classified records. 79 /// Gets the classified records.
@@ -86,10 +87,10 @@ namespace OpenSim.Data.MySQL
86 public OSDArray GetClassifiedRecords(UUID creatorId) 87 public OSDArray GetClassifiedRecords(UUID creatorId)
87 { 88 {
88 OSDArray data = new OSDArray(); 89 OSDArray data = new OSDArray();
89 90
90 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 91 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
91 { 92 {
92 string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; 93 const string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
93 dbcon.Open(); 94 dbcon.Open();
94 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 95 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
95 { 96 {
@@ -102,7 +103,7 @@ namespace OpenSim.Data.MySQL
102 { 103 {
103 OSDMap n = new OSDMap(); 104 OSDMap n = new OSDMap();
104 UUID Id = UUID.Zero; 105 UUID Id = UUID.Zero;
105 106
106 string Name = null; 107 string Name = null;
107 try 108 try
108 { 109 {
@@ -111,8 +112,7 @@ namespace OpenSim.Data.MySQL
111 } 112 }
112 catch (Exception e) 113 catch (Exception e)
113 { 114 {
114 m_log.ErrorFormat("[PROFILES_DATA]" + 115 m_log.ErrorFormat("[PROFILES_DATA] GetClassifiedRecords exception {0}", e.Message);
115 ": UserAccount exception {0}", e.Message);
116 } 116 }
117 n.Add("classifieduuid", OSD.FromUUID(Id)); 117 n.Add("classifieduuid", OSD.FromUUID(Id));
118 n.Add("name", OSD.FromString(Name)); 118 n.Add("name", OSD.FromString(Name));
@@ -121,73 +121,73 @@ namespace OpenSim.Data.MySQL
121 } 121 }
122 } 122 }
123 } 123 }
124 dbcon.Close();
124 } 125 }
125 return data; 126 return data;
126 } 127 }
127 128
128 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) 129 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
129 { 130 {
130 string query = string.Empty; 131 const string query =
131 132 "INSERT INTO classifieds ("
132 133 + "`classifieduuid`,"
133 query += "INSERT INTO classifieds ("; 134 + "`creatoruuid`,"
134 query += "`classifieduuid`,"; 135 + "`creationdate`,"
135 query += "`creatoruuid`,"; 136 + "`expirationdate`,"
136 query += "`creationdate`,"; 137 + "`category`,"
137 query += "`expirationdate`,"; 138 + "`name`,"
138 query += "`category`,"; 139 + "`description`,"
139 query += "`name`,"; 140 + "`parceluuid`,"
140 query += "`description`,"; 141 + "`parentestate`,"
141 query += "`parceluuid`,"; 142 + "`snapshotuuid`,"
142 query += "`parentestate`,"; 143 + "`simname`,"
143 query += "`snapshotuuid`,"; 144 + "`posglobal`,"
144 query += "`simname`,"; 145 + "`parcelname`,"
145 query += "`posglobal`,"; 146 + "`classifiedflags`,"
146 query += "`parcelname`,"; 147 + "`priceforlisting`) "
147 query += "`classifiedflags`,"; 148 + "VALUES ("
148 query += "`priceforlisting`) "; 149 + "?ClassifiedId,"
149 query += "VALUES ("; 150 + "?CreatorId,"
150 query += "?ClassifiedId,"; 151 + "?CreatedDate,"
151 query += "?CreatorId,"; 152 + "?ExpirationDate,"
152 query += "?CreatedDate,"; 153 + "?Category,"
153 query += "?ExpirationDate,"; 154 + "?Name,"
154 query += "?Category,"; 155 + "?Description,"
155 query += "?Name,"; 156 + "?ParcelId,"
156 query += "?Description,"; 157 + "?ParentEstate,"
157 query += "?ParcelId,"; 158 + "?SnapshotId,"
158 query += "?ParentEstate,"; 159 + "?SimName,"
159 query += "?SnapshotId,"; 160 + "?GlobalPos,"
160 query += "?SimName,"; 161 + "?ParcelName,"
161 query += "?GlobalPos,"; 162 + "?Flags,"
162 query += "?ParcelName,"; 163 + "?ListingPrice ) "
163 query += "?Flags,"; 164 + "ON DUPLICATE KEY UPDATE "
164 query += "?ListingPrice ) "; 165 + "category=?Category, "
165 query += "ON DUPLICATE KEY UPDATE "; 166 + "expirationdate=?ExpirationDate, "
166 query += "category=?Category, "; 167 + "name=?Name, "
167 query += "expirationdate=?ExpirationDate, "; 168 + "description=?Description, "
168 query += "name=?Name, "; 169 + "parentestate=?ParentEstate, "
169 query += "description=?Description, "; 170 + "posglobal=?GlobalPos, "
170 query += "parentestate=?ParentEstate, "; 171 + "parcelname=?ParcelName, "
171 query += "posglobal=?GlobalPos, "; 172 + "classifiedflags=?Flags, "
172 query += "parcelname=?ParcelName, "; 173 + "priceforlisting=?ListingPrice, "
173 query += "classifiedflags=?Flags, "; 174 + "snapshotuuid=?SnapshotId"
174 query += "priceforlisting=?ListingPrice, "; 175 ;
175 query += "snapshotuuid=?SnapshotId"; 176
176
177 if(string.IsNullOrEmpty(ad.ParcelName)) 177 if(string.IsNullOrEmpty(ad.ParcelName))
178 ad.ParcelName = "Unknown"; 178 ad.ParcelName = "Unknown";
179 if(ad.ParcelId == null) 179 if(ad.ParcelId == null)
180 ad.ParcelId = UUID.Zero; 180 ad.ParcelId = UUID.Zero;
181 if(string.IsNullOrEmpty(ad.Description)) 181 if(string.IsNullOrEmpty(ad.Description))
182 ad.Description = "No Description"; 182 ad.Description = "No Description";
183 183
184 DateTime epoch = new DateTime(1970, 1, 1); 184 DateTime epoch = new DateTime(1970, 1, 1);
185 DateTime now = DateTime.Now; 185 DateTime now = DateTime.Now;
186 TimeSpan epochnow = now - epoch; 186 TimeSpan epochnow = now - epoch;
187 TimeSpan duration; 187 TimeSpan duration;
188 DateTime expiration; 188 DateTime expiration;
189 TimeSpan epochexp; 189 TimeSpan epochexp;
190 190
191 if(ad.Flags == 2) 191 if(ad.Flags == 2)
192 { 192 {
193 duration = new TimeSpan(7,0,0,0); 193 duration = new TimeSpan(7,0,0,0);
@@ -202,7 +202,7 @@ namespace OpenSim.Data.MySQL
202 } 202 }
203 ad.CreationDate = (int)epochnow.TotalSeconds; 203 ad.CreationDate = (int)epochnow.TotalSeconds;
204 ad.ExpirationDate = (int)epochexp.TotalSeconds; 204 ad.ExpirationDate = (int)epochexp.TotalSeconds;
205 205
206 try 206 try
207 { 207 {
208 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 208 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -225,57 +225,52 @@ namespace OpenSim.Data.MySQL
225 cmd.Parameters.AddWithValue("?ParcelName", ad.ParcelName.ToString()); 225 cmd.Parameters.AddWithValue("?ParcelName", ad.ParcelName.ToString());
226 cmd.Parameters.AddWithValue("?Flags", ad.Flags.ToString()); 226 cmd.Parameters.AddWithValue("?Flags", ad.Flags.ToString());
227 cmd.Parameters.AddWithValue("?ListingPrice", ad.Price.ToString ()); 227 cmd.Parameters.AddWithValue("?ListingPrice", ad.Price.ToString ());
228 228
229 cmd.ExecuteNonQuery(); 229 cmd.ExecuteNonQuery();
230 } 230 }
231 dbcon.Close();
231 } 232 }
232 } 233 }
233 catch (Exception e) 234 catch (Exception e)
234 { 235 {
235 m_log.ErrorFormat("[PROFILES_DATA]" + 236 m_log.ErrorFormat("[PROFILES_DATA]: UpdateClassifiedRecord exception {0}", e.Message);
236 ": ClassifiedesUpdate exception {0}", e.Message);
237 result = e.Message; 237 result = e.Message;
238 return false; 238 return false;
239 } 239 }
240 return true; 240 return true;
241 } 241 }
242 242
243 public bool DeleteClassifiedRecord(UUID recordId) 243 public bool DeleteClassifiedRecord(UUID recordId)
244 { 244 {
245 string query = string.Empty; 245 const string query = "DELETE FROM classifieds WHERE classifieduuid = ?recordId";
246 246
247 query += "DELETE FROM classifieds WHERE ";
248 query += "classifieduuid = ?recordId";
249
250 try 247 try
251 { 248 {
252 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 249 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
253 { 250 {
254 dbcon.Open(); 251 dbcon.Open();
255 252
256 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 253 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
257 { 254 {
258 cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); 255 cmd.Parameters.AddWithValue("?recordId", recordId.ToString());
259 cmd.ExecuteNonQuery(); 256 cmd.ExecuteNonQuery();
260 } 257 }
258 dbcon.Close();
261 } 259 }
262 } 260 }
263 catch (Exception e) 261 catch (Exception e)
264 { 262 {
265 m_log.ErrorFormat("[PROFILES_DATA]" + 263 m_log.ErrorFormat("[PROFILES_DATA]: DeleteClassifiedRecord exception {0}", e.Message);
266 ": DeleteClassifiedRecord exception {0}", e.Message);
267 return false; 264 return false;
268 } 265 }
269 return true; 266 return true;
270 } 267 }
271 268
272 public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) 269 public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result)
273 { 270 {
274 string query = string.Empty; 271
275 272 const string query = "SELECT * FROM classifieds WHERE classifieduuid = ?AdId";
276 query += "SELECT * FROM classifieds WHERE "; 273
277 query += "classifieduuid = ?AdId";
278
279 try 274 try
280 { 275 {
281 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 276 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -284,7 +279,7 @@ namespace OpenSim.Data.MySQL
284 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 279 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
285 { 280 {
286 cmd.Parameters.AddWithValue("?AdId", ad.ClassifiedId.ToString()); 281 cmd.Parameters.AddWithValue("?AdId", ad.ClassifiedId.ToString());
287 282
288 using (MySqlDataReader reader = cmd.ExecuteReader()) 283 using (MySqlDataReader reader = cmd.ExecuteReader())
289 { 284 {
290 if(reader.Read ()) 285 if(reader.Read ())
@@ -303,7 +298,7 @@ namespace OpenSim.Data.MySQL
303 ad.SimName = reader.GetString("simname"); 298 ad.SimName = reader.GetString("simname");
304 ad.GlobalPos = reader.GetString("posglobal"); 299 ad.GlobalPos = reader.GetString("posglobal");
305 ad.ParcelName = reader.GetString("parcelname"); 300 ad.ParcelName = reader.GetString("parcelname");
306 301
307 } 302 }
308 } 303 }
309 } 304 }
@@ -312,22 +307,19 @@ namespace OpenSim.Data.MySQL
312 } 307 }
313 catch (Exception e) 308 catch (Exception e)
314 { 309 {
315 m_log.ErrorFormat("[PROFILES_DATA]" + 310 m_log.ErrorFormat("[PROFILES_DATA]: GetClassifiedInfo exception {0}", e.Message);
316 ": GetPickInfo exception {0}", e.Message);
317 } 311 }
318 return true; 312 return true;
319 } 313 }
320 #endregion Classifieds Queries 314 #endregion Classifieds Queries
321 315
322 #region Picks Queries 316 #region Picks Queries
323 public OSDArray GetAvatarPicks(UUID avatarId) 317 public OSDArray GetAvatarPicks(UUID avatarId)
324 { 318 {
325 string query = string.Empty; 319 const string query = "SELECT `pickuuid`,`name` FROM userpicks WHERE creatoruuid = ?Id";
326 320
327 query += "SELECT `pickuuid`,`name` FROM userpicks WHERE ";
328 query += "creatoruuid = ?Id";
329 OSDArray data = new OSDArray(); 321 OSDArray data = new OSDArray();
330 322
331 try 323 try
332 { 324 {
333 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 325 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -336,7 +328,7 @@ namespace OpenSim.Data.MySQL
336 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 328 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
337 { 329 {
338 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 330 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
339 331
340 using (MySqlDataReader reader = cmd.ExecuteReader()) 332 using (MySqlDataReader reader = cmd.ExecuteReader())
341 { 333 {
342 if(reader.HasRows) 334 if(reader.HasRows)
@@ -344,7 +336,7 @@ namespace OpenSim.Data.MySQL
344 while (reader.Read()) 336 while (reader.Read())
345 { 337 {
346 OSDMap record = new OSDMap(); 338 OSDMap record = new OSDMap();
347 339
348 record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); 340 record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"]));
349 record.Add("name",OSD.FromString((string)reader["name"])); 341 record.Add("name",OSD.FromString((string)reader["name"]));
350 data.Add(record); 342 data.Add(record);
@@ -352,25 +344,21 @@ namespace OpenSim.Data.MySQL
352 } 344 }
353 } 345 }
354 } 346 }
347 dbcon.Close();
355 } 348 }
356 } 349 }
357 catch (Exception e) 350 catch (Exception e)
358 { 351 {
359 m_log.ErrorFormat("[PROFILES_DATA]" + 352 m_log.ErrorFormat("[PROFILES_DATA]: GetAvatarPicks exception {0}", e.Message);
360 ": GetAvatarPicks exception {0}", e.Message);
361 } 353 }
362 return data; 354 return data;
363 } 355 }
364 356
365 public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) 357 public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
366 { 358 {
367 string query = string.Empty;
368 UserProfilePick pick = new UserProfilePick(); 359 UserProfilePick pick = new UserProfilePick();
369 360 const string query = "SELECT * FROM userpicks WHERE creatoruuid = ?CreatorId AND pickuuid = ?PickId";
370 query += "SELECT * FROM userpicks WHERE "; 361
371 query += "creatoruuid = ?CreatorId AND ";
372 query += "pickuuid = ?PickId";
373
374 try 362 try
375 { 363 {
376 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 364 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -380,18 +368,18 @@ namespace OpenSim.Data.MySQL
380 { 368 {
381 cmd.Parameters.AddWithValue("?CreatorId", avatarId.ToString()); 369 cmd.Parameters.AddWithValue("?CreatorId", avatarId.ToString());
382 cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); 370 cmd.Parameters.AddWithValue("?PickId", pickId.ToString());
383 371
384 using (MySqlDataReader reader = cmd.ExecuteReader()) 372 using (MySqlDataReader reader = cmd.ExecuteReader())
385 { 373 {
386 if(reader.HasRows) 374 if(reader.HasRows)
387 { 375 {
388 reader.Read(); 376 reader.Read();
389 377
390 string description = (string)reader["description"]; 378 string description = (string)reader["description"];
391 379
392 if (string.IsNullOrEmpty(description)) 380 if (string.IsNullOrEmpty(description))
393 description = "No description given."; 381 description = "No description given.";
394 382
395 UUID.TryParse((string)reader["pickuuid"], out pick.PickId); 383 UUID.TryParse((string)reader["pickuuid"], out pick.PickId);
396 UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); 384 UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId);
397 UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); 385 UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId);
@@ -414,42 +402,41 @@ namespace OpenSim.Data.MySQL
414 } 402 }
415 catch (Exception e) 403 catch (Exception e)
416 { 404 {
417 m_log.ErrorFormat("[PROFILES_DATA]" + 405 m_log.ErrorFormat("[PROFILES_DATA]: GetPickInfo exception {0}", e.Message);
418 ": GetPickInfo exception {0}", e.Message);
419 } 406 }
420 return pick; 407 return pick;
421 } 408 }
422 409
423 public bool UpdatePicksRecord(UserProfilePick pick) 410 public bool UpdatePicksRecord(UserProfilePick pick)
424 { 411 {
425 string query = string.Empty; 412 const string query =
426 413 "INSERT INTO userpicks VALUES ("
427 query += "INSERT INTO userpicks VALUES ("; 414 + "?PickId,"
428 query += "?PickId,"; 415 + "?CreatorId,"
429 query += "?CreatorId,"; 416 + "?TopPick,"
430 query += "?TopPick,"; 417 + "?ParcelId,"
431 query += "?ParcelId,"; 418 + "?Name,"
432 query += "?Name,"; 419 + "?Desc,"
433 query += "?Desc,"; 420 + "?SnapshotId,"
434 query += "?SnapshotId,"; 421 + "?User,"
435 query += "?User,"; 422 + "?Original,"
436 query += "?Original,"; 423 + "?SimName,"
437 query += "?SimName,"; 424 + "?GlobalPos,"
438 query += "?GlobalPos,"; 425 + "?SortOrder,"
439 query += "?SortOrder,"; 426 + "?Enabled,"
440 query += "?Enabled,"; 427 + "?Gatekeeper)"
441 query += "?Gatekeeper)"; 428 + "ON DUPLICATE KEY UPDATE "
442 query += "ON DUPLICATE KEY UPDATE "; 429 + "parceluuid=?ParcelId,"
443 query += "parceluuid=?ParcelId,"; 430 + "name=?Name,"
444 query += "name=?Name,"; 431 + "description=?Desc,"
445 query += "description=?Desc,"; 432 + "user=?User,"
446 query += "user=?User,"; 433 + "simname=?SimName,"
447 query += "simname=?SimName,"; 434 + "snapshotuuid=?SnapshotId,"
448 query += "snapshotuuid=?SnapshotId,"; 435 + "pickuuid=?PickId,"
449 query += "pickuuid=?PickId,"; 436 + "posglobal=?GlobalPos,"
450 query += "posglobal=?GlobalPos,"; 437 + "gatekeeper=?Gatekeeper"
451 query += "gatekeeper=?Gatekeeper"; 438 ;
452 439
453 try 440 try
454 { 441 {
455 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 442 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -471,61 +458,53 @@ namespace OpenSim.Data.MySQL
471 cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper); 458 cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper);
472 cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); 459 cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ());
473 cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); 460 cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString());
474 461
475 cmd.ExecuteNonQuery(); 462 cmd.ExecuteNonQuery();
476 } 463 }
464 dbcon.Close();
477 } 465 }
478 } 466 }
479 catch (Exception e) 467 catch (Exception e)
480 { 468 {
481 m_log.ErrorFormat("[PROFILES_DATA]" + 469 m_log.ErrorFormat("[PROFILES_DATA]: UpdatePicksRecord exception {0}", e.Message);
482 ": UpdateAvatarNotes exception {0}", e.Message);
483 return false; 470 return false;
484 } 471 }
485 return true; 472 return true;
486 } 473 }
487 474
488 public bool DeletePicksRecord(UUID pickId) 475 public bool DeletePicksRecord(UUID pickId)
489 { 476 {
490 string query = string.Empty; 477 string query = "DELETE FROM userpicks WHERE pickuuid = ?PickId";
491 478
492 query += "DELETE FROM userpicks WHERE ";
493 query += "pickuuid = ?PickId";
494
495 try 479 try
496 { 480 {
497 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 481 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
498 { 482 {
499 dbcon.Open(); 483 dbcon.Open();
500 484
501 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 485 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
502 { 486 {
503 cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); 487 cmd.Parameters.AddWithValue("?PickId", pickId.ToString());
504 488
505 cmd.ExecuteNonQuery(); 489 cmd.ExecuteNonQuery();
506 } 490 }
491 dbcon.Close();
507 } 492 }
508 } 493 }
509 catch (Exception e) 494 catch (Exception e)
510 { 495 {
511 m_log.ErrorFormat("[PROFILES_DATA]" + 496 m_log.ErrorFormat("[PROFILES_DATA]: DeletePicksRecord exception {0}", e.Message);
512 ": DeleteUserPickRecord exception {0}", e.Message);
513 return false; 497 return false;
514 } 498 }
515 return true; 499 return true;
516 } 500 }
517 #endregion Picks Queries 501 #endregion Picks Queries
518 502
519 #region Avatar Notes Queries 503 #region Avatar Notes Queries
520 public bool GetAvatarNotes(ref UserProfileNotes notes) 504 public bool GetAvatarNotes(ref UserProfileNotes notes)
521 { // WIP 505 { // WIP
522 string query = string.Empty; 506 const string query = "SELECT `notes` FROM usernotes WHERE useruuid = ?Id AND targetuuid = ?TargetId";
523 507
524 query += "SELECT `notes` FROM usernotes WHERE ";
525 query += "useruuid = ?Id AND ";
526 query += "targetuuid = ?TargetId";
527 OSDArray data = new OSDArray();
528
529 try 508 try
530 { 509 {
531 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 510 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -535,7 +514,7 @@ namespace OpenSim.Data.MySQL
535 { 514 {
536 cmd.Parameters.AddWithValue("?Id", notes.UserId.ToString()); 515 cmd.Parameters.AddWithValue("?Id", notes.UserId.ToString());
537 cmd.Parameters.AddWithValue("?TargetId", notes.TargetId.ToString()); 516 cmd.Parameters.AddWithValue("?TargetId", notes.TargetId.ToString());
538 517
539 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 518 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
540 { 519 {
541 if(reader.HasRows) 520 if(reader.HasRows)
@@ -549,40 +528,39 @@ namespace OpenSim.Data.MySQL
549 } 528 }
550 } 529 }
551 } 530 }
531 dbcon.Close();
552 } 532 }
553 } 533 }
554 catch (Exception e) 534 catch (Exception e)
555 { 535 {
556 m_log.ErrorFormat("[PROFILES_DATA]" + 536 m_log.ErrorFormat("[PROFILES_DATA]: GetAvatarNotes exception {0}", e.Message);
557 ": GetAvatarNotes exception {0}", e.Message);
558 } 537 }
559 return true; 538 return true;
560 } 539 }
561 540
562 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) 541 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
563 { 542 {
564 string query = string.Empty; 543 string query;
565 bool remove; 544 bool remove;
566 545
567 if(string.IsNullOrEmpty(note.Notes)) 546 if(string.IsNullOrEmpty(note.Notes))
568 { 547 {
569 remove = true; 548 remove = true;
570 query += "DELETE FROM usernotes WHERE "; 549 query = "DELETE FROM usernotes WHERE useruuid=?UserId AND targetuuid=?TargetId";
571 query += "useruuid=?UserId AND ";
572 query += "targetuuid=?TargetId";
573 } 550 }
574 else 551 else
575 { 552 {
576 remove = false; 553 remove = false;
577 query += "INSERT INTO usernotes VALUES ( "; 554 query = "INSERT INTO usernotes VALUES ("
578 query += "?UserId,"; 555 + "?UserId,"
579 query += "?TargetId,"; 556 + "?TargetId,"
580 query += "?Notes )"; 557 + "?Notes )"
581 query += "ON DUPLICATE KEY "; 558 + "ON DUPLICATE KEY "
582 query += "UPDATE "; 559 + "UPDATE "
583 query += "notes=?Notes"; 560 + "notes=?Notes"
561 ;
584 } 562 }
585 563
586 try 564 try
587 { 565 {
588 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 566 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -594,30 +572,27 @@ namespace OpenSim.Data.MySQL
594 cmd.Parameters.AddWithValue("?Notes", note.Notes); 572 cmd.Parameters.AddWithValue("?Notes", note.Notes);
595 cmd.Parameters.AddWithValue("?TargetId", note.TargetId.ToString ()); 573 cmd.Parameters.AddWithValue("?TargetId", note.TargetId.ToString ());
596 cmd.Parameters.AddWithValue("?UserId", note.UserId.ToString()); 574 cmd.Parameters.AddWithValue("?UserId", note.UserId.ToString());
597 575
598 cmd.ExecuteNonQuery(); 576 cmd.ExecuteNonQuery();
599 } 577 }
578 dbcon.Close();
600 } 579 }
601 } 580 }
602 catch (Exception e) 581 catch (Exception e)
603 { 582 {
604 m_log.ErrorFormat("[PROFILES_DATA]" + 583 m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarNotes exception {0}", e.Message);
605 ": UpdateAvatarNotes exception {0}", e.Message);
606 return false; 584 return false;
607 } 585 }
608 return true; 586 return true;
609 587
610 } 588 }
611 #endregion Avatar Notes Queries 589 #endregion Avatar Notes Queries
612 590
613 #region Avatar Properties 591 #region Avatar Properties
614 public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) 592 public bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
615 { 593 {
616 string query = string.Empty; 594 string query = "SELECT * FROM userprofile WHERE useruuid = ?Id";
617 595
618 query += "SELECT * FROM userprofile WHERE ";
619 query += "useruuid = ?Id";
620
621 try 596 try
622 { 597 {
623 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 598 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -626,11 +601,13 @@ namespace OpenSim.Data.MySQL
626 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 601 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
627 { 602 {
628 cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); 603 cmd.Parameters.AddWithValue("?Id", props.UserId.ToString());
629 604
630 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 605 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
631 { 606 {
632 if(reader.HasRows) 607 if(reader.HasRows)
633 { 608 {
609 m_log.DebugFormat("[PROFILES_DATA]" +
610 ": Getting data for {0}.", props.UserId);
634 reader.Read(); 611 reader.Read();
635 props.WebUrl = (string)reader["profileURL"]; 612 props.WebUrl = (string)reader["profileURL"];
636 UUID.TryParse((string)reader["profileImage"], out props.ImageId); 613 UUID.TryParse((string)reader["profileImage"], out props.ImageId);
@@ -646,6 +623,9 @@ namespace OpenSim.Data.MySQL
646 } 623 }
647 else 624 else
648 { 625 {
626 m_log.DebugFormat("[PROFILES_DATA]" +
627 ": No data for {0}", props.UserId);
628
649 props.WebUrl = string.Empty; 629 props.WebUrl = string.Empty;
650 props.ImageId = UUID.Zero; 630 props.ImageId = UUID.Zero;
651 props.AboutText = string.Empty; 631 props.AboutText = string.Empty;
@@ -660,35 +640,36 @@ namespace OpenSim.Data.MySQL
660 props.PublishProfile = false; 640 props.PublishProfile = false;
661 props.PublishMature = false; 641 props.PublishMature = false;
662 642
663 query = "INSERT INTO userprofile ("; 643 query = "INSERT INTO userprofile ("
664 query += "useruuid, "; 644 + "useruuid, "
665 query += "profilePartner, "; 645 + "profilePartner, "
666 query += "profileAllowPublish, "; 646 + "profileAllowPublish, "
667 query += "profileMaturePublish, "; 647 + "profileMaturePublish, "
668 query += "profileURL, "; 648 + "profileURL, "
669 query += "profileWantToMask, "; 649 + "profileWantToMask, "
670 query += "profileWantToText, "; 650 + "profileWantToText, "
671 query += "profileSkillsMask, "; 651 + "profileSkillsMask, "
672 query += "profileSkillsText, "; 652 + "profileSkillsText, "
673 query += "profileLanguages, "; 653 + "profileLanguages, "
674 query += "profileImage, "; 654 + "profileImage, "
675 query += "profileAboutText, "; 655 + "profileAboutText, "
676 query += "profileFirstImage, "; 656 + "profileFirstImage, "
677 query += "profileFirstText) VALUES ("; 657 + "profileFirstText) VALUES ("
678 query += "?userId, "; 658 + "?userId, "
679 query += "?profilePartner, "; 659 + "?profilePartner, "
680 query += "?profileAllowPublish, "; 660 + "?profileAllowPublish, "
681 query += "?profileMaturePublish, "; 661 + "?profileMaturePublish, "
682 query += "?profileURL, "; 662 + "?profileURL, "
683 query += "?profileWantToMask, "; 663 + "?profileWantToMask, "
684 query += "?profileWantToText, "; 664 + "?profileWantToText, "
685 query += "?profileSkillsMask, "; 665 + "?profileSkillsMask, "
686 query += "?profileSkillsText, "; 666 + "?profileSkillsText, "
687 query += "?profileLanguages, "; 667 + "?profileLanguages, "
688 query += "?profileImage, "; 668 + "?profileImage, "
689 query += "?profileAboutText, "; 669 + "?profileAboutText, "
690 query += "?profileFirstImage, "; 670 + "?profileFirstImage, "
691 query += "?profileFirstText)"; 671 + "?profileFirstText)"
672 ;
692 673
693 dbcon.Close(); 674 dbcon.Close();
694 dbcon.Open(); 675 dbcon.Open();
@@ -715,30 +696,25 @@ namespace OpenSim.Data.MySQL
715 } 696 }
716 } 697 }
717 } 698 }
699 dbcon.Close();
718 } 700 }
719 } 701 }
720 catch (Exception e) 702 catch (Exception e)
721 { 703 {
722 m_log.ErrorFormat("[PROFILES_DATA]" + 704 m_log.ErrorFormat("[PROFILES_DATA]: GetAvatarProperties exception {0}", e.Message);
723 ": Requst properties exception {0}", e.Message);
724 result = e.Message; 705 result = e.Message;
725 return false; 706 return false;
726 } 707 }
727 return true; 708 return true;
728 } 709 }
729 710
730 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) 711 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
731 { 712 {
732 string query = string.Empty; 713 const string query = "UPDATE userprofile SET profileURL=?profileURL,"
733 714 + "profileImage=?image, profileAboutText=?abouttext,"
734 query += "UPDATE userprofile SET "; 715 + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext "
735 query += "profileURL=?profileURL, "; 716 + "WHERE useruuid=?uuid";
736 query += "profileImage=?image, "; 717
737 query += "profileAboutText=?abouttext,";
738 query += "profileFirstImage=?firstlifeimage,";
739 query += "profileFirstText=?firstlifetext ";
740 query += "WHERE useruuid=?uuid";
741
742 try 718 try
743 { 719 {
744 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 720 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -752,35 +728,33 @@ namespace OpenSim.Data.MySQL
752 cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); 728 cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString());
753 cmd.Parameters.AddWithValue("?firstlifetext", props.FirstLifeText); 729 cmd.Parameters.AddWithValue("?firstlifetext", props.FirstLifeText);
754 cmd.Parameters.AddWithValue("?uuid", props.UserId.ToString()); 730 cmd.Parameters.AddWithValue("?uuid", props.UserId.ToString());
755 731
756 cmd.ExecuteNonQuery(); 732 cmd.ExecuteNonQuery();
757 } 733 }
734 dbcon.Close();
758 } 735 }
759 } 736 }
760 catch (Exception e) 737 catch (Exception e)
761 { 738 {
762 m_log.ErrorFormat("[PROFILES_DATA]" + 739 m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarProperties exception {0}", e.Message);
763 ": AgentPropertiesUpdate exception {0}", e.Message); 740
764
765 return false; 741 return false;
766 } 742 }
767 return true; 743 return true;
768 } 744 }
769 #endregion Avatar Properties 745 #endregion Avatar Properties
770 746
771 #region Avatar Interests 747 #region Avatar Interests
772 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) 748 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
773 { 749 {
774 string query = string.Empty; 750 const string query = "UPDATE userprofile SET "
775 751 + "profileWantToMask=?WantMask, "
776 query += "UPDATE userprofile SET "; 752 + "profileWantToText=?WantText,"
777 query += "profileWantToMask=?WantMask, "; 753 + "profileSkillsMask=?SkillsMask,"
778 query += "profileWantToText=?WantText,"; 754 + "profileSkillsText=?SkillsText, "
779 query += "profileSkillsMask=?SkillsMask,"; 755 + "profileLanguages=?Languages "
780 query += "profileSkillsText=?SkillsText, "; 756 + "WHERE useruuid=?uuid";
781 query += "profileLanguages=?Languages "; 757
782 query += "WHERE useruuid=?uuid";
783
784 try 758 try
785 { 759 {
786 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 760 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -794,15 +768,14 @@ namespace OpenSim.Data.MySQL
794 cmd.Parameters.AddWithValue("?SkillsText", up.SkillsText); 768 cmd.Parameters.AddWithValue("?SkillsText", up.SkillsText);
795 cmd.Parameters.AddWithValue("?Languages", up.Language); 769 cmd.Parameters.AddWithValue("?Languages", up.Language);
796 cmd.Parameters.AddWithValue("?uuid", up.UserId.ToString()); 770 cmd.Parameters.AddWithValue("?uuid", up.UserId.ToString());
797 771
798 cmd.ExecuteNonQuery(); 772 cmd.ExecuteNonQuery();
799 } 773 }
800 } 774 }
801 } 775 }
802 catch (Exception e) 776 catch (Exception e)
803 { 777 {
804 m_log.ErrorFormat("[PROFILES_DATA]" + 778 m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarInterests exception {0}", e.Message);
805 ": AgentInterestsUpdate exception {0}", e.Message);
806 result = e.Message; 779 result = e.Message;
807 return false; 780 return false;
808 } 781 }
@@ -813,21 +786,20 @@ namespace OpenSim.Data.MySQL
813 public OSDArray GetUserImageAssets(UUID avatarId) 786 public OSDArray GetUserImageAssets(UUID avatarId)
814 { 787 {
815 OSDArray data = new OSDArray(); 788 OSDArray data = new OSDArray();
816 string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; 789 const string queryA = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
817 790
818 // Get classified image assets 791 // Get classified image assets
819 792
820
821 try 793 try
822 { 794 {
823 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 795 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
824 { 796 {
825 dbcon.Open(); 797 dbcon.Open();
826 798
827 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) 799 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`classifieds`"), dbcon))
828 { 800 {
829 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 801 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
830 802
831 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 803 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
832 { 804 {
833 if(reader.HasRows) 805 if(reader.HasRows)
@@ -843,10 +815,10 @@ namespace OpenSim.Data.MySQL
843 dbcon.Close(); 815 dbcon.Close();
844 dbcon.Open(); 816 dbcon.Open();
845 817
846 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) 818 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`userpicks`"), dbcon))
847 { 819 {
848 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 820 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
849 821
850 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 822 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
851 { 823 {
852 if(reader.HasRows) 824 if(reader.HasRows)
@@ -858,16 +830,16 @@ namespace OpenSim.Data.MySQL
858 } 830 }
859 } 831 }
860 } 832 }
861 833
862 dbcon.Close(); 834 dbcon.Close();
863 dbcon.Open(); 835 dbcon.Open();
864 836
865 query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; 837 const string queryB = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
866 838
867 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) 839 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryB,"`userpicks`"), dbcon))
868 { 840 {
869 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 841 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
870 842
871 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 843 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
872 { 844 {
873 if(reader.HasRows) 845 if(reader.HasRows)
@@ -880,27 +852,21 @@ namespace OpenSim.Data.MySQL
880 } 852 }
881 } 853 }
882 } 854 }
855 dbcon.Close();
883 } 856 }
884 } 857 }
885 catch (Exception e) 858 catch (Exception e)
886 { 859 {
887 m_log.ErrorFormat("[PROFILES_DATA]" + 860 m_log.ErrorFormat("[PROFILES_DATA]: GetUserImageAssets exception {0}", e.Message);
888 ": GetAvatarNotes exception {0}", e.Message);
889 } 861 }
890 return data; 862 return data;
891 } 863 }
892 864
893 #region User Preferences 865 #region User Preferences
894 public bool GetUserPreferences(ref UserPreferences pref, ref string result) 866 public bool GetUserPreferences(ref UserPreferences pref, ref string result)
895 { 867 {
896 string query = string.Empty; 868 const string query = "SELECT imviaemail,visible,email FROM usersettings WHERE useruuid = ?Id";
897 869
898 query += "SELECT imviaemail,visible,email FROM ";
899 query += "usersettings WHERE ";
900 query += "useruuid = ?Id";
901
902 OSDArray data = new OSDArray();
903
904 try 870 try
905 { 871 {
906 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 872 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -909,10 +875,9 @@ namespace OpenSim.Data.MySQL
909 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 875 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
910 { 876 {
911 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); 877 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString());
912
913 using (MySqlDataReader reader = cmd.ExecuteReader()) 878 using (MySqlDataReader reader = cmd.ExecuteReader())
914 { 879 {
915 if(reader.HasRows) 880 if (reader.HasRows)
916 { 881 {
917 reader.Read(); 882 reader.Read();
918 bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); 883 bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail);
@@ -923,13 +888,12 @@ namespace OpenSim.Data.MySQL
923 { 888 {
924 dbcon.Close(); 889 dbcon.Close();
925 dbcon.Open(); 890 dbcon.Open();
926
927 query = "INSERT INTO usersettings VALUES ";
928 query += "(?uuid,'false','false', ?Email)";
929 891
930 using (MySqlCommand put = new MySqlCommand(query, dbcon)) 892 const string queryB = "INSERT INTO usersettings VALUES (?uuid,'false','false', ?Email)";
893
894 using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
931 { 895 {
932 896
933 put.Parameters.AddWithValue("?Email", pref.EMail); 897 put.Parameters.AddWithValue("?Email", pref.EMail);
934 put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); 898 put.Parameters.AddWithValue("?uuid", pref.UserId.ToString());
935 899
@@ -938,28 +902,24 @@ namespace OpenSim.Data.MySQL
938 } 902 }
939 } 903 }
940 } 904 }
905 dbcon.Close();
941 } 906 }
942 } 907 }
943 catch (Exception e) 908 catch (Exception e)
944 { 909 {
945 m_log.ErrorFormat("[PROFILES_DATA]" + 910 m_log.ErrorFormat("[PROFILES_DATA]: GetUserPreferences exception {0}", e.Message);
946 ": Get preferences exception {0}", e.Message);
947 result = e.Message; 911 result = e.Message;
948 return false; 912 return false;
949 } 913 }
950 return true; 914 return true;
951 } 915 }
952 916
953 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) 917 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
954 { 918 {
955 string query = string.Empty; 919 const string query = "UPDATE usersettings SET imviaemail=?ImViaEmail,"
956 920 + "visible=?Visible, email=?EMail "
957 query += "UPDATE usersettings SET "; 921 + "WHERE useruuid=?uuid";
958 query += "imviaemail=?ImViaEmail, "; 922
959 query += "visible=?Visible, ";
960 query += "email=?EMail ";
961 query += "WHERE useruuid=?uuid";
962
963 try 923 try
964 { 924 {
965 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 925 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -974,28 +934,24 @@ namespace OpenSim.Data.MySQL
974 934
975 cmd.ExecuteNonQuery(); 935 cmd.ExecuteNonQuery();
976 } 936 }
937 dbcon.Close();
977 } 938 }
978 } 939 }
979 catch (Exception e) 940 catch (Exception e)
980 { 941 {
981 m_log.ErrorFormat("[PROFILES_DATA]" + 942 m_log.ErrorFormat("[PROFILES_DATA]: UpdateUserPreferences exception {0} {1}", e.Message, e.InnerException);
982 ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException);
983 result = e.Message; 943 result = e.Message;
984 return false; 944 return false;
985 } 945 }
986 return true; 946 return true;
987 } 947 }
988 #endregion User Preferences 948 #endregion User Preferences
989 949
990 #region Integration 950 #region Integration
991 public bool GetUserAppData(ref UserAppData props, ref string result) 951 public bool GetUserAppData(ref UserAppData props, ref string result)
992 { 952 {
993 string query = string.Empty; 953 const string query = "SELECT * FROM `userdata` WHERE UserId = ?Id AND TagId = ?TagId";
994 954
995 query += "SELECT * FROM `userdata` WHERE ";
996 query += "UserId = ?Id AND ";
997 query += "TagId = ?TagId";
998
999 try 955 try
1000 { 956 {
1001 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 957 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -1005,7 +961,7 @@ namespace OpenSim.Data.MySQL
1005 { 961 {
1006 cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); 962 cmd.Parameters.AddWithValue("?Id", props.UserId.ToString());
1007 cmd.Parameters.AddWithValue ("?TagId", props.TagId.ToString()); 963 cmd.Parameters.AddWithValue ("?TagId", props.TagId.ToString());
1008 964
1009 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 965 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
1010 { 966 {
1011 if(reader.HasRows) 967 if(reader.HasRows)
@@ -1016,13 +972,8 @@ namespace OpenSim.Data.MySQL
1016 } 972 }
1017 else 973 else
1018 { 974 {
1019 query += "INSERT INTO userdata VALUES ( "; 975 const string queryB = "INSERT INTO userdata VALUES (?UserId, ?TagId, ?DataKey, ?DataVal)";
1020 query += "?UserId,"; 976 using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
1021 query += "?TagId,";
1022 query += "?DataKey,";
1023 query += "?DataVal) ";
1024
1025 using (MySqlCommand put = new MySqlCommand(query, dbcon))
1026 { 977 {
1027 put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); 978 put.Parameters.AddWithValue("?UserId", props.UserId.ToString());
1028 put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); 979 put.Parameters.AddWithValue("?TagId", props.TagId.ToString());
@@ -1034,12 +985,12 @@ namespace OpenSim.Data.MySQL
1034 } 985 }
1035 } 986 }
1036 } 987 }
988 dbcon.Close();
1037 } 989 }
1038 } 990 }
1039 catch (Exception e) 991 catch (Exception e)
1040 { 992 {
1041 m_log.ErrorFormat("[PROFILES_DATA]" + 993 m_log.ErrorFormat("[PROFILES_DATA]: GetUserAppData exception {0}", e.Message);
1042 ": Requst application data exception {0}", e.Message);
1043 result = e.Message; 994 result = e.Message;
1044 return false; 995 return false;
1045 } 996 }
@@ -1047,16 +998,9 @@ namespace OpenSim.Data.MySQL
1047 } 998 }
1048 999
1049 public bool SetUserAppData(UserAppData props, ref string result) 1000 public bool SetUserAppData(UserAppData props, ref string result)
1050 { 1001 {
1051 string query = string.Empty; 1002 const string query = "UPDATE userdata SET TagId = ?TagId, DataKey = ?DataKey, DataVal = ?DataVal WHERE UserId = ?UserId AND TagId = ?TagId";
1052 1003
1053 query += "UPDATE userdata SET ";
1054 query += "TagId = ?TagId, ";
1055 query += "DataKey = ?DataKey, ";
1056 query += "DataVal = ?DataVal WHERE ";
1057 query += "UserId = ?UserId AND ";
1058 query += "TagId = ?TagId";
1059
1060 try 1004 try
1061 { 1005 {
1062 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 1006 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -1071,12 +1015,12 @@ namespace OpenSim.Data.MySQL
1071 1015
1072 cmd.ExecuteNonQuery(); 1016 cmd.ExecuteNonQuery();
1073 } 1017 }
1018 dbcon.Close();
1074 } 1019 }
1075 } 1020 }
1076 catch (Exception e) 1021 catch (Exception e)
1077 { 1022 {
1078 m_log.ErrorFormat("[PROFILES_DATA]" + 1023 m_log.ErrorFormat("[PROFILES_DATA]: SetUserAppData exception {0}", e.Message);
1079 ": SetUserData exception {0}", e.Message);
1080 return false; 1024 return false;
1081 } 1025 }
1082 return true; 1026 return true;
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index af7e876..9f9c9cf 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -97,6 +97,7 @@ namespace OpenSim.Data.MySQL
97 dbcon.Open(); 97 dbcon.Open();
98 Migration m = new Migration(dbcon, Assembly, "XAssetStore"); 98 Migration m = new Migration(dbcon, Assembly, "XAssetStore");
99 m.Update(); 99 m.Update();
100 dbcon.Close();
100 } 101 }
101 } 102 }
102 103
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); 131// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
131 132
132 AssetBase asset = null; 133 AssetBase asset = null;
134 int accessTime = 0;
133 135
134 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 136 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
135 { 137 {
@@ -140,7 +142,6 @@ namespace OpenSim.Data.MySQL
140 dbcon)) 142 dbcon))
141 { 143 {
142 cmd.Parameters.AddWithValue("?ID", assetID.ToString()); 144 cmd.Parameters.AddWithValue("?ID", assetID.ToString());
143
144 try 145 try
145 { 146 {
146 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 147 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -159,23 +160,7 @@ namespace OpenSim.Data.MySQL
159 160
160 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); 161 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
161 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); 162 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
162 163 accessTime = (int)dbReader["AccessTime"];
163 if (m_enableCompression)
164 {
165 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
166 {
167 MemoryStream outputStream = new MemoryStream();
168 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
169// int compressedLength = asset.Data.Length;
170 asset.Data = outputStream.ToArray();
171
172// m_log.DebugFormat(
173// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
174// asset.ID, asset.Name, asset.Data.Length, compressedLength);
175 }
176 }
177
178 UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
179 } 164 }
180 } 165 }
181 } 166 }
@@ -184,9 +169,38 @@ namespace OpenSim.Data.MySQL
184 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); 169 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
185 } 170 }
186 } 171 }
172 dbcon.Close();
187 } 173 }
188 174
189 return asset; 175 if(asset == null)
176 return asset;
177
178 if(accessTime > 0)
179 {
180 try
181 {
182 UpdateAccessTime(asset.Metadata, accessTime);
183 }
184 catch { }
185 }
186
187 if (m_enableCompression && asset.Data != null)
188 {
189 using(MemoryStream ms = new MemoryStream(asset.Data))
190 using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
191 {
192 using(MemoryStream outputStream = new MemoryStream())
193 {
194 decompressionStream.CopyTo(outputStream, int.MaxValue);
195// int compressedLength = asset.Data.Length;
196 asset.Data = outputStream.ToArray();
197 }
198// m_log.DebugFormat(
199// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
200// asset.ID, asset.Name, asset.Data.Length, compressedLength);
201 }
202 }
203 return asset;
190 } 204 }
191 205
192 /// <summary> 206 /// <summary>
@@ -209,7 +223,7 @@ namespace OpenSim.Data.MySQL
209 { 223 {
210 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); 224 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
211 m_log.WarnFormat( 225 m_log.WarnFormat(
212 "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", 226 "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
213 asset.Name, asset.ID, asset.Name.Length, assetName.Length); 227 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
214 } 228 }
215 229
@@ -218,7 +232,7 @@ namespace OpenSim.Data.MySQL
218 { 232 {
219 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); 233 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
220 m_log.WarnFormat( 234 m_log.WarnFormat(
221 "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 235 "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
222 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 236 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
223 } 237 }
224 238
@@ -303,6 +317,7 @@ namespace OpenSim.Data.MySQL
303 317
304 transaction.Commit(); 318 transaction.Commit();
305 } 319 }
320 dbcon.Close();
306 } 321 }
307 } 322 }
308 323
@@ -341,9 +356,10 @@ namespace OpenSim.Data.MySQL
341 catch (Exception) 356 catch (Exception)
342 { 357 {
343 m_log.ErrorFormat( 358 m_log.ErrorFormat(
344 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", 359 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
345 assetMetadata.ID, assetMetadata.Name); 360 assetMetadata.ID, assetMetadata.Name);
346 } 361 }
362 dbcon.Close();
347 } 363 }
348 } 364 }
349 365
@@ -440,38 +456,41 @@ namespace OpenSim.Data.MySQL
440 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 456 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
441 { 457 {
442 dbcon.Open(); 458 dbcon.Open();
443 MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); 459 using(MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count",dbcon))
444 cmd.Parameters.AddWithValue("?start", start);
445 cmd.Parameters.AddWithValue("?count", count);
446
447 try
448 { 460 {
449 using (MySqlDataReader dbReader = cmd.ExecuteReader()) 461 cmd.Parameters.AddWithValue("?start",start);
462 cmd.Parameters.AddWithValue("?count", count);
463
464 try
450 { 465 {
451 while (dbReader.Read()) 466 using (MySqlDataReader dbReader = cmd.ExecuteReader())
452 { 467 {
453 AssetMetadata metadata = new AssetMetadata(); 468 while (dbReader.Read())
454 metadata.Name = (string)dbReader["Name"]; 469 {
455 metadata.Description = (string)dbReader["Description"]; 470 AssetMetadata metadata = new AssetMetadata();
456 metadata.Type = (sbyte)dbReader["AssetType"]; 471 metadata.Name = (string)dbReader["Name"];
457 metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. 472 metadata.Description = (string)dbReader["Description"];
458 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); 473 metadata.Type = (sbyte)dbReader["AssetType"];
459 metadata.FullID = DBGuid.FromDB(dbReader["ID"]); 474 metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
460 metadata.CreatorID = dbReader["CreatorID"].ToString(); 475 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
476 metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
477 metadata.CreatorID = dbReader["CreatorID"].ToString();
461 478
462 // We'll ignore this for now - it appears unused! 479 // We'll ignore this for now - it appears unused!
463// metadata.SHA1 = dbReader["hash"]); 480 // metadata.SHA1 = dbReader["hash"]);
464 481
465 UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); 482 UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
466 483
467 retList.Add(metadata); 484 retList.Add(metadata);
485 }
468 } 486 }
469 } 487 }
488 catch (Exception e)
489 {
490 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
491 }
470 } 492 }
471 catch (Exception e) 493 dbcon.Close();
472 {
473 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
474 }
475 } 494 }
476 495
477 return retList; 496 return retList;
@@ -490,9 +509,9 @@ namespace OpenSim.Data.MySQL
490 cmd.Parameters.AddWithValue("?ID", id); 509 cmd.Parameters.AddWithValue("?ID", id);
491 cmd.ExecuteNonQuery(); 510 cmd.ExecuteNonQuery();
492 } 511 }
493
494 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we 512 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
495 // keep a reference count (?) 513 // keep a reference count (?)
514 dbcon.Close();
496 } 515 }
497 516
498 return true; 517 return true;
@@ -500,4 +519,4 @@ namespace OpenSim.Data.MySQL
500 519
501 #endregion 520 #endregion
502 } 521 }
503} \ No newline at end of file 522}
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index c74033e..5019994 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Data.MySQL
80 80
81 return m_Items.Store(item); 81 return m_Items.Store(item);
82 } 82 }
83 83
84 public bool DeleteFolders(string field, string val) 84 public bool DeleteFolders(string field, string val)
85 { 85 {
86 return m_Folders.Delete(field, val); 86 return m_Folders.Delete(field, val);
@@ -193,7 +193,9 @@ namespace OpenSim.Data.MySQL
193 { 193 {
194 using (MySqlCommand cmd = new MySqlCommand()) 194 using (MySqlCommand cmd = new MySqlCommand())
195 { 195 {
196 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags & 1", m_Realm); 196// cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags & 1", m_Realm);
197
198 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags & 1");
197 199
198 cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); 200 cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
199 cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); 201 cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
@@ -212,15 +214,18 @@ namespace OpenSim.Data.MySQL
212 { 214 {
213 cmd.Connection = dbcon; 215 cmd.Connection = dbcon;
214 216
215 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm); 217// cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
218
219 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID");
220
216 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 221 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
217 cmd.Parameters.AddWithValue("?AssetID", assetID.ToString()); 222 cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
218 223
219 using (IDataReader reader = cmd.ExecuteReader()) 224 using (IDataReader reader = cmd.ExecuteReader())
220 { 225 {
221 226
222 int perms = 0; 227 int perms = 0;
223 228
224 if (reader.Read()) 229 if (reader.Read())
225 { 230 {
226 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); 231 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
@@ -323,7 +328,6 @@ namespace OpenSim.Data.MySQL
323 { 328 {
324 return false; 329 return false;
325 } 330 }
326 cmd.Dispose();
327 } 331 }
328 332
329 dbcon.Close(); 333 dbcon.Close();
diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs
index b46d175..6507a37 100644
--- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/MySQL/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/MySQL/Resources/AgentPrefs.migrations b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations
index e76db07..e496f72 100644
--- a/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations
+++ b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations
@@ -13,6 +13,6 @@ CREATE TABLE `AgentPrefs` (
13 `PermNextOwner` INT(6) NOT NULL DEFAULT 532480, 13 `PermNextOwner` INT(6) NOT NULL DEFAULT 532480,
14 UNIQUE KEY `PrincipalID` (`PrincipalID`), 14 UNIQUE KEY `PrincipalID` (`PrincipalID`),
15 PRIMARY KEY(`PrincipalID`) 15 PRIMARY KEY(`PrincipalID`)
16) ENGINE=MyISAM DEFAULT CHARSET=utf8; 16) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17 17
18COMMIT; 18COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations
index 52715fd..820799d 100644
--- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations
@@ -1,81 +1,21 @@
1# ----------------- 1# -----------------
2:VERSION 1 2:VERSION 10
3 3
4BEGIN; 4BEGIN;
5 5
6CREATE TABLE `assets` ( 6CREATE TABLE IF NOT EXISTS `assets` (
7 `id` binary(16) NOT NULL,
8 `name` varchar(64) NOT NULL, 7 `name` varchar(64) NOT NULL,
9 `description` varchar(64) NOT NULL, 8 `description` varchar(64) NOT NULL,
10 `assetType` tinyint(4) NOT NULL, 9 `assetType` tinyint(4) NOT NULL,
11 `invType` tinyint(4) NOT NULL,
12 `local` tinyint(1) NOT NULL, 10 `local` tinyint(1) NOT NULL,
13 `temporary` tinyint(1) NOT NULL, 11 `temporary` tinyint(1) NOT NULL,
14 `data` longblob NOT NULL, 12 `data` longblob NOT NULL,
13 `id` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
14 `create_time` int(11) DEFAULT '0',
15 `access_time` int(11) DEFAULT '0',
16 `asset_flags` int(11) NOT NULL DEFAULT '0',
17 `CreatorID` varchar(128) NOT NULL DEFAULT '',
15 PRIMARY KEY (`id`) 18 PRIMARY KEY (`id`)
16) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; 19) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17 20
18COMMIT; 21COMMIT;
19
20# -----------------
21:VERSION 2
22
23BEGIN;
24
25ALTER TABLE assets change id oldid binary(16);
26ALTER TABLE assets add id varchar(36) not null default '';
27UPDATE assets set id = concat(substr(hex(oldid),1,8),"-",substr(hex(oldid),9,4),"-",substr(hex(oldid),13,4),"-",substr(hex(oldid),17,4),"-",substr(hex(oldid),21,12));
28ALTER TABLE assets drop oldid;
29ALTER TABLE assets add constraint primary key(id);
30
31COMMIT;
32
33# -----------------
34:VERSION 3
35
36BEGIN;
37
38ALTER TABLE assets change id oldid varchar(36);
39ALTER TABLE assets add id char(36) not null default '00000000-0000-0000-0000-000000000000';
40UPDATE assets set id = oldid;
41ALTER TABLE assets drop oldid;
42ALTER TABLE assets add constraint primary key(id);
43
44COMMIT;
45
46# -----------------
47:VERSION 4
48
49BEGIN;
50
51ALTER TABLE assets drop InvType;
52
53COMMIT;
54
55# -----------------
56:VERSION 5
57
58BEGIN;
59
60ALTER TABLE assets add create_time integer default 0;
61ALTER TABLE assets add access_time integer default 0;
62
63COMMIT;
64
65# -----------------
66:VERSION 6
67
68DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621'
69
70:VERSION 7
71
72ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0;
73
74:VERSION 8
75
76ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT '';
77
78:VERSION 9
79
80BEGIN;
81COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/AuthStore.migrations b/OpenSim/Data/MySQL/Resources/AuthStore.migrations
index 9450940..f00979f 100644
--- a/OpenSim/Data/MySQL/Resources/AuthStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/AuthStore.migrations
@@ -1,16 +1,17 @@
1:VERSION 1 # ------------------------------- 1:VERSION 4 # -------------------------------
2 2
3begin; 3begin;
4 4
5CREATE TABLE `auth` ( 5CREATE TABLE IF NOT EXISTS `auth` (
6 `UUID` char(36) NOT NULL, 6 `UUID` char(36) NOT NULL,
7 `passwordHash` char(32) NOT NULL default '', 7 `passwordHash` char(32) NOT NULL DEFAULT '',
8 `passwordSalt` char(32) NOT NULL default '', 8 `passwordSalt` char(32) NOT NULL DEFAULT '',
9 `webLoginKey` varchar(255) NOT NULL default '', 9 `webLoginKey` varchar(255) NOT NULL DEFAULT '',
10 PRIMARY KEY (`UUID`) 10 `accountType` varchar(32) NOT NULL DEFAULT 'UserAccount',
11) ENGINE=MyISAM; 11 PRIMARY KEY (`UUID`)
12 12) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13CREATE TABLE `tokens` ( 13
14CREATE TABLE IF NOT EXISTS `tokens` (
14 `UUID` char(36) NOT NULL, 15 `UUID` char(36) NOT NULL,
15 `token` varchar(255) NOT NULL, 16 `token` varchar(255) NOT NULL,
16 `validity` datetime NOT NULL, 17 `validity` datetime NOT NULL,
@@ -18,22 +19,6 @@ CREATE TABLE `tokens` (
18 KEY `UUID` (`UUID`), 19 KEY `UUID` (`UUID`),
19 KEY `token` (`token`), 20 KEY `token` (`token`),
20 KEY `validity` (`validity`) 21 KEY `validity` (`validity`)
21) ENGINE=MyISAM; 22) ENGINE=InnoDB DEFAULT CHARSET=utf8;
22
23commit;
24
25:VERSION 2 # -------------------------------
26
27BEGIN;
28
29INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users;
30
31COMMIT;
32
33:VERSION 3 # -------------------------------
34
35BEGIN;
36
37ALTER TABLE `auth` ADD COLUMN `accountType` VARCHAR(32) NOT NULL DEFAULT 'UserAccount';
38 23
39COMMIT; 24COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/Avatar.migrations b/OpenSim/Data/MySQL/Resources/Avatar.migrations
index f7cf176..c5ec9ca 100644
--- a/OpenSim/Data/MySQL/Resources/Avatar.migrations
+++ b/OpenSim/Data/MySQL/Resources/Avatar.migrations
@@ -1,20 +1,13 @@
1:VERSION 1 1:VERSION 3
2 2
3BEGIN; 3BEGIN;
4 4
5CREATE TABLE Avatars ( 5CREATE TABLE IF NOT EXISTS `Avatars` (
6 PrincipalID CHAR(36) NOT NULL, 6 `PrincipalID` char(36) NOT NULL,
7 Name VARCHAR(32) NOT NULL, 7 `Name` varchar(32) NOT NULL,
8 Value VARCHAR(255) NOT NULL DEFAULT '', 8 `Value` text,
9 PRIMARY KEY(PrincipalID, Name), 9 PRIMARY KEY (`PrincipalID`,`Name`),
10 KEY(PrincipalID)); 10 KEY `PrincipalID` (`PrincipalID`)
11 11) ENGINE=InnoDB DEFAULT CHARSET=utf8;
12COMMIT;
13
14:VERSION 2
15
16BEGIN;
17
18alter table Avatars change column Value Value text;
19 12
20COMMIT; 13COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations
index 9dfb77b..615af95 100644
--- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations
@@ -1,41 +1,29 @@
1:VERSION 13 1:VERSION 34
2
3# The estate migrations used to be in Region store
4# here they will do nothing (bad) if the tables are already there,
5# just update the store version.
6 2
7BEGIN; 3BEGIN;
8 4
9CREATE TABLE IF NOT EXISTS `estate_managers` (
10 `EstateID` int(10) unsigned NOT NULL,
11 `uuid` char(36) NOT NULL,
12 KEY `EstateID` (`EstateID`)
13) ENGINE=MyISAM;
14
15CREATE TABLE IF NOT EXISTS `estate_groups` ( 5CREATE TABLE IF NOT EXISTS `estate_groups` (
16 `EstateID` int(10) unsigned NOT NULL, 6 `EstateID` int(10) unsigned NOT NULL,
17 `uuid` char(36) NOT NULL, 7 `uuid` char(36) NOT NULL,
18 KEY `EstateID` (`EstateID`) 8 KEY `EstateID` (`EstateID`)
19) ENGINE=MyISAM; 9) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20 10
21CREATE TABLE IF NOT EXISTS `estate_users` ( 11CREATE TABLE IF NOT EXISTS `estate_managers` (
22 `EstateID` int(10) unsigned NOT NULL, 12 `EstateID` int(10) unsigned NOT NULL,
23 `uuid` char(36) NOT NULL, 13 `uuid` char(36) NOT NULL,
24 KEY `EstateID` (`EstateID`) 14 KEY `EstateID` (`EstateID`)
25) ENGINE=MyISAM; 15) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26 16
27CREATE TABLE IF NOT EXISTS `estateban` ( 17CREATE TABLE IF NOT EXISTS `estate_map` (
28 `EstateID` int(10) unsigned NOT NULL, 18 `RegionID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
29 `bannedUUID` varchar(36) NOT NULL, 19 `EstateID` int(11) NOT NULL,
30 `bannedIp` varchar(16) NOT NULL, 20 PRIMARY KEY (`RegionID`),
31 `bannedIpHostMask` varchar(16) NOT NULL, 21 KEY `EstateID` (`EstateID`)
32 `bannedNameMask` varchar(64) default NULL, 22) ENGINE=InnoDB DEFAULT CHARSET=utf8;
33 KEY `estateban_EstateID` (`EstateID`)
34) ENGINE=MyISAM;
35 23
36CREATE TABLE IF NOT EXISTS `estate_settings` ( 24CREATE TABLE IF NOT EXISTS `estate_settings` (
37 `EstateID` int(10) unsigned NOT NULL auto_increment, 25 `EstateID` int(10) unsigned NOT NULL AUTO_INCREMENT,
38 `EstateName` varchar(64) default NULL, 26 `EstateName` varchar(64) DEFAULT NULL,
39 `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, 27 `AbuseEmailToEstateOwner` tinyint(4) NOT NULL,
40 `DenyAnonymous` tinyint(4) NOT NULL, 28 `DenyAnonymous` tinyint(4) NOT NULL,
41 `ResetHomeOnTeleport` tinyint(4) NOT NULL, 29 `ResetHomeOnTeleport` tinyint(4) NOT NULL,
@@ -55,33 +43,29 @@ CREATE TABLE IF NOT EXISTS `estate_settings` (
55 `EstateSkipScripts` tinyint(4) NOT NULL, 43 `EstateSkipScripts` tinyint(4) NOT NULL,
56 `BillableFactor` float NOT NULL, 44 `BillableFactor` float NOT NULL,
57 `PublicAccess` tinyint(4) NOT NULL, 45 `PublicAccess` tinyint(4) NOT NULL,
58 `AbuseEmail` varchar(255) not null, 46 `AbuseEmail` varchar(255) NOT NULL,
59 `EstateOwner` varchar(36) not null, 47 `EstateOwner` varchar(36) NOT NULL,
60 `DenyMinors` tinyint not null, 48 `DenyMinors` tinyint(4) NOT NULL,
61 49 `AllowLandmark` tinyint(4) NOT NULL DEFAULT '1',
62 PRIMARY KEY (`EstateID`) 50 `AllowParcelChanges` tinyint(4) NOT NULL DEFAULT '1',
63) ENGINE=MyISAM AUTO_INCREMENT=100; 51 `AllowSetHome` tinyint(4) NOT NULL DEFAULT '1',
52 PRIMARY KEY (`EstateID`)
53) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8;
64 54
65CREATE TABLE IF NOT EXISTS `estate_map` ( 55CREATE TABLE IF NOT EXISTS `estate_users` (
66 `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', 56 `EstateID` int(10) unsigned NOT NULL,
67 `EstateID` int(11) NOT NULL, 57 `uuid` char(36) NOT NULL,
68 PRIMARY KEY (`RegionID`),
69 KEY `EstateID` (`EstateID`) 58 KEY `EstateID` (`EstateID`)
70) ENGINE=MyISAM; 59) ENGINE=InnoDB DEFAULT CHARSET=utf8;
71 60
72COMMIT; 61CREATE TABLE IF NOT EXISTS `estateban` (
73 62 `EstateID` int(10) unsigned NOT NULL,
74:VERSION 32 #--------------------- (moved from RegionStore migr, just in case) 63 `bannedUUID` varchar(36) NOT NULL,
75 64 `bannedIp` varchar(16) NOT NULL,
76BEGIN; 65 `bannedIpHostMask` varchar(16) NOT NULL,
77ALTER TABLE estate_settings AUTO_INCREMENT = 100; 66 `bannedNameMask` varchar(64) DEFAULT NULL,
78COMMIT; 67 KEY `estateban_EstateID` (`EstateID`)
79 68) ENGINE=InnoDB DEFAULT CHARSET=utf8;
80:VERSION 33 #---------------------
81 69
82BEGIN;
83ALTER TABLE estate_settings ADD COLUMN `AllowLandmark` tinyint(4) NOT NULL default '1';
84ALTER TABLE estate_settings ADD COLUMN `AllowParcelChanges` tinyint(4) NOT NULL default '1';
85ALTER TABLE estate_settings ADD COLUMN `AllowSetHome` tinyint(4) NOT NULL default '1';
86COMMIT; 70COMMIT;
87 71
diff --git a/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations
index 4194af3..87d08c6 100644
--- a/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations
@@ -13,6 +13,6 @@ CREATE TABLE `fsassets` (
13 `access_time` int(11) NOT NULL DEFAULT '0', 13 `access_time` int(11) NOT NULL DEFAULT '0',
14 `asset_flags` int(11) NOT NULL DEFAULT '0', 14 `asset_flags` int(11) NOT NULL DEFAULT '0',
15 PRIMARY KEY (`id`) 15 PRIMARY KEY (`id`)
16) ENGINE=MyISAM DEFAULT CHARSET=utf8; 16) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17 17
18COMMIT; \ No newline at end of file 18COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations
index 5de0e35..6840f07 100644
--- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations
@@ -1,32 +1,14 @@
1:VERSION 1 # ------------------------- 1:VERSION 4 # -------------------------
2 2
3BEGIN; 3BEGIN;
4 4
5CREATE TABLE `Friends` ( 5CREATE TABLE IF NOT EXISTS `Friends` (
6 `PrincipalID` CHAR(36) NOT NULL, 6 `PrincipalID` varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
7 `Friend` VARCHAR(255) NOT NULL, 7 `Friend` varchar(255) NOT NULL,
8 `Flags` VARCHAR(16) NOT NULL DEFAULT 0, 8 `Flags` varchar(16) NOT NULL DEFAULT '0',
9 `Offered` VARCHAR(32) NOT NULL DEFAULT 0, 9 `Offered` varchar(32) NOT NULL DEFAULT '0',
10 PRIMARY KEY(`PrincipalID`, `Friend`), 10 PRIMARY KEY (`PrincipalID`(36),`Friend`(36)),
11 KEY(`PrincipalID`) 11 KEY `PrincipalID` (`PrincipalID`)
12) ENGINE=MyISAM; 12) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13
14COMMIT;
15
16:VERSION 2 # -------------------------
17
18BEGIN;
19
20INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`;
21
22COMMIT;
23
24:VERSION 3 # -------------------------
25
26BEGIN;
27
28ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
29ALTER TABLE `Friends` DROP PRIMARY KEY;
30ALTER TABLE `Friends` ADD PRIMARY KEY(PrincipalID(36), Friend(36));
31 13
32COMMIT; 14COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations
index 52ced24..e4c8fc3 100644
--- a/OpenSim/Data/MySQL/Resources/GridStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations
@@ -1,109 +1,52 @@
1:VERSION 1 1:VERSION 10
2 2
3BEGIN; 3BEGIN;
4 4
5CREATE TABLE `regions` ( 5CREATE TABLE IF NOT EXISTS `regions` (
6 `uuid` varchar(36) NOT NULL, 6 `uuid` varchar(36) NOT NULL,
7 `regionHandle` bigint(20) unsigned NOT NULL, 7 `regionHandle` bigint(20) unsigned NOT NULL,
8 `regionName` varchar(32) default NULL, 8 `regionName` varchar(128) DEFAULT NULL,
9 `regionRecvKey` varchar(128) default NULL, 9 `regionRecvKey` varchar(128) DEFAULT NULL,
10 `regionSendKey` varchar(128) default NULL, 10 `regionSendKey` varchar(128) DEFAULT NULL,
11 `regionSecret` varchar(128) default NULL, 11 `regionSecret` varchar(128) DEFAULT NULL,
12 `regionDataURI` varchar(255) default NULL, 12 `regionDataURI` varchar(255) DEFAULT NULL,
13 `serverIP` varchar(64) default NULL, 13 `serverIP` varchar(64) DEFAULT NULL,
14 `serverPort` int(10) unsigned default NULL, 14 `serverPort` int(10) unsigned DEFAULT NULL,
15 `serverURI` varchar(255) default NULL, 15 `serverURI` varchar(255) DEFAULT NULL,
16 `locX` int(10) unsigned default NULL, 16 `locX` int(10) unsigned DEFAULT NULL,
17 `locY` int(10) unsigned default NULL, 17 `locY` int(10) unsigned DEFAULT NULL,
18 `locZ` int(10) unsigned default NULL, 18 `locZ` int(10) unsigned DEFAULT NULL,
19 `eastOverrideHandle` bigint(20) unsigned default NULL, 19 `eastOverrideHandle` bigint(20) unsigned DEFAULT NULL,
20 `westOverrideHandle` bigint(20) unsigned default NULL, 20 `westOverrideHandle` bigint(20) unsigned DEFAULT NULL,
21 `southOverrideHandle` bigint(20) unsigned default NULL, 21 `southOverrideHandle` bigint(20) unsigned DEFAULT NULL,
22 `northOverrideHandle` bigint(20) unsigned default NULL, 22 `northOverrideHandle` bigint(20) unsigned DEFAULT NULL,
23 `regionAssetURI` varchar(255) default NULL, 23 `regionAssetURI` varchar(255) DEFAULT NULL,
24 `regionAssetRecvKey` varchar(128) default NULL, 24 `regionAssetRecvKey` varchar(128) DEFAULT NULL,
25 `regionAssetSendKey` varchar(128) default NULL, 25 `regionAssetSendKey` varchar(128) DEFAULT NULL,
26 `regionUserURI` varchar(255) default NULL, 26 `regionUserURI` varchar(255) DEFAULT NULL,
27 `regionUserRecvKey` varchar(128) default NULL, 27 `regionUserRecvKey` varchar(128) DEFAULT NULL,
28 `regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL, 28 `regionUserSendKey` varchar(128) DEFAULT NULL,
29 `serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL, 29 `regionMapTexture` varchar(36) DEFAULT NULL,
30 `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, 30 `serverHttpPort` int(10) DEFAULT NULL,
31 `originUUID` varchar(36), 31 `serverRemotingPort` int(10) DEFAULT NULL,
32 PRIMARY KEY (`uuid`), 32 `owner_uuid` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
33 `originUUID` varchar(36) DEFAULT NULL,
34 `access` int(10) unsigned DEFAULT '1',
35 `ScopeID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
36 `sizeX` int(11) NOT NULL DEFAULT '0',
37 `sizeY` int(11) NOT NULL DEFAULT '0',
38 `flags` int(11) NOT NULL DEFAULT '0',
39 `last_seen` int(11) NOT NULL DEFAULT '0',
40 `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
41 `Token` varchar(255) NOT NULL,
42 `parcelMapTexture` varchar(36) DEFAULT NULL,
43 PRIMARY KEY (`uuid`),
33 KEY `regionName` (`regionName`), 44 KEY `regionName` (`regionName`),
34 KEY `regionHandle` (`regionHandle`), 45 KEY `regionHandle` (`regionHandle`),
35 KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) 46 KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`),
36) ENGINE=MyISAM DEFAULT CHARSET=utf8; 47 KEY `ScopeID` (`ScopeID`),
37 48 KEY `flags` (`flags`)
38COMMIT; 49) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39
40:VERSION 2
41
42BEGIN;
43
44ALTER TABLE regions add column access integer unsigned default 1;
45
46COMMIT;
47
48:VERSION 3
49
50BEGIN;
51
52ALTER TABLE regions add column ScopeID char(36) not null default '00000000-0000-0000-0000-000000000000';
53
54create index ScopeID on regions(ScopeID);
55
56COMMIT;
57
58:VERSION 4
59
60BEGIN;
61
62ALTER TABLE regions add column sizeX integer not null default 0;
63ALTER TABLE regions add column sizeY integer not null default 0;
64
65COMMIT;
66
67:VERSION 5
68
69BEGIN;
70
71ALTER TABLE `regions` ADD COLUMN `flags` integer NOT NULL DEFAULT 0;
72CREATE INDEX flags ON regions(flags);
73
74COMMIT;
75
76:VERSION 6
77
78BEGIN;
79
80ALTER TABLE `regions` ADD COLUMN `last_seen` integer NOT NULL DEFAULT 0;
81
82COMMIT;
83
84:VERSION 7
85
86BEGIN;
87
88ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
89ALTER TABLE `regions` ADD COLUMN `Token` varchar(255) NOT NULL;
90
91COMMIT;
92
93
94:VERSION 8 # ------------
95
96BEGIN;
97
98alter table regions modify column regionName varchar(128) default NULL;
99
100COMMIT;
101
102:VERSION 9 # ------------
103
104BEGIN;
105
106alter table regions add column `parcelMapTexture` varchar(36) default NULL;
107 50
108COMMIT; 51COMMIT;
109 52
diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations
index e2be27e..d08e096 100644
--- a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations
@@ -14,7 +14,7 @@ CREATE TABLE `GridUser` (
14 `Login` CHAR(16) NOT NULL DEFAULT '0', 14 `Login` CHAR(16) NOT NULL DEFAULT '0',
15 `Logout` CHAR(16) NOT NULL DEFAULT '0', 15 `Logout` CHAR(16) NOT NULL DEFAULT '0',
16 PRIMARY KEY (`UserID`) 16 PRIMARY KEY (`UserID`)
17) ENGINE=MyISAM; 17) ENGINE=InnoDB;
18 18
19COMMIT; 19COMMIT;
20 20
diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
index 06ca29d..b4e4422 100644
--- a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
@@ -12,7 +12,7 @@ CREATE TABLE `hg_traveling_data` (
12 `TMStamp` timestamp NOT NULL, 12 `TMStamp` timestamp NOT NULL,
13 PRIMARY KEY (`SessionID`), 13 PRIMARY KEY (`SessionID`),
14 KEY (`UserID`) 14 KEY (`UserID`)
15) ENGINE=MyISAM; 15) ENGINE=InnoDB;
16 16
17COMMIT; 17COMMIT;
18 18
diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations
index 79ead98..4f14826 100644
--- a/OpenSim/Data/MySQL/Resources/IM_Store.migrations
+++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations
@@ -1,42 +1,16 @@
1:VERSION 1 # -------------------------- 1:VERSION 5 # --------------------------
2 2
3BEGIN; 3BEGIN;
4 4
5CREATE TABLE `im_offline` ( 5CREATE TABLE IF NOT EXISTS `im_offline` (
6 `ID` MEDIUMINT NOT NULL AUTO_INCREMENT, 6 `ID` mediumint(9) NOT NULL AUTO_INCREMENT,
7 `PrincipalID` char(36) NOT NULL default '', 7 `PrincipalID` char(36) NOT NULL DEFAULT '',
8 `FromID` char(36) NOT NULL DEFAULT '',
8 `Message` text NOT NULL, 9 `Message` text NOT NULL,
9 `TMStamp` timestamp NOT NULL, 10 `TMStamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10 PRIMARY KEY (`ID`), 11 PRIMARY KEY (`ID`),
11 KEY `PrincipalID` (`PrincipalID`) 12 KEY `PrincipalID` (`PrincipalID`),
12) ENGINE=MyISAM; 13 KEY `FromID` (`FromID`)
13 14) ENGINE=InnoDB DEFAULT CHARSET=utf8;
14COMMIT;
15
16:VERSION 2 # --------------------------
17
18BEGIN;
19
20INSERT INTO `im_offline` SELECT * from `diva_im_offline`;
21DROP TABLE `diva_im_offline`;
22DELETE FROM `migrations` WHERE name='diva_im_Store';
23
24COMMIT;
25
26:VERSION 3 # --------------------------
27
28BEGIN;
29
30ALTER TABLE `im_offline`
31 ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`,
32 ADD KEY `FromID` (`FromID`);
33
34COMMIT;
35
36:VERSION 4 # --------------------------
37
38BEGIN;
39
40ALTER TABLE im_offline CONVERT TO CHARACTER SET utf8;
41 15
42COMMIT; 16COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations
index ca2fe11..2d4384c 100644
--- a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations
@@ -1,109 +1,42 @@
1:VERSION 1 # ------------ 1:VERSION 7 # ------------
2BEGIN; 2BEGIN;
3 3
4CREATE TABLE `inventoryfolders` ( 4CREATE TABLE IF NOT EXISTS `inventoryitems` (
5 `folderID` varchar(36) NOT NULL default '', 5 `assetID` varchar(36) DEFAULT NULL,
6 `agentID` varchar(36) default NULL, 6 `assetType` int(11) DEFAULT NULL,
7 `parentFolderID` varchar(36) default NULL, 7 `inventoryName` varchar(64) DEFAULT NULL,
8 `folderName` varchar(64) default NULL, 8 `inventoryDescription` varchar(128) DEFAULT NULL,
9 `type` smallint NOT NULL default 0, 9 `inventoryNextPermissions` int(10) unsigned DEFAULT NULL,
10 `version` int NOT NULL default 0, 10 `inventoryCurrentPermissions` int(10) unsigned DEFAULT NULL,
11 PRIMARY KEY (`folderID`), 11 `invType` int(11) DEFAULT NULL,
12 KEY `owner` (`agentID`), 12 `creatorID` varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
13 KEY `parent` (`parentFolderID`) 13 `inventoryBasePermissions` int(10) unsigned NOT NULL DEFAULT '0',
14) ENGINE=MyISAM DEFAULT CHARSET=utf8; 14 `inventoryEveryOnePermissions` int(10) unsigned NOT NULL DEFAULT '0',
15 15 `salePrice` int(11) NOT NULL DEFAULT '0',
16CREATE TABLE `inventoryitems` ( 16 `saleType` tinyint(4) NOT NULL DEFAULT '0',
17 `inventoryID` varchar(36) NOT NULL default '', 17 `creationDate` int(11) NOT NULL DEFAULT '0',
18 `assetID` varchar(36) default NULL, 18 `groupID` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
19 `assetType` int(11) default NULL, 19 `groupOwned` tinyint(4) NOT NULL DEFAULT '0',
20 `parentFolderID` varchar(36) default NULL, 20 `flags` int(11) unsigned NOT NULL DEFAULT '0',
21 `avatarID` varchar(36) default NULL, 21 `inventoryID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
22 `inventoryName` varchar(64) default NULL, 22 `avatarID` char(36) DEFAULT NULL,
23 `inventoryDescription` varchar(128) default NULL, 23 `parentFolderID` char(36) DEFAULT NULL,
24 `inventoryNextPermissions` int(10) unsigned default NULL, 24 `inventoryGroupPermissions` int(10) unsigned NOT NULL DEFAULT '0',
25 `inventoryCurrentPermissions` int(10) unsigned default NULL, 25 PRIMARY KEY (`inventoryID`),
26 `invType` int(11) default NULL, 26 KEY `inventoryitems_avatarid` (`avatarID`),
27 `creatorID` varchar(36) default NULL, 27 KEY `inventoryitems_parentFolderid` (`parentFolderID`)
28 `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, 28) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29 `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, 29
30 `salePrice` int(11) NOT NULL default 0, 30CREATE TABLE IF NOT EXISTS `inventoryfolders` (
31 `saleType` tinyint(4) NOT NULL default 0, 31 `folderName` varchar(64) DEFAULT NULL,
32 `creationDate` int(11) NOT NULL default 0, 32 `type` smallint(6) NOT NULL DEFAULT '0',
33 `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', 33 `version` int(11) NOT NULL DEFAULT '0',
34 `groupOwned` tinyint(4) NOT NULL default 0, 34 `folderID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
35 `flags` int(11) unsigned NOT NULL default 0, 35 `agentID` char(36) DEFAULT NULL,
36 PRIMARY KEY (`inventoryID`), 36 `parentFolderID` char(36) DEFAULT NULL,
37 KEY `owner` (`avatarID`), 37 PRIMARY KEY (`folderID`),
38 KEY `folder` (`parentFolderID`) 38 KEY `inventoryfolders_agentid` (`agentID`),
39) ENGINE=MyISAM DEFAULT CHARSET=utf8; 39 KEY `inventoryfolders_parentFolderid` (`parentFolderID`)
40 40) ENGINE=InnoDB DEFAULT CHARSET=utf8;
41COMMIT;
42
43:VERSION 2 # ------------
44
45BEGIN;
46
47ALTER TABLE inventoryfolders change folderID folderIDold varchar(36);
48ALTER TABLE inventoryfolders change agentID agentIDold varchar(36);
49ALTER TABLE inventoryfolders change parentFolderID parentFolderIDold varchar(36);
50ALTER TABLE inventoryfolders add folderID char(36) not null default '00000000-0000-0000-0000-000000000000';
51ALTER TABLE inventoryfolders add agentID char(36) default NULL;
52ALTER TABLE inventoryfolders add parentFolderID char(36) default NULL;
53UPDATE inventoryfolders set folderID = folderIDold, agentID = agentIDold, parentFolderID = parentFolderIDold;
54ALTER TABLE inventoryfolders drop folderIDold;
55ALTER TABLE inventoryfolders drop agentIDold;
56ALTER TABLE inventoryfolders drop parentFolderIDold;
57ALTER TABLE inventoryfolders add constraint primary key(folderID);
58ALTER TABLE inventoryfolders add index inventoryfolders_agentid(agentID);
59ALTER TABLE inventoryfolders add index inventoryfolders_parentFolderid(parentFolderID);
60
61ALTER TABLE inventoryitems change inventoryID inventoryIDold varchar(36);
62ALTER TABLE inventoryitems change avatarID avatarIDold varchar(36);
63ALTER TABLE inventoryitems change parentFolderID parentFolderIDold varchar(36);
64ALTER TABLE inventoryitems add inventoryID char(36) not null default '00000000-0000-0000-0000-000000000000';
65ALTER TABLE inventoryitems add avatarID char(36) default NULL;
66ALTER TABLE inventoryitems add parentFolderID char(36) default NULL;
67UPDATE inventoryitems set inventoryID = inventoryIDold, avatarID = avatarIDold, parentFolderID = parentFolderIDold;
68ALTER TABLE inventoryitems drop inventoryIDold;
69ALTER TABLE inventoryitems drop avatarIDold;
70ALTER TABLE inventoryitems drop parentFolderIDold;
71ALTER TABLE inventoryitems add constraint primary key(inventoryID);
72ALTER TABLE inventoryitems add index inventoryitems_avatarid(avatarID);
73ALTER TABLE inventoryitems add index inventoryitems_parentFolderid(parentFolderID);
74
75COMMIT;
76
77:VERSION 3 # ------------
78
79BEGIN;
80
81alter table inventoryitems add column inventoryGroupPermissions integer unsigned not null default 0;
82
83COMMIT;
84
85:VERSION 4 # ------------
86
87BEGIN;
88
89update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID is NULL;
90update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID = '';
91alter table inventoryitems modify column creatorID varchar(36) not NULL default '00000000-0000-0000-0000-000000000000';
92
93COMMIT;
94
95:VERSION 5 # ------------
96
97BEGIN;
98
99alter table inventoryitems modify column creatorID varchar(128) not NULL default '00000000-0000-0000-0000-000000000000';
100
101COMMIT;
102
103:VERSION 6 # ------------
104
105BEGIN;
106
107alter table inventoryitems modify column creatorID varchar(255) not NULL default '00000000-0000-0000-0000-000000000000';
108 41
109COMMIT; 42COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/LogStore.migrations b/OpenSim/Data/MySQL/Resources/LogStore.migrations
index b572411..9ac26ac 100644
--- a/OpenSim/Data/MySQL/Resources/LogStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/LogStore.migrations
@@ -10,4 +10,4 @@ CREATE TABLE `logs` (
10 `priority` int(11) default NULL, 10 `priority` int(11) default NULL,
11 `message` text, 11 `message` text,
12 PRIMARY KEY (`logID`) 12 PRIMARY KEY (`logID`)
13) ENGINE=MyISAM DEFAULT CHARSET=utf8; 13) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/OpenSim/Data/MySQL/Resources/MuteListStore.migrations b/OpenSim/Data/MySQL/Resources/MuteListStore.migrations
new file mode 100644
index 0000000..5bde63e
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/MuteListStore.migrations
@@ -0,0 +1,16 @@
1:VERSION 1
2
3BEGIN;
4
5CREATE TABLE `MuteList` (
6 `AgentID` char(36) NOT NULL,
7 `MuteID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
8 `MuteName` varchar(64) NOT NULL DEFAULT '',
9 `MuteType` int(11) NOT NULL DEFAULT '1',
10 `MuteFlags` int(11) NOT NULL DEFAULT '0',
11 `Stamp` int(11) NOT NULL,
12 UNIQUE KEY `AgentID_2` (`AgentID`,`MuteID`,`MuteName`),
13 KEY `AgentID` (`AgentID`)
14);
15
16COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations
index 6dc9384..50aa756 100644
--- a/OpenSim/Data/MySQL/Resources/Presence.migrations
+++ b/OpenSim/Data/MySQL/Resources/Presence.migrations
@@ -1,31 +1,16 @@
1:VERSION 1 # -------------------------- 1:VERSION 4 # --------------------------
2 2
3BEGIN; 3BEGIN;
4 4
5CREATE TABLE `Presence` ( 5CREATE TABLE IF NOT EXISTS `Presence` (
6 `UserID` VARCHAR(255) NOT NULL, 6 `UserID` varchar(255) NOT NULL,
7 `RegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', 7 `RegionID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
8 `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', 8 `SessionID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
9 `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' 9 `SecureSessionID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
10) ENGINE=MyISAM; 10 `LastSeen` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
11 11 UNIQUE KEY `SessionID` (`SessionID`),
12CREATE UNIQUE INDEX SessionID ON Presence(SessionID); 12 KEY `UserID` (`UserID`),
13CREATE INDEX UserID ON Presence(UserID); 13 KEY `RegionID` (`RegionID`)
14 14) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15COMMIT;
16
17:VERSION 2 # --------------------------
18
19BEGIN;
20
21ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp;
22
23COMMIT;
24
25:VERSION 3 # --------------------------
26
27BEGIN;
28
29CREATE INDEX RegionID ON Presence(RegionID);
30 15
31COMMIT; 16COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index 834d249..0577392 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -1,354 +1,226 @@
1 1
2:VERSION 1 #--------------------- 2:VERSION 51 #---------------------
3 3
4BEGIN; 4BEGIN;
5 5
6CREATE TABLE `prims` ( 6CREATE TABLE IF NOT EXISTS `prims` (
7 `UUID` varchar(255) NOT NULL, 7 `CreationDate` int(11) DEFAULT NULL,
8 `RegionUUID` varchar(255) default NULL, 8 `Name` varchar(255) DEFAULT NULL,
9 `ParentID` int(11) default NULL, 9 `Text` varchar(255) DEFAULT NULL,
10 `CreationDate` int(11) default NULL, 10 `Description` varchar(255) DEFAULT NULL,
11 `Name` varchar(255) default NULL, 11 `SitName` varchar(255) DEFAULT NULL,
12 `SceneGroupID` varchar(255) default NULL, 12 `TouchName` varchar(255) DEFAULT NULL,
13 `Text` varchar(255) default NULL, 13 `ObjectFlags` int(11) DEFAULT NULL,
14 `Description` varchar(255) default NULL, 14 `OwnerMask` int(11) DEFAULT NULL,
15 `SitName` varchar(255) default NULL, 15 `NextOwnerMask` int(11) DEFAULT NULL,
16 `TouchName` varchar(255) default NULL, 16 `GroupMask` int(11) DEFAULT NULL,
17 `ObjectFlags` int(11) default NULL, 17 `EveryoneMask` int(11) DEFAULT NULL,
18 `CreatorID` varchar(255) default NULL, 18 `BaseMask` int(11) DEFAULT NULL,
19 `OwnerID` varchar(255) default NULL, 19 `PositionX` double DEFAULT NULL,
20 `GroupID` varchar(255) default NULL, 20 `PositionY` double DEFAULT NULL,
21 `LastOwnerID` varchar(255) default NULL, 21 `PositionZ` double DEFAULT NULL,
22 `OwnerMask` int(11) default NULL, 22 `GroupPositionX` double DEFAULT NULL,
23 `NextOwnerMask` int(11) default NULL, 23 `GroupPositionY` double DEFAULT NULL,
24 `GroupMask` int(11) default NULL, 24 `GroupPositionZ` double DEFAULT NULL,
25 `EveryoneMask` int(11) default NULL, 25 `VelocityX` double DEFAULT NULL,
26 `BaseMask` int(11) default NULL, 26 `VelocityY` double DEFAULT NULL,
27 `PositionX` float default NULL, 27 `VelocityZ` double DEFAULT NULL,
28 `PositionY` float default NULL, 28 `AngularVelocityX` double DEFAULT NULL,
29 `PositionZ` float default NULL, 29 `AngularVelocityY` double DEFAULT NULL,
30 `GroupPositionX` float default NULL, 30 `AngularVelocityZ` double DEFAULT NULL,
31 `GroupPositionY` float default NULL, 31 `AccelerationX` double DEFAULT NULL,
32 `GroupPositionZ` float default NULL, 32 `AccelerationY` double DEFAULT NULL,
33 `VelocityX` float default NULL, 33 `AccelerationZ` double DEFAULT NULL,
34 `VelocityY` float default NULL, 34 `RotationX` double DEFAULT NULL,
35 `VelocityZ` float default NULL, 35 `RotationY` double DEFAULT NULL,
36 `AngularVelocityX` float default NULL, 36 `RotationZ` double DEFAULT NULL,
37 `AngularVelocityY` float default NULL, 37 `RotationW` double DEFAULT NULL,
38 `AngularVelocityZ` float default NULL, 38 `SitTargetOffsetX` double DEFAULT NULL,
39 `AccelerationX` float default NULL, 39 `SitTargetOffsetY` double DEFAULT NULL,
40 `AccelerationY` float default NULL, 40 `SitTargetOffsetZ` double DEFAULT NULL,
41 `AccelerationZ` float default NULL, 41 `SitTargetOrientW` double DEFAULT NULL,
42 `RotationX` float default NULL, 42 `SitTargetOrientX` double DEFAULT NULL,
43 `RotationY` float default NULL, 43 `SitTargetOrientY` double DEFAULT NULL,
44 `RotationZ` float default NULL, 44 `SitTargetOrientZ` double DEFAULT NULL,
45 `RotationW` float default NULL, 45 `UUID` char(36) NOT NULL DEFAULT '',
46 `SitTargetOffsetX` float default NULL, 46 `RegionUUID` char(36) DEFAULT NULL,
47 `SitTargetOffsetY` float default NULL, 47 `CreatorID` varchar(255) NOT NULL DEFAULT '',
48 `SitTargetOffsetZ` float default NULL, 48 `OwnerID` char(36) DEFAULT NULL,
49 `SitTargetOrientW` float default NULL, 49 `GroupID` char(36) DEFAULT NULL,
50 `SitTargetOrientX` float default NULL, 50 `LastOwnerID` char(36) DEFAULT NULL,
51 `SitTargetOrientY` float default NULL, 51 `SceneGroupID` char(36) DEFAULT NULL,
52 `SitTargetOrientZ` float default NULL, 52 `PayPrice` int(11) NOT NULL DEFAULT '0',
53 PRIMARY KEY (`UUID`) 53 `PayButton1` int(11) NOT NULL DEFAULT '0',
54) ENGINE=MyISAM DEFAULT CHARSET=latin1; 54 `PayButton2` int(11) NOT NULL DEFAULT '0',
55 55 `PayButton3` int(11) NOT NULL DEFAULT '0',
56CREATE TABLE `primshapes` ( 56 `PayButton4` int(11) NOT NULL DEFAULT '0',
57 `UUID` varchar(255) NOT NULL, 57 `LoopedSound` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
58 `Shape` int(11) default NULL, 58 `LoopedSoundGain` double NOT NULL DEFAULT '0',
59 `ScaleX` float default NULL, 59 `TextureAnimation` blob,
60 `ScaleY` float default NULL, 60 `OmegaX` double NOT NULL DEFAULT '0',
61 `ScaleZ` float default NULL, 61 `OmegaY` double NOT NULL DEFAULT '0',
62 `PCode` int(11) default NULL, 62 `OmegaZ` double NOT NULL DEFAULT '0',
63 `PathBegin` int(11) default NULL, 63 `CameraEyeOffsetX` double NOT NULL DEFAULT '0',
64 `PathEnd` int(11) default NULL, 64 `CameraEyeOffsetY` double NOT NULL DEFAULT '0',
65 `PathScaleX` int(11) default NULL, 65 `CameraEyeOffsetZ` double NOT NULL DEFAULT '0',
66 `PathScaleY` int(11) default NULL, 66 `CameraAtOffsetX` double NOT NULL DEFAULT '0',
67 `PathShearX` int(11) default NULL, 67 `CameraAtOffsetY` double NOT NULL DEFAULT '0',
68 `PathShearY` int(11) default NULL, 68 `CameraAtOffsetZ` double NOT NULL DEFAULT '0',
69 `PathSkew` int(11) default NULL, 69 `ForceMouselook` tinyint(4) NOT NULL DEFAULT '0',
70 `PathCurve` int(11) default NULL, 70 `ScriptAccessPin` int(11) NOT NULL DEFAULT '0',
71 `PathRadiusOffset` int(11) default NULL, 71 `AllowedDrop` tinyint(4) NOT NULL DEFAULT '0',
72 `PathRevolutions` int(11) default NULL, 72 `DieAtEdge` tinyint(4) NOT NULL DEFAULT '0',
73 `PathTaperX` int(11) default NULL, 73 `SalePrice` int(11) NOT NULL DEFAULT '10',
74 `PathTaperY` int(11) default NULL, 74 `SaleType` tinyint(4) NOT NULL DEFAULT '0',
75 `PathTwist` int(11) default NULL, 75 `ColorR` int(11) NOT NULL DEFAULT '0',
76 `PathTwistBegin` int(11) default NULL, 76 `ColorG` int(11) NOT NULL DEFAULT '0',
77 `ProfileBegin` int(11) default NULL, 77 `ColorB` int(11) NOT NULL DEFAULT '0',
78 `ProfileEnd` int(11) default NULL, 78 `ColorA` int(11) NOT NULL DEFAULT '0',
79 `ProfileCurve` int(11) default NULL, 79 `ParticleSystem` blob,
80 `ProfileHollow` int(11) default NULL, 80 `ClickAction` tinyint(4) NOT NULL DEFAULT '0',
81 `State` int(11) default NULL, 81 `Material` tinyint(4) NOT NULL DEFAULT '3',
82 `CollisionSound` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
83 `CollisionSoundVolume` double NOT NULL DEFAULT '0',
84 `LinkNumber` int(11) NOT NULL DEFAULT '0',
85 `PassTouches` tinyint(4) NOT NULL DEFAULT '0',
86 `MediaURL` varchar(255) DEFAULT NULL,
87 `DynAttrs` text,
88 `PhysicsShapeType` tinyint(4) NOT NULL DEFAULT '0',
89 `Density` double NOT NULL DEFAULT '1000',
90 `GravityModifier` double NOT NULL DEFAULT '1',
91 `Friction` double NOT NULL DEFAULT '0.6',
92 `Restitution` double NOT NULL DEFAULT '0.5',
93 `KeyframeMotion` blob,
94 `AttachedPosX` double DEFAULT '0',
95 `AttachedPosY` double DEFAULT '0',
96 `AttachedPosZ` double DEFAULT '0',
97 PRIMARY KEY (`UUID`),
98 KEY `prims_regionuuid` (`RegionUUID`),
99 KEY `prims_scenegroupid` (`SceneGroupID`)
100) ENGINE=InnoDB DEFAULT CHARSET=latin1;
101
102CREATE TABLE IF NOT EXISTS `primshapes` (
103 `Shape` int(11) DEFAULT NULL,
104 `ScaleX` double NOT NULL DEFAULT '0',
105 `ScaleY` double NOT NULL DEFAULT '0',
106 `ScaleZ` double NOT NULL DEFAULT '0',
107 `PCode` int(11) DEFAULT NULL,
108 `PathBegin` int(11) DEFAULT NULL,
109 `PathEnd` int(11) DEFAULT NULL,
110 `PathScaleX` int(11) DEFAULT NULL,
111 `PathScaleY` int(11) DEFAULT NULL,
112 `PathShearX` int(11) DEFAULT NULL,
113 `PathShearY` int(11) DEFAULT NULL,
114 `PathSkew` int(11) DEFAULT NULL,
115 `PathCurve` int(11) DEFAULT NULL,
116 `PathRadiusOffset` int(11) DEFAULT NULL,
117 `PathRevolutions` int(11) DEFAULT NULL,
118 `PathTaperX` int(11) DEFAULT NULL,
119 `PathTaperY` int(11) DEFAULT NULL,
120 `PathTwist` int(11) DEFAULT NULL,
121 `PathTwistBegin` int(11) DEFAULT NULL,
122 `ProfileBegin` int(11) DEFAULT NULL,
123 `ProfileEnd` int(11) DEFAULT NULL,
124 `ProfileCurve` int(11) DEFAULT NULL,
125 `ProfileHollow` int(11) DEFAULT NULL,
126 `State` int(11) DEFAULT NULL,
82 `Texture` longblob, 127 `Texture` longblob,
83 `ExtraParams` longblob, 128 `ExtraParams` longblob,
84 PRIMARY KEY (`UUID`) 129 `UUID` char(36) NOT NULL DEFAULT '',
85) ENGINE=MyISAM DEFAULT CHARSET=latin1; 130 `Media` text,
86 131 `LastAttachPoint` int(4) NOT NULL DEFAULT '0',
87CREATE TABLE `primitems` ( 132 PRIMARY KEY (`UUID`)
88 `itemID` varchar(255) NOT NULL, 133) ENGINE=InnoDB DEFAULT CHARSET=latin1;
89 `primID` varchar(255) default NULL, 134
90 `assetID` varchar(255) default NULL, 135CREATE TABLE IF NOT EXISTS `primitems` (
91 `parentFolderID` varchar(255) default NULL, 136 `invType` int(11) DEFAULT NULL,
92 `invType` int(11) default NULL, 137 `assetType` int(11) DEFAULT NULL,
93 `assetType` int(11) default NULL, 138 `name` varchar(255) DEFAULT NULL,
94 `name` varchar(255) default NULL, 139 `description` varchar(255) DEFAULT NULL,
95 `description` varchar(255) default NULL, 140 `creationDate` bigint(20) DEFAULT NULL,
96 `creationDate` bigint(20) default NULL, 141 `nextPermissions` int(11) DEFAULT NULL,
97 `creatorID` varchar(255) default NULL, 142 `currentPermissions` int(11) DEFAULT NULL,
98 `ownerID` varchar(255) default NULL, 143 `basePermissions` int(11) DEFAULT NULL,
99 `lastOwnerID` varchar(255) default NULL, 144 `everyonePermissions` int(11) DEFAULT NULL,
100 `groupID` varchar(255) default NULL, 145 `groupPermissions` int(11) DEFAULT NULL,
101 `nextPermissions` int(11) default NULL, 146 `flags` int(11) NOT NULL DEFAULT '0',
102 `currentPermissions` int(11) default NULL, 147 `itemID` char(36) NOT NULL DEFAULT '',
103 `basePermissions` int(11) default NULL, 148 `primID` char(36) DEFAULT NULL,
104 `everyonePermissions` int(11) default NULL, 149 `assetID` char(36) DEFAULT NULL,
105 `groupPermissions` int(11) default NULL, 150 `parentFolderID` char(36) DEFAULT NULL,
106 PRIMARY KEY (`itemID`) 151 `CreatorID` varchar(255) NOT NULL DEFAULT '',
107) ENGINE=MyISAM DEFAULT CHARSET=latin1; 152 `ownerID` char(36) DEFAULT NULL,
108 153 `groupID` char(36) DEFAULT NULL,
109CREATE TABLE `terrain` ( 154 `lastOwnerID` char(36) DEFAULT NULL,
110 `RegionUUID` varchar(255) default NULL, 155 PRIMARY KEY (`itemID`),
111 `Revision` int(11) default NULL, 156 KEY `primitems_primid` (`primID`)
157) ENGINE=InnoDB DEFAULT CHARSET=latin1;
158
159CREATE TABLE IF NOT EXISTS `terrain` (
160 `RegionUUID` varchar(255) DEFAULT NULL,
161 `Revision` int(11) DEFAULT NULL,
112 `Heightfield` longblob 162 `Heightfield` longblob
113) ENGINE=MyISAM DEFAULT CHARSET=latin1; 163) ENGINE=InnoDB DEFAULT CHARSET=latin1;
114 164
115CREATE TABLE `land` ( 165CREATE TABLE IF NOT EXISTS `land` (
116 `UUID` varchar(255) NOT NULL, 166 `UUID` varchar(255) NOT NULL,
117 `RegionUUID` varchar(255) default NULL, 167 `RegionUUID` varchar(255) DEFAULT NULL,
118 `LocalLandID` int(11) default NULL, 168 `LocalLandID` int(11) DEFAULT NULL,
119 `Bitmap` longblob, 169 `Bitmap` longblob,
120 `Name` varchar(255) default NULL, 170 `Name` varchar(255) DEFAULT NULL,
121 `Description` varchar(255) default NULL, 171 `Description` varchar(255) DEFAULT NULL,
122 `OwnerUUID` varchar(255) default NULL, 172 `OwnerUUID` varchar(255) DEFAULT NULL,
123 `IsGroupOwned` int(11) default NULL, 173 `IsGroupOwned` int(11) DEFAULT NULL,
124 `Area` int(11) default NULL, 174 `Area` int(11) DEFAULT NULL,
125 `AuctionID` int(11) default NULL, 175 `AuctionID` int(11) DEFAULT NULL,
126 `Category` int(11) default NULL, 176 `Category` int(11) DEFAULT NULL,
127 `ClaimDate` int(11) default NULL, 177 `ClaimDate` int(11) DEFAULT NULL,
128 `ClaimPrice` int(11) default NULL, 178 `ClaimPrice` int(11) DEFAULT NULL,
129 `GroupUUID` varchar(255) default NULL, 179 `GroupUUID` varchar(255) DEFAULT NULL,
130 `SalePrice` int(11) default NULL, 180 `SalePrice` int(11) DEFAULT NULL,
131 `LandStatus` int(11) default NULL, 181 `LandStatus` int(11) DEFAULT NULL,
132 `LandFlags` int(11) default NULL, 182 `LandFlags` int(10) unsigned DEFAULT NULL,
133 `LandingType` int(11) default NULL, 183 `LandingType` int(11) DEFAULT NULL,
134 `MediaAutoScale` int(11) default NULL, 184 `MediaAutoScale` int(11) DEFAULT NULL,
135 `MediaTextureUUID` varchar(255) default NULL, 185 `MediaTextureUUID` varchar(255) DEFAULT NULL,
136 `MediaURL` varchar(255) default NULL, 186 `MediaURL` varchar(255) DEFAULT NULL,
137 `MusicURL` varchar(255) default NULL, 187 `MusicURL` varchar(255) DEFAULT NULL,
138 `PassHours` float default NULL, 188 `PassHours` float DEFAULT NULL,
139 `PassPrice` int(11) default NULL, 189 `PassPrice` int(11) DEFAULT NULL,
140 `SnapshotUUID` varchar(255) default NULL, 190 `SnapshotUUID` varchar(255) DEFAULT NULL,
141 `UserLocationX` float default NULL, 191 `UserLocationX` float DEFAULT NULL,
142 `UserLocationY` float default NULL, 192 `UserLocationY` float DEFAULT NULL,
143 `UserLocationZ` float default NULL, 193 `UserLocationZ` float DEFAULT NULL,
144 `UserLookAtX` float default NULL, 194 `UserLookAtX` float DEFAULT NULL,
145 `UserLookAtY` float default NULL, 195 `UserLookAtY` float DEFAULT NULL,
146 `UserLookAtZ` float default NULL, 196 `UserLookAtZ` float DEFAULT NULL,
147 `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', 197 `AuthbuyerID` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
148 PRIMARY KEY (`UUID`) 198 `OtherCleanTime` int(11) NOT NULL DEFAULT '0',
149) ENGINE=MyISAM DEFAULT CHARSET=utf8; 199 `Dwell` int(11) NOT NULL DEFAULT '0',
150 200 `MediaType` varchar(32) NOT NULL DEFAULT 'none/none',
151CREATE TABLE `landaccesslist` ( 201 `MediaDescription` varchar(255) NOT NULL DEFAULT '',
152 `LandUUID` varchar(255) default NULL, 202 `MediaSize` varchar(16) NOT NULL DEFAULT '0,0',
153 `AccessUUID` varchar(255) default NULL, 203 `MediaLoop` tinyint(1) NOT NULL DEFAULT '0',
154 `Flags` int(11) default NULL 204 `ObscureMusic` tinyint(1) NOT NULL DEFAULT '0',
155) ENGINE=MyISAM DEFAULT CHARSET=latin1; 205 `ObscureMedia` tinyint(1) NOT NULL DEFAULT '0',
156 206 PRIMARY KEY (`UUID`)
157COMMIT; 207) ENGINE=InnoDB DEFAULT CHARSET=utf8;
158 208
159:VERSION 2 #--------------------- 209CREATE TABLE IF NOT EXISTS `landaccesslist` (
160 210 `LandUUID` varchar(255) DEFAULT NULL,
161BEGIN; 211 `AccessUUID` varchar(255) DEFAULT NULL,
162 212 `Flags` int(11) DEFAULT NULL,
163CREATE index prims_regionuuid on prims(RegionUUID); 213 `Expires` int(11) NOT NULL DEFAULT '0'
164CREATE index primitems_primid on primitems(primID); 214) ENGINE=InnoDB DEFAULT CHARSET=latin1;
165 215
166COMMIT; 216CREATE TABLE IF NOT EXISTS `regionban` (
167 217 `regionUUID` varchar(36) NOT NULL,
168:VERSION 3 #--------------------- 218 `bannedUUID` varchar(36) NOT NULL,
169 219 `bannedIp` varchar(16) NOT NULL,
170BEGIN; 220 `bannedIpHostMask` varchar(16) NOT NULL
171 CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; 221) ENGINE=InnoDB DEFAULT CHARSET=utf8;
172COMMIT; 222
173 223CREATE TABLE IF NOT EXISTS `regionsettings` (
174:VERSION 4 #---------------------
175
176BEGIN;
177
178ALTER TABLE primitems add flags integer not null default 0;
179
180COMMIT;
181
182:VERSION 5 #---------------------
183BEGIN;
184
185create table regionsettings (
186 regionUUID char(36) not null,
187 block_terraform integer not null,
188 block_fly integer not null,
189 allow_damage integer not null,
190 restrict_pushing integer not null,
191 allow_land_resell integer not null,
192 allow_land_join_divide integer not null,
193 block_show_in_search integer not null,
194 agent_limit integer not null,
195 object_bonus float not null,
196 maturity integer not null,
197 disable_scripts integer not null,
198 disable_collisions integer not null,
199 disable_physics integer not null,
200 terrain_texture_1 char(36) not null,
201 terrain_texture_2 char(36) not null,
202 terrain_texture_3 char(36) not null,
203 terrain_texture_4 char(36) not null,
204 elevation_1_nw float not null,
205 elevation_2_nw float not null,
206 elevation_1_ne float not null,
207 elevation_2_ne float not null,
208 elevation_1_se float not null,
209 elevation_2_se float not null,
210 elevation_1_sw float not null,
211 elevation_2_sw float not null,
212 water_height float not null,
213 terrain_raise_limit float not null,
214 terrain_lower_limit float not null,
215 use_estate_sun integer not null,
216 fixed_sun integer not null,
217 sun_position float not null,
218 covenant char(36),
219 primary key(regionUUID)
220);
221
222COMMIT;
223
224
225:VERSION 6 #---------------------
226
227BEGIN;
228
229alter table landaccesslist ENGINE = MyISAM;
230alter table migrations ENGINE = MyISAM;
231alter table primitems ENGINE = MyISAM;
232alter table prims ENGINE = MyISAM;
233alter table primshapes ENGINE = MyISAM;
234alter table regionsettings ENGINE = MyISAM;
235alter table terrain ENGINE = MyISAM;
236
237COMMIT;
238
239:VERSION 7 #---------------------
240
241BEGIN;
242
243ALTER TABLE prims change UUID UUIDold varchar(255);
244ALTER TABLE prims change RegionUUID RegionUUIDold varchar(255);
245ALTER TABLE prims change CreatorID CreatorIDold varchar(255);
246ALTER TABLE prims change OwnerID OwnerIDold varchar(255);
247ALTER TABLE prims change GroupID GroupIDold varchar(255);
248ALTER TABLE prims change LastOwnerID LastOwnerIDold varchar(255);
249ALTER TABLE prims add UUID char(36);
250ALTER TABLE prims add RegionUUID char(36);
251ALTER TABLE prims add CreatorID char(36);
252ALTER TABLE prims add OwnerID char(36);
253ALTER TABLE prims add GroupID char(36);
254ALTER TABLE prims add LastOwnerID char(36);
255UPDATE prims set UUID = UUIDold, RegionUUID = RegionUUIDold, CreatorID = CreatorIDold, OwnerID = OwnerIDold, GroupID = GroupIDold, LastOwnerID = LastOwnerIDold;
256ALTER TABLE prims drop UUIDold;
257ALTER TABLE prims drop RegionUUIDold;
258ALTER TABLE prims drop CreatorIDold;
259ALTER TABLE prims drop OwnerIDold;
260ALTER TABLE prims drop GroupIDold;
261ALTER TABLE prims drop LastOwnerIDold;
262ALTER TABLE prims add constraint primary key(UUID);
263ALTER TABLE prims add index prims_regionuuid(RegionUUID);
264
265COMMIT;
266
267:VERSION 8 #---------------------
268
269BEGIN;
270
271ALTER TABLE primshapes change UUID UUIDold varchar(255);
272ALTER TABLE primshapes add UUID char(36);
273UPDATE primshapes set UUID = UUIDold;
274ALTER TABLE primshapes drop UUIDold;
275ALTER TABLE primshapes add constraint primary key(UUID);
276
277COMMIT;
278
279:VERSION 9 #---------------------
280
281BEGIN;
282
283ALTER TABLE primitems change itemID itemIDold varchar(255);
284ALTER TABLE primitems change primID primIDold varchar(255);
285ALTER TABLE primitems change assetID assetIDold varchar(255);
286ALTER TABLE primitems change parentFolderID parentFolderIDold varchar(255);
287ALTER TABLE primitems change creatorID creatorIDold varchar(255);
288ALTER TABLE primitems change ownerID ownerIDold varchar(255);
289ALTER TABLE primitems change groupID groupIDold varchar(255);
290ALTER TABLE primitems change lastOwnerID lastOwnerIDold varchar(255);
291ALTER TABLE primitems add itemID char(36);
292ALTER TABLE primitems add primID char(36);
293ALTER TABLE primitems add assetID char(36);
294ALTER TABLE primitems add parentFolderID char(36);
295ALTER TABLE primitems add creatorID char(36);
296ALTER TABLE primitems add ownerID char(36);
297ALTER TABLE primitems add groupID char(36);
298ALTER TABLE primitems add lastOwnerID char(36);
299UPDATE primitems set itemID = itemIDold, primID = primIDold, assetID = assetIDold, parentFolderID = parentFolderIDold, creatorID = creatorIDold, ownerID = ownerIDold, groupID = groupIDold, lastOwnerID = lastOwnerIDold;
300ALTER TABLE primitems drop itemIDold;
301ALTER TABLE primitems drop primIDold;
302ALTER TABLE primitems drop assetIDold;
303ALTER TABLE primitems drop parentFolderIDold;
304ALTER TABLE primitems drop creatorIDold;
305ALTER TABLE primitems drop ownerIDold;
306ALTER TABLE primitems drop groupIDold;
307ALTER TABLE primitems drop lastOwnerIDold;
308ALTER TABLE primitems add constraint primary key(itemID);
309ALTER TABLE primitems add index primitems_primid(primID);
310
311COMMIT;
312
313:VERSION 10 #---------------------
314
315# 1 "010_RegionStore.sql"
316# 1 "<built-in>"
317# 1 "<command line>"
318# 1 "010_RegionStore.sql"
319BEGIN;
320
321DELETE FROM regionsettings;
322
323COMMIT;
324
325
326:VERSION 11 #---------------------
327
328BEGIN;
329
330ALTER TABLE prims change SceneGroupID SceneGroupIDold varchar(255);
331ALTER TABLE prims add SceneGroupID char(36);
332UPDATE prims set SceneGroupID = SceneGroupIDold;
333ALTER TABLE prims drop SceneGroupIDold;
334ALTER TABLE prims add index prims_scenegroupid(SceneGroupID);
335
336COMMIT;
337
338:VERSION 12 #---------------------
339
340BEGIN;
341
342ALTER TABLE prims add index prims_parentid(ParentID);
343
344COMMIT;
345
346:VERSION 13 #---------------------
347begin;
348
349drop table regionsettings;
350
351CREATE TABLE `regionsettings` (
352 `regionUUID` char(36) NOT NULL, 224 `regionUUID` char(36) NOT NULL,
353 `block_terraform` int(11) NOT NULL, 225 `block_terraform` int(11) NOT NULL,
354 `block_fly` int(11) NOT NULL, 226 `block_fly` int(11) NOT NULL,
@@ -358,7 +230,7 @@ CREATE TABLE `regionsettings` (
358 `allow_land_join_divide` int(11) NOT NULL, 230 `allow_land_join_divide` int(11) NOT NULL,
359 `block_show_in_search` int(11) NOT NULL, 231 `block_show_in_search` int(11) NOT NULL,
360 `agent_limit` int(11) NOT NULL, 232 `agent_limit` int(11) NOT NULL,
361 `object_bonus` float NOT NULL, 233 `object_bonus` double NOT NULL,
362 `maturity` int(11) NOT NULL, 234 `maturity` int(11) NOT NULL,
363 `disable_scripts` int(11) NOT NULL, 235 `disable_scripts` int(11) NOT NULL,
364 `disable_collisions` int(11) NOT NULL, 236 `disable_collisions` int(11) NOT NULL,
@@ -367,360 +239,35 @@ CREATE TABLE `regionsettings` (
367 `terrain_texture_2` char(36) NOT NULL, 239 `terrain_texture_2` char(36) NOT NULL,
368 `terrain_texture_3` char(36) NOT NULL, 240 `terrain_texture_3` char(36) NOT NULL,
369 `terrain_texture_4` char(36) NOT NULL, 241 `terrain_texture_4` char(36) NOT NULL,
370 `elevation_1_nw` float NOT NULL, 242 `elevation_1_nw` double NOT NULL,
371 `elevation_2_nw` float NOT NULL, 243 `elevation_2_nw` double NOT NULL,
372 `elevation_1_ne` float NOT NULL, 244 `elevation_1_ne` double NOT NULL,
373 `elevation_2_ne` float NOT NULL, 245 `elevation_2_ne` double NOT NULL,
374 `elevation_1_se` float NOT NULL, 246 `elevation_1_se` double NOT NULL,
375 `elevation_2_se` float NOT NULL, 247 `elevation_2_se` double NOT NULL,
376 `elevation_1_sw` float NOT NULL, 248 `elevation_1_sw` double NOT NULL,
377 `elevation_2_sw` float NOT NULL, 249 `elevation_2_sw` double NOT NULL,
378 `water_height` float NOT NULL, 250 `water_height` double NOT NULL,
379 `terrain_raise_limit` float NOT NULL, 251 `terrain_raise_limit` double NOT NULL,
380 `terrain_lower_limit` float NOT NULL, 252 `terrain_lower_limit` double NOT NULL,
381 `use_estate_sun` int(11) NOT NULL, 253 `use_estate_sun` int(11) NOT NULL,
382 `fixed_sun` int(11) NOT NULL, 254 `fixed_sun` int(11) NOT NULL,
383 `sun_position` float NOT NULL, 255 `sun_position` double NOT NULL,
384 `covenant` char(36) default NULL, 256 `covenant` char(36) DEFAULT NULL,
385 `Sandbox` tinyint(4) NOT NULL, 257 `Sandbox` tinyint(4) NOT NULL,
386 PRIMARY KEY (`regionUUID`) 258 `sunvectorx` double NOT NULL DEFAULT '0',
387) ENGINE=MyISAM; 259 `sunvectory` double NOT NULL DEFAULT '0',
388 260 `sunvectorz` double NOT NULL DEFAULT '0',
389commit; 261 `loaded_creation_id` varchar(64) DEFAULT NULL,
390 262 `loaded_creation_datetime` int(10) unsigned NOT NULL DEFAULT '0',
391:VERSION 16 #--------------------- 263 `map_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
392 264 `TelehubObject` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
393BEGIN; 265 `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
394 266 `covenant_datetime` int(10) unsigned NOT NULL DEFAULT '0',
395ALTER TABLE prims ADD COLUMN PayPrice integer not null default 0; 267 PRIMARY KEY (`regionUUID`)
396ALTER TABLE prims ADD COLUMN PayButton1 integer not null default 0; 268) ENGINE=InnoDB DEFAULT CHARSET=utf8;
397ALTER TABLE prims ADD COLUMN PayButton2 integer not null default 0; 269
398ALTER TABLE prims ADD COLUMN PayButton3 integer not null default 0; 270CREATE TABLE IF NOT EXISTS `regionwindlight` (
399ALTER TABLE prims ADD COLUMN PayButton4 integer not null default 0;
400ALTER TABLE prims ADD COLUMN LoopedSound char(36) not null default '00000000-0000-0000-0000-000000000000';
401ALTER TABLE prims ADD COLUMN LoopedSoundGain float not null default 0.0;
402ALTER TABLE prims ADD COLUMN TextureAnimation blob;
403ALTER TABLE prims ADD COLUMN OmegaX float not null default 0.0;
404ALTER TABLE prims ADD COLUMN OmegaY float not null default 0.0;
405ALTER TABLE prims ADD COLUMN OmegaZ float not null default 0.0;
406ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float not null default 0.0;
407ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float not null default 0.0;
408ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float not null default 0.0;
409ALTER TABLE prims ADD COLUMN CameraAtOffsetX float not null default 0.0;
410ALTER TABLE prims ADD COLUMN CameraAtOffsetY float not null default 0.0;
411ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float not null default 0.0;
412ALTER TABLE prims ADD COLUMN ForceMouselook tinyint not null default 0;
413ALTER TABLE prims ADD COLUMN ScriptAccessPin integer not null default 0;
414ALTER TABLE prims ADD COLUMN AllowedDrop tinyint not null default 0;
415ALTER TABLE prims ADD COLUMN DieAtEdge tinyint not null default 0;
416ALTER TABLE prims ADD COLUMN SalePrice integer not null default 10;
417ALTER TABLE prims ADD COLUMN SaleType tinyint not null default 0;
418
419COMMIT;
420
421
422:VERSION 17 #---------------------
423
424BEGIN;
425
426ALTER TABLE prims ADD COLUMN ColorR integer not null default 0;
427ALTER TABLE prims ADD COLUMN ColorG integer not null default 0;
428ALTER TABLE prims ADD COLUMN ColorB integer not null default 0;
429ALTER TABLE prims ADD COLUMN ColorA integer not null default 0;
430ALTER TABLE prims ADD COLUMN ParticleSystem blob;
431
432COMMIT;
433
434
435:VERSION 18 #---------------------
436
437begin;
438
439ALTER TABLE prims ADD COLUMN ClickAction tinyint NOT NULL default 0;
440
441commit;
442
443:VERSION 19 #---------------------
444
445begin;
446
447ALTER TABLE prims ADD COLUMN Material tinyint NOT NULL default 3;
448
449commit;
450
451
452:VERSION 20 #---------------------
453
454begin;
455
456ALTER TABLE land ADD COLUMN OtherCleanTime integer NOT NULL default 0;
457ALTER TABLE land ADD COLUMN Dwell integer NOT NULL default 0;
458
459commit;
460
461:VERSION 21 #---------------------
462
463begin;
464
465ALTER TABLE regionsettings ADD COLUMN sunvectorx double NOT NULL default 0;
466ALTER TABLE regionsettings ADD COLUMN sunvectory double NOT NULL default 0;
467ALTER TABLE regionsettings ADD COLUMN sunvectorz double NOT NULL default 0;
468
469commit;
470
471
472:VERSION 22 #---------------------
473
474BEGIN;
475
476ALTER TABLE prims ADD COLUMN CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000';
477ALTER TABLE prims ADD COLUMN CollisionSoundVolume float not null default 0.0;
478
479COMMIT;
480
481:VERSION 23 #---------------------
482
483BEGIN;
484
485ALTER TABLE prims ADD COLUMN LinkNumber integer not null default 0;
486
487COMMIT;
488
489:VERSION 24 #---------------------
490
491BEGIN;
492
493alter table regionsettings change column `object_bonus` `object_bonus` double NOT NULL;
494alter table regionsettings change column `elevation_1_nw` `elevation_1_nw` double NOT NULL;
495alter table regionsettings change column `elevation_2_nw` `elevation_2_nw` double NOT NULL;
496alter table regionsettings change column `elevation_1_ne` `elevation_1_ne` double NOT NULL;
497alter table regionsettings change column `elevation_2_ne` `elevation_2_ne` double NOT NULL;
498alter table regionsettings change column `elevation_1_se` `elevation_1_se` double NOT NULL;
499alter table regionsettings change column `elevation_2_se` `elevation_2_se` double NOT NULL;
500alter table regionsettings change column `elevation_1_sw` `elevation_1_sw` double NOT NULL;
501alter table regionsettings change column `elevation_2_sw` `elevation_2_sw` double NOT NULL;
502alter table regionsettings change column `water_height` `water_height` double NOT NULL;
503alter table regionsettings change column `terrain_raise_limit` `terrain_raise_limit` double NOT NULL;
504alter table regionsettings change column `terrain_lower_limit` `terrain_lower_limit` double NOT NULL;
505alter table regionsettings change column `sun_position` `sun_position` double NOT NULL;
506
507COMMIT;
508
509
510:VERSION 25 #---------------------
511
512BEGIN;
513
514alter table prims change column `PositionX` `PositionX` double default NULL;
515alter table prims change column `PositionY` `PositionY` double default NULL;
516alter table prims change column `PositionZ` `PositionZ` double default NULL;
517alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL;
518alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL;
519alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL;
520alter table prims change column `VelocityX` `VelocityX` double default NULL;
521alter table prims change column `VelocityY` `VelocityY` double default NULL;
522alter table prims change column `VelocityZ` `VelocityZ` double default NULL;
523alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL;
524alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL;
525alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL;
526alter table prims change column `AccelerationX` `AccelerationX` double default NULL;
527alter table prims change column `AccelerationY` `AccelerationY` double default NULL;
528alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL;
529alter table prims change column `RotationX` `RotationX` double default NULL;
530alter table prims change column `RotationY` `RotationY` double default NULL;
531alter table prims change column `RotationZ` `RotationZ` double default NULL;
532alter table prims change column `RotationW` `RotationW` double default NULL;
533alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL;
534alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL;
535alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL;
536alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL;
537alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL;
538alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL;
539alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL;
540alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0';
541alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0';
542alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0';
543alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0';
544alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0';
545alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0';
546alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0';
547alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0';
548alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0';
549alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0';
550alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0';
551
552alter table primshapes change column `ScaleX` `ScaleX` double NOT NULL default '0';
553alter table primshapes change column `ScaleY` `ScaleY` double NOT NULL default '0';
554alter table primshapes change column `ScaleZ` `ScaleZ` double NOT NULL default '0';
555
556COMMIT;
557
558:VERSION 26 #---------------------
559
560begin;
561
562alter table prims change column `PositionX` `PositionX` double default NULL;
563alter table prims change column `PositionY` `PositionY` double default NULL;
564alter table prims change column `PositionZ` `PositionZ` double default NULL;
565alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL;
566alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL;
567alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL;
568alter table prims change column `VelocityX` `VelocityX` double default NULL;
569alter table prims change column `VelocityY` `VelocityY` double default NULL;
570alter table prims change column `VelocityZ` `VelocityZ` double default NULL;
571alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL;
572alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL;
573alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL;
574alter table prims change column `AccelerationX` `AccelerationX` double default NULL;
575alter table prims change column `AccelerationY` `AccelerationY` double default NULL;
576alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL;
577alter table prims change column `RotationX` `RotationX` double default NULL;
578alter table prims change column `RotationY` `RotationY` double default NULL;
579alter table prims change column `RotationZ` `RotationZ` double default NULL;
580alter table prims change column `RotationW` `RotationW` double default NULL;
581alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL;
582alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL;
583alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL;
584alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL;
585alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL;
586alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL;
587alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL;
588alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0';
589alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0';
590alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0';
591alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0';
592alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0';
593alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0';
594alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0';
595alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0';
596alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0';
597alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0';
598alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0';
599
600commit;
601
602:VERSION 27 #---------------------
603
604BEGIN;
605
606ALTER TABLE prims DROP COLUMN ParentID;
607
608COMMIT;
609
610:VERSION 28 #---------------------
611
612BEGIN;
613
614update terrain
615 set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12))
616 where RegionUUID not like '%-%';
617
618
619update landaccesslist
620 set LandUUID = concat(substr(LandUUID, 1, 8), "-", substr(LandUUID, 9, 4), "-", substr(LandUUID, 13, 4), "-", substr(LandUUID, 17, 4), "-", substr(LandUUID, 21, 12))
621 where LandUUID not like '%-%';
622
623update landaccesslist
624 set AccessUUID = concat(substr(AccessUUID, 1, 8), "-", substr(AccessUUID, 9, 4), "-", substr(AccessUUID, 13, 4), "-", substr(AccessUUID, 17, 4), "-", substr(AccessUUID, 21, 12))
625 where AccessUUID not like '%-%';
626
627
628update prims
629 set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12))
630 where UUID not like '%-%';
631
632update prims
633 set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12))
634 where RegionUUID not like '%-%';
635
636update prims
637 set SceneGroupID = concat(substr(SceneGroupID, 1, 8), "-", substr(SceneGroupID, 9, 4), "-", substr(SceneGroupID, 13, 4), "-", substr(SceneGroupID, 17, 4), "-", substr(SceneGroupID, 21, 12))
638 where SceneGroupID not like '%-%';
639
640update prims
641 set CreatorID = concat(substr(CreatorID, 1, 8), "-", substr(CreatorID, 9, 4), "-", substr(CreatorID, 13, 4), "-", substr(CreatorID, 17, 4), "-", substr(CreatorID, 21, 12))
642 where CreatorID not like '%-%';
643
644update prims
645 set OwnerID = concat(substr(OwnerID, 1, 8), "-", substr(OwnerID, 9, 4), "-", substr(OwnerID, 13, 4), "-", substr(OwnerID, 17, 4), "-", substr(OwnerID, 21, 12))
646 where OwnerID not like '%-%';
647
648update prims
649 set GroupID = concat(substr(GroupID, 1, 8), "-", substr(GroupID, 9, 4), "-", substr(GroupID, 13, 4), "-", substr(GroupID, 17, 4), "-", substr(GroupID, 21, 12))
650 where GroupID not like '%-%';
651
652update prims
653 set LastOwnerID = concat(substr(LastOwnerID, 1, 8), "-", substr(LastOwnerID, 9, 4), "-", substr(LastOwnerID, 13, 4), "-", substr(LastOwnerID, 17, 4), "-", substr(LastOwnerID, 21, 12))
654 where LastOwnerID not like '%-%';
655
656
657update primshapes
658 set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12))
659 where UUID not like '%-%';
660
661
662update land
663 set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12))
664 where UUID not like '%-%';
665
666update land
667 set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12))
668 where RegionUUID not like '%-%';
669
670update land
671 set OwnerUUID = concat(substr(OwnerUUID, 1, 8), "-", substr(OwnerUUID, 9, 4), "-", substr(OwnerUUID, 13, 4), "-", substr(OwnerUUID, 17, 4), "-", substr(OwnerUUID, 21, 12))
672 where OwnerUUID not like '%-%';
673
674update land
675 set GroupUUID = concat(substr(GroupUUID, 1, 8), "-", substr(GroupUUID, 9, 4), "-", substr(GroupUUID, 13, 4), "-", substr(GroupUUID, 17, 4), "-", substr(GroupUUID, 21, 12))
676 where GroupUUID not like '%-%';
677
678update land
679 set MediaTextureUUID = concat(substr(MediaTextureUUID, 1, 8), "-", substr(MediaTextureUUID, 9, 4), "-", substr(MediaTextureUUID, 13, 4), "-", substr(MediaTextureUUID, 17, 4), "-", substr(MediaTextureUUID, 21, 12))
680 where MediaTextureUUID not like '%-%';
681
682update land
683 set SnapshotUUID = concat(substr(SnapshotUUID, 1, 8), "-", substr(SnapshotUUID, 9, 4), "-", substr(SnapshotUUID, 13, 4), "-", substr(SnapshotUUID, 17, 4), "-", substr(SnapshotUUID, 21, 12))
684 where SnapshotUUID not like '%-%';
685
686update land
687 set AuthbuyerID = concat(substr(AuthbuyerID, 1, 8), "-", substr(AuthbuyerID, 9, 4), "-", substr(AuthbuyerID, 13, 4), "-", substr(AuthbuyerID, 17, 4), "-", substr(AuthbuyerID, 21, 12))
688 where AuthbuyerID not like '%-%';
689
690COMMIT;
691
692:VERSION 29 #---------------------
693
694BEGIN;
695
696ALTER TABLE prims ADD COLUMN PassTouches tinyint not null default 0;
697
698COMMIT;
699
700:VERSION 30 #---------------------
701
702BEGIN;
703
704ALTER TABLE regionsettings ADD COLUMN loaded_creation_date varchar(20) default NULL;
705ALTER TABLE regionsettings ADD COLUMN loaded_creation_time varchar(20) default NULL;
706ALTER TABLE regionsettings ADD COLUMN loaded_creation_id varchar(64) default NULL;
707
708COMMIT;
709
710:VERSION 31 #---------------------
711
712BEGIN;
713
714ALTER TABLE regionsettings DROP COLUMN loaded_creation_date;
715ALTER TABLE regionsettings DROP COLUMN loaded_creation_time;
716ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT NULL default 0;
717
718COMMIT;
719
720:VERSION 32
721
722BEGIN;
723CREATE TABLE `regionwindlight` (
724 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000', 271 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000',
725 `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000', 272 `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000',
726 `water_color_g` float(9,6) unsigned NOT NULL DEFAULT '38.000000', 273 `water_color_g` float(9,6) unsigned NOT NULL DEFAULT '38.000000',
@@ -779,172 +326,144 @@ CREATE TABLE `regionwindlight` (
779 `cloud_detail_x` float(3,2) unsigned NOT NULL DEFAULT '1.00', 326 `cloud_detail_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
780 `cloud_detail_y` float(3,2) unsigned NOT NULL DEFAULT '0.53', 327 `cloud_detail_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
781 `cloud_detail_density` float(3,2) unsigned NOT NULL DEFAULT '0.12', 328 `cloud_detail_density` float(3,2) unsigned NOT NULL DEFAULT '0.12',
782 `cloud_scroll_x` float(3,2) unsigned NOT NULL DEFAULT '0.20', 329 `cloud_scroll_x` float(4,2) NOT NULL DEFAULT '0.20',
783 `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', 330 `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
784 `cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01', 331 `cloud_scroll_y` float(4,2) NOT NULL DEFAULT '0.01',
785 `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', 332 `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
786 `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1', 333 `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1',
787 PRIMARY KEY (`region_id`) 334 PRIMARY KEY (`region_id`)
788); 335) ENGINE=InnoDB DEFAULT CHARSET=utf8;
789
790
791:VERSION 33 #---------------------
792
793BEGIN;
794ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
795COMMIT;
796
797:VERSION 34 #---------------------
798
799BEGIN;
800ALTER TABLE `regionwindlight` CHANGE COLUMN `cloud_scroll_x` `cloud_scroll_x` FLOAT(4,2) NOT NULL DEFAULT '0.20' AFTER `cloud_detail_density`, CHANGE COLUMN `cloud_scroll_y` `cloud_scroll_y` FLOAT(4,2) NOT NULL DEFAULT '0.01' AFTER `cloud_scroll_x_lock`;
801COMMIT;
802 336
803:VERSION 35 #---------------------
804
805BEGIN;
806ALTER TABLE prims ADD COLUMN MediaURL varchar(255);
807ALTER TABLE primshapes ADD COLUMN Media TEXT;
808COMMIT;
809
810:VERSION 36 #---------------------
811
812BEGIN;
813ALTER TABLE `land` ADD COLUMN `MediaType` VARCHAR(32) NOT NULL DEFAULT 'none/none' ;
814ALTER TABLE `land` ADD COLUMN `MediaDescription` VARCHAR(255) NOT NULL DEFAULT '';
815ALTER TABLE `land` ADD COLUMN `MediaSize` VARCHAR(16) NOT NULL DEFAULT '0,0';
816ALTER TABLE `land` ADD COLUMN `MediaLoop` BOOLEAN NOT NULL DEFAULT FALSE;
817ALTER TABLE `land` ADD COLUMN `ObscureMusic` BOOLEAN NOT NULL DEFAULT FALSE;
818ALTER TABLE `land` ADD COLUMN `ObscureMedia` BOOLEAN NOT NULL DEFAULT FALSE;
819COMMIT;
820
821:VERSION 37 #---------------------
822
823BEGIN;
824
825ALTER TABLE `prims` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT '';
826ALTER TABLE `primitems` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT '';
827
828COMMIT;
829
830:VERSION 38 #---------------------
831
832BEGIN;
833
834alter table land ENGINE = MyISAM;
835alter table landaccesslist ENGINE = MyISAM;
836alter table migrations ENGINE = MyISAM;
837alter table primitems ENGINE = MyISAM;
838alter table prims ENGINE = MyISAM;
839alter table primshapes ENGINE = MyISAM;
840alter table regionban ENGINE = MyISAM;
841alter table regionsettings ENGINE = MyISAM;
842alter table terrain ENGINE = MyISAM;
843
844COMMIT;
845
846:VERSION 39 #--------------- Telehub support
847
848BEGIN;
849CREATE TABLE IF NOT EXISTS `spawn_points` ( 337CREATE TABLE IF NOT EXISTS `spawn_points` (
850 `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, 338 `RegionID` varchar(36) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
851 `Yaw` float NOT NULL, 339 `Yaw` float NOT NULL,
852 `Pitch` float NOT NULL, 340 `Pitch` float NOT NULL,
853 `Distance` float NOT NULL, 341 `Distance` float NOT NULL,
854 KEY `RegionID` (`RegionID`) 342 KEY `RegionID` (`RegionID`)
855) ENGINE=MyISAM; 343) ENGINE=InnoDB DEFAULT CHARSET=utf8;
856
857ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL;
858COMMIT;
859
860:VERSION 40 #---------------- Parcels for sale
861
862BEGIN;
863ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
864COMMIT;
865
866:VERSION 41 #---------------- Timed bans/access
867
868BEGIN;
869ALTER TABLE `landaccesslist` ADD COLUMN `Expires` INTEGER NOT NULL DEFAULT 0;
870COMMIT;
871 344
872:VERSION 42 #--------------------- Region Covenant changed time 345CREATE TABLE IF NOT EXISTS `regionenvironment` (
873
874BEGIN;
875ALTER TABLE regionsettings ADD COLUMN covenant_datetime int unsigned NOT NULL DEFAULT '0';
876COMMIT;
877
878:VERSION 43 #---------------------
879
880BEGIN;
881
882ALTER TABLE `regionsettings` MODIFY COLUMN `TelehubObject` VARCHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
883
884COMMIT;
885
886:VERSION 44 #--------------------- Environment Settings
887
888BEGIN;
889
890CREATE TABLE `regionenvironment` (
891 `region_id` varchar(36) NOT NULL, 346 `region_id` varchar(36) NOT NULL,
892 `llsd_settings` TEXT NOT NULL, 347 `llsd_settings` text NOT NULL,
893 PRIMARY KEY (`region_id`) 348 PRIMARY KEY (`region_id`)
894) ENGINE=MyISAM DEFAULT CHARSET=utf8; 349) ENGINE=InnoDB DEFAULT CHARSET=utf8;
895
896COMMIT;
897 350
898:VERSION 45 351CREATE TABLE IF NOT EXISTS `regionextra` (
899 352 `RegionID` char(36) NOT NULL,
900BEGIN; 353 `Name` varchar(32) NOT NULL,
901 354 `value` text,
902CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); 355 PRIMARY KEY (`RegionID`,`Name`)
356) ENGINE=InnoDB DEFAULT CHARSET=utf8;
903 357
904COMMIT; 358COMMIT;
905 359
906:VERSION 46 #---------------- Dynamic attributes 360:VERSION 52 #---- avination fields
907 361
908BEGIN; 362BEGIN;
909 363
910ALTER TABLE prims ADD COLUMN DynAttrs TEXT; 364ALTER TABLE `prims` ADD COLUMN `PassCollisions` tinyint(4) NOT NULL default '0';
365ALTER TABLE `prims` ADD COLUMN `Vehicle` TEXT default NULL;
366ALTER TABLE `regionsettings` ADD COLUMN `block_search` tinyint(4) NOT NULL default '0';
367ALTER TABLE `regionsettings` ADD COLUMN `casino` tinyint(4) NOT NULL default '0';
368ALTER TABLE `land` ADD COLUMN `SeeAVs` tinyint(4) NOT NULL default '1';
369ALTER TABLE `land` ADD COLUMN `AnyAVSounds` tinyint(4) NOT NULL default '1';
370ALTER TABLE `land` ADD COLUMN `GroupAVSounds` tinyint(4) NOT NULL default '1';
911 371
912COMMIT; 372COMMIT;
913 373
914:VERSION 47 #---------------- Extra physics params 374:VERSION 53 #---- STATUS ROTATION axis locks
915 375
916BEGIN; 376BEGIN;
917 377
918ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; 378ALTER TABLE `prims` ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0';
919ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000';
920ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1';
921ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6';
922ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5';
923 379
924COMMIT; 380COMMIT;
925 381
926:VERSION 48 #---------------- Keyframes 382:VERSION 54 #----- add baked terrain store
927 383
928BEGIN; 384BEGIN;
929 385
930ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; 386CREATE TABLE IF NOT EXISTS `bakedterrain` (
931 387 `RegionUUID` varchar(255) DEFAULT NULL,
932COMMIT; 388 `Revision` int(11) DEFAULT NULL,
933 389 `Heightfield` longblob
934:VERSION 49 #--------------------- Save attachment info 390) ENGINE=InnoDB DEFAULT CHARSET=utf8;
935 391
936BEGIN; 392COMMIT;
937ALTER TABLE prims ADD COLUMN AttachedPosX double default 0; 393
938ALTER TABLE prims ADD COLUMN AttachedPosY double default 0; 394:VERSION 55 #----- Increase float precision for windlight needed by scripts
939ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0; 395
940ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; 396BEGIN;
941COMMIT; 397
942 398ALTER TABLE `regionwindlight`
943:VERSION 50 #---- Change LandFlags to unsigned 399
944 400MODIFY `water_fog_density_exponent` float(9,7) unsigned NOT NULL DEFAULT '4.0',
945BEGIN; 401MODIFY `underwater_fog_modifier` float(9,8) unsigned NOT NULL DEFAULT '0.25',
946 402MODIFY `reflection_wavelet_scale_1` float(9,7) unsigned NOT NULL DEFAULT '2.0',
947ALTER TABLE land CHANGE COLUMN LandFlags LandFlags int unsigned default null; 403MODIFY `reflection_wavelet_scale_2` float(9,7) unsigned NOT NULL DEFAULT '2.0',
948 404MODIFY `reflection_wavelet_scale_3` float(9,7) unsigned NOT NULL DEFAULT '2.0',
405MODIFY `fresnel_scale` float(9,8) unsigned NOT NULL DEFAULT '0.40',
406MODIFY `fresnel_offset` float(9,8) unsigned NOT NULL DEFAULT '0.50',
407MODIFY `refract_scale_above` float(9,8) unsigned NOT NULL DEFAULT '0.03',
408MODIFY `refract_scale_below` float(9,8) unsigned NOT NULL DEFAULT '0.20',
409MODIFY `blur_multiplier` float(9,8) unsigned NOT NULL DEFAULT '0.040',
410MODIFY `big_wave_direction_x` float(9,8) NOT NULL DEFAULT '1.05',
411MODIFY `big_wave_direction_y` float(9,8) NOT NULL DEFAULT '-0.42',
412MODIFY `little_wave_direction_x` float(9,8) NOT NULL DEFAULT '1.11',
413MODIFY `little_wave_direction_y` float(9,8) NOT NULL DEFAULT '-1.16',
414MODIFY `horizon_r` float(9,8) unsigned NOT NULL DEFAULT '0.25',
415MODIFY `horizon_g` float(9,8) unsigned NOT NULL DEFAULT '0.25',
416MODIFY `horizon_b` float(9,8) unsigned NOT NULL DEFAULT '0.32',
417MODIFY `horizon_i` float(9,8) unsigned NOT NULL DEFAULT '0.32',
418MODIFY `haze_horizon` float(9,8) unsigned NOT NULL DEFAULT '0.19',
419MODIFY `blue_density_r` float(9,8) unsigned NOT NULL DEFAULT '0.12',
420MODIFY `blue_density_g` float(9,8) unsigned NOT NULL DEFAULT '0.22',
421MODIFY `blue_density_b` float(9,8) unsigned NOT NULL DEFAULT '0.38',
422MODIFY `blue_density_i` float(9,8) unsigned NOT NULL DEFAULT '0.38',
423MODIFY `haze_density` float(9,8) unsigned NOT NULL DEFAULT '0.70',
424MODIFY `density_multiplier` float(9,8) unsigned NOT NULL DEFAULT '0.18',
425MODIFY `distance_multiplier` float(9,6) unsigned NOT NULL DEFAULT '0.8',
426MODIFY `sun_moon_color_r` float(9,8) unsigned NOT NULL DEFAULT '0.24',
427MODIFY `sun_moon_color_g` float(9,8) unsigned NOT NULL DEFAULT '0.26',
428MODIFY `sun_moon_color_b` float(9,8) unsigned NOT NULL DEFAULT '0.30',
429MODIFY `sun_moon_color_i` float(9,8) unsigned NOT NULL DEFAULT '0.30',
430MODIFY `sun_moon_position` float(9,8) unsigned NOT NULL DEFAULT '0.317',
431MODIFY `ambient_r` float(9,8) unsigned NOT NULL DEFAULT '0.35',
432MODIFY `ambient_g` float(9,8) unsigned NOT NULL DEFAULT '0.35',
433MODIFY `ambient_b` float(9,8) unsigned NOT NULL DEFAULT '0.35',
434MODIFY `ambient_i` float(9,8) unsigned NOT NULL DEFAULT '0.35',
435MODIFY `east_angle` float(9,8) unsigned NOT NULL DEFAULT '0.00',
436MODIFY `sun_glow_focus` float(9,8) unsigned NOT NULL DEFAULT '0.10',
437MODIFY `sun_glow_size` float(9,8) unsigned NOT NULL DEFAULT '1.75',
438MODIFY `scene_gamma` float(9,7) unsigned NOT NULL DEFAULT '1.00',
439MODIFY `star_brightness` float(9,8) unsigned NOT NULL DEFAULT '0.00',
440MODIFY `cloud_color_r` float(9,8) unsigned NOT NULL DEFAULT '0.41',
441MODIFY `cloud_color_g` float(9,8) unsigned NOT NULL DEFAULT '0.41',
442MODIFY `cloud_color_b` float(9,8) unsigned NOT NULL DEFAULT '0.41',
443MODIFY `cloud_color_i` float(9,8) unsigned NOT NULL DEFAULT '0.41',
444MODIFY `cloud_x` float(9,8) unsigned NOT NULL DEFAULT '1.00',
445MODIFY `cloud_y` float(9,8) unsigned NOT NULL DEFAULT '0.53',
446MODIFY `cloud_density` float(9,8) unsigned NOT NULL DEFAULT '1.00',
447MODIFY `cloud_coverage` float(9,8) unsigned NOT NULL DEFAULT '0.27',
448MODIFY `cloud_scale` float(9,8) unsigned NOT NULL DEFAULT '0.42',
449MODIFY `cloud_detail_x` float(9,8) unsigned NOT NULL DEFAULT '1.00',
450MODIFY `cloud_detail_y` float(9,8) unsigned NOT NULL DEFAULT '0.53',
451MODIFY `cloud_detail_density` float(9,8) unsigned NOT NULL DEFAULT '0.12',
452MODIFY `cloud_scroll_x` float(9,7) NOT NULL DEFAULT '0.20',
453MODIFY `cloud_scroll_y` float(9,7) NOT NULL DEFAULT '0.01';
454
455COMMIT;
456
457:VERSION 56 #----- Add RezzerID field in table prims
458
459BEGIN;
460
461ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL;
462
463COMMIT;
464
465:VERSION 57 #----- Add physics inertia data
466
467BEGIN;
468ALTER TABLE `prims` ADD COLUMN `PhysInertia` TEXT default NULL;
949COMMIT; 469COMMIT;
950
diff --git a/OpenSim/Data/MySQL/Resources/UserAccount.migrations b/OpenSim/Data/MySQL/Resources/UserAccount.migrations
index 97e5e4f..98be097 100644
--- a/OpenSim/Data/MySQL/Resources/UserAccount.migrations
+++ b/OpenSim/Data/MySQL/Resources/UserAccount.migrations
@@ -1,47 +1,31 @@
1:VERSION 1 # ------------------------- 1:VERSION 5 # -------------------------
2 2
3BEGIN; 3BEGIN;
4 4
5CREATE TABLE `UserAccounts` ( 5CREATE TABLE IF NOT EXISTS `UserAccounts` (
6 `PrincipalID` CHAR(36) NOT NULL, 6 `PrincipalID` char(36) NOT NULL,
7 `ScopeID` CHAR(36) NOT NULL, 7 `ScopeID` char(36) NOT NULL,
8 `FirstName` VARCHAR(64) NOT NULL, 8 `FirstName` varchar(64) NOT NULL,
9 `LastName` VARCHAR(64) NOT NULL, 9 `LastName` varchar(64) NOT NULL,
10 `Email` VARCHAR(64), 10 `Email` varchar(64) DEFAULT NULL,
11 `ServiceURLs` TEXT, 11 `ServiceURLs` text,
12 `Created` INT(11) 12 `Created` int(11) DEFAULT NULL,
13) ENGINE=MyISAM DEFAULT CHARSET=utf8; 13 `UserLevel` int(11) NOT NULL DEFAULT '0',
14 `UserFlags` int(11) NOT NULL DEFAULT '0',
15 `UserTitle` varchar(64) NOT NULL DEFAULT '',
16 UNIQUE KEY `PrincipalID` (`PrincipalID`),
17 KEY `Email` (`Email`),
18 KEY `FirstName` (`FirstName`),
19 KEY `LastName` (`LastName`),
20 KEY `Name` (`FirstName`,`LastName`)
21) ENGINE=InnoDB DEFAULT CHARSET=utf8;
14 22
15COMMIT; 23COMMIT;
16 24
17:VERSION 2 # ------------------------- 25:VERSION 6 # -------------------------
18 26
19BEGIN; 27BEGIN;
20 28
21INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; 29ALTER TABLE `UserAccounts` ADD `active` INT NOT NULL DEFAULT '1';
22 30
23COMMIT; 31COMMIT;
24
25:VERSION 3 # -------------------------
26
27BEGIN;
28
29CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID);
30CREATE INDEX Email ON UserAccounts(Email);
31CREATE INDEX FirstName ON UserAccounts(FirstName);
32CREATE INDEX LastName ON UserAccounts(LastName);
33CREATE INDEX Name ON UserAccounts(FirstName,LastName);
34
35COMMIT;
36
37:VERSION 4 # -------------------------
38
39BEGIN;
40
41ALTER TABLE UserAccounts ADD COLUMN UserLevel integer NOT NULL DEFAULT 0;
42ALTER TABLE UserAccounts ADD COLUMN UserFlags integer NOT NULL DEFAULT 0;
43ALTER TABLE UserAccounts ADD COLUMN UserTitle varchar(64) NOT NULL DEFAULT '';
44
45COMMIT;
46
47
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
index 0759b26..cfcc18b 100644
--- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
+++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
@@ -1,4 +1,4 @@
1:VERSION 1 # ------------------------------- 1:VERSION 5 # -------------------------------
2 2
3begin; 3begin;
4 4
@@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS `classifieds` (
19 `classifiedflags` int(8) NOT NULL, 19 `classifiedflags` int(8) NOT NULL,
20 `priceforlisting` int(5) NOT NULL, 20 `priceforlisting` int(5) NOT NULL,
21 PRIMARY KEY (`classifieduuid`) 21 PRIMARY KEY (`classifieduuid`)
22) ENGINE=MyISAM DEFAULT CHARSET=latin1; 22) ENGINE=InnoDB DEFAULT CHARSET=latin1;
23 23
24 24
25CREATE TABLE IF NOT EXISTS `usernotes` ( 25CREATE TABLE IF NOT EXISTS `usernotes` (
@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `usernotes` (
27 `targetuuid` varchar(36) NOT NULL, 27 `targetuuid` varchar(36) NOT NULL,
28 `notes` text NOT NULL, 28 `notes` text NOT NULL,
29 UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) 29 UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`)
30) ENGINE=MyISAM DEFAULT CHARSET=latin1; 30) ENGINE=InnoDB DEFAULT CHARSET=latin1;
31 31
32 32
33CREATE TABLE IF NOT EXISTS `userpicks` ( 33CREATE TABLE IF NOT EXISTS `userpicks` (
@@ -44,8 +44,9 @@ CREATE TABLE IF NOT EXISTS `userpicks` (
44 `posglobal` varchar(255) NOT NULL, 44 `posglobal` varchar(255) NOT NULL,
45 `sortorder` int(2) NOT NULL, 45 `sortorder` int(2) NOT NULL,
46 `enabled` enum('true','false') NOT NULL, 46 `enabled` enum('true','false') NOT NULL,
47 `gatekeeper` varchar(255),
47 PRIMARY KEY (`pickuuid`) 48 PRIMARY KEY (`pickuuid`)
48) ENGINE=MyISAM DEFAULT CHARSET=latin1; 49) ENGINE=InnoDB DEFAULT CHARSET=latin1;
49 50
50 51
51CREATE TABLE IF NOT EXISTS `userprofile` ( 52CREATE TABLE IF NOT EXISTS `userprofile` (
@@ -64,35 +65,22 @@ CREATE TABLE IF NOT EXISTS `userprofile` (
64 `profileFirstImage` varchar(36) NOT NULL, 65 `profileFirstImage` varchar(36) NOT NULL,
65 `profileFirstText` text NOT NULL, 66 `profileFirstText` text NOT NULL,
66 PRIMARY KEY (`useruuid`) 67 PRIMARY KEY (`useruuid`)
67) ENGINE=MyISAM DEFAULT CHARSET=latin1; 68) ENGINE=InnoDB DEFAULT CHARSET=latin1;
68 69
69commit;
70
71:VERSION 2 # -------------------------------
72
73begin;
74CREATE TABLE IF NOT EXISTS `userdata` ( 70CREATE TABLE IF NOT EXISTS `userdata` (
75 `UserId` char(36) NOT NULL, 71 `UserId` char(36) NOT NULL,
76 `TagId` varchar(64) NOT NULL, 72 `TagId` varchar(64) NOT NULL,
77 `DataKey` varchar(255), 73 `DataKey` varchar(255),
78 `DataVal` varchar(255), 74 `DataVal` varchar(255),
79 PRIMARY KEY (`UserId`,`TagId`) 75 PRIMARY KEY (`UserId`,`TagId`)
80) ENGINE=MyISAM DEFAULT CHARSET=latin1; 76) ENGINE=InnoDB DEFAULT CHARSET=latin1;
81
82commit;
83 77
84:VERSION 3 # -------------------------------
85begin;
86CREATE TABLE IF NOT EXISTS `usersettings` ( 78CREATE TABLE IF NOT EXISTS `usersettings` (
87 `useruuid` varchar(36) NOT NULL, 79 `useruuid` varchar(36) NOT NULL,
88 `imviaemail` enum('true','false') NOT NULL, 80 `imviaemail` enum('true','false') NOT NULL,
89 `visible` enum('true','false') NOT NULL, 81 `visible` enum('true','false') NOT NULL,
90 `email` varchar(254) NOT NULL, 82 `email` varchar(254) NOT NULL,
91 PRIMARY KEY (`useruuid`) 83 PRIMARY KEY (`useruuid`)
92) ENGINE=MyISAM DEFAULT CHARSET=latin1; 84) ENGINE=InnoDB DEFAULT CHARSET=latin1;
93commit;
94 85
95:VERSION 4 # -------------------------------
96begin;
97ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255);
98commit; 86commit;
diff --git a/OpenSim/Data/MySQL/Resources/UserStore.migrations b/OpenSim/Data/MySQL/Resources/UserStore.migrations
deleted file mode 100644
index 9129075..0000000
--- a/OpenSim/Data/MySQL/Resources/UserStore.migrations
+++ /dev/null
@@ -1,168 +0,0 @@
1:VERSION 1 # -----------------------------
2
3BEGIN;
4
5SET FOREIGN_KEY_CHECKS=0;
6-- ----------------------------
7-- Table structure for agents
8-- ----------------------------
9CREATE TABLE `agents` (
10 `UUID` varchar(36) NOT NULL,
11 `sessionID` varchar(36) NOT NULL,
12 `secureSessionID` varchar(36) NOT NULL,
13 `agentIP` varchar(16) NOT NULL,
14 `agentPort` int(11) NOT NULL,
15 `agentOnline` tinyint(4) NOT NULL,
16 `loginTime` int(11) NOT NULL,
17 `logoutTime` int(11) NOT NULL,
18 `currentRegion` varchar(36) NOT NULL,
19 `currentHandle` bigint(20) unsigned NOT NULL,
20 `currentPos` varchar(64) NOT NULL,
21 PRIMARY KEY (`UUID`),
22 UNIQUE KEY `session` (`sessionID`),
23 UNIQUE KEY `ssession` (`secureSessionID`)
24) ENGINE=MyISAM DEFAULT CHARSET=utf8;
25
26-- Create schema avatar_appearance
27--
28
29CREATE TABLE `avatarappearance` (
30 Owner char(36) NOT NULL,
31 Serial int(10) unsigned NOT NULL,
32 Visual_Params blob NOT NULL,
33 Texture blob NOT NULL,
34 Avatar_Height float NOT NULL,
35 Body_Item char(36) NOT NULL,
36 Body_Asset char(36) NOT NULL,
37 Skin_Item char(36) NOT NULL,
38 Skin_Asset char(36) NOT NULL,
39 Hair_Item char(36) NOT NULL,
40 Hair_Asset char(36) NOT NULL,
41 Eyes_Item char(36) NOT NULL,
42 Eyes_Asset char(36) NOT NULL,
43 Shirt_Item char(36) NOT NULL,
44 Shirt_Asset char(36) NOT NULL,
45 Pants_Item char(36) NOT NULL,
46 Pants_Asset char(36) NOT NULL,
47 Shoes_Item char(36) NOT NULL,
48 Shoes_Asset char(36) NOT NULL,
49 Socks_Item char(36) NOT NULL,
50 Socks_Asset char(36) NOT NULL,
51 Jacket_Item char(36) NOT NULL,
52 Jacket_Asset char(36) NOT NULL,
53 Gloves_Item char(36) NOT NULL,
54 Gloves_Asset char(36) NOT NULL,
55 Undershirt_Item char(36) NOT NULL,
56 Undershirt_Asset char(36) NOT NULL,
57 Underpants_Item char(36) NOT NULL,
58 Underpants_Asset char(36) NOT NULL,
59 Skirt_Item char(36) NOT NULL,
60 Skirt_Asset char(36) NOT NULL,
61 PRIMARY KEY (`Owner`)
62) ENGINE=MyISAM DEFAULT CHARSET=utf8;
63
64SET FOREIGN_KEY_CHECKS=0;
65-- ----------------------------
66-- Table structure for users
67-- ----------------------------
68CREATE TABLE `userfriends` (
69 `ownerID` VARCHAR(37) NOT NULL,
70 `friendID` VARCHAR(37) NOT NULL,
71 `friendPerms` INT NOT NULL,
72 `datetimestamp` INT NOT NULL,
73 UNIQUE KEY (`ownerID`, `friendID`)
74) ENGINE=MyISAM DEFAULT CHARSET=utf8;
75-- ----------------------------
76-- Table structure for users
77-- ----------------------------
78CREATE TABLE `users` (
79 `UUID` varchar(36) NOT NULL default '',
80 `username` varchar(32) NOT NULL,
81 `lastname` varchar(32) NOT NULL,
82 `passwordHash` varchar(32) NOT NULL,
83 `passwordSalt` varchar(32) NOT NULL,
84 `homeRegion` bigint(20) unsigned default NULL,
85 `homeLocationX` float default NULL,
86 `homeLocationY` float default NULL,
87 `homeLocationZ` float default NULL,
88 `homeLookAtX` float default NULL,
89 `homeLookAtY` float default NULL,
90 `homeLookAtZ` float default NULL,
91 `created` int(11) NOT NULL,
92 `lastLogin` int(11) NOT NULL,
93 `userInventoryURI` varchar(255) default NULL,
94 `userAssetURI` varchar(255) default NULL,
95 `profileCanDoMask` int(10) unsigned default NULL,
96 `profileWantDoMask` int(10) unsigned default NULL,
97 `profileAboutText` text,
98 `profileFirstText` text,
99 `profileImage` varchar(36) default NULL,
100 `profileFirstImage` varchar(36) default NULL,
101 `webLoginKey` varchar(36) default NULL,
102 PRIMARY KEY (`UUID`),
103 UNIQUE KEY `usernames` (`username`,`lastname`)
104) ENGINE=MyISAM DEFAULT CHARSET=utf8;
105
106-- ----------------------------
107-- Records
108-- ----------------------------
109COMMIT;
110
111:VERSION 2 # -----------------------------
112
113BEGIN;
114
115ALTER TABLE users add homeRegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
116
117COMMIT;
118
119:VERSION 3 # -----------------------------
120
121BEGIN;
122
123ALTER TABLE users add userFlags integer NOT NULL default 0;
124ALTER TABLE users add godLevel integer NOT NULL default 0;
125
126COMMIT;
127
128:VERSION 4 # -----------------------------
129
130BEGIN;
131
132ALTER TABLE users add customType varchar(32) not null default '';
133ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000';
134
135COMMIT;
136
137:VERSION 5 # -----------------------------
138
139BEGIN;
140
141CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=MyISAM;
142
143COMMIT;
144
145:VERSION 6 # -----------------------------
146
147BEGIN;
148
149ALTER TABLE agents add currentLookAt varchar(36) not null default '';
150
151COMMIT;
152
153:VERSION 7 # -----------------------------
154
155BEGIN;
156
157ALTER TABLE users add email varchar(250);
158
159COMMIT;
160
161:VERSION 8 # -----------------------------
162
163BEGIN;
164
165ALTER TABLE users add scopeID char(36) not null default '00000000-0000-0000-0000-000000000000';
166
167COMMIT;
168
diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
index 78d6e51..9459e3e 100644
--- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
@@ -16,13 +16,13 @@ CREATE TABLE `XAssetsMeta` (
16 `AssetFlags` int(11) NOT NULL, 16 `AssetFlags` int(11) NOT NULL,
17 `CreatorID` varchar(128) NOT NULL, 17 `CreatorID` varchar(128) NOT NULL,
18 PRIMARY KEY (`id`) 18 PRIMARY KEY (`id`)
19) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Version 1'; 19) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
20 20
21CREATE TABLE `XAssetsData` ( 21CREATE TABLE `XAssetsData` (
22 `Hash` binary(32) NOT NULL, 22 `Hash` binary(32) NOT NULL,
23 `Data` longblob NOT NULL, 23 `Data` longblob NOT NULL,
24 PRIMARY KEY (`hash`) 24 PRIMARY KEY (`hash`)
25) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Version 1'; 25) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
26 26
27COMMIT; 27COMMIT;
28 28
diff --git a/OpenSim/Data/MySQL/Resources/XMute.migrations b/OpenSim/Data/MySQL/Resources/XMute.migrations
new file mode 100644
index 0000000..4ac7f82
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/XMute.migrations
@@ -0,0 +1,16 @@
1:VERSION 1
2
3BEGIN;
4
5CREATE TABLE `XMute` (
6 `AgentID` char(36) NOT NULL,
7 `MuteID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
8 `MuteName` varchar(64) NOT NULL DEFAULT '',
9 `MuteType` int(11) NOT NULL DEFAULT '1',
10 `MuteFlags` int(11) NOT NULL DEFAULT '0',
11 `Stamp` int(11) NOT NULL,
12 UNIQUE KEY `AgentID_2` (`AgentID`,`MuteID`,`MuteName`),
13 KEY `AgentID` (`AgentID`)
14);
15
16COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
index 9e6f1c1..6ec8914 100644
--- a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
+++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
@@ -31,7 +31,7 @@ CREATE TABLE `os_groups_membership` (
31 `AccessToken` char(36) NOT NULL default '', 31 `AccessToken` char(36) NOT NULL default '',
32 PRIMARY KEY (`GroupID`,`PrincipalID`), 32 PRIMARY KEY (`GroupID`,`PrincipalID`),
33 KEY `PrincipalID` (`PrincipalID`) 33 KEY `PrincipalID` (`PrincipalID`)
34) ENGINE=MyISAM; 34) ENGINE=InnoDB;
35 35
36 36
37CREATE TABLE `os_groups_roles` ( 37CREATE TABLE `os_groups_roles` (
@@ -43,7 +43,7 @@ CREATE TABLE `os_groups_roles` (
43 `Powers` bigint(20) unsigned NOT NULL default '0', 43 `Powers` bigint(20) unsigned NOT NULL default '0',
44 PRIMARY KEY (`GroupID`,`RoleID`), 44 PRIMARY KEY (`GroupID`,`RoleID`),
45 KEY `GroupID` (`GroupID`) 45 KEY `GroupID` (`GroupID`)
46) ENGINE=MyISAM; 46) ENGINE=InnoDB;
47 47
48 48
49CREATE TABLE `os_groups_rolemembership` ( 49CREATE TABLE `os_groups_rolemembership` (
@@ -52,7 +52,7 @@ CREATE TABLE `os_groups_rolemembership` (
52 `PrincipalID` VARCHAR(255) NOT NULL default '', 52 `PrincipalID` VARCHAR(255) NOT NULL default '',
53 PRIMARY KEY (`GroupID`,`RoleID`,`PrincipalID`), 53 PRIMARY KEY (`GroupID`,`RoleID`,`PrincipalID`),
54 KEY `PrincipalID` (`PrincipalID`) 54 KEY `PrincipalID` (`PrincipalID`)
55) ENGINE=MyISAM; 55) ENGINE=InnoDB;
56 56
57 57
58CREATE TABLE `os_groups_invites` ( 58CREATE TABLE `os_groups_invites` (
@@ -63,7 +63,7 @@ CREATE TABLE `os_groups_invites` (
63 `TMStamp` timestamp NOT NULL, 63 `TMStamp` timestamp NOT NULL,
64 PRIMARY KEY (`InviteID`), 64 PRIMARY KEY (`InviteID`),
65 UNIQUE KEY `PrincipalGroup` (`GroupID`,`PrincipalID`) 65 UNIQUE KEY `PrincipalGroup` (`GroupID`,`PrincipalID`)
66) ENGINE=MyISAM; 66) ENGINE=InnoDB;
67 67
68 68
69CREATE TABLE `os_groups_notices` ( 69CREATE TABLE `os_groups_notices` (
@@ -81,13 +81,13 @@ CREATE TABLE `os_groups_notices` (
81 PRIMARY KEY (`NoticeID`), 81 PRIMARY KEY (`NoticeID`),
82 KEY `GroupID` (`GroupID`), 82 KEY `GroupID` (`GroupID`),
83 KEY `TMStamp` (`TMStamp`) 83 KEY `TMStamp` (`TMStamp`)
84) ENGINE=MyISAM; 84) ENGINE=InnoDB;
85 85
86CREATE TABLE `os_groups_principals` ( 86CREATE TABLE `os_groups_principals` (
87 `PrincipalID` VARCHAR(255) NOT NULL default '', 87 `PrincipalID` VARCHAR(255) NOT NULL default '',
88 `ActiveGroupID` char(36) NOT NULL default '', 88 `ActiveGroupID` char(36) NOT NULL default '',
89 PRIMARY KEY (`PrincipalID`) 89 PRIMARY KEY (`PrincipalID`)
90) ENGINE=MyISAM; 90) ENGINE=InnoDB;
91 91
92COMMIT; 92COMMIT;
93 93
@@ -112,4 +112,4 @@ DROP TABLE `diva_groups_principals`;
112 112
113DELETE FROM `migrations` WHERE name='diva_im_Store'; 113DELETE FROM `migrations` WHERE name='diva_im_Store';
114 114
115COMMIT; \ No newline at end of file 115COMMIT;
diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs
index 57592f1..9f22896 100644..100755
--- a/OpenSim/Data/Null/NullEstateData.cs
+++ b/OpenSim/Data/Null/NullEstateData.cs
@@ -102,19 +102,19 @@ namespace OpenSim.Data.Null
102 { 102 {
103 return new EstateSettings(); 103 return new EstateSettings();
104 } 104 }
105 105
106 public List<EstateSettings> LoadEstateSettingsAll() 106 public List<EstateSettings> LoadEstateSettingsAll()
107 { 107 {
108 List<EstateSettings> allEstateSettings = new List<EstateSettings>(); 108 List<EstateSettings> allEstateSettings = new List<EstateSettings>();
109 allEstateSettings.Add(GetEstate()); 109 allEstateSettings.Add(GetEstate());
110 return allEstateSettings; 110 return allEstateSettings;
111 } 111 }
112 112
113 public List<int> GetEstatesAll() 113 public List<int> GetEstatesAll()
114 { 114 {
115 List<int> result = new List<int>(); 115 List<int> result = new List<int>();
116 result.Add((int)GetEstate().EstateID); 116 result.Add((int)GetEstate().EstateID);
117 return result; 117 return result;
118 } 118 }
119 119
120 public List<int> GetEstates(string search) 120 public List<int> GetEstates(string search)
diff --git a/OpenSim/Data/Null/NullFriendsData.cs b/OpenSim/Data/Null/NullFriendsData.cs
index 473999f..dc9cd38 100644
--- a/OpenSim/Data/Null/NullFriendsData.cs
+++ b/OpenSim/Data/Null/NullFriendsData.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Data.Null
79 { 79 {
80 return fdata.PrincipalID == userID.ToString(); 80 return fdata.PrincipalID == userID.ToString();
81 }); 81 });
82 82
83 if (lst != null) 83 if (lst != null)
84 { 84 {
85 lst.ForEach(f => 85 lst.ForEach(f =>
@@ -87,14 +87,14 @@ namespace OpenSim.Data.Null
87 FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID); 87 FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID);
88 if (f2 != null) 88 if (f2 != null)
89 f.Data["TheirFlags"] = f2.Data["Flags"]; 89 f.Data["TheirFlags"] = f2.Data["Flags"];
90 90
91 // m_log.DebugFormat( 91 // m_log.DebugFormat(
92 // "[NULL FRIENDS DATA]: Got {0} {1} {2} for {3}", 92 // "[NULL FRIENDS DATA]: Got {0} {1} {2} for {3}",
93 // f.Friend, f.Data["Flags"], f2 != null ? f.Data["TheirFlags"] : "not found!", f.PrincipalID); 93 // f.Friend, f.Data["Flags"], f2 != null ? f.Data["TheirFlags"] : "not found!", f.PrincipalID);
94 }); 94 });
95 95
96 // m_log.DebugFormat("[NULL FRIENDS DATA]: Got {0} friends for {1}", lst.Count, userID); 96 // m_log.DebugFormat("[NULL FRIENDS DATA]: Got {0} friends for {1}", lst.Count, userID);
97 97
98 return lst.ToArray(); 98 return lst.ToArray();
99 } 99 }
100 } 100 }
@@ -134,7 +134,7 @@ namespace OpenSim.Data.Null
134 // m_log.DebugFormat( 134 // m_log.DebugFormat(
135 // "[NULL FRIENDS DATA]: Deleting friend {0} {1} for {2}", 135 // "[NULL FRIENDS DATA]: Deleting friend {0} {1} for {2}",
136 // friend.Friend, friend.Data["Flags"], friend.PrincipalID); 136 // friend.Friend, friend.Data["Flags"], friend.PrincipalID);
137 137
138 m_Data.Remove(friend); 138 m_Data.Remove(friend);
139 return true; 139 return true;
140 } 140 }
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs
index aff0b0b..8c442c9 100644
--- a/OpenSim/Data/Null/NullPresenceData.cs
+++ b/OpenSim/Data/Null/NullPresenceData.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Data.Null
39 public class NullPresenceData : IPresenceData 39 public class NullPresenceData : IPresenceData
40 { 40 {
41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 public static NullPresenceData Instance; 43 public static NullPresenceData Instance;
44 44
45 Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>(); 45 Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>();
@@ -100,7 +100,7 @@ namespace OpenSim.Data.Null
100 { 100 {
101 if (Instance != this) 101 if (Instance != this)
102 return Instance.ReportAgent(sessionID, regionID); 102 return Instance.ReportAgent(sessionID, regionID);
103 103
104 if (m_presenceData.ContainsKey(sessionID)) 104 if (m_presenceData.ContainsKey(sessionID))
105 { 105 {
106 m_presenceData[sessionID].RegionID = regionID; 106 m_presenceData[sessionID].RegionID = regionID;
@@ -129,7 +129,7 @@ namespace OpenSim.Data.Null
129// Console.WriteLine("HOME for " + p.UserID + " is " + (p.Data.ContainsKey("HomeRegionID") ? p.Data["HomeRegionID"] : "Not found")); 129// Console.WriteLine("HOME for " + p.UserID + " is " + (p.Data.ContainsKey("HomeRegionID") ? p.Data["HomeRegionID"] : "Not found"));
130 } 130 }
131 } 131 }
132 132
133 return presences.ToArray(); 133 return presences.ToArray();
134 } 134 }
135 else if (field == "SessionID") 135 else if (field == "SessionID")
@@ -172,7 +172,7 @@ namespace OpenSim.Data.Null
172 { 172 {
173// m_log.DebugFormat( 173// m_log.DebugFormat(
174// "[NULL PRESENCE DATA]: Deleting presence data for field {0} with parameter {1}", field, data); 174// "[NULL PRESENCE DATA]: Deleting presence data for field {0} with parameter {1}", field, data);
175 175
176 if (Instance != this) 176 if (Instance != this)
177 return Instance.Delete(field, data); 177 return Instance.Delete(field, data);
178 178
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index d28cd99..595db2f 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -134,21 +134,22 @@ namespace OpenSim.Data.Null
134 if (m_useStaticInstance && Instance != this) 134 if (m_useStaticInstance && Instance != this)
135 return Instance.Get(posX, posY, scopeID); 135 return Instance.Get(posX, posY, scopeID);
136 136
137 List<RegionData> ret = new List<RegionData>(); 137 RegionData ret = null;
138 138
139 lock (m_regionData) 139 lock (m_regionData)
140 { 140 {
141 foreach (RegionData r in m_regionData.Values) 141 foreach (RegionData r in m_regionData.Values)
142 { 142 {
143 if (r.posX == posX && r.posY == posY) 143 if (posX >= r.posX && posX < r.posX + r.sizeX
144 ret.Add(r); 144 && posY >= r.posY && posY < r.posY + r.sizeY)
145 {
146 ret = r;
147 break;
148 }
145 } 149 }
146 } 150 }
147 151
148 if (ret.Count > 0) 152 return ret;
149 return ret[0];
150
151 return null;
152 } 153 }
153 154
154 public RegionData Get(UUID regionID, UUID scopeID) 155 public RegionData Get(UUID regionID, UUID scopeID)
@@ -176,8 +177,9 @@ namespace OpenSim.Data.Null
176 { 177 {
177 foreach (RegionData r in m_regionData.Values) 178 foreach (RegionData r in m_regionData.Values)
178 { 179 {
179 if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY) 180 if (r.posX + r.sizeX > startX && r.posX <= endX
180 ret.Add(r); 181 && r.posY + r.sizeX > startY && r.posY <= endY)
182 ret.Add(r);
181 } 183 }
182 } 184 }
183 185
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs
index deeaced..7bb6da3 100644
--- a/OpenSim/Data/Null/NullSimulationData.cs
+++ b/OpenSim/Data/Null/NullSimulationData.cs
@@ -133,6 +133,7 @@ namespace OpenSim.Data.Null
133 } 133 }
134 134
135 Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); 135 Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
136 Dictionary<UUID, TerrainData> m_bakedterrains = new Dictionary<UUID, TerrainData>();
136 public void StoreTerrain(TerrainData ter, UUID regionID) 137 public void StoreTerrain(TerrainData ter, UUID regionID)
137 { 138 {
138 if (m_terrains.ContainsKey(regionID)) 139 if (m_terrains.ContainsKey(regionID))
@@ -140,6 +141,13 @@ namespace OpenSim.Data.Null
140 m_terrains.Add(regionID, ter); 141 m_terrains.Add(regionID, ter);
141 } 142 }
142 143
144 public void StoreBakedTerrain(TerrainData ter, UUID regionID)
145 {
146 if (m_bakedterrains.ContainsKey(regionID))
147 m_bakedterrains.Remove(regionID);
148 m_bakedterrains.Add(regionID, ter);
149 }
150
143 // Legacy. Just don't do this. 151 // Legacy. Just don't do this.
144 public void StoreTerrain(double[,] ter, UUID regionID) 152 public void StoreTerrain(double[,] ter, UUID regionID)
145 { 153 {
@@ -167,6 +175,15 @@ namespace OpenSim.Data.Null
167 return null; 175 return null;
168 } 176 }
169 177
178 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
179 {
180 if (m_bakedterrains.ContainsKey(regionID))
181 {
182 return m_bakedterrains[regionID];
183 }
184 return null;
185 }
186
170 public void RemoveLandObject(UUID globalID) 187 public void RemoveLandObject(UUID globalID)
171 { 188 {
172 } 189 }
@@ -184,6 +201,11 @@ namespace OpenSim.Data.Null
184 { 201 {
185 } 202 }
186 203
204 public UUID[] GetObjectIDs(UUID regionID)
205 {
206 return new UUID[0];
207 }
208
187 public void SaveExtra(UUID regionID, string name, string value) 209 public void SaveExtra(UUID regionID, string name, string value)
188 { 210 {
189 } 211 }
diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs
index ec54dba..6d2e05a 100644
--- a/OpenSim/Data/Null/NullUserAccountData.cs
+++ b/OpenSim/Data/Null/NullUserAccountData.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Data.Null
40 public class NullUserAccountData : IUserAccountData 40 public class NullUserAccountData : IUserAccountData
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>(); 44 private Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>();
45 private Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>(); 45 private Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>();
46 private Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>(); 46 private Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>();
@@ -48,7 +48,7 @@ namespace OpenSim.Data.Null
48 public NullUserAccountData(string connectionString, string realm) 48 public NullUserAccountData(string connectionString, string realm)
49 { 49 {
50// m_log.DebugFormat( 50// m_log.DebugFormat(
51// "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]", 51// "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]",
52// connectionString, realm); 52// connectionString, realm);
53 } 53 }
54 54
@@ -65,12 +65,12 @@ namespace OpenSim.Data.Null
65// if (m_log.IsDebugEnabled) 65// if (m_log.IsDebugEnabled)
66// { 66// {
67// m_log.DebugFormat( 67// m_log.DebugFormat(
68// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]", 68// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]",
69// string.Join(", ", fields), string.Join(", ", values)); 69// string.Join(", ", fields), string.Join(", ", values));
70// } 70// }
71 71
72 UserAccountData[] userAccounts = new UserAccountData[0]; 72 UserAccountData[] userAccounts = new UserAccountData[0];
73 73
74 List<string> fieldsLst = new List<string>(fields); 74 List<string> fieldsLst = new List<string>(fields);
75 if (fieldsLst.Contains("PrincipalID")) 75 if (fieldsLst.Contains("PrincipalID"))
76 { 76 {
@@ -79,33 +79,33 @@ namespace OpenSim.Data.Null
79 if (UUID.TryParse(values[i], out id)) 79 if (UUID.TryParse(values[i], out id))
80 if (m_DataByUUID.ContainsKey(id)) 80 if (m_DataByUUID.ContainsKey(id))
81 userAccounts = new UserAccountData[] { m_DataByUUID[id] }; 81 userAccounts = new UserAccountData[] { m_DataByUUID[id] };
82 } 82 }
83 else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) 83 else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName"))
84 { 84 {
85 int findex = fieldsLst.IndexOf("FirstName"); 85 int findex = fieldsLst.IndexOf("FirstName");
86 int lindex = fieldsLst.IndexOf("LastName"); 86 int lindex = fieldsLst.IndexOf("LastName");
87 if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex])) 87 if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex]))
88 { 88 {
89 userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; 89 userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] };
90 } 90 }
91 } 91 }
92 else if (fieldsLst.Contains("Email")) 92 else if (fieldsLst.Contains("Email"))
93 { 93 {
94 int i = fieldsLst.IndexOf("Email"); 94 int i = fieldsLst.IndexOf("Email");
95 if (m_DataByEmail.ContainsKey(values[i])) 95 if (m_DataByEmail.ContainsKey(values[i]))
96 userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] }; 96 userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] };
97 } 97 }
98 98
99// if (m_log.IsDebugEnabled) 99// if (m_log.IsDebugEnabled)
100// { 100// {
101// StringBuilder sb = new StringBuilder(); 101// StringBuilder sb = new StringBuilder();
102// foreach (UserAccountData uad in userAccounts) 102// foreach (UserAccountData uad in userAccounts)
103// sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID); 103// sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID);
104// 104//
105// m_log.DebugFormat( 105// m_log.DebugFormat(
106// "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb); 106// "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb);
107// } 107// }
108 108
109 return userAccounts; 109 return userAccounts;
110 } 110 }
111 111
@@ -113,16 +113,16 @@ namespace OpenSim.Data.Null
113 { 113 {
114 if (data == null) 114 if (data == null)
115 return false; 115 return false;
116 116
117 m_log.DebugFormat( 117 m_log.DebugFormat(
118 "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}", 118 "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}",
119 data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode()); 119 data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode());
120 120
121 m_DataByUUID[data.PrincipalID] = data; 121 m_DataByUUID[data.PrincipalID] = data;
122 m_DataByName[data.FirstName + " " + data.LastName] = data; 122 m_DataByName[data.FirstName + " " + data.LastName] = data;
123 if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty) 123 if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty)
124 m_DataByEmail[data.Data["Email"]] = data; 124 m_DataByEmail[data.Data["Email"]] = data;
125 125
126// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count); 126// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count);
127 127
128 return true; 128 return true;
@@ -132,7 +132,7 @@ namespace OpenSim.Data.Null
132 { 132 {
133// m_log.DebugFormat( 133// m_log.DebugFormat(
134// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query); 134// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query);
135 135
136 string[] words = query.Split(new char[] { ' ' }); 136 string[] words = query.Split(new char[] { ' ' });
137 137
138 for (int i = 0; i < words.Length; i++) 138 for (int i = 0; i < words.Length; i++)
@@ -193,5 +193,10 @@ namespace OpenSim.Data.Null
193 193
194 return false; 194 return false;
195 } 195 }
196
197 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
198 {
199 return null;
200 }
196 } 201 }
197} 202}
diff --git a/OpenSim/Data/Null/Properties/AssemblyInfo.cs b/OpenSim/Data/Null/Properties/AssemblyInfo.cs
index a827bd0..508f1c7 100644
--- a/OpenSim/Data/Null/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/Null/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/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;
diff --git a/OpenSim/Data/Properties/AssemblyInfo.cs b/OpenSim/Data/Properties/AssemblyInfo.cs
index b1f234b..92c48bc 100644
--- a/OpenSim/Data/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/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/SQLite/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs
index d2e62d2..9884f74 100644
--- a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/SQLite/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/SQLite/Resources/AgentPrefs.migrations b/OpenSim/Data/SQLite/Resources/AgentPrefs.migrations
index 7e0525d..8c2663e 100644
--- a/OpenSim/Data/SQLite/Resources/AgentPrefs.migrations
+++ b/OpenSim/Data/SQLite/Resources/AgentPrefs.migrations
@@ -11,7 +11,7 @@ CREATE TABLE `AgentPrefs` (
11 `PermEveryone` INT(6) NOT NULL DEFAULT 0, 11 `PermEveryone` INT(6) NOT NULL DEFAULT 0,
12 `PermGroup` INT(6) NOT NULL DEFAULT 0, 12 `PermGroup` INT(6) NOT NULL DEFAULT 0,
13 `PermNextOwner` INT(6) NOT NULL DEFAULT 532480, 13 `PermNextOwner` INT(6) NOT NULL DEFAULT 532480,
14 UNIQUE KEY `PrincipalID` (`PrincipalID`), 14 UNIQUE (`PrincipalID`),
15 PRIMARY KEY(`PrincipalID`)); 15 PRIMARY KEY(`PrincipalID`));
16 16
17COMMIT; 17COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/AssetStore.migrations b/OpenSim/Data/SQLite/Resources/AssetStore.migrations
index f20631c..0743c45 100644
--- a/OpenSim/Data/SQLite/Resources/AssetStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/AssetStore.migrations
@@ -1,66 +1,17 @@
1:VERSION 1 1:VERSION 6
2 2
3BEGIN TRANSACTION; 3BEGIN TRANSACTION;
4CREATE TABLE assets(
5 UUID varchar(255) primary key,
6 Name varchar(255),
7 Description varchar(255),
8 Type integer,
9 InvType integer,
10 Local integer,
11 Temporary integer,
12 Data blob);
13 4
14COMMIT; 5CREATE TABLE IF NOT EXISTS assets(
15 6 UUID NOT NULL PRIMARY KEY,
16:VERSION 2 7 Name,
17 8 Description,
18BEGIN TRANSACTION; 9 Type,
19 10 Local,
20CREATE TEMPORARY TABLE assets_backup(UUID,Name,Description,Type,Local,Temporary,Data); 11 Temporary,
21INSERT INTO assets_backup SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets; 12 asset_flags INTEGER NOT NULL DEFAULT 0,
22DROP TABLE assets; 13 CreatorID varchar(128) default '',
23CREATE TABLE assets(UUID,Name,Description,Type,Local,Temporary,Data); 14 Data);
24INSERT INTO assets SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets_backup;
25DROP TABLE assets_backup;
26
27COMMIT;
28
29:VERSION 3
30
31DELETE FROM assets WHERE UUID = 'dc4b9f0bd00845c696a401dd947ac621'
32
33:VERSION 4
34
35BEGIN;
36
37update assets
38 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
39 where UUID not like '%-%';
40
41COMMIT;
42
43:VERSION 5
44
45BEGIN TRANSACTION;
46
47CREATE TEMPORARY TABLE assets_backup(UUID,Name,Description,Type,Local,Temporary,Data);
48INSERT INTO assets_backup SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets;
49DROP TABLE assets;
50CREATE TABLE assets(
51 UUID NOT NULL PRIMARY KEY,
52 Name,
53 Description,
54 Type,
55 Local,
56 Temporary,
57 asset_flags INTEGER NOT NULL DEFAULT 0,
58 CreatorID varchar(128) default '',
59 Data);
60
61INSERT INTO assets(UUID,Name,Description,Type,Local,Temporary,Data)
62SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets_backup;
63DROP TABLE assets_backup;
64 15
65COMMIT; 16COMMIT;
66 17
diff --git a/OpenSim/Data/SQLite/Resources/EstateStore.migrations b/OpenSim/Data/SQLite/Resources/EstateStore.migrations
index 0aec49b..37fa1d9 100644
--- a/OpenSim/Data/SQLite/Resources/EstateStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/EstateStore.migrations
@@ -1,23 +1,27 @@
1:VERSION 6 1:VERSION 10
2 2
3BEGIN TRANSACTION; 3BEGIN TRANSACTION;
4 4
5CREATE TABLE estate_groups ( 5CREATE TABLE IF NOT EXISTS estate_groups (
6 EstateID int(10) NOT NULL, 6 EstateID int(10) NOT NULL,
7 uuid char(36) NOT NULL 7 uuid char(36) NOT NULL
8); 8);
9CREATE INDEX estate_groups_estate_id on estate_groups(EstateID);
9 10
10CREATE TABLE estate_managers ( 11CREATE TABLE IF NOT EXISTS estate_managers (
11 EstateID int(10) NOT NULL, 12 EstateID int(10) NOT NULL,
12 uuid char(36) NOT NULL 13 uuid char(36) NOT NULL
13); 14);
15CREATE INDEX estate_managers_estate_id on estate_managers(EstateID);
14 16
15CREATE TABLE estate_map ( 17CREATE TABLE IF NOT EXISTS estate_map (
16 RegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', 18 RegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
17 EstateID int(11) NOT NULL 19 EstateID int(11) NOT NULL
18); 20);
21CREATE INDEX estate_map_estate_id on estate_map(EstateID);
22CREATE UNIQUE INDEX estate_map_region_id on estate_map(RegionID);
19 23
20CREATE TABLE estate_settings ( 24CREATE TABLE IF NOT EXISTS estate_settings (
21 EstateID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 25 EstateID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
22 EstateName varchar(64) default NULL, 26 EstateName varchar(64) default NULL,
23 AbuseEmailToEstateOwner tinyint(4) NOT NULL, 27 AbuseEmailToEstateOwner tinyint(4) NOT NULL,
@@ -38,60 +42,28 @@ CREATE TABLE estate_settings (
38 SunPosition double NOT NULL, 42 SunPosition double NOT NULL,
39 EstateSkipScripts tinyint(4) NOT NULL, 43 EstateSkipScripts tinyint(4) NOT NULL,
40 BillableFactor float NOT NULL, 44 BillableFactor float NOT NULL,
41 PublicAccess tinyint(4) NOT NULL 45 PublicAccess tinyint(4) NOT NULL,
42); 46 AbuseEmail varchar(255) not null default '',
43 47 EstateOwner varchar(36) not null default '',
44insert into estate_settings ( 48 DenyMinors tinyint not null default 0,
45 EstateID,EstateName,AbuseEmailToEstateOwner,DenyAnonymous,ResetHomeOnTeleport,FixedSun,DenyTransacted,BlockDwell,DenyIdentified,AllowVoice,UseGlobalTime,PricePerMeter,TaxFree,AllowDirectTeleport,RedirectGridX,RedirectGridY,ParentEstateID,SunPosition,PublicAccess,EstateSkipScripts,BillableFactor) 49 AllowLandmark tinyint not null default '1',
46 values ( 99, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); 50 AllowParcelChanges tinyint not null default '1',
47delete from estate_settings; 51 AllowSetHome tinyint not null default '1');
48 52
49CREATE TABLE estate_users ( 53CREATE TABLE IF NOT EXISTS estate_users (
50 EstateID int(10) NOT NULL, 54 EstateID int(10) NOT NULL,
51 uuid char(36) NOT NULL 55 uuid char(36) NOT NULL
52); 56);
57CREATE INDEX estate_users_estate_id on estate_users(EstateID);
53 58
54CREATE TABLE estateban ( 59CREATE TABLE IF NOT EXISTS estateban (
55 EstateID int(10) NOT NULL, 60 EstateID int(10) NOT NULL,
56 bannedUUID varchar(36) NOT NULL, 61 bannedUUID varchar(36) NOT NULL,
57 bannedIp varchar(16) NOT NULL, 62 bannedIp varchar(16) NOT NULL,
58 bannedIpHostMask varchar(16) NOT NULL, 63 bannedIpHostMask varchar(16) NOT NULL,
59 bannedNameMask varchar(64) default NULL 64 bannedNameMask varchar(64) default NULL
60); 65);
61
62CREATE INDEX estate_ban_estate_id on estateban(EstateID); 66CREATE INDEX estate_ban_estate_id on estateban(EstateID);
63CREATE INDEX estate_groups_estate_id on estate_groups(EstateID);
64CREATE INDEX estate_managers_estate_id on estate_managers(EstateID);
65CREATE INDEX estate_map_estate_id on estate_map(EstateID);
66CREATE UNIQUE INDEX estate_map_region_id on estate_map(RegionID);
67CREATE INDEX estate_users_estate_id on estate_users(EstateID);
68 67
69COMMIT; 68COMMIT;
70 69
71
72:VERSION 7
73
74begin;
75
76alter table estate_settings add column AbuseEmail varchar(255) not null default '';
77
78alter table estate_settings add column EstateOwner varchar(36) not null default '';
79
80commit;
81
82:VERSION 8
83
84begin;
85
86alter table estate_settings add column DenyMinors tinyint not null default 0;
87
88commit;
89
90:VERSION 9
91
92begin;
93alter table estate_settings add column AllowLandmark tinyint not null default '1';
94alter table estate_settings add column AllowParcelChanges tinyint not null default '1';
95alter table estate_settings add column AllowSetHome tinyint not null default '1';
96commit;
97
diff --git a/OpenSim/Data/SQLite/Resources/InventoryStore.migrations b/OpenSim/Data/SQLite/Resources/InventoryStore.migrations
deleted file mode 100644
index 585ac49..0000000
--- a/OpenSim/Data/SQLite/Resources/InventoryStore.migrations
+++ /dev/null
@@ -1,92 +0,0 @@
1:VERSION 1
2
3BEGIN TRANSACTION;
4
5CREATE TABLE inventoryfolders(
6 UUID varchar(255) primary key,
7 name varchar(255),
8 agentID varchar(255),
9 parentID varchar(255),
10 type integer,
11 version integer);
12
13CREATE TABLE inventoryitems(
14 UUID varchar(255) primary key,
15 assetID varchar(255),
16 assetType integer,
17 invType integer,
18 parentFolderID varchar(255),
19 avatarID varchar(255),
20 creatorsID varchar(255),
21 inventoryName varchar(255),
22 inventoryDescription varchar(255),
23 inventoryNextPermissions integer,
24 inventoryCurrentPermissions integer,
25 inventoryBasePermissions integer,
26 inventoryEveryOnePermissions integer,
27 salePrice integer default 99,
28 saleType integer default 0,
29 creationDate integer default 2000,
30 groupID varchar(255) default '00000000-0000-0000-0000-000000000000',
31 groupOwned integer default 0,
32 flags integer default 0);
33
34COMMIT;
35
36:VERSION 2
37
38BEGIN TRANSACTION;
39
40create index inventoryfolders_agentid on inventoryfolders(agentid);
41create index inventoryfolders_parentid on inventoryfolders(parentid);
42create index inventoryitems_parentfolderid on inventoryitems(parentfolderid);
43create index inventoryitems_avatarid on inventoryitems(avatarid);
44
45COMMIT;
46
47:VERSION 3
48
49BEGIN;
50
51alter table inventoryitems add column inventoryGroupPermissions integer unsigned not null default 0;
52
53COMMIT;
54
55:VERSION 4
56
57BEGIN;
58
59update inventoryitems
60 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
61 where UUID not like '%-%';
62
63update inventoryitems
64 set assetID = substr(assetID, 1, 8) || "-" || substr(assetID, 9, 4) || "-" || substr(assetID, 13, 4) || "-" || substr(assetID, 17, 4) || "-" || substr(assetID, 21, 12)
65 where assetID not like '%-%';
66
67update inventoryitems
68 set parentFolderID = substr(parentFolderID, 1, 8) || "-" || substr(parentFolderID, 9, 4) || "-" || substr(parentFolderID, 13, 4) || "-" || substr(parentFolderID, 17, 4) || "-" || substr(parentFolderID, 21, 12)
69 where parentFolderID not like '%-%';
70
71update inventoryitems
72 set avatarID = substr(avatarID, 1, 8) || "-" || substr(avatarID, 9, 4) || "-" || substr(avatarID, 13, 4) || "-" || substr(avatarID, 17, 4) || "-" || substr(avatarID, 21, 12)
73 where avatarID not like '%-%';
74
75update inventoryitems
76 set creatorsID = substr(creatorsID, 1, 8) || "-" || substr(creatorsID, 9, 4) || "-" || substr(creatorsID, 13, 4) || "-" || substr(creatorsID, 17, 4) || "-" || substr(creatorsID, 21, 12)
77 where creatorsID not like '%-%';
78
79
80update inventoryfolders
81 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
82 where UUID not like '%-%';
83
84update inventoryfolders
85 set agentID = substr(agentID, 1, 8) || "-" || substr(agentID, 9, 4) || "-" || substr(agentID, 13, 4) || "-" || substr(agentID, 17, 4) || "-" || substr(agentID, 21, 12)
86 where agentID not like '%-%';
87
88update inventoryfolders
89 set parentID = substr(parentID, 1, 8) || "-" || substr(parentID, 9, 4) || "-" || substr(parentID, 13, 4) || "-" || substr(parentID, 17, 4) || "-" || substr(parentID, 21, 12)
90 where parentID not like '%-%';
91
92COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
index 901068f..fb154cf 100644
--- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
@@ -1,56 +1,99 @@
1:VERSION 1 1:VERSION 31
2 2
3BEGIN TRANSACTION; 3BEGIN TRANSACTION;
4 4
5CREATE TABLE prims( 5CREATE TABLE IF NOT EXISTS prims(
6 UUID varchar(255) primary key, 6 UUID varchar(255) primary key,
7 RegionUUID varchar(255), 7 RegionUUID varchar(255),
8 ParentID integer, 8 CreationDate integer,
9 CreationDate integer, 9 Name varchar(255),
10 Name varchar(255), 10 SceneGroupID varchar(255),
11 SceneGroupID varchar(255), 11 Text varchar(255),
12 Text varchar(255), 12 Description varchar(255),
13 Description varchar(255), 13 SitName varchar(255),
14 SitName varchar(255), 14 TouchName varchar(255),
15 TouchName varchar(255), 15 CreatorID varchar(255),
16 CreatorID varchar(255), 16 OwnerID varchar(255),
17 OwnerID varchar(255), 17 GroupID varchar(255),
18 GroupID varchar(255), 18 LastOwnerID varchar(255),
19 LastOwnerID varchar(255), 19 OwnerMask integer,
20 OwnerMask integer, 20 NextOwnerMask integer,
21 NextOwnerMask integer, 21 GroupMask integer,
22 GroupMask integer, 22 EveryoneMask integer,
23 EveryoneMask integer, 23 BaseMask integer,
24 BaseMask integer, 24 PositionX float,
25 PositionX float, 25 PositionY float,
26 PositionY float, 26 PositionZ float,
27 PositionZ float, 27 GroupPositionX float,
28 GroupPositionX float, 28 GroupPositionY float,
29 GroupPositionY float, 29 GroupPositionZ float,
30 GroupPositionZ float, 30 VelocityX float,
31 VelocityX float, 31 VelocityY float,
32 VelocityY float, 32 VelocityZ float,
33 VelocityZ float, 33 AngularVelocityX float,
34 AngularVelocityX float, 34 AngularVelocityY float,
35 AngularVelocityY float, 35 AngularVelocityZ float,
36 AngularVelocityZ float, 36 AccelerationX float,
37 AccelerationX float, 37 AccelerationY float,
38 AccelerationY float, 38 AccelerationZ float,
39 AccelerationZ float, 39 RotationX float,
40 RotationX float, 40 RotationY float,
41 RotationY float, 41 RotationZ float,
42 RotationZ float, 42 RotationW float,
43 RotationW float, 43 ObjectFlags integer,
44 ObjectFlags integer, 44 SitTargetOffsetX float NOT NULL default 0,
45 SitTargetOffsetX float NOT NULL default 0, 45 SitTargetOffsetY float NOT NULL default 0,
46 SitTargetOffsetY float NOT NULL default 0, 46 SitTargetOffsetZ float NOT NULL default 0,
47 SitTargetOffsetZ float NOT NULL default 0, 47 SitTargetOrientW float NOT NULL default 0,
48 SitTargetOrientW float NOT NULL default 0, 48 SitTargetOrientX float NOT NULL default 0,
49 SitTargetOrientX float NOT NULL default 0, 49 SitTargetOrientY float NOT NULL default 0,
50 SitTargetOrientY float NOT NULL default 0, 50 SitTargetOrientZ float NOT NULL default 0,
51 SitTargetOrientZ float NOT NULL default 0); 51 ColorR integer not null default 0,
52 52 ColorG integer not null default 0,
53CREATE TABLE primshapes( 53 ColorB integer not null default 0,
54 ColorA integer not null default 0,
55 ClickAction integer not null default 0,
56 PayPrice integer not null default 0,
57 PayButton1 integer not null default 0,
58 PayButton2 integer not null default 0,
59 PayButton3 integer not null default 0,
60 PayButton4 integer not null default 0,
61 LoopedSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
62 LoopedSoundGain float NOT NULL default 0,
63 TextureAnimation string,
64 ParticleSystem string,
65 OmegaX float NOT NULL default 0,
66 OmegaY float NOT NULL default 0,
67 OmegaZ float NOT NULL default 0,
68 CameraEyeOffsetX float NOT NULL default 0,
69 CameraEyeOffsetY float NOT NULL default 0,
70 CameraEyeOffsetZ float NOT NULL default 0,
71 CameraAtOffsetX float NOT NULL default 0,
72 CameraAtOffsetY float NOT NULL default 0,
73 CameraAtOffsetZ float NOT NULL default 0,
74 ForceMouselook string NOT NULL default 0,
75 ScriptAccessPin INTEGER NOT NULL default 0,
76 AllowedDrop INTEGER NOT NULL default 0,
77 DieAtEdge string NOT NULL default 0,
78 SalePrice INTEGER NOT NULL default 0,
79 SaleType string NOT NULL default 0,
80 Material INTEGER NOT NULL default 3,
81 CollisionSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
82 CollisionSoundVolume float NOT NULL default 0,
83 VolumeDetect INTEGER NOT NULL DEFAULT 0,
84 MediaURL varchar(255),
85 DynAttrs TEXT,
86 `PhysicsShapeType` tinyint(4) NOT NULL default '0',
87 `Density` double NOT NULL default '1000',
88 `GravityModifier` double NOT NULL default '1',
89 `Friction` double NOT NULL default '0.6',
90 `Restitution` double NOT NULL default '0.5',
91 `KeyframeMotion` blob,
92 AttachedPosX double default '0',
93 AttachedPosY double default '0',
94 AttachedPosZ double default '0');
95
96CREATE TABLE IF NOT EXISTS primshapes(
54 UUID varchar(255) primary key, 97 UUID varchar(255) primary key,
55 Shape integer, 98 Shape integer,
56 ScaleX float, 99 ScaleX float,
@@ -76,10 +119,12 @@ CREATE TABLE primshapes(
76 ProfileCurve integer, 119 ProfileCurve integer,
77 ProfileHollow integer, 120 ProfileHollow integer,
78 Texture blob, 121 Texture blob,
79 ExtraParams blob, 122 ExtraParams blob,
80 State Integer NOT NULL default 0); 123 State Integer NOT NULL default 0,
124 Media TEXT,
125 LastAttachPoint int not null default '0');
81 126
82CREATE TABLE primitems( 127CREATE TABLE IF NOT EXISTS primitems(
83 itemID varchar(255) primary key, 128 itemID varchar(255) primary key,
84 primID varchar(255), 129 primID varchar(255),
85 assetID varchar(255), 130 assetID varchar(255),
@@ -97,14 +142,15 @@ CREATE TABLE primitems(
97 currentPermissions string, 142 currentPermissions string,
98 basePermissions string, 143 basePermissions string,
99 everyonePermissions string, 144 everyonePermissions string,
100 groupPermissions string); 145 groupPermissions string,
146 flags integer not null default 0);
101 147
102CREATE TABLE terrain( 148CREATE TABLE IF NOT EXISTS terrain(
103 RegionUUID varchar(255), 149 RegionUUID varchar(255),
104 Revision integer, 150 Revision integer,
105 Heightfield blob); 151 Heightfield blob);
106 152
107CREATE TABLE land( 153CREATE TABLE IF NOT EXISTS land(
108 UUID varchar(255) primary key, 154 UUID varchar(255) primary key,
109 RegionUUID varchar(255), 155 RegionUUID varchar(255),
110 LocalLandID string, 156 LocalLandID string,
@@ -135,92 +181,30 @@ CREATE TABLE land(
135 UserLocationZ float, 181 UserLocationZ float,
136 UserLookAtX float, 182 UserLookAtX float,
137 UserLookAtY float, 183 UserLookAtY float,
138 UserLookAtZ float, 184 UserLookAtZ float,
139 AuthbuyerID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'); 185 AuthbuyerID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
140 186 OtherCleanTime INTEGER NOT NULL default 0,
141CREATE TABLE landaccesslist( 187 Dwell INTEGER NOT NULL default 0,
188 `MediaType` VARCHAR(32) NOT NULL DEFAULT 'none/none',
189 `MediaDescription` VARCHAR(255) NOT NULL DEFAULT '',
190 `MediaSize` VARCHAR(16) NOT NULL DEFAULT '0,0',
191 `MediaLoop` BOOLEAN NOT NULL DEFAULT FALSE,
192 `ObscureMusic` BOOLEAN NOT NULL DEFAULT FALSE,
193 `ObscureMedia` BOOLEAN NOT NULL DEFAULT FALSE);
194
195CREATE TABLE IF NOT EXISTS landaccesslist(
142 LandUUID varchar(255), 196 LandUUID varchar(255),
143 AccessUUID varchar(255), 197 AccessUUID varchar(255),
144 Flags string); 198 Flags string);
145 199
146COMMIT; 200CREATE TABLE IF NOT EXISTS regionban(
147 201 regionUUID varchar (255),
148:VERSION 2 202 bannedUUID varchar (255),
149 203 bannedIp varchar (255),
150BEGIN TRANSACTION; 204 bannedIpHostMask varchar (255)
151 205 );
152CREATE TABLE regionban(
153 regionUUID varchar (255),
154 bannedUUID varchar (255),
155 bannedIp varchar (255),
156 bannedIpHostMask varchar (255)
157 );
158
159COMMIT;
160
161:VERSION 3
162
163BEGIN;
164
165ALTER TABLE primitems add flags integer not null default 0;
166
167COMMIT;
168
169:VERSION 4
170
171BEGIN;
172
173create table regionsettings (
174 regionUUID char(36) not null,
175 block_terraform integer not null,
176 block_fly integer not null,
177 allow_damage integer not null,
178 restrict_pushing integer not null,
179 allow_land_resell integer not null,
180 allow_land_join_divide integer not null,
181 block_show_in_search integer not null,
182 agent_limit integer not null,
183 object_bonus float not null,
184 maturity integer not null,
185 disable_scripts integer not null,
186 disable_collisions integer not null,
187 disable_physics integer not null,
188 terrain_texture_1 char(36) not null,
189 terrain_texture_2 char(36) not null,
190 terrain_texture_3 char(36) not null,
191 terrain_texture_4 char(36) not null,
192 elevation_1_nw float not null,
193 elevation_2_nw float not null,
194 elevation_1_ne float not null,
195 elevation_2_ne float not null,
196 elevation_1_se float not null,
197 elevation_2_se float not null,
198 elevation_1_sw float not null,
199 elevation_2_sw float not null,
200 water_height float not null,
201 terrain_raise_limit float not null,
202 terrain_lower_limit float not null,
203 use_estate_sun integer not null,
204 fixed_sun integer not null,
205 sun_position float not null,
206 covenant char(36));
207
208COMMIT;
209
210:VERSION 5
211
212BEGIN;
213
214delete from regionsettings;
215
216COMMIT;
217
218:VERSION 6
219 206
220BEGIN TRANSACTION; 207CREATE TABLE IF NOT EXISTS regionsettings (
221
222drop table regionsettings;
223CREATE TABLE regionsettings (
224 regionUUID char(36) NOT NULL, 208 regionUUID char(36) NOT NULL,
225 block_terraform int(11) NOT NULL, 209 block_terraform int(11) NOT NULL,
226 block_fly int(11) NOT NULL, 210 block_fly int(11) NOT NULL,
@@ -254,228 +238,18 @@ CREATE TABLE regionsettings (
254 fixed_sun int(11) NOT NULL, 238 fixed_sun int(11) NOT NULL,
255 sun_position float NOT NULL, 239 sun_position float NOT NULL,
256 covenant char(36) default NULL, 240 covenant char(36) default NULL,
257 sandbox tinyint(4) NOT NULL, 241 sandbox tinyint(4) NOT NULL,
242 sunvectorx double NOT NULL default 0,
243 sunvectory double NOT NULL default 0,
244 sunvectorz double NOT NULL default 0,
245 map_tile_ID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000',
246 covenant_datetime INTEGER NOT NULL default 0,
247 `TelehubObject` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
248 `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
258 PRIMARY KEY (regionUUID) 249 PRIMARY KEY (regionUUID)
259); 250);
260 251
261COMMIT; 252CREATE TABLE IF NOT EXISTS regionwindlight (
262
263:VERSION 9
264
265BEGIN;
266
267ALTER TABLE prims ADD COLUMN ColorR integer not null default 0;
268ALTER TABLE prims ADD COLUMN ColorG integer not null default 0;
269ALTER TABLE prims ADD COLUMN ColorB integer not null default 0;
270ALTER TABLE prims ADD COLUMN ColorA integer not null default 0;
271
272COMMIT;
273
274:VERSION 10
275
276BEGIN;
277
278ALTER TABLE prims ADD COLUMN ClickAction INTEGER NOT NULL default 0;
279
280COMMIT;
281
282:VERSION 11
283
284BEGIN;
285
286ALTER TABLE prims ADD COLUMN PayPrice INTEGER NOT NULL default 0;
287ALTER TABLE prims ADD COLUMN PayButton1 INTEGER NOT NULL default 0;
288ALTER TABLE prims ADD COLUMN PayButton2 INTEGER NOT NULL default 0;
289ALTER TABLE prims ADD COLUMN PayButton3 INTEGER NOT NULL default 0;
290ALTER TABLE prims ADD COLUMN PayButton4 INTEGER NOT NULL default 0;
291ALTER TABLE prims ADD COLUMN LoopedSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
292ALTER TABLE prims ADD COLUMN LoopedSoundGain float NOT NULL default 0;
293ALTER TABLE prims ADD COLUMN TextureAnimation string;
294ALTER TABLE prims ADD COLUMN ParticleSystem string;
295ALTER TABLE prims ADD COLUMN OmegaX float NOT NULL default 0;
296ALTER TABLE prims ADD COLUMN OmegaY float NOT NULL default 0;
297ALTER TABLE prims ADD COLUMN OmegaZ float NOT NULL default 0;
298ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float NOT NULL default 0;
299ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float NOT NULL default 0;
300ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float NOT NULL default 0;
301ALTER TABLE prims ADD COLUMN CameraAtOffsetX float NOT NULL default 0;
302ALTER TABLE prims ADD COLUMN CameraAtOffsetY float NOT NULL default 0;
303ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float NOT NULL default 0;
304ALTER TABLE prims ADD COLUMN ForceMouselook string NOT NULL default 0;
305ALTER TABLE prims ADD COLUMN ScriptAccessPin INTEGER NOT NULL default 0;
306ALTER TABLE prims ADD COLUMN AllowedDrop INTEGER NOT NULL default 0;
307ALTER TABLE prims ADD COLUMN DieAtEdge string NOT NULL default 0;
308ALTER TABLE prims ADD COLUMN SalePrice INTEGER NOT NULL default 0;
309ALTER TABLE prims ADD COLUMN SaleType string NOT NULL default 0;
310
311COMMIT;
312
313:VERSION 12
314
315BEGIN;
316
317ALTER TABLE prims ADD COLUMN Material INTEGER NOT NULL default 3;
318
319COMMIT;
320
321:VERSION 13
322
323BEGIN;
324
325ALTER TABLE land ADD COLUMN OtherCleanTime INTEGER NOT NULL default 0;
326ALTER TABLE land ADD COLUMN Dwell INTEGER NOT NULL default 0;
327
328COMMIT;
329
330:VERSION 14
331
332begin;
333
334ALTER TABLE regionsettings ADD COLUMN sunvectorx double NOT NULL default 0;
335ALTER TABLE regionsettings ADD COLUMN sunvectory double NOT NULL default 0;
336ALTER TABLE regionsettings ADD COLUMN sunvectorz double NOT NULL default 0;
337
338commit;
339
340:VERSION 15
341
342BEGIN;
343
344ALTER TABLE prims ADD COLUMN CollisionSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
345ALTER TABLE prims ADD COLUMN CollisionSoundVolume float NOT NULL default 0;
346
347COMMIT;
348
349:VERSION 16
350
351BEGIN;
352
353ALTER TABLE prims ADD COLUMN VolumeDetect INTEGER NOT NULL DEFAULT 0;
354
355COMMIT;
356
357:VERSION 17
358
359BEGIN;
360CREATE TEMPORARY TABLE prims_backup(UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect);
361INSERT INTO prims_backup SELECT UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect FROM prims;
362DROP TABLE prims;
363CREATE TABLE prims(UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect);
364INSERT INTO prims SELECT UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect FROM prims_backup;
365DROP TABLE prims_backup;
366COMMIT;
367
368:VERSION 18
369
370BEGIN;
371
372update terrain
373 set RegionUUID = substr(RegionUUID, 1, 8) || "-" || substr(RegionUUID, 9, 4) || "-" || substr(RegionUUID, 13, 4) || "-" || substr(RegionUUID, 17, 4) || "-" || substr(RegionUUID, 21, 12)
374 where RegionUUID not like '%-%';
375
376
377update landaccesslist
378 set LandUUID = substr(LandUUID, 1, 8) || "-" || substr(LandUUID, 9, 4) || "-" || substr(LandUUID, 13, 4) || "-" || substr(LandUUID, 17, 4) || "-" || substr(LandUUID, 21, 12)
379 where LandUUID not like '%-%';
380
381update landaccesslist
382 set AccessUUID = substr(AccessUUID, 1, 8) || "-" || substr(AccessUUID, 9, 4) || "-" || substr(AccessUUID, 13, 4) || "-" || substr(AccessUUID, 17, 4) || "-" || substr(AccessUUID, 21, 12)
383 where AccessUUID not like '%-%';
384
385
386update prims
387 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
388 where UUID not like '%-%';
389
390update prims
391 set RegionUUID = substr(RegionUUID, 1, 8) || "-" || substr(RegionUUID, 9, 4) || "-" || substr(RegionUUID, 13, 4) || "-" || substr(RegionUUID, 17, 4) || "-" || substr(RegionUUID, 21, 12)
392 where RegionUUID not like '%-%';
393
394update prims
395 set SceneGroupID = substr(SceneGroupID, 1, 8) || "-" || substr(SceneGroupID, 9, 4) || "-" || substr(SceneGroupID, 13, 4) || "-" || substr(SceneGroupID, 17, 4) || "-" || substr(SceneGroupID, 21, 12)
396 where SceneGroupID not like '%-%';
397
398update prims
399 set CreatorID = substr(CreatorID, 1, 8) || "-" || substr(CreatorID, 9, 4) || "-" || substr(CreatorID, 13, 4) || "-" || substr(CreatorID, 17, 4) || "-" || substr(CreatorID, 21, 12)
400 where CreatorID not like '%-%';
401
402update prims
403 set OwnerID = substr(OwnerID, 1, 8) || "-" || substr(OwnerID, 9, 4) || "-" || substr(OwnerID, 13, 4) || "-" || substr(OwnerID, 17, 4) || "-" || substr(OwnerID, 21, 12)
404 where OwnerID not like '%-%';
405
406update prims
407 set GroupID = substr(GroupID, 1, 8) || "-" || substr(GroupID, 9, 4) || "-" || substr(GroupID, 13, 4) || "-" || substr(GroupID, 17, 4) || "-" || substr(GroupID, 21, 12)
408 where GroupID not like '%-%';
409
410update prims
411 set LastOwnerID = substr(LastOwnerID, 1, 8) || "-" || substr(LastOwnerID, 9, 4) || "-" || substr(LastOwnerID, 13, 4) || "-" || substr(LastOwnerID, 17, 4) || "-" || substr(LastOwnerID, 21, 12)
412 where LastOwnerID not like '%-%';
413
414
415update primshapes
416 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
417 where UUID not like '%-%';
418
419
420update land
421 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
422 where UUID not like '%-%';
423
424update land
425 set RegionUUID = substr(RegionUUID, 1, 8) || "-" || substr(RegionUUID, 9, 4) || "-" || substr(RegionUUID, 13, 4) || "-" || substr(RegionUUID, 17, 4) || "-" || substr(RegionUUID, 21, 12)
426 where RegionUUID not like '%-%';
427
428update land
429 set OwnerUUID = substr(OwnerUUID, 1, 8) || "-" || substr(OwnerUUID, 9, 4) || "-" || substr(OwnerUUID, 13, 4) || "-" || substr(OwnerUUID, 17, 4) || "-" || substr(OwnerUUID, 21, 12)
430 where OwnerUUID not like '%-%';
431
432update land
433 set GroupUUID = substr(GroupUUID, 1, 8) || "-" || substr(GroupUUID, 9, 4) || "-" || substr(GroupUUID, 13, 4) || "-" || substr(GroupUUID, 17, 4) || "-" || substr(GroupUUID, 21, 12)
434 where GroupUUID not like '%-%';
435
436update land
437 set MediaTextureUUID = substr(MediaTextureUUID, 1, 8) || "-" || substr(MediaTextureUUID, 9, 4) || "-" || substr(MediaTextureUUID, 13, 4) || "-" || substr(MediaTextureUUID, 17, 4) || "-" || substr(MediaTextureUUID, 21, 12)
438 where MediaTextureUUID not like '%-%';
439
440update land
441 set SnapshotUUID = substr(SnapshotUUID, 1, 8) || "-" || substr(SnapshotUUID, 9, 4) || "-" || substr(SnapshotUUID, 13, 4) || "-" || substr(SnapshotUUID, 17, 4) || "-" || substr(SnapshotUUID, 21, 12)
442 where SnapshotUUID not like '%-%';
443
444update land
445 set AuthbuyerID = substr(AuthbuyerID, 1, 8) || "-" || substr(AuthbuyerID, 9, 4) || "-" || substr(AuthbuyerID, 13, 4) || "-" || substr(AuthbuyerID, 17, 4) || "-" || substr(AuthbuyerID, 21, 12)
446 where AuthbuyerID not like '%-%';
447
448COMMIT;
449
450:VERSION 19
451BEGIN;
452ALTER TABLE regionsettings ADD COLUMN map_tile_ID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
453COMMIT;
454
455:VERSION 20
456BEGIN;
457ALTER TABLE prims ADD COLUMN MediaURL varchar(255);
458ALTER TABLE primshapes ADD COLUMN Media TEXT;
459COMMIT;
460
461:VERSION 21
462BEGIN;
463ALTER TABLE `land` ADD COLUMN `MediaType` VARCHAR(32) NOT NULL DEFAULT 'none/none';
464ALTER TABLE `land` ADD COLUMN `MediaDescription` VARCHAR(255) NOT NULL DEFAULT '';
465ALTER TABLE `land` ADD COLUMN `MediaSize` VARCHAR(16) NOT NULL DEFAULT '0,0';
466ALTER TABLE `land` ADD COLUMN `MediaLoop` BOOLEAN NOT NULL DEFAULT FALSE;
467ALTER TABLE `land` ADD COLUMN `ObscureMusic` BOOLEAN NOT NULL DEFAULT FALSE;
468ALTER TABLE `land` ADD COLUMN `ObscureMedia` BOOLEAN NOT NULL DEFAULT FALSE;
469COMMIT;
470
471:VERSION 22
472BEGIN;
473ALTER TABLE regionsettings ADD COLUMN covenant_datetime INTEGER NOT NULL default 0;
474COMMIT;
475
476:VERSION 23
477BEGIN;
478CREATE TABLE regionwindlight (
479 region_id VARCHAR(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY, 253 region_id VARCHAR(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY,
480 water_color_r FLOAT NOT NULL DEFAULT '4.000000', 254 water_color_r FLOAT NOT NULL DEFAULT '4.000000',
481 water_color_g FLOAT NOT NULL DEFAULT '38.000000', 255 water_color_g FLOAT NOT NULL DEFAULT '38.000000',
@@ -541,13 +315,6 @@ CREATE TABLE regionwindlight (
541 cloud_scroll_y_lock INTEGER NOT NULL DEFAULT '0', 315 cloud_scroll_y_lock INTEGER NOT NULL DEFAULT '0',
542 draw_classic_clouds INTEGER NOT NULL DEFAULT '1'); 316 draw_classic_clouds INTEGER NOT NULL DEFAULT '1');
543 317
544COMMIT;
545
546
547:VERSION 24
548
549BEGIN;
550
551CREATE TABLE IF NOT EXISTS `spawn_points` ( 318CREATE TABLE IF NOT EXISTS `spawn_points` (
552 `RegionID` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000', 319 `RegionID` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000',
553 `Yaw` float NOT NULL, 320 `Yaw` float NOT NULL,
@@ -555,60 +322,58 @@ CREATE TABLE IF NOT EXISTS `spawn_points` (
555 `Distance` float NOT NULL 322 `Distance` float NOT NULL
556); 323);
557 324
558ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; 325CREATE TABLE IF NOT EXISTS `regionenvironment` (
326 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY,
327 `llsd_settings` TEXT NOT NULL
328);
559 329
560COMMIT; 330COMMIT;
561 331
562:VERSION 25
563
564BEGIN;
565ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
566COMMIT;
567 332
568:VERSION 26 333:VERSION 32 #---- avination fields plus a few others
569 334
570BEGIN; 335BEGIN;
571 336
572CREATE TABLE `regionenvironment` ( 337ALTER TABLE `prims` ADD COLUMN `PassTouches` BOOLEAN NOT NULL DEFAULT FALSE;
573 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY, 338ALTER TABLE `prims` ADD COLUMN `PassCollisions`BOOLEAN NOT NULL DEFAULT FALSE;
574 `llsd_settings` TEXT NOT NULL 339ALTER TABLE `prims` ADD COLUMN `Vehicle` TEXT default NULL;
575); 340ALTER TABLE `regionsettings` ADD COLUMN `block_search` BOOLEAN NOT NULL DEFAULT FALSE;;
341ALTER TABLE `regionsettings` ADD COLUMN `casino` BOOLEAN NOT NULL DEFAULT FALSE;;
342ALTER TABLE `land` ADD COLUMN `SeeAVs` BOOLEAN NOT NULL DEFAULT TRUE;
343ALTER TABLE `land` ADD COLUMN `AnyAVSounds` BOOLEAN NOT NULL DEFAULT TRUE;
344ALTER TABLE `land` ADD COLUMN `GroupAVSounds` BOOLEAN NOT NULL DEFAULT TRUE;
576 345
577COMMIT; 346COMMIT;
578 347
579:VERSION 27 348:VERSION 33 #---- Rotation axis locks
580BEGIN;
581ALTER TABLE prims ADD COLUMN DynAttrs TEXT;
582COMMIT;
583
584:VERSION 28
585 349
586BEGIN; 350BEGIN;
587 351
588ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; 352ALTER TABLE prims ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0';
589ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000';
590ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1';
591ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6';
592ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5';
593 353
594COMMIT; 354COMMIT;
595 355
596:VERSION 29 #---------------- Keyframes 356:VERSION 34 #---- add baked terrain store
597 357
598BEGIN; 358BEGIN;
599 359
600ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; 360CREATE TABLE IF NOT EXISTS bakedterrain(
361 RegionUUID varchar(255),
362 Revision integer,
363 Heightfield blob);
601 364
602COMMIT; 365COMMIT;
603 366
604:VERSION 30 #---------------- Save Attachment info 367:VERSION 35 #----- Add RezzerID field in table prims
605 368
606BEGIN; 369BEGIN;
607 370
608ALTER TABLE prims ADD COLUMN AttachedPosX double default '0'; 371ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL;
609ALTER TABLE prims ADD COLUMN AttachedPosY double default '0';
610ALTER TABLE prims ADD COLUMN AttachedPosZ double default '0';
611ALTER TABLE primshapes ADD COLUMN LastAttachPoint int not null default '0';
612 372
613COMMIT; 373COMMIT;
614 374
375:VERSION 36 #----- Add physics inertia data
376
377BEGIN;
378ALTER TABLE `prims` ADD COLUMN `PhysInertia` TEXT default NULL;
379COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/UserAccount.migrations b/OpenSim/Data/SQLite/Resources/UserAccount.migrations
index 854fe69..f37a222 100644
--- a/OpenSim/Data/SQLite/Resources/UserAccount.migrations
+++ b/OpenSim/Data/SQLite/Resources/UserAccount.migrations
@@ -25,3 +25,11 @@ BEGIN TRANSACTION;
25INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, surname AS LastName, '' as Email, '' AS ServiceURLs, created as Created FROM users; 25INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, surname AS LastName, '' as Email, '' AS ServiceURLs, created as Created FROM users;
26 26
27COMMIT; 27COMMIT;
28
29:VERSION 3 # -------------------------
30
31BEGIN;
32
33ALTER TABLE `UserAccounts` ADD `active` BOOLEAN NOT NULL DEFAULT TRUE;
34
35COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations
index 86434e8..207dde0 100644
--- a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations
+++ b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations
@@ -99,4 +99,4 @@ CREATE TABLE IF NOT EXISTS usersettings (
99 email varchar(254) NOT NULL, 99 email varchar(254) NOT NULL,
100 PRIMARY KEY (useruuid) 100 PRIMARY KEY (useruuid)
101) 101)
102commit; \ No newline at end of file 102commit;
diff --git a/OpenSim/Data/SQLite/Resources/UserStore.migrations b/OpenSim/Data/SQLite/Resources/UserStore.migrations
deleted file mode 100644
index 73d35e8..0000000
--- a/OpenSim/Data/SQLite/Resources/UserStore.migrations
+++ /dev/null
@@ -1,169 +0,0 @@
1:VERSION 1
2
3BEGIN TRANSACTION;
4
5-- users table
6CREATE TABLE users(
7 UUID varchar(255) primary key,
8 username varchar(255),
9 surname varchar(255),
10 passwordHash varchar(255),
11 passwordSalt varchar(255),
12 homeRegionX integer,
13 homeRegionY integer,
14 homeLocationX float,
15 homeLocationY float,
16 homeLocationZ float,
17 homeLookAtX float,
18 homeLookAtY float,
19 homeLookAtZ float,
20 created integer,
21 lastLogin integer,
22 rootInventoryFolderID varchar(255),
23 userInventoryURI varchar(255),
24 userAssetURI varchar(255),
25 profileCanDoMask integer,
26 profileWantDoMask integer,
27 profileAboutText varchar(255),
28 profileFirstText varchar(255),
29 profileImage varchar(255),
30 profileFirstImage varchar(255),
31 webLoginKey text default '00000000-0000-0000-0000-000000000000');
32-- friends table
33CREATE TABLE userfriends(
34 ownerID varchar(255),
35 friendID varchar(255),
36 friendPerms integer,
37 ownerPerms integer,
38 datetimestamp integer);
39
40COMMIT;
41
42:VERSION 2
43
44BEGIN;
45
46ALTER TABLE users add homeRegionID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
47
48COMMIT;
49
50:VERSION 3
51
52BEGIN;
53
54ALTER TABLE users add userFlags integer NOT NULL default 0;
55ALTER TABLE users add godLevel integer NOT NULL default 0;
56
57COMMIT;
58
59:VERSION 4
60
61BEGIN;
62
63ALTER TABLE users add customType varchar(32) not null default '';
64ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000';
65
66COMMIT;
67
68:VERSION 5
69
70BEGIN;
71
72CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', `attachpoint` int(11) NOT NULL DEFAULT 0, `item` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', `asset` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000');
73
74COMMIT;
75
76:VERSION 6
77
78BEGIN TRANSACTION;
79
80-- usersagents table
81CREATE TABLE IF NOT EXISTS useragents(
82 UUID varchar(255) primary key,
83 agentIP varchar(255),
84 agentPort integer,
85 agentOnline boolean,
86 sessionID varchar(255),
87 secureSessionID varchar(255),
88 regionID varchar(255),
89 loginTime integer,
90 logoutTime integer,
91 currentRegion varchar(255),
92 currentHandle varchar(255),
93 currentPosX float,
94 currentPosY float,
95 currentPosZ float);
96
97COMMIT;
98
99:VERSION 7
100
101BEGIN TRANSACTION;
102
103ALTER TABLE useragents add currentLookAtX float not null default 128;
104ALTER TABLE useragents add currentLookAtY float not null default 128;
105ALTER TABLE useragents add currentLookAtZ float not null default 70;
106
107COMMIT;
108
109:VERSION 8
110
111BEGIN TRANSACTION;
112
113ALTER TABLE users add email varchar(250);
114
115COMMIT;
116
117:VERSION 9
118
119BEGIN;
120
121update users
122 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
123 where UUID not like '%-%';
124
125update useragents
126 set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12)
127 where UUID not like '%-%';
128
129COMMIT;
130
131:VERSION 10
132
133BEGIN TRANSACTION;
134
135CREATE TABLE IF NOT EXISTS avatarappearance(
136 Owner varchar(36) NOT NULL primary key,
137 BodyItem varchar(36) DEFAULT NULL,
138 BodyAsset varchar(36) DEFAULT NULL,
139 SkinItem varchar(36) DEFAULT NULL,
140 SkinAsset varchar(36) DEFAULT NULL,
141 HairItem varchar(36) DEFAULT NULL,
142 HairAsset varchar(36) DEFAULT NULL,
143 EyesItem varchar(36) DEFAULT NULL,
144 EyesAsset varchar(36) DEFAULT NULL,
145 ShirtItem varchar(36) DEFAULT NULL,
146 ShirtAsset varchar(36) DEFAULT NULL,
147 PantsItem varchar(36) DEFAULT NULL,
148 PantsAsset varchar(36) DEFAULT NULL,
149 ShoesItem varchar(36) DEFAULT NULL,
150 ShoesAsset varchar(36) DEFAULT NULL,
151 SocksItem varchar(36) DEFAULT NULL,
152 SocksAsset varchar(36) DEFAULT NULL,
153 JacketItem varchar(36) DEFAULT NULL,
154 JacketAsset varchar(36) DEFAULT NULL,
155 GlovesItem varchar(36) DEFAULT NULL,
156 GlovesAsset varchar(36) DEFAULT NULL,
157 UnderShirtItem varchar(36) DEFAULT NULL,
158 UnderShirtAsset varchar(36) DEFAULT NULL,
159 UnderPantsItem varchar(36) DEFAULT NULL,
160 UnderPantsAsset varchar(36) DEFAULT NULL,
161 SkirtItem varchar(36) DEFAULT NULL,
162 SkirtAsset varchar(36) DEFAULT NULL,
163 Texture blob,
164 VisualParams blob,
165 Serial int DEFAULT NULL,
166 AvatarHeight float DEFAULT NULL
167);
168
169COMMIT;
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index 30b26c4..966d0b8 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Data.SQLite
86 86
87 if (dbconnect == string.Empty) 87 if (dbconnect == string.Empty)
88 { 88 {
89 dbconnect = "URI=file:../db/Asset.db,version=3"; 89 dbconnect = "URI=file:Asset.db,version=3";
90 } 90 }
91 m_conn = new SqliteConnection(dbconnect); 91 m_conn = new SqliteConnection(dbconnect);
92 m_conn.Open(); 92 m_conn.Open();
@@ -131,14 +131,14 @@ namespace OpenSim.Data.SQLite
131 /// Create an asset 131 /// Create an asset
132 /// </summary> 132 /// </summary>
133 /// <param name="asset">Asset Base</param> 133 /// <param name="asset">Asset Base</param>
134 override public void StoreAsset(AssetBase asset) 134 override public bool StoreAsset(AssetBase asset)
135 { 135 {
136 string assetName = asset.Name; 136 string assetName = asset.Name;
137 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) 137 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
138 { 138 {
139 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); 139 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
140 m_log.WarnFormat( 140 m_log.WarnFormat(
141 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", 141 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
142 asset.Name, asset.ID, asset.Name.Length, assetName.Length); 142 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
143 } 143 }
144 144
@@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLite
147 { 147 {
148 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); 148 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
149 m_log.WarnFormat( 149 m_log.WarnFormat(
150 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 150 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
151 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 151 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
152 } 152 }
153 153
@@ -171,6 +171,7 @@ namespace OpenSim.Data.SQLite
171 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); 171 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
172 172
173 cmd.ExecuteNonQuery(); 173 cmd.ExecuteNonQuery();
174 return true;
174 } 175 }
175 } 176 }
176 } 177 }
@@ -191,6 +192,7 @@ namespace OpenSim.Data.SQLite
191 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); 192 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
192 193
193 cmd.ExecuteNonQuery(); 194 cmd.ExecuteNonQuery();
195 return true;
194 } 196 }
195 } 197 }
196 } 198 }
@@ -358,7 +360,7 @@ namespace OpenSim.Data.SQLite
358 /// </summary> 360 /// </summary>
359 override public void Initialise() 361 override public void Initialise()
360 { 362 {
361 Initialise("URI=file:../db/Asset.db,version=3"); 363 Initialise("URI=file:Asset.db,version=3");
362 } 364 }
363 365
364 /// <summary> 366 /// <summary>
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
index 0428c11..8fb955c 100644
--- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Data.SQLite
45 public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData 45 public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData
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 private string m_Realm; 49 private string m_Realm;
50 private List<string> m_ColumnNames; 50 private List<string> m_ColumnNames;
51 private int m_LastExpire; 51 private int m_LastExpire;
@@ -223,7 +223,7 @@ namespace OpenSim.Data.SQLite
223 if (System.Environment.TickCount - m_LastExpire > 30000) 223 if (System.Environment.TickCount - m_LastExpire > 30000)
224 DoExpire(); 224 DoExpire();
225 225
226 using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + 226 using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
227 "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))")) 227 "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"))
228 { 228 {
229 if (ExecuteNonQuery(cmd, m_Connection) > 0) 229 if (ExecuteNonQuery(cmd, m_Connection) > 0)
@@ -238,7 +238,7 @@ namespace OpenSim.Data.SQLite
238 if (System.Environment.TickCount - m_LastExpire > 30000) 238 if (System.Environment.TickCount - m_LastExpire > 30000)
239 DoExpire(); 239 DoExpire();
240 240
241 using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + 241 using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() +
242 " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')")) 242 " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"))
243 { 243 {
244 if (ExecuteNonQuery(cmd, m_Connection) > 0) 244 if (ExecuteNonQuery(cmd, m_Connection) > 0)
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs
index d51f2d4..0fcab21 100644
--- a/OpenSim/Data/SQLite/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs
@@ -190,7 +190,7 @@ namespace OpenSim.Data.SQLite
190 IDataReader r = null; 190 IDataReader r = null;
191 191
192 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 192 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
193 { 193 {
194 names.Remove("EstateID"); 194 names.Remove("EstateID");
195 195
196 string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; 196 string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
@@ -386,15 +386,15 @@ namespace OpenSim.Data.SQLite
386 return DoLoad(cmd, UUID.Zero, false); 386 return DoLoad(cmd, UUID.Zero, false);
387 } 387 }
388 } 388 }
389 389
390 public List<EstateSettings> LoadEstateSettingsAll() 390 public List<EstateSettings> LoadEstateSettingsAll()
391 { 391 {
392 List<EstateSettings> estateSettings = new List<EstateSettings>(); 392 List<EstateSettings> estateSettings = new List<EstateSettings>();
393 393
394 List<int> estateIds = GetEstatesAll(); 394 List<int> estateIds = GetEstatesAll();
395 foreach (int estateId in estateIds) 395 foreach (int estateId in estateIds)
396 estateSettings.Add(LoadEstateSettings(estateId)); 396 estateSettings.Add(LoadEstateSettings(estateId));
397 397
398 return estateSettings; 398 return estateSettings;
399 } 399 }
400 400
@@ -421,7 +421,7 @@ namespace OpenSim.Data.SQLite
421 421
422 return result; 422 return result;
423 } 423 }
424 424
425 public List<int> GetEstatesAll() 425 public List<int> GetEstatesAll()
426 { 426 {
427 List<int> result = new List<int>(); 427 List<int> result = new List<int>();
@@ -442,7 +442,7 @@ namespace OpenSim.Data.SQLite
442 } 442 }
443 r.Close(); 443 r.Close();
444 444
445 return result; 445 return result;
446 } 446 }
447 447
448 public List<int> GetEstatesByOwner(UUID ownerID) 448 public List<int> GetEstatesByOwner(UUID ownerID)
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 9fbeb10..a4b84b1 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -189,7 +189,7 @@ namespace OpenSim.Data.SQLite
189 m_Fields[name].SetValue(row, reader[name]); 189 m_Fields[name].SetValue(row, reader[name]);
190 } 190 }
191 } 191 }
192 192
193 if (m_DataField != null) 193 if (m_DataField != null)
194 { 194 {
195 Dictionary<string, string> data = 195 Dictionary<string, string> data =
@@ -268,7 +268,7 @@ namespace OpenSim.Data.SQLite
268 public virtual bool Delete(string field, string key) 268 public virtual bool Delete(string field, string key)
269 { 269 {
270 return Delete(new string[] { field }, new string[] { key }); 270 return Delete(new string[] { field }, new string[] { key });
271 } 271 }
272 272
273 public virtual bool Delete(string[] fields, string[] keys) 273 public virtual bool Delete(string[] fields, string[] keys)
274 { 274 {
diff --git a/OpenSim/Data/SQLite/SQLiteGridUserData.cs b/OpenSim/Data/SQLite/SQLiteGridUserData.cs
index d8c52f8..987240c 100644
--- a/OpenSim/Data/SQLite/SQLiteGridUserData.cs
+++ b/OpenSim/Data/SQLite/SQLiteGridUserData.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Data.SQLite
43 { 43 {
44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 public SQLiteGridUserData(string connectionString, string realm) 46 public SQLiteGridUserData(string connectionString, string realm)
47 : base(connectionString, realm, "GridUserStore") {} 47 : base(connectionString, realm, "GridUserStore") {}
48 48
49 public new GridUserData Get(string userID) 49 public new GridUserData Get(string userID)
diff --git a/OpenSim/Data/SQLite/SQLiteHGTravelData.cs b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs
index db288b2..dd34710 100644
--- a/OpenSim/Data/SQLite/SQLiteHGTravelData.cs
+++ b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Data.SQLite
44 { 44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 public SQLiteHGTravelData(string connectionString, string realm) 47 public SQLiteHGTravelData(string connectionString, string realm)
48 : base(connectionString, realm, "HGTravelStore") {} 48 : base(connectionString, realm, "HGTravelStore") {}
49 49
50 public HGTravelingData Get(UUID sessionID) 50 public HGTravelingData Get(UUID sessionID)
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
deleted file mode 100644
index 7caf347..0000000
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ /dev/null
@@ -1,916 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Reflection;
32using log4net;
33#if CSharpSqlite
34 using Community.CsharpSqlite.Sqlite;
35#else
36 using Mono.Data.Sqlite;
37#endif
38using OpenMetaverse;
39using OpenSim.Framework;
40
41namespace OpenSim.Data.SQLite
42{
43 /// <summary>
44 /// An Inventory Interface to the SQLite database
45 /// </summary>
46 public class SQLiteInventoryStore : SQLiteUtil, IInventoryDataPlugin
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private const string invItemsSelect = "select * from inventoryitems";
51 private const string invFoldersSelect = "select * from inventoryfolders";
52
53 private static SqliteConnection conn;
54 private static DataSet ds;
55 private static SqliteDataAdapter invItemsDa;
56 private static SqliteDataAdapter invFoldersDa;
57
58 private static bool m_Initialized = false;
59
60 public void Initialise()
61 {
62 m_log.Info("[SQLiteInventoryData]: " + Name + " cannot be default-initialized!");
63 throw new PluginNotInitialisedException(Name);
64 }
65
66 /// <summary>
67 /// <list type="bullet">
68 /// <item>Initialises Inventory interface</item>
69 /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
70 /// <item>use default URI if connect string string is empty.</item>
71 /// </list>
72 /// </summary>
73 /// <param name="dbconnect">connect string</param>
74 public void Initialise(string dbconnect)
75 {
76 if (!m_Initialized)
77 {
78 m_Initialized = true;
79
80 if (Util.IsWindows())
81 Util.LoadArchSpecificWindowsDll("sqlite3.dll");
82
83 if (dbconnect == string.Empty)
84 {
85 dbconnect = "URI=file:../db/inventoryStore.db,version=3";
86 }
87 m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect);
88 conn = new SqliteConnection(dbconnect);
89
90 conn.Open();
91
92 Assembly assem = GetType().Assembly;
93 Migration m = new Migration(conn, assem, "InventoryStore");
94 m.Update();
95
96 SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn);
97 invItemsDa = new SqliteDataAdapter(itemsSelectCmd);
98 // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
99
100 SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn);
101 invFoldersDa = new SqliteDataAdapter(foldersSelectCmd);
102
103 ds = new DataSet();
104
105 ds.Tables.Add(createInventoryFoldersTable());
106 invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
107 setupFoldersCommands(invFoldersDa, conn);
108 CreateDataSetMapping(invFoldersDa, "inventoryfolders");
109 m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
110
111 ds.Tables.Add(createInventoryItemsTable());
112 invItemsDa.Fill(ds.Tables["inventoryitems"]);
113 setupItemsCommands(invItemsDa, conn);
114 CreateDataSetMapping(invItemsDa, "inventoryitems");
115 m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
116
117 ds.AcceptChanges();
118 }
119 }
120
121 /// <summary>
122 /// Closes the inventory interface
123 /// </summary>
124 public void Dispose()
125 {
126 if (conn != null)
127 {
128 conn.Close();
129 conn = null;
130 }
131 if (invItemsDa != null)
132 {
133 invItemsDa.Dispose();
134 invItemsDa = null;
135 }
136 if (invFoldersDa != null)
137 {
138 invFoldersDa.Dispose();
139 invFoldersDa = null;
140 }
141 if (ds != null)
142 {
143 ds.Dispose();
144 ds = null;
145 }
146 }
147
148 /// <summary>
149 ///
150 /// </summary>
151 /// <param name="row"></param>
152 /// <returns></returns>
153 public InventoryItemBase buildItem(DataRow row)
154 {
155 InventoryItemBase item = new InventoryItemBase();
156 item.ID = new UUID((string) row["UUID"]);
157 item.AssetID = new UUID((string) row["assetID"]);
158 item.AssetType = Convert.ToInt32(row["assetType"]);
159 item.InvType = Convert.ToInt32(row["invType"]);
160 item.Folder = new UUID((string) row["parentFolderID"]);
161 item.Owner = new UUID((string) row["avatarID"]);
162 item.CreatorIdentification = (string)row["creatorsID"];
163 item.Name = (string) row["inventoryName"];
164 item.Description = (string) row["inventoryDescription"];
165
166 item.NextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]);
167 item.CurrentPermissions = Convert.ToUInt32(row["inventoryCurrentPermissions"]);
168 item.BasePermissions = Convert.ToUInt32(row["inventoryBasePermissions"]);
169 item.EveryOnePermissions = Convert.ToUInt32(row["inventoryEveryOnePermissions"]);
170 item.GroupPermissions = Convert.ToUInt32(row["inventoryGroupPermissions"]);
171
172 // new fields
173 if (!Convert.IsDBNull(row["salePrice"]))
174 item.SalePrice = Convert.ToInt32(row["salePrice"]);
175
176 if (!Convert.IsDBNull(row["saleType"]))
177 item.SaleType = Convert.ToByte(row["saleType"]);
178
179 if (!Convert.IsDBNull(row["creationDate"]))
180 item.CreationDate = Convert.ToInt32(row["creationDate"]);
181
182 if (!Convert.IsDBNull(row["groupID"]))
183 item.GroupID = new UUID((string)row["groupID"]);
184
185 if (!Convert.IsDBNull(row["groupOwned"]))
186 item.GroupOwned = Convert.ToBoolean(row["groupOwned"]);
187
188 if (!Convert.IsDBNull(row["Flags"]))
189 item.Flags = Convert.ToUInt32(row["Flags"]);
190
191 return item;
192 }
193
194 /// <summary>
195 /// Fill a database row with item data
196 /// </summary>
197 /// <param name="row"></param>
198 /// <param name="item"></param>
199 private static void fillItemRow(DataRow row, InventoryItemBase item)
200 {
201 row["UUID"] = item.ID.ToString();
202 row["assetID"] = item.AssetID.ToString();
203 row["assetType"] = item.AssetType;
204 row["invType"] = item.InvType;
205 row["parentFolderID"] = item.Folder.ToString();
206 row["avatarID"] = item.Owner.ToString();
207 row["creatorsID"] = item.CreatorIdentification.ToString();
208 row["inventoryName"] = item.Name;
209 row["inventoryDescription"] = item.Description;
210
211 row["inventoryNextPermissions"] = item.NextPermissions;
212 row["inventoryCurrentPermissions"] = item.CurrentPermissions;
213 row["inventoryBasePermissions"] = item.BasePermissions;
214 row["inventoryEveryOnePermissions"] = item.EveryOnePermissions;
215 row["inventoryGroupPermissions"] = item.GroupPermissions;
216
217 // new fields
218 row["salePrice"] = item.SalePrice;
219 row["saleType"] = item.SaleType;
220 row["creationDate"] = item.CreationDate;
221 row["groupID"] = item.GroupID.ToString();
222 row["groupOwned"] = item.GroupOwned;
223 row["flags"] = item.Flags;
224 }
225
226 /// <summary>
227 /// Add inventory folder
228 /// </summary>
229 /// <param name="folder">Folder base</param>
230 /// <param name="add">true=create folder. false=update existing folder</param>
231 /// <remarks>nasty</remarks>
232 private void addFolder(InventoryFolderBase folder, bool add)
233 {
234 lock (ds)
235 {
236 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
237
238 DataRow inventoryRow = inventoryFolderTable.Rows.Find(folder.ID.ToString());
239 if (inventoryRow == null)
240 {
241 if (! add)
242 m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existent inventory folder: {0}", folder.ID);
243
244 inventoryRow = inventoryFolderTable.NewRow();
245 fillFolderRow(inventoryRow, folder);
246 inventoryFolderTable.Rows.Add(inventoryRow);
247 }
248 else
249 {
250 if (add)
251 m_log.ErrorFormat("Interface Misuse: Attempting to Add inventory folder that already exists: {0}", folder.ID);
252
253 fillFolderRow(inventoryRow, folder);
254 }
255
256 invFoldersDa.Update(ds, "inventoryfolders");
257 }
258 }
259
260 /// <summary>
261 /// Move an inventory folder
262 /// </summary>
263 /// <param name="folder">folder base</param>
264 private void moveFolder(InventoryFolderBase folder)
265 {
266 lock (ds)
267 {
268 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
269
270 DataRow inventoryRow = inventoryFolderTable.Rows.Find(folder.ID.ToString());
271 if (inventoryRow == null)
272 {
273 inventoryRow = inventoryFolderTable.NewRow();
274 fillFolderRow(inventoryRow, folder);
275 inventoryFolderTable.Rows.Add(inventoryRow);
276 }
277 else
278 {
279 moveFolderRow(inventoryRow, folder);
280 }
281
282 invFoldersDa.Update(ds, "inventoryfolders");
283 }
284 }
285
286 /// <summary>
287 /// add an item in inventory
288 /// </summary>
289 /// <param name="item">the item</param>
290 /// <param name="add">true=add item ; false=update existing item</param>
291 private void addItem(InventoryItemBase item, bool add)
292 {
293 lock (ds)
294 {
295 DataTable inventoryItemTable = ds.Tables["inventoryitems"];
296
297 DataRow inventoryRow = inventoryItemTable.Rows.Find(item.ID.ToString());
298 if (inventoryRow == null)
299 {
300 if (!add)
301 m_log.ErrorFormat("[INVENTORY DB]: Interface Misuse: Attempting to Update non-existent inventory item: {0}", item.ID);
302
303 inventoryRow = inventoryItemTable.NewRow();
304 fillItemRow(inventoryRow, item);
305 inventoryItemTable.Rows.Add(inventoryRow);
306 }
307 else
308 {
309 if (add)
310 m_log.ErrorFormat("[INVENTORY DB]: Interface Misuse: Attempting to Add inventory item that already exists: {0}", item.ID);
311
312 fillItemRow(inventoryRow, item);
313 }
314
315 invItemsDa.Update(ds, "inventoryitems");
316
317 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
318
319 inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString());
320 if (inventoryRow != null) //MySQL doesn't throw an exception here, so sqlite shouldn't either.
321 inventoryRow["version"] = (int)inventoryRow["version"] + 1;
322
323 invFoldersDa.Update(ds, "inventoryfolders");
324 }
325 }
326
327 /// <summary>
328 /// TODO : DataSet commit
329 /// </summary>
330 public void Shutdown()
331 {
332 // TODO: DataSet commit
333 }
334
335 /// <summary>
336 /// The name of this DB provider
337 /// </summary>
338 /// <returns>Name of DB provider</returns>
339 public string Name
340 {
341 get { return "SQLite Inventory Data Interface"; }
342 }
343
344 /// <summary>
345 /// Returns the version of this DB provider
346 /// </summary>
347 /// <returns>A string containing the DB provider version</returns>
348 public string Version
349 {
350 get
351 {
352 Module module = GetType().Module;
353 // string dllName = module.Assembly.ManifestModule.Name;
354 Version dllVersion = module.Assembly.GetName().Version;
355
356
357 return
358 string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
359 dllVersion.Revision);
360 }
361 }
362
363 /// <summary>
364 /// Returns a list of inventory items contained within the specified folder
365 /// </summary>
366 /// <param name="folderID">The UUID of the target folder</param>
367 /// <returns>A List of InventoryItemBase items</returns>
368 public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
369 {
370 lock (ds)
371 {
372 List<InventoryItemBase> retval = new List<InventoryItemBase>();
373 DataTable inventoryItemTable = ds.Tables["inventoryitems"];
374 string selectExp = "parentFolderID = '" + folderID + "'";
375 DataRow[] rows = inventoryItemTable.Select(selectExp);
376 foreach (DataRow row in rows)
377 {
378 retval.Add(buildItem(row));
379 }
380
381 return retval;
382 }
383 }
384
385 /// <summary>
386 /// Returns a list of the root folders within a users inventory
387 /// </summary>
388 /// <param name="user">The user whos inventory is to be searched</param>
389 /// <returns>A list of folder objects</returns>
390 public List<InventoryFolderBase> getUserRootFolders(UUID user)
391 {
392 return new List<InventoryFolderBase>();
393 }
394
395 // see InventoryItemBase.getUserRootFolder
396 public InventoryFolderBase getUserRootFolder(UUID user)
397 {
398 lock (ds)
399 {
400 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
401 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
402 string selectExp = "agentID = '" + user + "' AND parentID = '" + UUID.Zero + "'";
403 DataRow[] rows = inventoryFolderTable.Select(selectExp);
404 foreach (DataRow row in rows)
405 {
406 folders.Add(buildFolder(row));
407 }
408
409 // There should only ever be one root folder for a user. However, if there's more
410 // than one we'll simply use the first one rather than failing. It would be even
411 // nicer to print some message to this effect, but this feels like it's too low a
412 // to put such a message out, and it's too minor right now to spare the time to
413 // suitably refactor.
414 if (folders.Count > 0)
415 {
416 return folders[0];
417 }
418
419 return null;
420 }
421 }
422
423 /// <summary>
424 /// Append a list of all the child folders of a parent folder
425 /// </summary>
426 /// <param name="folders">list where folders will be appended</param>
427 /// <param name="parentID">ID of parent</param>
428 protected void getInventoryFolders(ref List<InventoryFolderBase> folders, UUID parentID)
429 {
430 lock (ds)
431 {
432 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
433 string selectExp = "parentID = '" + parentID + "'";
434 DataRow[] rows = inventoryFolderTable.Select(selectExp);
435 foreach (DataRow row in rows)
436 {
437 folders.Add(buildFolder(row));
438 }
439
440 }
441 }
442
443 /// <summary>
444 /// Returns a list of inventory folders contained in the folder 'parentID'
445 /// </summary>
446 /// <param name="parentID">The folder to get subfolders for</param>
447 /// <returns>A list of inventory folders</returns>
448 public List<InventoryFolderBase> getInventoryFolders(UUID parentID)
449 {
450 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
451 getInventoryFolders(ref folders, parentID);
452 return folders;
453 }
454
455 /// <summary>
456 /// See IInventoryDataPlugin
457 /// </summary>
458 /// <param name="parentID"></param>
459 /// <returns></returns>
460 public List<InventoryFolderBase> getFolderHierarchy(UUID parentID)
461 {
462 /* Note: There are subtle changes between this implementation of getFolderHierarchy and the previous one
463 * - We will only need to hit the database twice instead of n times.
464 * - We assume the database is well-formed - no stranded/dangling folders, all folders in heirarchy owned
465 * by the same person, each user only has 1 inventory heirarchy
466 * - The returned list is not ordered, instead of breadth-first ordered
467 There are basically 2 usage cases for getFolderHeirarchy:
468 1) Getting the user's entire inventory heirarchy when they log in
469 2) Finding a subfolder heirarchy to delete when emptying the trash.
470 This implementation will pull all inventory folders from the database, and then prune away any folder that
471 is not part of the requested sub-heirarchy. The theory is that it is cheaper to make 1 request from the
472 database than to make n requests. This pays off only if requested heirarchy is large.
473 By making this choice, we are making the worst case better at the cost of making the best case worse
474 - Francis
475 */
476
477 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
478 DataRow[] folderRows = null, parentRow;
479 InventoryFolderBase parentFolder = null;
480 lock (ds)
481 {
482 /* Fetch the parent folder from the database to determine the agent ID.
483 * Then fetch all inventory folders for that agent from the agent ID.
484 */
485 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
486 string selectExp = "UUID = '" + parentID + "'";
487 parentRow = inventoryFolderTable.Select(selectExp); // Assume at most 1 result
488 if (parentRow.GetLength(0) >= 1) // No result means parent folder does not exist
489 {
490 parentFolder = buildFolder(parentRow[0]);
491 UUID agentID = parentFolder.Owner;
492 selectExp = "agentID = '" + agentID + "'";
493 folderRows = inventoryFolderTable.Select(selectExp);
494 }
495
496 if (folderRows != null && folderRows.GetLength(0) >= 1) // No result means parent folder does not exist
497 { // or has no children
498 /* if we're querying the root folder, just return an unordered list of all folders in the user's
499 * inventory
500 */
501 if (parentFolder.ParentID == UUID.Zero)
502 {
503 foreach (DataRow row in folderRows)
504 {
505 InventoryFolderBase curFolder = buildFolder(row);
506 if (curFolder.ID != parentID) // Return all folders except the parent folder of heirarchy
507 folders.Add(buildFolder(row));
508 }
509 } // If requesting root folder
510 /* else we are querying a non-root folder. We currently have a list of all of the user's folders,
511 * we must construct a list of all folders in the heirarchy below parentID.
512 * Our first step will be to construct a hash table of all folders, indexed by parent ID.
513 * Once we have constructed the hash table, we will do a breadth-first traversal on the tree using the
514 * hash table to find child folders.
515 */
516 else
517 { // Querying a non-root folder
518
519 // Build a hash table of all user's inventory folders, indexed by each folder's parent ID
520 Dictionary<UUID, List<InventoryFolderBase>> hashtable =
521 new Dictionary<UUID, List<InventoryFolderBase>>(folderRows.GetLength(0));
522
523 foreach (DataRow row in folderRows)
524 {
525 InventoryFolderBase curFolder = buildFolder(row);
526 if (curFolder.ParentID != UUID.Zero) // Discard root of tree - not needed
527 {
528 if (hashtable.ContainsKey(curFolder.ParentID))
529 {
530 // Current folder already has a sibling - append to sibling list
531 hashtable[curFolder.ParentID].Add(curFolder);
532 }
533 else
534 {
535 List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>();
536 siblingList.Add(curFolder);
537 // Current folder has no known (yet) siblings
538 hashtable.Add(curFolder.ParentID, siblingList);
539 }
540 }
541 } // For all inventory folders
542
543 // Note: Could release the ds lock here - we don't access folderRows or the database anymore.
544 // This is somewhat of a moot point as the callers of this function usually lock db anyways.
545
546 if (hashtable.ContainsKey(parentID)) // if requested folder does have children
547 folders.AddRange(hashtable[parentID]);
548
549 // BreadthFirstSearch build inventory tree **Note: folders.Count is *not* static
550 for (int i = 0; i < folders.Count; i++)
551 if (hashtable.ContainsKey(folders[i].ID))
552 folders.AddRange(hashtable[folders[i].ID]);
553
554 } // if requesting a subfolder heirarchy
555 } // if folder parentID exists and has children
556 } // lock ds
557 return folders;
558 }
559
560 /// <summary>
561 /// Returns an inventory item by its UUID
562 /// </summary>
563 /// <param name="item">The UUID of the item to be returned</param>
564 /// <returns>A class containing item information</returns>
565 public InventoryItemBase getInventoryItem(UUID item)
566 {
567 lock (ds)
568 {
569 DataRow row = ds.Tables["inventoryitems"].Rows.Find(item.ToString());
570 if (row != null)
571 {
572 return buildItem(row);
573 }
574 else
575 {
576 return null;
577 }
578 }
579 }
580
581 /// <summary>
582 /// Returns a specified inventory folder by its UUID
583 /// </summary>
584 /// <param name="folder">The UUID of the folder to be returned</param>
585 /// <returns>A class containing folder information</returns>
586 public InventoryFolderBase getInventoryFolder(UUID folder)
587 {
588 // TODO: Deep voodoo here. If you enable this code then
589 // multi region breaks. No idea why, but I figured it was
590 // better to leave multi region at this point. It does mean
591 // that you don't get to see system textures why creating
592 // clothes and the like. :(
593 lock (ds)
594 {
595 DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder.ToString());
596 if (row != null)
597 {
598 return buildFolder(row);
599 }
600 else
601 {
602 return null;
603 }
604 }
605 }
606
607 /// <summary>
608 /// Creates a new inventory item based on item
609 /// </summary>
610 /// <param name="item">The item to be created</param>
611 public void addInventoryItem(InventoryItemBase item)
612 {
613 addItem(item, true);
614 }
615
616 /// <summary>
617 /// Updates an inventory item with item (updates based on ID)
618 /// </summary>
619 /// <param name="item">The updated item</param>
620 public void updateInventoryItem(InventoryItemBase item)
621 {
622 addItem(item, false);
623 }
624
625 /// <summary>
626 /// Delete an inventory item
627 /// </summary>
628 /// <param name="item">The item UUID</param>
629 public void deleteInventoryItem(UUID itemID)
630 {
631 lock (ds)
632 {
633 DataTable inventoryItemTable = ds.Tables["inventoryitems"];
634
635 DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID.ToString());
636 if (inventoryRow != null)
637 {
638 inventoryRow.Delete();
639 }
640
641 invItemsDa.Update(ds, "inventoryitems");
642 }
643 }
644
645 public InventoryItemBase queryInventoryItem(UUID itemID)
646 {
647 return getInventoryItem(itemID);
648 }
649
650 public InventoryFolderBase queryInventoryFolder(UUID folderID)
651 {
652 return getInventoryFolder(folderID);
653 }
654
655 /// <summary>
656 /// Delete all items in the specified folder
657 /// </summary>
658 /// <param name="folderId">id of the folder, whose item content should be deleted</param>
659 /// <todo>this is horribly inefficient, but I don't want to ruin the overall structure of this implementation</todo>
660 private void deleteItemsInFolder(UUID folderId)
661 {
662 List<InventoryItemBase> items = getInventoryInFolder(folderId);
663
664 foreach (InventoryItemBase i in items)
665 deleteInventoryItem(i.ID);
666 }
667
668 /// <summary>
669 /// Adds a new folder specified by folder
670 /// </summary>
671 /// <param name="folder">The inventory folder</param>
672 public void addInventoryFolder(InventoryFolderBase folder)
673 {
674 addFolder(folder, true);
675 }
676
677 /// <summary>
678 /// Updates a folder based on its ID with folder
679 /// </summary>
680 /// <param name="folder">The inventory folder</param>
681 public void updateInventoryFolder(InventoryFolderBase folder)
682 {
683 addFolder(folder, false);
684 }
685
686 /// <summary>
687 /// Moves a folder based on its ID with folder
688 /// </summary>
689 /// <param name="folder">The inventory folder</param>
690 public void moveInventoryFolder(InventoryFolderBase folder)
691 {
692 moveFolder(folder);
693 }
694
695 /// <summary>
696 /// Delete a folder
697 /// </summary>
698 /// <remarks>
699 /// This will clean-up any child folders and child items as well
700 /// </remarks>
701 /// <param name="folderID">the folder UUID</param>
702 public void deleteInventoryFolder(UUID folderID)
703 {
704 lock (ds)
705 {
706 List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
707
708 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
709 DataRow inventoryRow;
710
711 //Delete all sub-folders
712 foreach (InventoryFolderBase f in subFolders)
713 {
714 inventoryRow = inventoryFolderTable.Rows.Find(f.ID.ToString());
715 if (inventoryRow != null)
716 {
717 deleteItemsInFolder(f.ID);
718 inventoryRow.Delete();
719 }
720 }
721
722 //Delete the actual row
723 inventoryRow = inventoryFolderTable.Rows.Find(folderID.ToString());
724 if (inventoryRow != null)
725 {
726 deleteItemsInFolder(folderID);
727 inventoryRow.Delete();
728 }
729
730 invFoldersDa.Update(ds, "inventoryfolders");
731 }
732 }
733
734 /***********************************************************************
735 *
736 * Data Table definitions
737 *
738 **********************************************************************/
739
740 protected void CreateDataSetMapping(IDataAdapter da, string tableName)
741 {
742 ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName);
743 foreach (DataColumn col in ds.Tables[tableName].Columns)
744 {
745 dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName);
746 }
747 }
748
749 /// <summary>
750 /// Create the "inventoryitems" table
751 /// </summary>
752 private static DataTable createInventoryItemsTable()
753 {
754 DataTable inv = new DataTable("inventoryitems");
755
756 createCol(inv, "UUID", typeof (String)); //inventoryID
757 createCol(inv, "assetID", typeof (String));
758 createCol(inv, "assetType", typeof (Int32));
759 createCol(inv, "invType", typeof (Int32));
760 createCol(inv, "parentFolderID", typeof (String));
761 createCol(inv, "avatarID", typeof (String));
762 createCol(inv, "creatorsID", typeof (String));
763
764 createCol(inv, "inventoryName", typeof (String));
765 createCol(inv, "inventoryDescription", typeof (String));
766 // permissions
767 createCol(inv, "inventoryNextPermissions", typeof (Int32));
768 createCol(inv, "inventoryCurrentPermissions", typeof (Int32));
769 createCol(inv, "inventoryBasePermissions", typeof (Int32));
770 createCol(inv, "inventoryEveryOnePermissions", typeof (Int32));
771 createCol(inv, "inventoryGroupPermissions", typeof (Int32));
772
773 // sale info
774 createCol(inv, "salePrice", typeof(Int32));
775 createCol(inv, "saleType", typeof(Byte));
776
777 // creation date
778 createCol(inv, "creationDate", typeof(Int32));
779
780 // group info
781 createCol(inv, "groupID", typeof(String));
782 createCol(inv, "groupOwned", typeof(Boolean));
783
784 // Flags
785 createCol(inv, "flags", typeof(UInt32));
786
787 inv.PrimaryKey = new DataColumn[] { inv.Columns["UUID"] };
788 return inv;
789 }
790
791 /// <summary>
792 /// Creates the "inventoryfolders" table
793 /// </summary>
794 /// <returns></returns>
795 private static DataTable createInventoryFoldersTable()
796 {
797 DataTable fol = new DataTable("inventoryfolders");
798
799 createCol(fol, "UUID", typeof (String)); //folderID
800 createCol(fol, "name", typeof (String));
801 createCol(fol, "agentID", typeof (String));
802 createCol(fol, "parentID", typeof (String));
803 createCol(fol, "type", typeof (Int32));
804 createCol(fol, "version", typeof (Int32));
805
806 fol.PrimaryKey = new DataColumn[] {fol.Columns["UUID"]};
807 return fol;
808 }
809
810 /// <summary>
811 ///
812 /// </summary>
813 /// <param name="da"></param>
814 /// <param name="conn"></param>
815 private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn)
816 {
817 lock (ds)
818 {
819 da.InsertCommand = createInsertCommand("inventoryitems", ds.Tables["inventoryitems"]);
820 da.InsertCommand.Connection = conn;
821
822 da.UpdateCommand = createUpdateCommand("inventoryitems", "UUID=:UUID", ds.Tables["inventoryitems"]);
823 da.UpdateCommand.Connection = conn;
824
825 SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID");
826 delete.Parameters.Add(createSqliteParameter("UUID", typeof(String)));
827 delete.Connection = conn;
828 da.DeleteCommand = delete;
829 }
830 }
831
832 /// <summary>
833 ///
834 /// </summary>
835 /// <param name="da"></param>
836 /// <param name="conn"></param>
837 private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn)
838 {
839 lock (ds)
840 {
841 da.InsertCommand = createInsertCommand("inventoryfolders", ds.Tables["inventoryfolders"]);
842 da.InsertCommand.Connection = conn;
843
844 da.UpdateCommand = createUpdateCommand("inventoryfolders", "UUID=:UUID", ds.Tables["inventoryfolders"]);
845 da.UpdateCommand.Connection = conn;
846
847 SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID");
848 delete.Parameters.Add(createSqliteParameter("UUID", typeof(String)));
849 delete.Connection = conn;
850 da.DeleteCommand = delete;
851 }
852 }
853
854 /// <summary>
855 ///
856 /// </summary>
857 /// <param name="row"></param>
858 /// <returns></returns>
859 private static InventoryFolderBase buildFolder(DataRow row)
860 {
861 InventoryFolderBase folder = new InventoryFolderBase();
862 folder.ID = new UUID((string) row["UUID"]);
863 folder.Name = (string) row["name"];
864 folder.Owner = new UUID((string) row["agentID"]);
865 folder.ParentID = new UUID((string) row["parentID"]);
866 folder.Type = Convert.ToInt16(row["type"]);
867 folder.Version = Convert.ToUInt16(row["version"]);
868 return folder;
869 }
870
871 /// <summary>
872 ///
873 /// </summary>
874 /// <param name="row"></param>
875 /// <param name="folder"></param>
876 private static void fillFolderRow(DataRow row, InventoryFolderBase folder)
877 {
878 row["UUID"] = folder.ID.ToString();
879 row["name"] = folder.Name;
880 row["agentID"] = folder.Owner.ToString();
881 row["parentID"] = folder.ParentID.ToString();
882 row["type"] = folder.Type;
883 row["version"] = folder.Version;
884 }
885
886 /// <summary>
887 ///
888 /// </summary>
889 /// <param name="row"></param>
890 /// <param name="folder"></param>
891 private static void moveFolderRow(DataRow row, InventoryFolderBase folder)
892 {
893 row["UUID"] = folder.ID.ToString();
894 row["parentID"] = folder.ParentID.ToString();
895 }
896
897 public List<InventoryItemBase> fetchActiveGestures (UUID avatarID)
898 {
899 lock (ds)
900 {
901 List<InventoryItemBase> items = new List<InventoryItemBase>();
902
903 DataTable inventoryItemTable = ds.Tables["inventoryitems"];
904 string selectExp
905 = "avatarID = '" + avatarID + "' AND assetType = " + (int)AssetType.Gesture + " AND flags = 1";
906 //m_log.DebugFormat("[SQL]: sql = " + selectExp);
907 DataRow[] rows = inventoryItemTable.Select(selectExp);
908 foreach (DataRow row in rows)
909 {
910 items.Add(buildItem(row));
911 }
912 return items;
913 }
914 }
915 }
916}
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index 6ed3d40..19880de 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -707,7 +707,7 @@ namespace OpenSim.Data.SQLite
707 DataRow[] primsForRegion = prims.Select(byRegion); 707 DataRow[] primsForRegion = prims.Select(byRegion);
708// m_log.Info("[SQLITE REGION DB]: Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); 708// m_log.Info("[SQLITE REGION DB]: Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
709 709
710 // First, create all groups 710 // First, create all groups
711 foreach (DataRow primRow in primsForRegion) 711 foreach (DataRow primRow in primsForRegion)
712 { 712 {
713 try 713 try
@@ -733,12 +733,12 @@ namespace OpenSim.Data.SQLite
733 } 733 }
734 734
735 SceneObjectGroup group = new SceneObjectGroup(prim); 735 SceneObjectGroup group = new SceneObjectGroup(prim);
736 736
737 createdObjects.Add(group.UUID, group); 737 createdObjects.Add(group.UUID, group);
738 retvals.Add(group); 738 retvals.Add(group);
739 LoadItems(prim); 739 LoadItems(prim);
740 740
741 741
742 } 742 }
743 } 743 }
744 catch (Exception e) 744 catch (Exception e)
@@ -827,7 +827,7 @@ namespace OpenSim.Data.SQLite
827 } 827 }
828 828
829 /// <summary> 829 /// <summary>
830 /// Store a terrain revision in region storage 830 /// Store a terrain in region storage
831 /// </summary> 831 /// </summary>
832 /// <param name="ter">terrain heightfield</param> 832 /// <param name="ter">terrain heightfield</param>
833 /// <param name="regionID">region UUID</param> 833 /// <param name="regionID">region UUID</param>
@@ -851,7 +851,44 @@ namespace OpenSim.Data.SQLite
851 Array terrainDBblob; 851 Array terrainDBblob;
852 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); 852 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
853 853
854 m_log.DebugFormat("{0} Storing terrain revision r {1}", LogHeader, terrainDBRevision); 854 m_log.DebugFormat("{0} Storing terrain format {1}", LogHeader, terrainDBRevision);
855
856 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
857 {
858 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
859 cmd.Parameters.Add(new SqliteParameter(":Revision", terrainDBRevision));
860 cmd.Parameters.Add(new SqliteParameter(":Heightfield", terrainDBblob));
861 cmd.ExecuteNonQuery();
862 }
863 }
864 }
865
866 /// <summary>
867 /// Store baked terrain in region storage
868 /// </summary>
869 /// <param name="ter">terrain heightfield</param>
870 /// <param name="regionID">region UUID</param>
871 public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
872 {
873 lock (ds)
874 {
875 using (
876 SqliteCommand cmd = new SqliteCommand("delete from bakedterrain where RegionUUID=:RegionUUID", m_conn))
877 {
878 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
879 cmd.ExecuteNonQuery();
880 }
881
882 // the following is an work around for .NET. The perf
883 // issues associated with it aren't as bad as you think.
884 String sql = "insert into bakedterrain(RegionUUID, Revision, Heightfield)" +
885 " values(:RegionUUID, :Revision, :Heightfield)";
886
887 int terrainDBRevision;
888 Array terrainDBblob;
889 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
890
891 m_log.DebugFormat("{0} Storing bakedterrain format {1}", LogHeader, terrainDBRevision);
855 892
856 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) 893 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
857 { 894 {
@@ -913,6 +950,34 @@ namespace OpenSim.Data.SQLite
913 return terrData; 950 return terrData;
914 } 951 }
915 952
953 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
954 {
955 TerrainData terrData = null;
956
957 lock (ds)
958 {
959 String sql = "select RegionUUID, Revision, Heightfield from bakedterrain" +
960 " where RegionUUID=:RegionUUID";
961
962 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
963 {
964 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
965
966 using (IDataReader row = cmd.ExecuteReader())
967 {
968 int rev = 0;
969 if (row.Read())
970 {
971 rev = Convert.ToInt32(row["Revision"]);
972 byte[] blob = (byte[])row["Heightfield"];
973 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
974 }
975 }
976 }
977 }
978 return terrData;
979 }
980
916 public void RemoveLandObject(UUID globalID) 981 public void RemoveLandObject(UUID globalID)
917 { 982 {
918 lock (ds) 983 lock (ds)
@@ -1151,6 +1216,7 @@ namespace OpenSim.Data.SQLite
1151 createCol(prims, "OwnerID", typeof(String)); 1216 createCol(prims, "OwnerID", typeof(String));
1152 createCol(prims, "GroupID", typeof(String)); 1217 createCol(prims, "GroupID", typeof(String));
1153 createCol(prims, "LastOwnerID", typeof(String)); 1218 createCol(prims, "LastOwnerID", typeof(String));
1219 createCol(prims, "RezzerID", typeof(String));
1154 createCol(prims, "OwnerMask", typeof(Int32)); 1220 createCol(prims, "OwnerMask", typeof(Int32));
1155 createCol(prims, "NextOwnerMask", typeof(Int32)); 1221 createCol(prims, "NextOwnerMask", typeof(Int32));
1156 createCol(prims, "GroupMask", typeof(Int32)); 1222 createCol(prims, "GroupMask", typeof(Int32));
@@ -1232,7 +1298,7 @@ namespace OpenSim.Data.SQLite
1232 createCol(prims, "VolumeDetect", typeof(Int16)); 1298 createCol(prims, "VolumeDetect", typeof(Int16));
1233 1299
1234 createCol(prims, "MediaURL", typeof(String)); 1300 createCol(prims, "MediaURL", typeof(String));
1235 1301
1236 createCol(prims, "AttachedPosX", typeof(Double)); 1302 createCol(prims, "AttachedPosX", typeof(Double));
1237 createCol(prims, "AttachedPosY", typeof(Double)); 1303 createCol(prims, "AttachedPosY", typeof(Double));
1238 createCol(prims, "AttachedPosZ", typeof(Double)); 1304 createCol(prims, "AttachedPosZ", typeof(Double));
@@ -1246,6 +1312,7 @@ namespace OpenSim.Data.SQLite
1246 createCol(prims, "Restitution", typeof(Double)); 1312 createCol(prims, "Restitution", typeof(Double));
1247 1313
1248 createCol(prims, "KeyframeMotion", typeof(Byte[])); 1314 createCol(prims, "KeyframeMotion", typeof(Byte[]));
1315
1249 // Add in contraints 1316 // Add in contraints
1250 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; 1317 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
1251 1318
@@ -1353,7 +1420,7 @@ namespace OpenSim.Data.SQLite
1353 createCol(land, "Name", typeof(String)); 1420 createCol(land, "Name", typeof(String));
1354 createCol(land, "Desc", typeof(String)); 1421 createCol(land, "Desc", typeof(String));
1355 createCol(land, "OwnerUUID", typeof(String)); 1422 createCol(land, "OwnerUUID", typeof(String));
1356 createCol(land, "IsGroupOwned", typeof(Boolean)); 1423 createCol(land, "IsGroupOwned", typeof(string));
1357 createCol(land, "Area", typeof(Int32)); 1424 createCol(land, "Area", typeof(Int32));
1358 createCol(land, "AuctionID", typeof(Int32)); //Unemplemented 1425 createCol(land, "AuctionID", typeof(Int32)); //Unemplemented
1359 createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory 1426 createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory
@@ -1386,6 +1453,9 @@ namespace OpenSim.Data.SQLite
1386 createCol(land, "MediaLoop", typeof(Boolean)); 1453 createCol(land, "MediaLoop", typeof(Boolean));
1387 createCol(land, "ObscureMedia", typeof(Boolean)); 1454 createCol(land, "ObscureMedia", typeof(Boolean));
1388 createCol(land, "ObscureMusic", typeof(Boolean)); 1455 createCol(land, "ObscureMusic", typeof(Boolean));
1456 createCol(land, "SeeAVs", typeof(Boolean));
1457 createCol(land, "AnyAVSounds", typeof(Boolean));
1458 createCol(land, "GroupAVSounds", typeof(Boolean));
1389 1459
1390 land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; 1460 land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] };
1391 1461
@@ -1610,6 +1680,7 @@ namespace OpenSim.Data.SQLite
1610 prim.OwnerID = new UUID((String)row["OwnerID"]); 1680 prim.OwnerID = new UUID((String)row["OwnerID"]);
1611 prim.GroupID = new UUID((String)row["GroupID"]); 1681 prim.GroupID = new UUID((String)row["GroupID"]);
1612 prim.LastOwnerID = new UUID((String)row["LastOwnerID"]); 1682 prim.LastOwnerID = new UUID((String)row["LastOwnerID"]);
1683 prim.RezzerID = row["RezzerID"] == DBNull.Value ? UUID.Zero : new UUID((String)row["RezzerID"]);
1613 prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); 1684 prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]);
1614 prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); 1685 prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]);
1615 prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); 1686 prim.GroupMask = Convert.ToUInt32(row["GroupMask"]);
@@ -1724,7 +1795,7 @@ namespace OpenSim.Data.SQLite
1724// m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType()); 1795// m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType());
1725 prim.MediaUrl = (string)row["MediaURL"]; 1796 prim.MediaUrl = (string)row["MediaURL"];
1726 } 1797 }
1727 1798
1728 prim.AttachedPos = new Vector3( 1799 prim.AttachedPos = new Vector3(
1729 Convert.ToSingle(row["AttachedPosX"]), 1800 Convert.ToSingle(row["AttachedPosX"]),
1730 Convert.ToSingle(row["AttachedPosY"]), 1801 Convert.ToSingle(row["AttachedPosY"]),
@@ -1735,7 +1806,7 @@ namespace OpenSim.Data.SQLite
1735 { 1806 {
1736 //m_log.DebugFormat("[SQLITE]: DynAttrs type [{0}]", row["DynAttrs"].GetType()); 1807 //m_log.DebugFormat("[SQLITE]: DynAttrs type [{0}]", row["DynAttrs"].GetType());
1737 prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); 1808 prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
1738 } 1809 }
1739 else 1810 else
1740 { 1811 {
1741 prim.DynAttrs = new DAMap(); 1812 prim.DynAttrs = new DAMap();
@@ -1747,7 +1818,7 @@ namespace OpenSim.Data.SQLite
1747 prim.Friction = Convert.ToSingle(row["Friction"]); 1818 prim.Friction = Convert.ToSingle(row["Friction"]);
1748 prim.Restitution = Convert.ToSingle(row["Restitution"]); 1819 prim.Restitution = Convert.ToSingle(row["Restitution"]);
1749 1820
1750 1821
1751 if (!(row["KeyframeMotion"] is DBNull)) 1822 if (!(row["KeyframeMotion"] is DBNull))
1752 { 1823 {
1753 Byte[] data = (byte[])row["KeyframeMotion"]; 1824 Byte[] data = (byte[])row["KeyframeMotion"];
@@ -1760,7 +1831,24 @@ namespace OpenSim.Data.SQLite
1760 { 1831 {
1761 prim.KeyframeMotion = null; 1832 prim.KeyframeMotion = null;
1762 } 1833 }
1763 1834
1835 prim.PassCollisions = Convert.ToBoolean(row["PassCollisions"]);
1836 prim.PassTouches = Convert.ToBoolean(row["PassTouches"]);
1837 prim.RotationAxisLocks = Convert.ToByte(row["RotationAxisLocks"]);
1838
1839 SOPVehicle vehicle = null;
1840 if (!(row["Vehicle"] is DBNull) && row["Vehicle"].ToString() != String.Empty)
1841 {
1842 vehicle = SOPVehicle.FromXml2(row["Vehicle"].ToString());
1843 if (vehicle != null)
1844 prim.VehicleParams = vehicle;
1845 }
1846
1847 PhysicsInertiaData pdata = null;
1848 if (!(row["PhysInertia"] is DBNull) && row["PhysInertia"].ToString() != String.Empty)
1849 pdata = PhysicsInertiaData.FromXml2(row["PhysInertia"].ToString());
1850 prim.PhysicsInertia = pdata;
1851
1764 return prim; 1852 return prim;
1765 } 1853 }
1766 1854
@@ -1817,7 +1905,7 @@ namespace OpenSim.Data.SQLite
1817 newData.Name = (String)row["Name"]; 1905 newData.Name = (String)row["Name"];
1818 newData.Description = (String)row["Desc"]; 1906 newData.Description = (String)row["Desc"];
1819 newData.OwnerID = (UUID)(String)row["OwnerUUID"]; 1907 newData.OwnerID = (UUID)(String)row["OwnerUUID"];
1820 newData.IsGroupOwned = (Boolean)row["IsGroupOwned"]; 1908 newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
1821 newData.Area = Convert.ToInt32(row["Area"]); 1909 newData.Area = Convert.ToInt32(row["Area"]);
1822 newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented 1910 newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented
1823 newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]); 1911 newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]);
@@ -1845,6 +1933,10 @@ namespace OpenSim.Data.SQLite
1845 newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); 1933 newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]);
1846 newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); 1934 newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]);
1847 newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); 1935 newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]);
1936 newData.SeeAVs = Convert.ToBoolean(row["SeeAVs"]);
1937 newData.AnyAVSounds = Convert.ToBoolean(row["AnyAVSounds"]);
1938 newData.GroupAVSounds = Convert.ToBoolean(row["GroupAVSounds"]);
1939
1848 try 1940 try
1849 { 1941 {
1850 newData.UserLocation = 1942 newData.UserLocation =
@@ -1918,7 +2010,8 @@ namespace OpenSim.Data.SQLite
1918 newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); 2010 newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]);
1919 newSettings.TelehubObject = new UUID((String)row["TelehubObject"]); 2011 newSettings.TelehubObject = new UUID((String)row["TelehubObject"]);
1920 newSettings.ParcelImageID = new UUID((String)row["parcel_tile_ID"]); 2012 newSettings.ParcelImageID = new UUID((String)row["parcel_tile_ID"]);
1921 2013 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
2014 newSettings.Casino = Convert.ToBoolean(row["casino"]);
1922 return newSettings; 2015 return newSettings;
1923 } 2016 }
1924 2017
@@ -2013,6 +2106,7 @@ namespace OpenSim.Data.SQLite
2013 return entry; 2106 return entry;
2014 } 2107 }
2015 2108
2109
2016 /// <summary> 2110 /// <summary>
2017 /// 2111 ///
2018 /// </summary> 2112 /// </summary>
@@ -2039,6 +2133,7 @@ namespace OpenSim.Data.SQLite
2039 row["OwnerID"] = prim.OwnerID.ToString(); 2133 row["OwnerID"] = prim.OwnerID.ToString();
2040 row["GroupID"] = prim.GroupID.ToString(); 2134 row["GroupID"] = prim.GroupID.ToString();
2041 row["LastOwnerID"] = prim.LastOwnerID.ToString(); 2135 row["LastOwnerID"] = prim.LastOwnerID.ToString();
2136 row["RezzerID"] = prim.RezzerID.ToString();
2042 row["OwnerMask"] = prim.OwnerMask; 2137 row["OwnerMask"] = prim.OwnerMask;
2043 row["NextOwnerMask"] = prim.NextOwnerMask; 2138 row["NextOwnerMask"] = prim.NextOwnerMask;
2044 row["GroupMask"] = prim.GroupMask; 2139 row["GroupMask"] = prim.GroupMask;
@@ -2137,7 +2232,6 @@ namespace OpenSim.Data.SQLite
2137 // click action 2232 // click action
2138 row["ClickAction"] = prim.ClickAction; 2233 row["ClickAction"] = prim.ClickAction;
2139 2234
2140 row["SalePrice"] = prim.SalePrice;
2141 row["Material"] = prim.Material; 2235 row["Material"] = prim.Material;
2142 2236
2143 row["CollisionSound"] = prim.CollisionSound.ToString(); 2237 row["CollisionSound"] = prim.CollisionSound.ToString();
@@ -2168,8 +2262,21 @@ namespace OpenSim.Data.SQLite
2168 row["KeyframeMotion"] = prim.KeyframeMotion.Serialize(); 2262 row["KeyframeMotion"] = prim.KeyframeMotion.Serialize();
2169 else 2263 else
2170 row["KeyframeMotion"] = new Byte[0]; 2264 row["KeyframeMotion"] = new Byte[0];
2171 2265
2172 2266 row["PassTouches"] = prim.PassTouches;
2267 row["PassCollisions"] = prim.PassCollisions;
2268 row["RotationAxisLocks"] = prim.RotationAxisLocks;
2269
2270 if (prim.VehicleParams != null)
2271 row["Vehicle"] = prim.VehicleParams.ToXml2();
2272 else
2273 row["Vehicle"] = String.Empty;
2274
2275 if (prim.PhysicsInertia != null)
2276 row["PhysInertia"] = prim.PhysicsInertia.ToXml2();
2277 else
2278 row["PhysInertia"] = String.Empty;
2279
2173 } 2280 }
2174 2281
2175 /// <summary> 2282 /// <summary>
@@ -2220,7 +2327,7 @@ namespace OpenSim.Data.SQLite
2220 row["Name"] = land.Name; 2327 row["Name"] = land.Name;
2221 row["Desc"] = land.Description; 2328 row["Desc"] = land.Description;
2222 row["OwnerUUID"] = land.OwnerID.ToString(); 2329 row["OwnerUUID"] = land.OwnerID.ToString();
2223 row["IsGroupOwned"] = land.IsGroupOwned; 2330 row["IsGroupOwned"] = land.IsGroupOwned.ToString();
2224 row["Area"] = land.Area; 2331 row["Area"] = land.Area;
2225 row["AuctionID"] = land.AuctionID; //Unemplemented 2332 row["AuctionID"] = land.AuctionID; //Unemplemented
2226 row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory 2333 row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory
@@ -2253,6 +2360,10 @@ namespace OpenSim.Data.SQLite
2253 row["MediaLoop"] = land.MediaLoop; 2360 row["MediaLoop"] = land.MediaLoop;
2254 row["ObscureMusic"] = land.ObscureMusic; 2361 row["ObscureMusic"] = land.ObscureMusic;
2255 row["ObscureMedia"] = land.ObscureMedia; 2362 row["ObscureMedia"] = land.ObscureMedia;
2363 row["SeeAVs"] = land.SeeAVs;
2364 row["AnyAVSounds"] = land.AnyAVSounds;
2365 row["GroupAVSounds"] = land.GroupAVSounds;
2366
2256 } 2367 }
2257 2368
2258 /// <summary> 2369 /// <summary>
@@ -2311,6 +2422,8 @@ namespace OpenSim.Data.SQLite
2311 row["map_tile_ID"] = settings.TerrainImageID.ToString(); 2422 row["map_tile_ID"] = settings.TerrainImageID.ToString();
2312 row["TelehubObject"] = settings.TelehubObject.ToString(); 2423 row["TelehubObject"] = settings.TelehubObject.ToString();
2313 row["parcel_tile_ID"] = settings.ParcelImageID.ToString(); 2424 row["parcel_tile_ID"] = settings.ParcelImageID.ToString();
2425 row["block_search"] = settings.GodBlockSearch;
2426 row["casino"] = settings.Casino;
2314 } 2427 }
2315 2428
2316 /// <summary> 2429 /// <summary>
@@ -2430,7 +2543,7 @@ namespace OpenSim.Data.SQLite
2430 2543
2431 if (!(row["Media"] is System.DBNull)) 2544 if (!(row["Media"] is System.DBNull))
2432 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); 2545 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]);
2433 2546
2434 return s; 2547 return s;
2435 } 2548 }
2436 2549
@@ -2908,6 +3021,10 @@ namespace OpenSim.Data.SQLite
2908 { 3021 {
2909 return DbType.Binary; 3022 return DbType.Binary;
2910 } 3023 }
3024 else if (type == typeof(Boolean))
3025 {
3026 return DbType.Boolean;
3027 }
2911 else 3028 else
2912 { 3029 {
2913 return DbType.String; 3030 return DbType.String;
@@ -2944,6 +3061,11 @@ namespace OpenSim.Data.SQLite
2944 } 3061 }
2945 } 3062 }
2946 3063
3064 public UUID[] GetObjectIDs(UUID regionID)
3065 {
3066 return new UUID[0];
3067 }
3068
2947 public void SaveExtra(UUID regionID, string name, string value) 3069 public void SaveExtra(UUID regionID, string name, string value)
2948 { 3070 {
2949 } 3071 }
diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
index f98d376..1b79185 100644
--- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
@@ -75,12 +75,17 @@ namespace OpenSim.Data.SQLite
75 } 75 }
76 else 76 else
77 { 77 {
78 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", 78 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
79 m_Realm, scopeID.ToString(), words[0], words[1]); 79 m_Realm, scopeID.ToString(), words[0], words[1]);
80 } 80 }
81 81
82 return DoQuery(cmd); 82 return DoQuery(cmd);
83 } 83 }
84 } 84 }
85
86 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
87 {
88 return null;
89 }
85 } 90 }
86} 91}
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs
index cd3e8b6..13aac79 100644
--- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs
@@ -46,43 +46,43 @@ namespace OpenSim.Data.SQLite
46 { 46 {
47 private static readonly ILog m_log = 47 private static readonly ILog m_log =
48 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private SqliteConnection m_connection; 50 private SqliteConnection m_connection;
51 private string m_connectionString; 51 private string m_connectionString;
52 52
53 private Dictionary<string, FieldInfo> m_FieldMap = 53 private Dictionary<string, FieldInfo> m_FieldMap =
54 new Dictionary<string, FieldInfo>(); 54 new Dictionary<string, FieldInfo>();
55 55
56 protected virtual Assembly Assembly 56 protected virtual Assembly Assembly
57 { 57 {
58 get { return GetType().Assembly; } 58 get { return GetType().Assembly; }
59 } 59 }
60 60
61 public SQLiteUserProfilesData() 61 public SQLiteUserProfilesData()
62 { 62 {
63 } 63 }
64 64
65 public SQLiteUserProfilesData(string connectionString) 65 public SQLiteUserProfilesData(string connectionString)
66 { 66 {
67 Initialise(connectionString); 67 Initialise(connectionString);
68 } 68 }
69 69
70 public void Initialise(string connectionString) 70 public void Initialise(string connectionString)
71 { 71 {
72 if (Util.IsWindows()) 72 if (Util.IsWindows())
73 Util.LoadArchSpecificWindowsDll("sqlite3.dll"); 73 Util.LoadArchSpecificWindowsDll("sqlite3.dll");
74 74
75 m_connectionString = connectionString; 75 m_connectionString = connectionString;
76 76
77 m_log.Info("[PROFILES_DATA]: Sqlite - connecting: "+m_connectionString); 77 m_log.Info("[PROFILES_DATA]: Sqlite - connecting: "+m_connectionString);
78 78
79 m_connection = new SqliteConnection(m_connectionString); 79 m_connection = new SqliteConnection(m_connectionString);
80 m_connection.Open(); 80 m_connection.Open();
81 81
82 Migration m = new Migration(m_connection, Assembly, "UserProfiles"); 82 Migration m = new Migration(m_connection, Assembly, "UserProfiles");
83 m.Update(); 83 m.Update();
84 } 84 }
85 85
86 private string[] FieldList 86 private string[] FieldList
87 { 87 {
88 get { return new List<string>(m_FieldMap.Keys).ToArray(); } 88 get { return new List<string>(m_FieldMap.Keys).ToArray(); }
@@ -123,7 +123,7 @@ namespace OpenSim.Data.SQLite
123 } 123 }
124 124
125 reader.Close(); 125 reader.Close();
126 126
127 return data; 127 return data;
128 } 128 }
129 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) 129 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
@@ -162,21 +162,21 @@ namespace OpenSim.Data.SQLite
162 query += ":ParcelName,"; 162 query += ":ParcelName,";
163 query += ":Flags,"; 163 query += ":Flags,";
164 query += ":ListingPrice ) "; 164 query += ":ListingPrice ) ";
165 165
166 if(string.IsNullOrEmpty(ad.ParcelName)) 166 if(string.IsNullOrEmpty(ad.ParcelName))
167 ad.ParcelName = "Unknown"; 167 ad.ParcelName = "Unknown";
168 if(ad.ParcelId == null) 168 if(ad.ParcelId == null)
169 ad.ParcelId = UUID.Zero; 169 ad.ParcelId = UUID.Zero;
170 if(string.IsNullOrEmpty(ad.Description)) 170 if(string.IsNullOrEmpty(ad.Description))
171 ad.Description = "No Description"; 171 ad.Description = "No Description";
172 172
173 DateTime epoch = new DateTime(1970, 1, 1); 173 DateTime epoch = new DateTime(1970, 1, 1);
174 DateTime now = DateTime.Now; 174 DateTime now = DateTime.Now;
175 TimeSpan epochnow = now - epoch; 175 TimeSpan epochnow = now - epoch;
176 TimeSpan duration; 176 TimeSpan duration;
177 DateTime expiration; 177 DateTime expiration;
178 TimeSpan epochexp; 178 TimeSpan epochexp;
179 179
180 if(ad.Flags == 2) 180 if(ad.Flags == 2)
181 { 181 {
182 duration = new TimeSpan(7,0,0,0); 182 duration = new TimeSpan(7,0,0,0);
@@ -211,7 +211,7 @@ namespace OpenSim.Data.SQLite
211 cmd.Parameters.AddWithValue(":ParcelName", ad.ParcelName.ToString()); 211 cmd.Parameters.AddWithValue(":ParcelName", ad.ParcelName.ToString());
212 cmd.Parameters.AddWithValue(":Flags", ad.Flags.ToString()); 212 cmd.Parameters.AddWithValue(":Flags", ad.Flags.ToString());
213 cmd.Parameters.AddWithValue(":ListingPrice", ad.Price.ToString ()); 213 cmd.Parameters.AddWithValue(":ListingPrice", ad.Price.ToString ());
214 214
215 cmd.ExecuteNonQuery(); 215 cmd.ExecuteNonQuery();
216 } 216 }
217 } 217 }
@@ -227,17 +227,17 @@ namespace OpenSim.Data.SQLite
227 public bool DeleteClassifiedRecord(UUID recordId) 227 public bool DeleteClassifiedRecord(UUID recordId)
228 { 228 {
229 string query = string.Empty; 229 string query = string.Empty;
230 230
231 query += "DELETE FROM classifieds WHERE "; 231 query += "DELETE FROM classifieds WHERE ";
232 query += "classifieduuid = :ClasifiedId"; 232 query += "classifieduuid = :ClasifiedId";
233 233
234 try 234 try
235 { 235 {
236 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 236 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
237 { 237 {
238 cmd.CommandText = query; 238 cmd.CommandText = query;
239 cmd.Parameters.AddWithValue(":ClassifiedId", recordId.ToString()); 239 cmd.Parameters.AddWithValue(":ClassifiedId", recordId.ToString());
240 240
241 cmd.ExecuteNonQuery(); 241 cmd.ExecuteNonQuery();
242 } 242 }
243 } 243 }
@@ -254,17 +254,17 @@ namespace OpenSim.Data.SQLite
254 { 254 {
255 IDataReader reader = null; 255 IDataReader reader = null;
256 string query = string.Empty; 256 string query = string.Empty;
257 257
258 query += "SELECT * FROM classifieds WHERE "; 258 query += "SELECT * FROM classifieds WHERE ";
259 query += "classifieduuid = :AdId"; 259 query += "classifieduuid = :AdId";
260 260
261 try 261 try
262 { 262 {
263 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 263 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
264 { 264 {
265 cmd.CommandText = query; 265 cmd.CommandText = query;
266 cmd.Parameters.AddWithValue(":AdId", ad.ClassifiedId.ToString()); 266 cmd.Parameters.AddWithValue(":AdId", ad.ClassifiedId.ToString());
267 267
268 using (reader = cmd.ExecuteReader()) 268 using (reader = cmd.ExecuteReader())
269 { 269 {
270 if(reader.Read ()) 270 if(reader.Read ())
@@ -299,24 +299,24 @@ namespace OpenSim.Data.SQLite
299 { 299 {
300 IDataReader reader = null; 300 IDataReader reader = null;
301 string query = string.Empty; 301 string query = string.Empty;
302 302
303 query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; 303 query += "SELECT `pickuuid`,`name` FROM userpicks WHERE ";
304 query += "creatoruuid = :Id"; 304 query += "creatoruuid = :Id";
305 OSDArray data = new OSDArray(); 305 OSDArray data = new OSDArray();
306 306
307 try 307 try
308 { 308 {
309 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 309 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
310 { 310 {
311 cmd.CommandText = query; 311 cmd.CommandText = query;
312 cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); 312 cmd.Parameters.AddWithValue(":Id", avatarId.ToString());
313 313
314 using (reader = cmd.ExecuteReader()) 314 using (reader = cmd.ExecuteReader())
315 { 315 {
316 while (reader.Read()) 316 while (reader.Read())
317 { 317 {
318 OSDMap record = new OSDMap(); 318 OSDMap record = new OSDMap();
319 319
320 record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); 320 record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"]));
321 record.Add("name",OSD.FromString((string)reader["name"])); 321 record.Add("name",OSD.FromString((string)reader["name"]));
322 data.Add(record); 322 data.Add(record);
@@ -336,11 +336,11 @@ namespace OpenSim.Data.SQLite
336 IDataReader reader = null; 336 IDataReader reader = null;
337 string query = string.Empty; 337 string query = string.Empty;
338 UserProfilePick pick = new UserProfilePick(); 338 UserProfilePick pick = new UserProfilePick();
339 339
340 query += "SELECT * FROM userpicks WHERE "; 340 query += "SELECT * FROM userpicks WHERE ";
341 query += "creatoruuid = :CreatorId AND "; 341 query += "creatoruuid = :CreatorId AND ";
342 query += "pickuuid = :PickId"; 342 query += "pickuuid = :PickId";
343 343
344 try 344 try
345 { 345 {
346 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 346 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -348,17 +348,17 @@ namespace OpenSim.Data.SQLite
348 cmd.CommandText = query; 348 cmd.CommandText = query;
349 cmd.Parameters.AddWithValue(":CreatorId", avatarId.ToString()); 349 cmd.Parameters.AddWithValue(":CreatorId", avatarId.ToString());
350 cmd.Parameters.AddWithValue(":PickId", pickId.ToString()); 350 cmd.Parameters.AddWithValue(":PickId", pickId.ToString());
351 351
352 using (reader = cmd.ExecuteReader()) 352 using (reader = cmd.ExecuteReader())
353 { 353 {
354 354
355 while (reader.Read()) 355 while (reader.Read())
356 { 356 {
357 string description = (string)reader["description"]; 357 string description = (string)reader["description"];
358 358
359 if (string.IsNullOrEmpty(description)) 359 if (string.IsNullOrEmpty(description))
360 description = "No description given."; 360 description = "No description given.";
361 361
362 UUID.TryParse((string)reader["pickuuid"], out pick.PickId); 362 UUID.TryParse((string)reader["pickuuid"], out pick.PickId);
363 UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); 363 UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId);
364 UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); 364 UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId);
@@ -385,7 +385,7 @@ namespace OpenSim.Data.SQLite
385 } 385 }
386 386
387 public bool UpdatePicksRecord(UserProfilePick pick) 387 public bool UpdatePicksRecord(UserProfilePick pick)
388 { 388 {
389 string query = string.Empty; 389 string query = string.Empty;
390 390
391 query += "INSERT OR REPLACE INTO userpicks ("; 391 query += "INSERT OR REPLACE INTO userpicks (";
@@ -416,7 +416,7 @@ namespace OpenSim.Data.SQLite
416 query += ":GlobalPos,"; 416 query += ":GlobalPos,";
417 query += ":SortOrder,"; 417 query += ":SortOrder,";
418 query += ":Enabled) "; 418 query += ":Enabled) ";
419 419
420 try 420 try
421 { 421 {
422 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 422 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -456,10 +456,10 @@ namespace OpenSim.Data.SQLite
456 public bool DeletePicksRecord(UUID pickId) 456 public bool DeletePicksRecord(UUID pickId)
457 { 457 {
458 string query = string.Empty; 458 string query = string.Empty;
459 459
460 query += "DELETE FROM userpicks WHERE "; 460 query += "DELETE FROM userpicks WHERE ";
461 query += "pickuuid = :PickId"; 461 query += "pickuuid = :PickId";
462 462
463 try 463 try
464 { 464 {
465 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 465 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -479,15 +479,15 @@ namespace OpenSim.Data.SQLite
479 } 479 }
480 480
481 public bool GetAvatarNotes(ref UserProfileNotes notes) 481 public bool GetAvatarNotes(ref UserProfileNotes notes)
482 { 482 {
483 IDataReader reader = null; 483 IDataReader reader = null;
484 string query = string.Empty; 484 string query = string.Empty;
485 485
486 query += "SELECT `notes` FROM usernotes WHERE "; 486 query += "SELECT `notes` FROM usernotes WHERE ";
487 query += "useruuid = :Id AND "; 487 query += "useruuid = :Id AND ";
488 query += "targetuuid = :TargetId"; 488 query += "targetuuid = :TargetId";
489 OSDArray data = new OSDArray(); 489 OSDArray data = new OSDArray();
490 490
491 try 491 try
492 { 492 {
493 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 493 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -495,7 +495,7 @@ namespace OpenSim.Data.SQLite
495 cmd.CommandText = query; 495 cmd.CommandText = query;
496 cmd.Parameters.AddWithValue(":Id", notes.UserId.ToString()); 496 cmd.Parameters.AddWithValue(":Id", notes.UserId.ToString());
497 cmd.Parameters.AddWithValue(":TargetId", notes.TargetId.ToString()); 497 cmd.Parameters.AddWithValue(":TargetId", notes.TargetId.ToString());
498 498
499 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 499 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
500 { 500 {
501 while (reader.Read()) 501 while (reader.Read())
@@ -514,10 +514,10 @@ namespace OpenSim.Data.SQLite
514 } 514 }
515 515
516 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) 516 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
517 { 517 {
518 string query = string.Empty; 518 string query = string.Empty;
519 bool remove; 519 bool remove;
520 520
521 if(string.IsNullOrEmpty(note.Notes)) 521 if(string.IsNullOrEmpty(note.Notes))
522 { 522 {
523 remove = true; 523 remove = true;
@@ -533,7 +533,7 @@ namespace OpenSim.Data.SQLite
533 query += ":TargetId,"; 533 query += ":TargetId,";
534 query += ":Notes )"; 534 query += ":Notes )";
535 } 535 }
536 536
537 try 537 try
538 { 538 {
539 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 539 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -544,7 +544,7 @@ namespace OpenSim.Data.SQLite
544 cmd.Parameters.AddWithValue(":Notes", note.Notes); 544 cmd.Parameters.AddWithValue(":Notes", note.Notes);
545 cmd.Parameters.AddWithValue(":TargetId", note.TargetId.ToString ()); 545 cmd.Parameters.AddWithValue(":TargetId", note.TargetId.ToString ());
546 cmd.Parameters.AddWithValue(":UserId", note.UserId.ToString()); 546 cmd.Parameters.AddWithValue(":UserId", note.UserId.ToString());
547 547
548 cmd.ExecuteNonQuery(); 548 cmd.ExecuteNonQuery();
549 } 549 }
550 } 550 }
@@ -561,7 +561,7 @@ namespace OpenSim.Data.SQLite
561 { 561 {
562 IDataReader reader = null; 562 IDataReader reader = null;
563 string query = string.Empty; 563 string query = string.Empty;
564 564
565 query += "SELECT * FROM userprofile WHERE "; 565 query += "SELECT * FROM userprofile WHERE ";
566 query += "useruuid = :Id"; 566 query += "useruuid = :Id";
567 567
@@ -569,7 +569,7 @@ namespace OpenSim.Data.SQLite
569 { 569 {
570 cmd.CommandText = query; 570 cmd.CommandText = query;
571 cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); 571 cmd.Parameters.AddWithValue(":Id", props.UserId.ToString());
572 572
573 573
574 try 574 try
575 { 575 {
@@ -611,7 +611,7 @@ namespace OpenSim.Data.SQLite
611 props.Language = string.Empty; 611 props.Language = string.Empty;
612 props.PublishProfile = false; 612 props.PublishProfile = false;
613 props.PublishMature = false; 613 props.PublishMature = false;
614 614
615 query = "INSERT INTO userprofile ("; 615 query = "INSERT INTO userprofile (";
616 query += "useruuid, "; 616 query += "useruuid, ";
617 query += "profilePartner, "; 617 query += "profilePartner, ";
@@ -659,7 +659,7 @@ namespace OpenSim.Data.SQLite
659 put.Parameters.AddWithValue(":profileAboutText", props.AboutText); 659 put.Parameters.AddWithValue(":profileAboutText", props.AboutText);
660 put.Parameters.AddWithValue(":profileFirstImage", props.FirstLifeImageId.ToString()); 660 put.Parameters.AddWithValue(":profileFirstImage", props.FirstLifeImageId.ToString());
661 put.Parameters.AddWithValue(":profileFirstText", props.FirstLifeText); 661 put.Parameters.AddWithValue(":profileFirstText", props.FirstLifeText);
662 662
663 put.ExecuteNonQuery(); 663 put.ExecuteNonQuery();
664 } 664 }
665 } 665 }
@@ -668,9 +668,9 @@ namespace OpenSim.Data.SQLite
668 } 668 }
669 669
670 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) 670 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
671 { 671 {
672 string query = string.Empty; 672 string query = string.Empty;
673 673
674 query += "UPDATE userprofile SET "; 674 query += "UPDATE userprofile SET ";
675 query += "profileURL=:profileURL, "; 675 query += "profileURL=:profileURL, ";
676 query += "profileImage=:image, "; 676 query += "profileImage=:image, ";
@@ -678,7 +678,7 @@ namespace OpenSim.Data.SQLite
678 query += "profileFirstImage=:firstlifeimage,"; 678 query += "profileFirstImage=:firstlifeimage,";
679 query += "profileFirstText=:firstlifetext "; 679 query += "profileFirstText=:firstlifetext ";
680 query += "WHERE useruuid=:uuid"; 680 query += "WHERE useruuid=:uuid";
681 681
682 try 682 try
683 { 683 {
684 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 684 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -690,7 +690,7 @@ namespace OpenSim.Data.SQLite
690 cmd.Parameters.AddWithValue(":firstlifeimage", props.FirstLifeImageId.ToString()); 690 cmd.Parameters.AddWithValue(":firstlifeimage", props.FirstLifeImageId.ToString());
691 cmd.Parameters.AddWithValue(":firstlifetext", props.FirstLifeText); 691 cmd.Parameters.AddWithValue(":firstlifetext", props.FirstLifeText);
692 cmd.Parameters.AddWithValue(":uuid", props.UserId.ToString()); 692 cmd.Parameters.AddWithValue(":uuid", props.UserId.ToString());
693 693
694 cmd.ExecuteNonQuery(); 694 cmd.ExecuteNonQuery();
695 } 695 }
696 } 696 }
@@ -698,16 +698,16 @@ namespace OpenSim.Data.SQLite
698 { 698 {
699 m_log.ErrorFormat("[PROFILES_DATA]" + 699 m_log.ErrorFormat("[PROFILES_DATA]" +
700 ": AgentPropertiesUpdate exception {0}", e.Message); 700 ": AgentPropertiesUpdate exception {0}", e.Message);
701 701
702 return false; 702 return false;
703 } 703 }
704 return true; 704 return true;
705 } 705 }
706 706
707 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) 707 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
708 { 708 {
709 string query = string.Empty; 709 string query = string.Empty;
710 710
711 query += "UPDATE userprofile SET "; 711 query += "UPDATE userprofile SET ";
712 query += "profileWantToMask=:WantMask, "; 712 query += "profileWantToMask=:WantMask, ";
713 query += "profileWantToText=:WantText,"; 713 query += "profileWantToText=:WantText,";
@@ -715,7 +715,7 @@ namespace OpenSim.Data.SQLite
715 query += "profileSkillsText=:SkillsText, "; 715 query += "profileSkillsText=:SkillsText, ";
716 query += "profileLanguages=:Languages "; 716 query += "profileLanguages=:Languages ";
717 query += "WHERE useruuid=:uuid"; 717 query += "WHERE useruuid=:uuid";
718 718
719 try 719 try
720 { 720 {
721 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 721 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -727,7 +727,7 @@ namespace OpenSim.Data.SQLite
727 cmd.Parameters.AddWithValue(":SkillsText", up.SkillsText); 727 cmd.Parameters.AddWithValue(":SkillsText", up.SkillsText);
728 cmd.Parameters.AddWithValue(":Languages", up.Language); 728 cmd.Parameters.AddWithValue(":Languages", up.Language);
729 cmd.Parameters.AddWithValue(":uuid", up.UserId.ToString()); 729 cmd.Parameters.AddWithValue(":uuid", up.UserId.ToString());
730 730
731 cmd.ExecuteNonQuery(); 731 cmd.ExecuteNonQuery();
732 } 732 }
733 } 733 }
@@ -741,16 +741,17 @@ namespace OpenSim.Data.SQLite
741 return true; 741 return true;
742 } 742 }
743 743
744
744 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) 745 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
745 { 746 {
746 string query = string.Empty; 747 string query = string.Empty;
747 748
748 query += "UPDATE usersettings SET "; 749 query += "UPDATE usersettings SET ";
749 query += "imviaemail=:ImViaEmail, "; 750 query += "imviaemail=:ImViaEmail, ";
750 query += "visible=:Visible, "; 751 query += "visible=:Visible, ";
751 query += "email=:EMail "; 752 query += "email=:EMail ";
752 query += "WHERE useruuid=:uuid"; 753 query += "WHERE useruuid=:uuid";
753 754
754 try 755 try
755 { 756 {
756 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 757 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -760,7 +761,7 @@ namespace OpenSim.Data.SQLite
760 cmd.Parameters.AddWithValue(":Visible", pref.Visible); 761 cmd.Parameters.AddWithValue(":Visible", pref.Visible);
761 cmd.Parameters.AddWithValue(":EMail", pref.EMail); 762 cmd.Parameters.AddWithValue(":EMail", pref.EMail);
762 cmd.Parameters.AddWithValue(":uuid", pref.UserId.ToString()); 763 cmd.Parameters.AddWithValue(":uuid", pref.UserId.ToString());
763 764
764 cmd.ExecuteNonQuery(); 765 cmd.ExecuteNonQuery();
765 } 766 }
766 } 767 }
@@ -778,20 +779,20 @@ namespace OpenSim.Data.SQLite
778 { 779 {
779 IDataReader reader = null; 780 IDataReader reader = null;
780 string query = string.Empty; 781 string query = string.Empty;
781 782
782 query += "SELECT imviaemail,visible,email FROM "; 783 query += "SELECT imviaemail,visible,email FROM ";
783 query += "usersettings WHERE "; 784 query += "usersettings WHERE ";
784 query += "useruuid = :Id"; 785 query += "useruuid = :Id";
785 786
786 OSDArray data = new OSDArray(); 787 OSDArray data = new OSDArray();
787 788
788 try 789 try
789 { 790 {
790 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 791 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
791 { 792 {
792 cmd.CommandText = query; 793 cmd.CommandText = query;
793 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); 794 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString());
794 795
795 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 796 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
796 { 797 {
797 if(reader.Read()) 798 if(reader.Read())
@@ -804,13 +805,13 @@ namespace OpenSim.Data.SQLite
804 { 805 {
805 query = "INSERT INTO usersettings VALUES "; 806 query = "INSERT INTO usersettings VALUES ";
806 query += "(:Id,'false','false', :Email)"; 807 query += "(:Id,'false','false', :Email)";
807 808
808 using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) 809 using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand())
809 { 810 {
810 put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); 811 put.Parameters.AddWithValue(":Id", pref.UserId.ToString());
811 put.Parameters.AddWithValue(":Email", pref.EMail); 812 put.Parameters.AddWithValue(":Email", pref.EMail);
812 put.ExecuteNonQuery(); 813 put.ExecuteNonQuery();
813 814
814 } 815 }
815 } 816 }
816 } 817 }
@@ -830,11 +831,11 @@ namespace OpenSim.Data.SQLite
830 { 831 {
831 IDataReader reader = null; 832 IDataReader reader = null;
832 string query = string.Empty; 833 string query = string.Empty;
833 834
834 query += "SELECT * FROM `userdata` WHERE "; 835 query += "SELECT * FROM `userdata` WHERE ";
835 query += "UserId = :Id AND "; 836 query += "UserId = :Id AND ";
836 query += "TagId = :TagId"; 837 query += "TagId = :TagId";
837 838
838 try 839 try
839 { 840 {
840 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 841 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -842,7 +843,7 @@ namespace OpenSim.Data.SQLite
842 cmd.CommandText = query; 843 cmd.CommandText = query;
843 cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); 844 cmd.Parameters.AddWithValue(":Id", props.UserId.ToString());
844 cmd.Parameters.AddWithValue (":TagId", props.TagId.ToString()); 845 cmd.Parameters.AddWithValue (":TagId", props.TagId.ToString());
845 846
846 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 847 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
847 { 848 {
848 if(reader.Read()) 849 if(reader.Read())
@@ -857,7 +858,7 @@ namespace OpenSim.Data.SQLite
857 query += ":TagId,"; 858 query += ":TagId,";
858 query += ":DataKey,"; 859 query += ":DataKey,";
859 query += ":DataVal) "; 860 query += ":DataVal) ";
860 861
861 using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) 862 using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand())
862 { 863 {
863 put.Parameters.AddWithValue(":Id", props.UserId.ToString()); 864 put.Parameters.AddWithValue(":Id", props.UserId.ToString());
@@ -881,16 +882,16 @@ namespace OpenSim.Data.SQLite
881 return true; 882 return true;
882 } 883 }
883 public bool SetUserAppData(UserAppData props, ref string result) 884 public bool SetUserAppData(UserAppData props, ref string result)
884 { 885 {
885 string query = string.Empty; 886 string query = string.Empty;
886 887
887 query += "UPDATE userdata SET "; 888 query += "UPDATE userdata SET ";
888 query += "TagId = :TagId, "; 889 query += "TagId = :TagId, ";
889 query += "DataKey = :DataKey, "; 890 query += "DataKey = :DataKey, ";
890 query += "DataVal = :DataVal WHERE "; 891 query += "DataVal = :DataVal WHERE ";
891 query += "UserId = :UserId AND "; 892 query += "UserId = :UserId AND ";
892 query += "TagId = :TagId"; 893 query += "TagId = :TagId";
893 894
894 try 895 try
895 { 896 {
896 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 897 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
@@ -917,17 +918,17 @@ namespace OpenSim.Data.SQLite
917 IDataReader reader = null; 918 IDataReader reader = null;
918 OSDArray data = new OSDArray(); 919 OSDArray data = new OSDArray();
919 string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = :Id"; 920 string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = :Id";
920 921
921 // Get classified image assets 922 // Get classified image assets
922 923
923 924
924 try 925 try
925 { 926 {
926 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 927 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
927 { 928 {
928 cmd.CommandText = query; 929 cmd.CommandText = query;
929 cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); 930 cmd.Parameters.AddWithValue(":Id", avatarId.ToString());
930 931
931 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 932 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
932 { 933 {
933 while(reader.Read()) 934 while(reader.Read())
@@ -941,7 +942,7 @@ namespace OpenSim.Data.SQLite
941 { 942 {
942 cmd.CommandText = query; 943 cmd.CommandText = query;
943 cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); 944 cmd.Parameters.AddWithValue(":Id", avatarId.ToString());
944 945
945 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 946 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
946 { 947 {
947 if(reader.Read()) 948 if(reader.Read())
@@ -950,14 +951,14 @@ namespace OpenSim.Data.SQLite
950 } 951 }
951 } 952 }
952 } 953 }
953 954
954 query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = :Id"; 955 query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = :Id";
955 956
956 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 957 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
957 { 958 {
958 cmd.CommandText = query; 959 cmd.CommandText = query;
959 cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); 960 cmd.Parameters.AddWithValue(":Id", avatarId.ToString());
960 961
961 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 962 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
962 { 963 {
963 if(reader.Read()) 964 if(reader.Read())
diff --git a/OpenSim/Data/SQLite/SQLiteUtils.cs b/OpenSim/Data/SQLite/SQLiteUtils.cs
index ca5861f..1218ebb 100644
--- a/OpenSim/Data/SQLite/SQLiteUtils.cs
+++ b/OpenSim/Data/SQLite/SQLiteUtils.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Data.SQLite
49 **********************************************************************/ 49 **********************************************************************/
50 50
51 /// <summary> 51 /// <summary>
52 /// 52 ///
53 /// </summary> 53 /// </summary>
54 /// <param name="dt"></param> 54 /// <param name="dt"></param>
55 /// <param name="name"></param> 55 /// <param name="name"></param>
@@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLite
147 } 147 }
148 148
149 /// <summary> 149 /// <summary>
150 /// 150 ///
151 /// </summary> 151 /// </summary>
152 /// <param name="dt">Data Table</param> 152 /// <param name="dt">Data Table</param>
153 /// <returns></returns> 153 /// <returns></returns>
@@ -191,7 +191,7 @@ namespace OpenSim.Data.SQLite
191 /// lines for defining SqliteParameters to 2 parameters: 191 /// lines for defining SqliteParameters to 2 parameters:
192 /// column name and database type. 192 /// column name and database type.
193 /// </para> 193 /// </para>
194 /// 194 ///
195 /// <para> 195 /// <para>
196 /// It assumes certain conventions like :param as the param 196 /// It assumes certain conventions like :param as the param
197 /// name to replace in parametrized queries, and that source 197 /// name to replace in parametrized queries, and that source
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 2a0a8f6..4ef1f30 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -107,7 +107,7 @@ namespace OpenSim.Data.SQLite
107 public bool DeleteItems(string[] fields, string[] vals) 107 public bool DeleteItems(string[] fields, string[] vals)
108 { 108 {
109 return m_Items.Delete(fields, vals); 109 return m_Items.Delete(fields, vals);
110 } 110 }
111 111
112 public bool MoveItem(string id, string newParent) 112 public bool MoveItem(string id, string newParent)
113 { 113 {
@@ -302,20 +302,14 @@ namespace OpenSim.Data.SQLite
302 { 302 {
303// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); 303// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
304// Util.PrintCallStack(); 304// Util.PrintCallStack();
305 305
306 using (SqliteCommand cmd = new SqliteCommand()) 306 using (SqliteCommand cmd = new SqliteCommand())
307 { 307 {
308 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID"; 308 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = :folderID";
309 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID)); 309 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
310 310
311 try 311 if(ExecuteNonQuery(cmd, m_Connection) == 0)
312 {
313 cmd.ExecuteNonQuery();
314 }
315 catch (Exception)
316 {
317 return false; 312 return false;
318 }
319 } 313 }
320 314
321 return true; 315 return true;
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index 5d7b169..70880cf 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Data.Tests
110 public void T010_StoreReadVerifyAssets() 110 public void T010_StoreReadVerifyAssets()
111 { 111 {
112 TestHelpers.InMethod(); 112 TestHelpers.InMethod();
113 113
114 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString()); 114 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString());
115 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString()); 115 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString());
116 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString()); 116 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString());
@@ -125,14 +125,20 @@ namespace OpenSim.Data.Tests
125 m_db.StoreAsset(a1); 125 m_db.StoreAsset(a1);
126 m_db.StoreAsset(a2); 126 m_db.StoreAsset(a2);
127 m_db.StoreAsset(a3); 127 m_db.StoreAsset(a3);
128 128 a1.UploadAttempts = 0;
129 a2.UploadAttempts = 0;
130 a3.UploadAttempts = 0;
131
129 AssetBase a1a = m_db.GetAsset(uuid1); 132 AssetBase a1a = m_db.GetAsset(uuid1);
133 a1a.UploadAttempts = 0;
130 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); 134 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
131 135
132 AssetBase a2a = m_db.GetAsset(uuid2); 136 AssetBase a2a = m_db.GetAsset(uuid2);
137 a2a.UploadAttempts = 0;
133 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); 138 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
134 139
135 AssetBase a3a = m_db.GetAsset(uuid3); 140 AssetBase a3a = m_db.GetAsset(uuid3);
141 a3a.UploadAttempts = 0;
136 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); 142 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
137 143
138 scrambler.Scramble(a1a); 144 scrambler.Scramble(a1a);
@@ -142,14 +148,20 @@ namespace OpenSim.Data.Tests
142 m_db.StoreAsset(a1a); 148 m_db.StoreAsset(a1a);
143 m_db.StoreAsset(a2a); 149 m_db.StoreAsset(a2a);
144 m_db.StoreAsset(a3a); 150 m_db.StoreAsset(a3a);
151 a1a.UploadAttempts = 0;
152 a2a.UploadAttempts = 0;
153 a3a.UploadAttempts = 0;
145 154
146 AssetBase a1b = m_db.GetAsset(uuid1); 155 AssetBase a1b = m_db.GetAsset(uuid1);
156 a1b.UploadAttempts = 0;
147 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); 157 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
148 158
149 AssetBase a2b = m_db.GetAsset(uuid2); 159 AssetBase a2b = m_db.GetAsset(uuid2);
160 a2b.UploadAttempts = 0;
150 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); 161 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
151 162
152 AssetBase a3b = m_db.GetAsset(uuid3); 163 AssetBase a3b = m_db.GetAsset(uuid3);
164 a3b.UploadAttempts = 0;
153 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); 165 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
154 166
155 bool[] exist = m_db.AssetsExist(new[] { uuid1, uuid2, uuid3 }); 167 bool[] exist = m_db.AssetsExist(new[] { uuid1, uuid2, uuid3 });
@@ -178,7 +190,7 @@ namespace OpenSim.Data.Tests
178 public void T020_CheckForWeirdCreatorID() 190 public void T020_CheckForWeirdCreatorID()
179 { 191 {
180 TestHelpers.InMethod(); 192 TestHelpers.InMethod();
181 193
182 // It is expected that eventually the CreatorID might be an arbitrary string (an URI) 194 // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
183 // rather than a valid UUID (?). This test is to make sure that the database layer does not 195 // rather than a valid UUID (?). This test is to make sure that the database layer does not
184 // attempt to convert CreatorID to GUID, but just passes it both ways as a string. 196 // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
@@ -190,16 +202,22 @@ namespace OpenSim.Data.Tests
190 a3.Data = data1; 202 a3.Data = data1;
191 203
192 m_db.StoreAsset(a1); 204 m_db.StoreAsset(a1);
205 a1.UploadAttempts = 0;
193 m_db.StoreAsset(a2); 206 m_db.StoreAsset(a2);
207 a2.UploadAttempts = 0;
194 m_db.StoreAsset(a3); 208 m_db.StoreAsset(a3);
209 a3.UploadAttempts = 0;
195 210
196 AssetBase a1a = m_db.GetAsset(uuid1); 211 AssetBase a1a = m_db.GetAsset(uuid1);
212 a1a.UploadAttempts = 0;
197 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); 213 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
198 214
199 AssetBase a2a = m_db.GetAsset(uuid2); 215 AssetBase a2a = m_db.GetAsset(uuid2);
216 a2a.UploadAttempts = 0;
200 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); 217 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
201 218
202 AssetBase a3a = m_db.GetAsset(uuid3); 219 AssetBase a3a = m_db.GetAsset(uuid3);
220 a3a.UploadAttempts = 0;
203 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); 221 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
204 } 222 }
205 } 223 }
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
index 8c296b9..79691e4 100644
--- a/OpenSim/Data/Tests/BasicDataServiceTest.cs
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -41,11 +41,11 @@ using System.Reflection;
41 41
42namespace OpenSim.Data.Tests 42namespace OpenSim.Data.Tests
43{ 43{
44 /// <summary>This is a base class for testing any Data service for any DBMS. 44 /// <summary>This is a base class for testing any Data service for any DBMS.
45 /// Requires NUnit 2.5 or better (to support the generics). 45 /// Requires NUnit 2.5 or better (to support the generics).
46 /// </summary> 46 /// </summary>
47 /// <remarks> 47 /// <remarks>
48 /// FIXME: Should extend OpenSimTestCase but compile on mono 2.4.3 currently fails with 48 /// FIXME: Should extend OpenSimTestCase but compile on mono 2.4.3 currently fails with
49 /// AssetTests`2 : System.MemberAccessException : Cannot create an instance of OpenSim.Data.Tests.AssetTests`2[TConn,TAssetData] because Type.ContainsGenericParameters is true. 49 /// AssetTests`2 : System.MemberAccessException : Cannot create an instance of OpenSim.Data.Tests.AssetTests`2[TConn,TAssetData] because Type.ContainsGenericParameters is true.
50 /// and similar on EstateTests, InventoryTests and RegionTests. 50 /// and similar on EstateTests, InventoryTests and RegionTests.
51 /// Runs fine with mono 2.10.8.1, so easiest thing is to wait until min Mono version uplifts. 51 /// Runs fine with mono 2.10.8.1, so easiest thing is to wait until min Mono version uplifts.
@@ -60,7 +60,7 @@ namespace OpenSim.Data.Tests
60 private TService m_service; 60 private TService m_service;
61 private string m_file; 61 private string m_file;
62 62
63 // TODO: Is this in the right place here? 63 // TODO: Is this in the right place here?
64 // Later: apparently it's not, but does it matter here? 64 // Later: apparently it's not, but does it matter here?
65// protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 65// protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
66 66
@@ -68,7 +68,7 @@ namespace OpenSim.Data.Tests
68 68
69 public BasicDataServiceTest() 69 public BasicDataServiceTest()
70 : this("") 70 : this("")
71 { 71 {
72 } 72 }
73 73
74 public BasicDataServiceTest(string conn) 74 public BasicDataServiceTest(string conn)
@@ -106,7 +106,7 @@ namespace OpenSim.Data.Tests
106 if (String.IsNullOrEmpty(m_connStr)) 106 if (String.IsNullOrEmpty(m_connStr))
107 { 107 {
108 m_file = Path.GetTempFileName() + ".db"; 108 m_file = Path.GetTempFileName() + ".db";
109 m_connStr = "URI=file:../db/" + m_file + ",version=3"; 109 m_connStr = "URI=file:" + m_file + ",version=3";
110 } 110 }
111 } 111 }
112 112
@@ -226,7 +226,7 @@ namespace OpenSim.Data.Tests
226 } 226 }
227 } 227 }
228 228
229 /// <summary>Clear tables listed as parameters (without dropping them). 229 /// <summary>Clear tables listed as parameters (without dropping them).
230 /// </summary> 230 /// </summary>
231 /// <param name="tables"></param> 231 /// <param name="tables"></param>
232 protected virtual void ResetMigrations(params string[] stores) 232 protected virtual void ResetMigrations(params string[] stores)
@@ -251,7 +251,7 @@ namespace OpenSim.Data.Tests
251 } 251 }
252 } 252 }
253 253
254 /// <summary>Clear tables listed as parameters (without dropping them). 254 /// <summary>Clear tables listed as parameters (without dropping them).
255 /// </summary> 255 /// </summary>
256 /// <param name="tables"></param> 256 /// <param name="tables"></param>
257 protected virtual void ClearTables(params string[] tables) 257 protected virtual void ClearTables(params string[] tables)
diff --git a/OpenSim/Data/Tests/DefaultTestConns.cs b/OpenSim/Data/Tests/DefaultTestConns.cs
index 7c47bdd..5ad238b 100644
--- a/OpenSim/Data/Tests/DefaultTestConns.cs
+++ b/OpenSim/Data/Tests/DefaultTestConns.cs
@@ -39,16 +39,16 @@ namespace OpenSim.Data.Tests
39 /// a connection string for testing one of the supported databases. 39 /// a connection string for testing one of the supported databases.
40 /// The connections must be in the section [TestConnections] with names matching the connection class 40 /// The connections must be in the section [TestConnections] with names matching the connection class
41 /// name for the specific database, e.g.: 41 /// name for the specific database, e.g.:
42 /// 42 ///
43 /// [TestConnections] 43 /// [TestConnections]
44 /// MySqlConnection="..." 44 /// MySqlConnection="..."
45 /// SqlConnection="..." 45 /// SqlConnection="..."
46 /// SqliteConnection="..." 46 /// SqliteConnection="..."
47 /// 47 ///
48 /// Note that the conn string may also be set explicitly in the [TestCase()] attribute of test classes 48 /// Note that the conn string may also be set explicitly in the [TestCase()] attribute of test classes
49 /// based on BasicDataServiceTest.cs. 49 /// based on BasicDataServiceTest.cs.
50 /// </summary> 50 /// </summary>
51 51
52 static class DefaultTestConns 52 static class DefaultTestConns
53 { 53 {
54 private static Dictionary<Type, string> conns = new Dictionary<Type, string>(); 54 private static Dictionary<Type, string> conns = new Dictionary<Type, string>();
@@ -63,8 +63,8 @@ namespace OpenSim.Data.Tests
63 Assembly asm = Assembly.GetExecutingAssembly(); 63 Assembly asm = Assembly.GetExecutingAssembly();
64 string sType = connType.Name; 64 string sType = connType.Name;
65 65
66 // Note: when running from NUnit, the DLL is located in some temp dir, so how do we get 66 // Note: when running from NUnit, the DLL is located in some temp dir, so how do we get
67 // to the INI file? Ok, so put it into the resources! 67 // to the INI file? Ok, so put it into the resources!
68 // string iniName = Path.Combine(Path.GetDirectoryName(asm.Location), "TestDataConnections.ini"); 68 // string iniName = Path.Combine(Path.GetDirectoryName(asm.Location), "TestDataConnections.ini");
69 69
70 string[] allres = asm.GetManifestResourceNames(); 70 string[] allres = asm.GetManifestResourceNames();
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index e2b2d12..cf3f2b4 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Data.Tests
100 public void T010_EstateSettingsSimpleStorage_MinimumParameterSet() 100 public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
101 { 101 {
102 TestHelpers.InMethod(); 102 TestHelpers.InMethod();
103 103
104 EstateSettingsSimpleStorage( 104 EstateSettingsSimpleStorage(
105 REGION_ID, 105 REGION_ID,
106 DataTestUtil.STRING_MIN, 106 DataTestUtil.STRING_MIN,
@@ -133,7 +133,7 @@ namespace OpenSim.Data.Tests
133 public void T011_EstateSettingsSimpleStorage_MaximumParameterSet() 133 public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
134 { 134 {
135 TestHelpers.InMethod(); 135 TestHelpers.InMethod();
136 136
137 EstateSettingsSimpleStorage( 137 EstateSettingsSimpleStorage(
138 REGION_ID, 138 REGION_ID,
139 DataTestUtil.STRING_MAX(64), 139 DataTestUtil.STRING_MAX(64),
@@ -166,7 +166,7 @@ namespace OpenSim.Data.Tests
166 public void T012_EstateSettingsSimpleStorage_AccurateParameterSet() 166 public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
167 { 167 {
168 TestHelpers.InMethod(); 168 TestHelpers.InMethod();
169 169
170 EstateSettingsSimpleStorage( 170 EstateSettingsSimpleStorage(
171 REGION_ID, 171 REGION_ID,
172 DataTestUtil.STRING_MAX(1), 172 DataTestUtil.STRING_MAX(1),
@@ -199,7 +199,7 @@ namespace OpenSim.Data.Tests
199 public void T012_EstateSettingsRandomStorage() 199 public void T012_EstateSettingsRandomStorage()
200 { 200 {
201 TestHelpers.InMethod(); 201 TestHelpers.InMethod();
202 202
203 // Letting estate store generate rows to database for us 203 // Letting estate store generate rows to database for us
204 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 204 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
205 new PropertyScrambler<EstateSettings>() 205 new PropertyScrambler<EstateSettings>()
@@ -220,7 +220,7 @@ namespace OpenSim.Data.Tests
220 public void T020_EstateSettingsManagerList() 220 public void T020_EstateSettingsManagerList()
221 { 221 {
222 TestHelpers.InMethod(); 222 TestHelpers.InMethod();
223 223
224 // Letting estate store generate rows to database for us 224 // Letting estate store generate rows to database for us
225 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 225 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
226 226
@@ -241,7 +241,7 @@ namespace OpenSim.Data.Tests
241 public void T021_EstateSettingsUserList() 241 public void T021_EstateSettingsUserList()
242 { 242 {
243 TestHelpers.InMethod(); 243 TestHelpers.InMethod();
244 244
245 // Letting estate store generate rows to database for us 245 // Letting estate store generate rows to database for us
246 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 246 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
247 247
@@ -262,7 +262,7 @@ namespace OpenSim.Data.Tests
262 public void T022_EstateSettingsGroupList() 262 public void T022_EstateSettingsGroupList()
263 { 263 {
264 TestHelpers.InMethod(); 264 TestHelpers.InMethod();
265 265
266 // Letting estate store generate rows to database for us 266 // Letting estate store generate rows to database for us
267 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 267 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
268 268
@@ -283,7 +283,7 @@ namespace OpenSim.Data.Tests
283 public void T022_EstateSettingsBanList() 283 public void T022_EstateSettingsBanList()
284 { 284 {
285 TestHelpers.InMethod(); 285 TestHelpers.InMethod();
286 286
287 // Letting estate store generate rows to database for us 287 // Letting estate store generate rows to database for us
288 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 288 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
289 289
@@ -310,7 +310,7 @@ namespace OpenSim.Data.Tests
310 310
311 #endregion 311 #endregion
312 312
313 #region Parametrizable Test Implementations 313 #region Parametrizable Test Implementations
314 314
315 private void EstateSettingsSimpleStorage( 315 private void EstateSettingsSimpleStorage(
316 UUID regionId, 316 UUID regionId,
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index 3edf89d..da6e7d4 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -44,14 +44,9 @@ using OpenSim.Data.SQLite;
44 44
45namespace OpenSim.Data.Tests 45namespace OpenSim.Data.Tests
46{ 46{
47 [TestFixture(Description = "Inventory store tests (SQLite)")]
48 public class SQLiteInventoryTests : InventoryTests<SqliteConnection, SQLiteInventoryStore>
49 {
50 }
51
52 [TestFixture(Description = "Inventory store tests (MySQL)")] 47 [TestFixture(Description = "Inventory store tests (MySQL)")]
53 public class MySqlInventoryTests : InventoryTests<MySqlConnection, MySQLInventoryData> 48 public class MySqlInventoryTests : InventoryTests<MySqlConnection, MySQLInventoryData>
54 { 49 {
55 } 50 }
56 51
57 public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore> 52 public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore>
@@ -107,7 +102,7 @@ namespace OpenSim.Data.Tests
107 public void T001_LoadEmpty() 102 public void T001_LoadEmpty()
108 { 103 {
109 TestHelpers.InMethod(); 104 TestHelpers.InMethod();
110 105
111 Assert.That(db.getInventoryFolder(zero), Is.Null); 106 Assert.That(db.getInventoryFolder(zero), Is.Null);
112 Assert.That(db.getInventoryFolder(folder1), Is.Null); 107 Assert.That(db.getInventoryFolder(folder1), Is.Null);
113 Assert.That(db.getInventoryFolder(folder2), Is.Null); 108 Assert.That(db.getInventoryFolder(folder2), Is.Null);
@@ -127,7 +122,7 @@ namespace OpenSim.Data.Tests
127 public void T010_FolderNonParent() 122 public void T010_FolderNonParent()
128 { 123 {
129 TestHelpers.InMethod(); 124 TestHelpers.InMethod();
130 125
131 InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2); 126 InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2);
132 // the folder will go in 127 // the folder will go in
133 db.addInventoryFolder(f1); 128 db.addInventoryFolder(f1);
@@ -139,7 +134,7 @@ namespace OpenSim.Data.Tests
139 public void T011_FolderCreate() 134 public void T011_FolderCreate()
140 { 135 {
141 TestHelpers.InMethod(); 136 TestHelpers.InMethod();
142 137
143 InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1); 138 InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1);
144 // TODO: this is probably wrong behavior, but is what we have 139 // TODO: this is probably wrong behavior, but is what we have
145 // db.updateInventoryFolder(f1); 140 // db.updateInventoryFolder(f1);
@@ -164,7 +159,7 @@ namespace OpenSim.Data.Tests
164 public void T012_FolderList() 159 public void T012_FolderList()
165 { 160 {
166 TestHelpers.InMethod(); 161 TestHelpers.InMethod();
167 162
168 InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3); 163 InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3);
169 db.addInventoryFolder(f2); 164 db.addInventoryFolder(f2);
170 165
@@ -180,7 +175,7 @@ namespace OpenSim.Data.Tests
180 public void T013_FolderHierarchy() 175 public void T013_FolderHierarchy()
181 { 176 {
182 TestHelpers.InMethod(); 177 TestHelpers.InMethod();
183 178
184 int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned) 179 int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned)
185 Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); 180 Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
186 n = db.getFolderHierarchy(folder1).Count; 181 n = db.getFolderHierarchy(folder1).Count;
@@ -195,7 +190,7 @@ namespace OpenSim.Data.Tests
195 public void T014_MoveFolder() 190 public void T014_MoveFolder()
196 { 191 {
197 TestHelpers.InMethod(); 192 TestHelpers.InMethod();
198 193
199 InventoryFolderBase f2 = db.getInventoryFolder(folder2); 194 InventoryFolderBase f2 = db.getInventoryFolder(folder2);
200 f2.ParentID = folder3; 195 f2.ParentID = folder3;
201 db.moveInventoryFolder(f2); 196 db.moveInventoryFolder(f2);
@@ -211,7 +206,7 @@ namespace OpenSim.Data.Tests
211 public void T015_FolderHierarchy() 206 public void T015_FolderHierarchy()
212 { 207 {
213 TestHelpers.InMethod(); 208 TestHelpers.InMethod();
214 209
215 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); 210 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
216 Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))"); 211 Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
217 Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))"); 212 Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
@@ -224,7 +219,7 @@ namespace OpenSim.Data.Tests
224 public void T100_NoItems() 219 public void T100_NoItems()
225 { 220 {
226 TestHelpers.InMethod(); 221 TestHelpers.InMethod();
227 222
228 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))"); 223 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
229 Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))"); 224 Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))");
230 Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))"); 225 Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))");
@@ -238,7 +233,7 @@ namespace OpenSim.Data.Tests
238 public void T101_CreatItems() 233 public void T101_CreatItems()
239 { 234 {
240 TestHelpers.InMethod(); 235 TestHelpers.InMethod();
241 236
242 db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1)); 237 db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1));
243 db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2)); 238 db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2));
244 db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3)); 239 db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3));
@@ -249,7 +244,7 @@ namespace OpenSim.Data.Tests
249 public void T102_CompareItems() 244 public void T102_CompareItems()
250 { 245 {
251 TestHelpers.InMethod(); 246 TestHelpers.InMethod();
252 247
253 InventoryItemBase i1 = db.getInventoryItem(item1); 248 InventoryItemBase i1 = db.getInventoryItem(item1);
254 InventoryItemBase i2 = db.getInventoryItem(item2); 249 InventoryItemBase i2 = db.getInventoryItem(item2);
255 InventoryItemBase i3 = db.getInventoryItem(item3); 250 InventoryItemBase i3 = db.getInventoryItem(item3);
@@ -268,7 +263,7 @@ namespace OpenSim.Data.Tests
268 public void T103_UpdateItem() 263 public void T103_UpdateItem()
269 { 264 {
270 TestHelpers.InMethod(); 265 TestHelpers.InMethod();
271 266
272 // TODO: probably shouldn't have the ability to have an 267 // TODO: probably shouldn't have the ability to have an
273 // owner of an item in a folder not owned by the user 268 // owner of an item in a folder not owned by the user
274 269
@@ -288,7 +283,7 @@ namespace OpenSim.Data.Tests
288 public void T104_RandomUpdateItem() 283 public void T104_RandomUpdateItem()
289 { 284 {
290 TestHelpers.InMethod(); 285 TestHelpers.InMethod();
291 286
292 PropertyScrambler<InventoryFolderBase> folderScrambler = 287 PropertyScrambler<InventoryFolderBase> folderScrambler =
293 new PropertyScrambler<InventoryFolderBase>() 288 new PropertyScrambler<InventoryFolderBase>()
294 .DontScramble(x => x.Owner) 289 .DontScramble(x => x.Owner)
@@ -347,7 +342,7 @@ namespace OpenSim.Data.Tests
347 public void T999_StillNull() 342 public void T999_StillNull()
348 { 343 {
349 TestHelpers.InMethod(); 344 TestHelpers.InMethod();
350 345
351 // After all tests are run, these should still return no results 346 // After all tests are run, these should still return no results
352 Assert.That(db.getInventoryFolder(zero), Is.Null); 347 Assert.That(db.getInventoryFolder(zero), Is.Null);
353 Assert.That(db.getInventoryItem(zero), Is.Null); 348 Assert.That(db.getInventoryItem(zero), Is.Null);
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs
index e0f5862..0d291df 100644
--- a/OpenSim/Data/Tests/PropertyScrambler.cs
+++ b/OpenSim/Data/Tests/PropertyScrambler.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Data.Tests
42 public class PropertyScrambler<T> 42 public class PropertyScrambler<T>
43 { 43 {
44 readonly System.Collections.Generic.List<string> membersToNotScramble = new List<string>(); 44 readonly System.Collections.Generic.List<string> membersToNotScramble = new List<string>();
45 45
46 private void AddExpressionToNotScrableList(Expression expression) 46 private void AddExpressionToNotScrableList(Expression expression)
47 { 47 {
48 UnaryExpression unaryExpression = expression as UnaryExpression; 48 UnaryExpression unaryExpression = expression as UnaryExpression;
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 8d4249a..4f81594 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -39,6 +39,7 @@ using OpenSim.Tests.Common;
39using log4net; 39using log4net;
40using System.Reflection; 40using System.Reflection;
41using System.Data.Common; 41using System.Data.Common;
42using System.Threading;
42 43
43// DBMS-specific: 44// DBMS-specific:
44using MySql.Data.MySqlClient; 45using MySql.Data.MySqlClient;
@@ -82,7 +83,7 @@ namespace OpenSim.Data.Tests
82 public UUID item3 = UUID.Random(); 83 public UUID item3 = UUID.Random();
83 84
84 public static Random random = new Random(); 85 public static Random random = new Random();
85 86
86 public string itemname1 = "item1"; 87 public string itemname1 = "item1";
87 88
88 public uint localID = 1; 89 public uint localID = 1;
@@ -110,10 +111,10 @@ namespace OpenSim.Data.Tests
110 111
111 private void ClearDB() 112 private void ClearDB()
112 { 113 {
113 string[] reg_tables = new string[] { 114 string[] reg_tables = new string[] {
114 "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" 115 "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings"
115 }; 116 };
116 117
117 if (m_rebuildDB) 118 if (m_rebuildDB)
118 { 119 {
119 DropTables(reg_tables); 120 DropTables(reg_tables);
@@ -144,7 +145,7 @@ namespace OpenSim.Data.Tests
144 public void T001_LoadEmpty() 145 public void T001_LoadEmpty()
145 { 146 {
146 TestHelpers.InMethod(); 147 TestHelpers.InMethod();
147 148
148 List<SceneObjectGroup> objs = db.LoadObjects(region1); 149 List<SceneObjectGroup> objs = db.LoadObjects(region1);
149 List<SceneObjectGroup> objs3 = db.LoadObjects(region3); 150 List<SceneObjectGroup> objs3 = db.LoadObjects(region3);
150 List<LandData> land = db.LoadLandObjects(region1); 151 List<LandData> land = db.LoadLandObjects(region1);
@@ -153,21 +154,21 @@ namespace OpenSim.Data.Tests
153 Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))"); 154 Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))");
154 Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))"); 155 Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))");
155 } 156 }
156 157
157 // SOG round trips 158 // SOG round trips
158 // * store objects, make sure they save 159 // * store objects, make sure they save
159 // * update 160 // * update
160 161
161 [Test] 162 [Test]
162 public void T010_StoreSimpleObject() 163 public void T010_StoreSimpleObject()
163 { 164 {
164 TestHelpers.InMethod(); 165 TestHelpers.InMethod();
165 166
166 SceneObjectGroup sog = NewSOG("object1", prim1, region1); 167 SceneObjectGroup sog = NewSOG("object1", prim1, region1);
167 SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); 168 SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
168 169
169 // in case the objects don't store 170 // in case the objects don't store
170 try 171 try
171 { 172 {
172 db.StoreObject(sog, region1); 173 db.StoreObject(sog, region1);
173 } 174 }
@@ -176,8 +177,8 @@ namespace OpenSim.Data.Tests
176 m_log.Error(e.ToString()); 177 m_log.Error(e.ToString());
177 Assert.Fail(); 178 Assert.Fail();
178 } 179 }
179 180
180 try 181 try
181 { 182 {
182 db.StoreObject(sog2, region1); 183 db.StoreObject(sog2, region1);
183 } 184 }
@@ -189,15 +190,15 @@ namespace OpenSim.Data.Tests
189 190
190 // This tests the ADO.NET driver 191 // This tests the ADO.NET driver
191 List<SceneObjectGroup> objs = db.LoadObjects(region1); 192 List<SceneObjectGroup> objs = db.LoadObjects(region1);
192 193
193 Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))"); 194 Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))");
194 } 195 }
195 196
196 [Test] 197 [Test]
197 public void T011_ObjectNames() 198 public void T011_ObjectNames()
198 { 199 {
199 TestHelpers.InMethod(); 200 TestHelpers.InMethod();
200 201
201 List<SceneObjectGroup> objs = db.LoadObjects(region1); 202 List<SceneObjectGroup> objs = db.LoadObjects(region1);
202 foreach (SceneObjectGroup sog in objs) 203 foreach (SceneObjectGroup sog in objs)
203 { 204 {
@@ -206,12 +207,12 @@ namespace OpenSim.Data.Tests
206 Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))"); 207 Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))");
207 } 208 }
208 } 209 }
209 210
210 [Test] 211 [Test]
211 public void T012_SceneParts() 212 public void T012_SceneParts()
212 { 213 {
213 TestHelpers.InMethod(); 214 TestHelpers.InMethod();
214 215
215 UUID tmp0 = UUID.Random(); 216 UUID tmp0 = UUID.Random();
216 UUID tmp1 = UUID.Random(); 217 UUID tmp1 = UUID.Random();
217 UUID tmp2 = UUID.Random(); 218 UUID tmp2 = UUID.Random();
@@ -224,10 +225,10 @@ namespace OpenSim.Data.Tests
224 sog.AddPart(p1); 225 sog.AddPart(p1);
225 sog.AddPart(p2); 226 sog.AddPart(p2);
226 sog.AddPart(p3); 227 sog.AddPart(p3);
227 228
228 SceneObjectPart[] parts = sog.Parts; 229 SceneObjectPart[] parts = sog.Parts;
229 Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); 230 Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))");
230 231
231 db.StoreObject(sog, newregion); 232 db.StoreObject(sog, newregion);
232 List<SceneObjectGroup> sogs = db.LoadObjects(newregion); 233 List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
233 Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); 234 Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))");
@@ -235,18 +236,18 @@ namespace OpenSim.Data.Tests
235 236
236 SceneObjectPart[] newparts = newsog.Parts; 237 SceneObjectPart[] newparts = newsog.Parts;
237 Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); 238 Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))");
238 239
239 Assert.That(newsog.ContainsPart(tmp0), "Assert.That(newsog.ContainsPart(tmp0))"); 240 Assert.That(newsog.ContainsPart(tmp0), "Assert.That(newsog.ContainsPart(tmp0))");
240 Assert.That(newsog.ContainsPart(tmp1), "Assert.That(newsog.ContainsPart(tmp1))"); 241 Assert.That(newsog.ContainsPart(tmp1), "Assert.That(newsog.ContainsPart(tmp1))");
241 Assert.That(newsog.ContainsPart(tmp2), "Assert.That(newsog.ContainsPart(tmp2))"); 242 Assert.That(newsog.ContainsPart(tmp2), "Assert.That(newsog.ContainsPart(tmp2))");
242 Assert.That(newsog.ContainsPart(tmp3), "Assert.That(newsog.ContainsPart(tmp3))"); 243 Assert.That(newsog.ContainsPart(tmp3), "Assert.That(newsog.ContainsPart(tmp3))");
243 } 244 }
244 245
245 [Test] 246 [Test]
246 public void T013_DatabasePersistency() 247 public void T013_DatabasePersistency()
247 { 248 {
248 TestHelpers.InMethod(); 249 TestHelpers.InMethod();
249 250
250 // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data 251 // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data
251 // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored 252 // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored
252 // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. 253 // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently.
@@ -259,7 +260,7 @@ namespace OpenSim.Data.Tests
259 uint localid = localID+1; 260 uint localid = localID+1;
260 localID = localID + 1; 261 localID = localID + 1;
261 string name = "Adam West"; 262 string name = "Adam West";
262 byte material = (byte) random.Next(127); 263 byte material = (byte) random.Next((int)SOPMaterialData.MaxMaterial);
263 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); 264 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
264 int pin = random.Next(); 265 int pin = random.Next();
265 Byte[] partsys = new byte[8]; 266 Byte[] partsys = new byte[8];
@@ -297,7 +298,7 @@ namespace OpenSim.Data.Tests
297 298
298 SceneObjectPart sop = new SceneObjectPart(); 299 SceneObjectPart sop = new SceneObjectPart();
299 SceneObjectGroup sog = new SceneObjectGroup(sop); 300 SceneObjectGroup sog = new SceneObjectGroup(sop);
300 301
301 sop.RegionHandle = regionh; 302 sop.RegionHandle = regionh;
302 sop.UUID = uuid; 303 sop.UUID = uuid;
303 sop.LocalId = localid; 304 sop.LocalId = localid;
@@ -359,10 +360,10 @@ namespace OpenSim.Data.Tests
359 Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); 360 Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))");
360 Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); 361 Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))");
361 Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); 362 Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))");
362 363
363 // This is necessary or object will not be inserted in DB 364 // This is necessary or object will not be inserted in DB
364 sop.Flags = PrimFlags.None; 365 sop.Flags = PrimFlags.None;
365 366
366 // Inserts group in DB 367 // Inserts group in DB
367 db.StoreObject(sog,region3); 368 db.StoreObject(sog,region3);
368 List<SceneObjectGroup> sogs = db.LoadObjects(region3); 369 List<SceneObjectGroup> sogs = db.LoadObjects(region3);
@@ -371,7 +372,7 @@ namespace OpenSim.Data.Tests
371 db.StoreObject(sog,region3); 372 db.StoreObject(sog,region3);
372 sogs = db.LoadObjects(region3); 373 sogs = db.LoadObjects(region3);
373 Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); 374 Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
374 375
375 376
376 // Tests if the parameters were inserted correctly 377 // Tests if the parameters were inserted correctly
377 SceneObjectPart p = sogs[0].RootPart; 378 SceneObjectPart p = sogs[0].RootPart;
@@ -413,12 +414,12 @@ namespace OpenSim.Data.Tests
413 Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))"); 414 Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))");
414 Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))"); 415 Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))");
415 } 416 }
416 417
417 [Test] 418 [Test]
418 public void T014_UpdateObject() 419 public void T014_UpdateObject()
419 { 420 {
420 TestHelpers.InMethod(); 421 TestHelpers.InMethod();
421 422
422 string text1 = "object1 text"; 423 string text1 = "object1 text";
423 SceneObjectGroup sog = FindSOG("object1", region1); 424 SceneObjectGroup sog = FindSOG("object1", region1);
424 sog.RootPart.Text = text1; 425 sog.RootPart.Text = text1;
@@ -433,7 +434,7 @@ namespace OpenSim.Data.Tests
433 TaskInventoryDictionary dic = new TaskInventoryDictionary(); 434 TaskInventoryDictionary dic = new TaskInventoryDictionary();
434 localID = localID + 1; 435 localID = localID + 1;
435 string name = "West Adam"; 436 string name = "West Adam";
436 byte material = (byte) random.Next(127); 437 byte material = (byte) random.Next((int)SOPMaterialData.MaxMaterial);
437 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); 438 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
438 int pin = random.Next(); 439 int pin = random.Next();
439 Byte[] partsys = new byte[8]; 440 Byte[] partsys = new byte[8];
@@ -458,7 +459,7 @@ namespace OpenSim.Data.Tests
458 PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); 459 PrimitiveBaseShape pbshap = new PrimitiveBaseShape();
459 pbshap = PrimitiveBaseShape.Default; 460 pbshap = PrimitiveBaseShape.Default;
460 Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); 461 Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
461 462
462 // Updates the region with new values 463 // Updates the region with new values
463 SceneObjectGroup sog2 = FindSOG("Adam West", region3); 464 SceneObjectGroup sog2 = FindSOG("Adam West", region3);
464 Assert.That(sog2,Is.Not.Null); 465 Assert.That(sog2,Is.Not.Null);
@@ -487,11 +488,11 @@ namespace OpenSim.Data.Tests
487 sog2.RootPart.LinkNum = linknum; 488 sog2.RootPart.LinkNum = linknum;
488 sog2.RootPart.ClickAction = clickaction; 489 sog2.RootPart.ClickAction = clickaction;
489 sog2.RootPart.Scale = scale; 490 sog2.RootPart.Scale = scale;
490 491
491 db.StoreObject(sog2, region3); 492 db.StoreObject(sog2, region3);
492 List<SceneObjectGroup> sogs = db.LoadObjects(region3); 493 List<SceneObjectGroup> sogs = db.LoadObjects(region3);
493 Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); 494 Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
494 495
495 SceneObjectGroup retsog = FindSOG("West Adam", region3); 496 SceneObjectGroup retsog = FindSOG("West Adam", region3);
496 Assert.That(retsog,Is.Not.Null); 497 Assert.That(retsog,Is.Not.Null);
497 SceneObjectPart p = retsog.RootPart; 498 SceneObjectPart p = retsog.RootPart;
@@ -518,7 +519,7 @@ namespace OpenSim.Data.Tests
518 Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); 519 Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
519 Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); 520 Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
520 } 521 }
521 522
522 /// <summary> 523 /// <summary>
523 /// Test storage and retrieval of a scene object with a large number of parts. 524 /// Test storage and retrieval of a scene object with a large number of parts.
524 /// </summary> 525 /// </summary>
@@ -526,12 +527,12 @@ namespace OpenSim.Data.Tests
526 public void T015_LargeSceneObjects() 527 public void T015_LargeSceneObjects()
527 { 528 {
528 TestHelpers.InMethod(); 529 TestHelpers.InMethod();
529 530
530 UUID id = UUID.Random(); 531 UUID id = UUID.Random();
531 Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); 532 Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>();
532 SceneObjectGroup sog = NewSOG("Test SOG", id, region4); 533 SceneObjectGroup sog = NewSOG("Test SOG", id, region4);
533 mydic.Add(sog.RootPart.UUID,sog.RootPart); 534 mydic.Add(sog.RootPart.UUID,sog.RootPart);
534 for (int i = 0; i < 30; i++) 535 for (int i = 0; i < 30; i++)
535 { 536 {
536 UUID tmp = UUID.Random(); 537 UUID tmp = UUID.Random();
537 SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); 538 SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp);
@@ -541,20 +542,20 @@ namespace OpenSim.Data.Tests
541 Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); 542 Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
542 Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); 543 Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
543 Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); 544 Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
544 545
545 sop.GroupPosition = groupos; 546 sop.GroupPosition = groupos;
546 sop.RotationOffset = rotoff; 547 sop.RotationOffset = rotoff;
547 sop.OffsetPosition = offset; 548 sop.OffsetPosition = offset;
548 sop.Velocity = velocity; 549 sop.Velocity = velocity;
549 sop.AngularVelocity = angvelo; 550 sop.AngularVelocity = angvelo;
550 sop.Acceleration = accel; 551 sop.Acceleration = accel;
551 552
552 mydic.Add(tmp,sop); 553 mydic.Add(tmp,sop);
553 sog.AddPart(sop); 554 sog.AddPart(sop);
554 } 555 }
555 556
556 db.StoreObject(sog, region4); 557 db.StoreObject(sog, region4);
557 558
558 SceneObjectGroup retsog = FindSOG("Test SOG", region4); 559 SceneObjectGroup retsog = FindSOG("Test SOG", region4);
559 SceneObjectPart[] parts = retsog.Parts; 560 SceneObjectPart[] parts = retsog.Parts;
560 for (int i = 0; i < 30; i++) 561 for (int i = 0; i < 30; i++)
@@ -573,7 +574,7 @@ namespace OpenSim.Data.Tests
573 public void T016_RandomSogWithSceneParts() 574 public void T016_RandomSogWithSceneParts()
574 { 575 {
575 TestHelpers.InMethod(); 576 TestHelpers.InMethod();
576 577
577 PropertyScrambler<SceneObjectPart> scrambler = 578 PropertyScrambler<SceneObjectPart> scrambler =
578 new PropertyScrambler<SceneObjectPart>() 579 new PropertyScrambler<SceneObjectPart>()
579 .DontScramble(x => x.UUID); 580 .DontScramble(x => x.UUID);
@@ -633,22 +634,22 @@ namespace OpenSim.Data.Tests
633 SceneObjectGroup sog = FindSOG(name, region1); 634 SceneObjectGroup sog = FindSOG(name, region1);
634 if (sog == null) 635 if (sog == null)
635 { 636 {
636 sog = NewSOG(name, prim1, region1); 637 sog = NewSOG(name, prim1, region1);
637 db.StoreObject(sog, region1); 638 db.StoreObject(sog, region1);
638 } 639 }
639 return sog; 640 return sog;
640 } 641 }
641 642
642 // NOTE: it is a bad practice to rely on some of the previous tests having been run before. 643 // NOTE: it is a bad practice to rely on some of the previous tests having been run before.
643 // If the tests are run manually, one at a time, each starts with full class init (DB cleared). 644 // If the tests are run manually, one at a time, each starts with full class init (DB cleared).
644 // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. 645 // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order.
645 // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! 646 // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*!
646 647
647 [Test] 648 [Test]
648 public void T020_PrimInventoryEmpty() 649 public void T020_PrimInventoryEmpty()
649 { 650 {
650 TestHelpers.InMethod(); 651 TestHelpers.InMethod();
651 652
652 SceneObjectGroup sog = GetMySOG("object1"); 653 SceneObjectGroup sog = GetMySOG("object1");
653 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 654 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
654 Assert.That(t, Is.Null); 655 Assert.That(t, Is.Null);
@@ -672,14 +673,14 @@ namespace OpenSim.Data.Tests
672 public void T021_PrimInventoryBasic() 673 public void T021_PrimInventoryBasic()
673 { 674 {
674 TestHelpers.InMethod(); 675 TestHelpers.InMethod();
675 676
676 SceneObjectGroup sog = GetMySOG("object1"); 677 SceneObjectGroup sog = GetMySOG("object1");
677 InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); 678 InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
678 679
679 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); 680 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True);
680 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 681 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
681 Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); 682 Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
682 683
683 StoreInventory(sog); 684 StoreInventory(sog);
684 685
685 SceneObjectGroup sog1 = FindSOG("object1", region1); 686 SceneObjectGroup sog1 = FindSOG("object1", region1);
@@ -707,12 +708,12 @@ namespace OpenSim.Data.Tests
707 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 708 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
708 Assert.That(t, Is.Null); 709 Assert.That(t, Is.Null);
709 } 710 }
710 711
711 [Test] 712 [Test]
712 public void T025_PrimInventoryPersistency() 713 public void T025_PrimInventoryPersistency()
713 { 714 {
714 TestHelpers.InMethod(); 715 TestHelpers.InMethod();
715 716
716 InventoryItemBase i = new InventoryItemBase(); 717 InventoryItemBase i = new InventoryItemBase();
717 UUID id = UUID.Random(); 718 UUID id = UUID.Random();
718 i.ID = id; 719 i.ID = id;
@@ -751,11 +752,11 @@ namespace OpenSim.Data.Tests
751 i.Flags = flags; 752 i.Flags = flags;
752 int creationd = random.Next(); 753 int creationd = random.Next();
753 i.CreationDate = creationd; 754 i.CreationDate = creationd;
754 755
755 SceneObjectGroup sog = GetMySOG("object1"); 756 SceneObjectGroup sog = GetMySOG("object1");
756 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True); 757 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True);
757 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); 758 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
758 759
759 Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); 760 Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))");
760 Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))"); 761 Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))");
761 Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))"); 762 Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))");
@@ -779,13 +780,13 @@ namespace OpenSim.Data.Tests
779 Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); 780 Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))");
780 Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); 781 Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))");
781 } 782 }
782 783
783 [Test] 784 [Test]
784 [ExpectedException(typeof(ArgumentException))] 785 [ExpectedException(typeof(ArgumentException))]
785 public void T026_PrimInventoryMany() 786 public void T026_PrimInventoryMany()
786 { 787 {
787 TestHelpers.InMethod(); 788 TestHelpers.InMethod();
788 789
789 UUID i1,i2,i3,i4; 790 UUID i1,i2,i3,i4;
790 i1 = UUID.Random(); 791 i1 = UUID.Random();
791 i2 = UUID.Random(); 792 i2 = UUID.Random();
@@ -795,14 +796,14 @@ namespace OpenSim.Data.Tests
795 InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero); 796 InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero);
796 InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero); 797 InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero);
797 InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero); 798 InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero);
798 799
799 SceneObjectGroup sog = FindSOG("object1", region1); 800 SceneObjectGroup sog = FindSOG("object1", region1);
800 801
801 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True); 802 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True);
802 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True); 803 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True);
803 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True); 804 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True);
804 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True); 805 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True);
805 806
806 TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); 807 TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1);
807 Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); 808 Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))");
808 TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2); 809 TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2);
@@ -817,7 +818,7 @@ namespace OpenSim.Data.Tests
817 public void T052_RemoveObject() 818 public void T052_RemoveObject()
818 { 819 {
819 TestHelpers.InMethod(); 820 TestHelpers.InMethod();
820 821
821 db.RemoveObject(prim1, region1); 822 db.RemoveObject(prim1, region1);
822 SceneObjectGroup sog = FindSOG("object1", region1); 823 SceneObjectGroup sog = FindSOG("object1", region1);
823 Assert.That(sog, Is.Null); 824 Assert.That(sog, Is.Null);
@@ -827,7 +828,7 @@ namespace OpenSim.Data.Tests
827 public void T100_DefaultRegionInfo() 828 public void T100_DefaultRegionInfo()
828 { 829 {
829 TestHelpers.InMethod(); 830 TestHelpers.InMethod();
830 831
831 RegionSettings r1 = db.LoadRegionSettings(region1); 832 RegionSettings r1 = db.LoadRegionSettings(region1);
832 Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); 833 Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
833 834
@@ -839,7 +840,7 @@ namespace OpenSim.Data.Tests
839 public void T101_UpdateRegionInfo() 840 public void T101_UpdateRegionInfo()
840 { 841 {
841 TestHelpers.InMethod(); 842 TestHelpers.InMethod();
842 843
843 int agentlimit = random.Next(); 844 int agentlimit = random.Next();
844 double objectbonus = random.Next(); 845 double objectbonus = random.Next();
845 int maturity = random.Next(); 846 int maturity = random.Next();
@@ -899,9 +900,9 @@ namespace OpenSim.Data.Tests
899 r1.FixedSun = true; 900 r1.FixedSun = true;
900 r1.SunPosition = sunpos; 901 r1.SunPosition = sunpos;
901 r1.Covenant = cov; 902 r1.Covenant = cov;
902 903
903 db.StoreRegionSettings(r1); 904 db.StoreRegionSettings(r1);
904 905
905 RegionSettings r1a = db.LoadRegionSettings(region1); 906 RegionSettings r1a = db.LoadRegionSettings(region1);
906 Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))"); 907 Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))");
907 Assert.That(r1a.BlockTerraform,Is.True); 908 Assert.That(r1a.BlockTerraform,Is.True);
@@ -938,14 +939,14 @@ namespace OpenSim.Data.Tests
938 //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); 939 //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))");
939 Assert.That(r1a.FixedSun,Is.True); 940 Assert.That(r1a.FixedSun,Is.True);
940 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); 941 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))");
941 Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); 942 Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))");
942 } 943 }
943 944
944 [Test] 945 [Test]
945 public void T300_NoTerrain() 946 public void T300_NoTerrain()
946 { 947 {
947 TestHelpers.InMethod(); 948 TestHelpers.InMethod();
948 949
949 Assert.That(db.LoadTerrain(zero), Is.Null); 950 Assert.That(db.LoadTerrain(zero), Is.Null);
950 Assert.That(db.LoadTerrain(region1), Is.Null); 951 Assert.That(db.LoadTerrain(region1), Is.Null);
951 Assert.That(db.LoadTerrain(region2), Is.Null); 952 Assert.That(db.LoadTerrain(region2), Is.Null);
@@ -956,10 +957,13 @@ namespace OpenSim.Data.Tests
956 public void T301_CreateTerrain() 957 public void T301_CreateTerrain()
957 { 958 {
958 TestHelpers.InMethod(); 959 TestHelpers.InMethod();
959 960
960 double[,] t1 = GenTerrain(height1); 961 double[,] t1 = GenTerrain(height1);
961 db.StoreTerrain(t1, region1); 962 db.StoreTerrain(t1, region1);
962 963
964 // store terrain is async
965 Thread.Sleep(1000);
966
963 Assert.That(db.LoadTerrain(zero), Is.Null); 967 Assert.That(db.LoadTerrain(zero), Is.Null);
964 Assert.That(db.LoadTerrain(region1), Is.Not.Null); 968 Assert.That(db.LoadTerrain(region1), Is.Not.Null);
965 Assert.That(db.LoadTerrain(region2), Is.Null); 969 Assert.That(db.LoadTerrain(region2), Is.Null);
@@ -970,7 +974,7 @@ namespace OpenSim.Data.Tests
970 public void T302_FetchTerrain() 974 public void T302_FetchTerrain()
971 { 975 {
972 TestHelpers.InMethod(); 976 TestHelpers.InMethod();
973 977
974 double[,] baseterrain1 = GenTerrain(height1); 978 double[,] baseterrain1 = GenTerrain(height1);
975 double[,] baseterrain2 = GenTerrain(height2); 979 double[,] baseterrain2 = GenTerrain(height2);
976 double[,] t1 = db.LoadTerrain(region1); 980 double[,] t1 = db.LoadTerrain(region1);
@@ -982,11 +986,14 @@ namespace OpenSim.Data.Tests
982 public void T303_UpdateTerrain() 986 public void T303_UpdateTerrain()
983 { 987 {
984 TestHelpers.InMethod(); 988 TestHelpers.InMethod();
985 989
986 double[,] baseterrain1 = GenTerrain(height1); 990 double[,] baseterrain1 = GenTerrain(height1);
987 double[,] baseterrain2 = GenTerrain(height2); 991 double[,] baseterrain2 = GenTerrain(height2);
988 db.StoreTerrain(baseterrain2, region1); 992 db.StoreTerrain(baseterrain2, region1);
989 993
994 // store terrain is async
995 Thread.Sleep(1000);
996
990 double[,] t1 = db.LoadTerrain(region1); 997 double[,] t1 = db.LoadTerrain(region1);
991 Assert.That(CompareTerrain(t1, baseterrain1), Is.False); 998 Assert.That(CompareTerrain(t1, baseterrain1), Is.False);
992 Assert.That(CompareTerrain(t1, baseterrain2), Is.True); 999 Assert.That(CompareTerrain(t1, baseterrain2), Is.True);
@@ -996,7 +1003,7 @@ namespace OpenSim.Data.Tests
996 public void T400_EmptyLand() 1003 public void T400_EmptyLand()
997 { 1004 {
998 TestHelpers.InMethod(); 1005 TestHelpers.InMethod();
999 1006
1000 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); 1007 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
1001 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); 1008 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");
1002 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); 1009 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))");
@@ -1018,15 +1025,15 @@ namespace OpenSim.Data.Tests
1018 for (int x = 0; x < Constants.RegionSize; x++) 1025 for (int x = 0; x < Constants.RegionSize; x++)
1019 for (int y = 0; y < Constants.RegionSize; y++) 1026 for (int y = 0; y < Constants.RegionSize; y++)
1020 terret[x,y] = value; 1027 terret[x,y] = value;
1021 1028
1022 return terret; 1029 return terret;
1023 } 1030 }
1024 1031
1025 private bool CompareTerrain(double[,] one, double[,] two) 1032 private bool CompareTerrain(double[,] one, double[,] two)
1026 { 1033 {
1027 for (int x = 0; x < Constants.RegionSize; x++) 1034 for (int x = 0; x < Constants.RegionSize; x++)
1028 for (int y = 0; y < Constants.RegionSize; y++) 1035 for (int y = 0; y < Constants.RegionSize; y++)
1029 if (one[x,y] != two[x,y]) 1036 if (one[x,y] != two[x,y])
1030 return false; 1037 return false;
1031 1038
1032 return true; 1039 return true;
@@ -1046,12 +1053,12 @@ namespace OpenSim.Data.Tests
1046 // common failure case is people adding new fields that aren't 1053 // common failure case is people adding new fields that aren't
1047 // initialized, but have non-null db constraints. We should 1054 // initialized, but have non-null db constraints. We should
1048 // honestly be passing more and more null things in here. 1055 // honestly be passing more and more null things in here.
1049 // 1056 //
1050 // Please note that in Sqlite.BuildPrim there is a commented out inline version 1057 // Please note that in Sqlite.BuildPrim there is a commented out inline version
1051 // of this so you can debug and step through the build process and check the fields 1058 // of this so you can debug and step through the build process and check the fields
1052 // 1059 //
1053 // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart 1060 // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart
1054 // causes the application to crash at the database layer because of null values 1061 // causes the application to crash at the database layer because of null values
1055 // in NOT NULL fields 1062 // in NOT NULL fields
1056 // 1063 //
1057 private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId) 1064 private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId)
@@ -1075,7 +1082,7 @@ namespace OpenSim.Data.Tests
1075 1082
1076 return sog; 1083 return sog;
1077 } 1084 }
1078 1085
1079 private SceneObjectPart NewSOP(string name, UUID uuid) 1086 private SceneObjectPart NewSOP(string name, UUID uuid)
1080 { 1087 {
1081 SceneObjectPart sop = new SceneObjectPart(); 1088 SceneObjectPart sop = new SceneObjectPart();
@@ -1089,7 +1096,7 @@ namespace OpenSim.Data.Tests
1089 return sop; 1096 return sop;
1090 } 1097 }
1091 1098
1092 // These are copied from the Inventory Item tests 1099 // These are copied from the Inventory Item tests
1093 1100
1094 private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) 1101 private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
1095 { 1102 {
@@ -1107,7 +1114,7 @@ namespace OpenSim.Data.Tests
1107 private static string RandomName() 1114 private static string RandomName()
1108 { 1115 {
1109 StringBuilder name = new StringBuilder(); 1116 StringBuilder name = new StringBuilder();
1110 int size = random.Next(5,12); 1117 int size = random.Next(5,12);
1111 char ch ; 1118 char ch ;
1112 for (int i=0; i<size; i++) 1119 for (int i=0; i<size; i++)
1113 { 1120 {
diff --git a/OpenSim/Data/Tests/Resources/TestDataConnections.ini b/OpenSim/Data/Tests/Resources/TestDataConnections.ini
index 75f7855..7b55467 100644
--- a/OpenSim/Data/Tests/Resources/TestDataConnections.ini
+++ b/OpenSim/Data/Tests/Resources/TestDataConnections.ini
@@ -16,9 +16,9 @@
16; file for the DB. If you want the resulting DB to persist (e.g. for performance testing, 16; file for the DB. If you want the resulting DB to persist (e.g. for performance testing,
17; when filling up the tables can take a long time), explicitly specify a conn string like this: 17; when filling up the tables can take a long time), explicitly specify a conn string like this:
18 18
19; SqliteConnection="URI=file:../db/<path_to_your_file>,version=3" 19; SqliteConnection="URI=file:<path_to_your_file>,version=3"
20 20
21[TestConnections] 21[TestConnections]
22MySqlConnection="Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;" 22MySqlConnection="Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;"
23SqlConnection="Server=.\SQL2008;Database=opensim-nunit;Trusted_Connection=True;" 23SqlConnection="Server=.\SQL2008;Database=opensim-nunit;Trusted_Connection=True;"
24SqliteConnection="URI=file:../db/opensim-nunit.db,version=3" \ No newline at end of file 24SqliteConnection="URI=file:opensim-nunit.db,version=3" \ No newline at end of file