diff options
Diffstat (limited to '')
129 files changed, 12953 insertions, 5231 deletions
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index e1a810c..1bb432c 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs | |||
@@ -37,9 +37,8 @@ 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 | |||
41 | public abstract void StoreAsset(AssetBase asset); | 40 | public abstract void StoreAsset(AssetBase asset); |
42 | public abstract bool ExistsAsset(UUID uuid); | 41 | public abstract bool[] AssetsExist(UUID[] uuids); |
43 | 42 | ||
44 | public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count); | 43 | public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count); |
45 | 44 | ||
diff --git a/OpenSim/Data/IAgentPreferencesData.cs b/OpenSim/Data/IAgentPreferencesData.cs new file mode 100644 index 0000000..8763299 --- /dev/null +++ b/OpenSim/Data/IAgentPreferencesData.cs | |||
@@ -0,0 +1,46 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | public class AgentPreferencesData | ||
36 | { | ||
37 | public Dictionary<string, string> Data; | ||
38 | } | ||
39 | |||
40 | public interface IAgentPreferencesData | ||
41 | { | ||
42 | bool Store(AgentPreferencesData data); | ||
43 | AgentPreferencesData GetPrefs(UUID agentID); | ||
44 | } | ||
45 | } | ||
46 | |||
diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs index f31b215c..a41e310 100644 --- a/OpenSim/Data/IAssetData.cs +++ b/OpenSim/Data/IAssetData.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Data | |||
35 | { | 35 | { |
36 | AssetBase GetAsset(UUID uuid); | 36 | AssetBase GetAsset(UUID uuid); |
37 | void StoreAsset(AssetBase asset); | 37 | void StoreAsset(AssetBase asset); |
38 | bool ExistsAsset(UUID uuid); | 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); |
41 | bool Delete(string id); | 41 | bool Delete(string id); |
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Data/IEstateDataStore.cs index 8febb13..f9070ea 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Data/IEstateDataStore.cs | |||
@@ -29,7 +29,7 @@ using System.Collections.Generic; | |||
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | 31 | ||
32 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Data |
33 | { | 33 | { |
34 | public interface IEstateDataStore | 34 | public interface IEstateDataStore |
35 | { | 35 | { |
diff --git a/OpenSim/Data/IFSAssetData.cs b/OpenSim/Data/IFSAssetData.cs new file mode 100644 index 0000000..8751dc0 --- /dev/null +++ b/OpenSim/Data/IFSAssetData.cs | |||
@@ -0,0 +1,47 @@ | |||
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 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | |||
32 | namespace OpenSim.Data | ||
33 | { | ||
34 | public delegate string FSStoreDelegate(AssetBase asset, bool force); | ||
35 | |||
36 | public interface IFSAssetDataPlugin : IPlugin | ||
37 | { | ||
38 | bool[] AssetsExist(UUID[] uuids); | ||
39 | void Initialise(string connect, string realm, int SkipAccessTimeDays); | ||
40 | bool Delete(string id); | ||
41 | |||
42 | AssetMetadata Get(string id, out string hash); | ||
43 | bool Store(AssetMetadata metadata, string hash); | ||
44 | void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store); | ||
45 | int Count(); | ||
46 | } | ||
47 | } | ||
diff --git a/OpenSim/Data/IGridUserData.cs b/OpenSim/Data/IGridUserData.cs index e15a1f8..9afa477 100644 --- a/OpenSim/Data/IGridUserData.cs +++ b/OpenSim/Data/IGridUserData.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Data | |||
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 | bool Store(GridUserData data); | 54 | bool Store(GridUserData data); |
54 | } | 55 | } |
55 | } \ No newline at end of file | 56 | } \ No newline at end of file |
diff --git a/OpenSim/Data/IGroupsData.cs b/OpenSim/Data/IGroupsData.cs new file mode 100644 index 0000000..c11e649 --- /dev/null +++ b/OpenSim/Data/IGroupsData.cs | |||
@@ -0,0 +1,144 @@ | |||
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 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenSim.Data; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Data | ||
33 | { | ||
34 | public class GroupData | ||
35 | { | ||
36 | public UUID GroupID; | ||
37 | public Dictionary<string, string> Data; | ||
38 | } | ||
39 | |||
40 | public class MembershipData | ||
41 | { | ||
42 | public UUID GroupID; | ||
43 | public string PrincipalID; | ||
44 | public Dictionary<string, string> Data; | ||
45 | } | ||
46 | |||
47 | public class RoleData | ||
48 | { | ||
49 | public UUID GroupID; | ||
50 | public UUID RoleID; | ||
51 | public Dictionary<string, string> Data; | ||
52 | } | ||
53 | |||
54 | public class RoleMembershipData | ||
55 | { | ||
56 | public UUID GroupID; | ||
57 | public UUID RoleID; | ||
58 | public string PrincipalID; | ||
59 | } | ||
60 | |||
61 | public class PrincipalData | ||
62 | { | ||
63 | public string PrincipalID; | ||
64 | public UUID ActiveGroupID; | ||
65 | } | ||
66 | |||
67 | public class InvitationData | ||
68 | { | ||
69 | public UUID InviteID; | ||
70 | public UUID GroupID; | ||
71 | public UUID RoleID; | ||
72 | public string PrincipalID; | ||
73 | public Dictionary<string, string> Data; | ||
74 | } | ||
75 | |||
76 | public class NoticeData | ||
77 | { | ||
78 | public UUID GroupID; | ||
79 | public UUID NoticeID; | ||
80 | public Dictionary<string, string> Data; | ||
81 | } | ||
82 | |||
83 | |||
84 | public interface IGroupsData | ||
85 | { | ||
86 | // groups table | ||
87 | bool StoreGroup(GroupData data); | ||
88 | GroupData RetrieveGroup(UUID groupID); | ||
89 | GroupData RetrieveGroup(string name); | ||
90 | GroupData[] RetrieveGroups(string pattern); | ||
91 | bool DeleteGroup(UUID groupID); | ||
92 | int GroupsCount(); | ||
93 | |||
94 | // membership table | ||
95 | MembershipData RetrieveMember(UUID groupID, string pricipalID); | ||
96 | MembershipData[] RetrieveMembers(UUID groupID); | ||
97 | MembershipData[] RetrieveMemberships(string pricipalID); | ||
98 | bool StoreMember(MembershipData data); | ||
99 | bool DeleteMember(UUID groupID, string pricipalID); | ||
100 | int MemberCount(UUID groupID); | ||
101 | |||
102 | // roles table | ||
103 | bool StoreRole(RoleData data); | ||
104 | RoleData RetrieveRole(UUID groupID, UUID roleID); | ||
105 | RoleData[] RetrieveRoles(UUID groupID); | ||
106 | bool DeleteRole(UUID groupID, UUID roleID); | ||
107 | int RoleCount(UUID groupID); | ||
108 | |||
109 | // rolememberhip table | ||
110 | RoleMembershipData[] RetrieveRolesMembers(UUID groupID); | ||
111 | RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID); | ||
112 | RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID); | ||
113 | RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID); | ||
114 | int RoleMemberCount(UUID groupID, UUID roleID); | ||
115 | bool StoreRoleMember(RoleMembershipData data); | ||
116 | bool DeleteRoleMember(RoleMembershipData data); | ||
117 | bool DeleteMemberAllRoles(UUID groupID, string principalID); | ||
118 | |||
119 | // principals table | ||
120 | bool StorePrincipal(PrincipalData data); | ||
121 | PrincipalData RetrievePrincipal(string principalID); | ||
122 | bool DeletePrincipal(string principalID); | ||
123 | |||
124 | // invites table | ||
125 | bool StoreInvitation(InvitationData data); | ||
126 | InvitationData RetrieveInvitation(UUID inviteID); | ||
127 | InvitationData RetrieveInvitation(UUID groupID, string principalID); | ||
128 | bool DeleteInvite(UUID inviteID); | ||
129 | void DeleteOldInvites(); | ||
130 | |||
131 | // notices table | ||
132 | bool StoreNotice(NoticeData data); | ||
133 | NoticeData RetrieveNotice(UUID noticeID); | ||
134 | NoticeData[] RetrieveNotices(UUID groupID); | ||
135 | bool DeleteNotice(UUID noticeID); | ||
136 | void DeleteOldNotices(); | ||
137 | |||
138 | // combinations | ||
139 | MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID); | ||
140 | MembershipData[] RetrievePrincipalGroupMemberships(string principalID); | ||
141 | |||
142 | // Misc | ||
143 | } | ||
144 | } | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Data/IHGTravelingData.cs index 7ab2a03..452af7b 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Data/IHGTravelingData.cs | |||
@@ -27,38 +27,33 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using Nini.Config; | 30 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Physics.Manager; | ||
33 | 32 | ||
34 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | 33 | namespace OpenSim.Data |
35 | { | 34 | { |
36 | /// <summary> | 35 | // This MUST be a ref type! |
37 | /// Effectively a physics plugin that simulates no physics at all. | 36 | public class HGTravelingData |
38 | /// </summary> | ||
39 | public class BasicPhysicsPlugin : IPhysicsPlugin | ||
40 | { | 37 | { |
41 | public BasicPhysicsPlugin() | 38 | public UUID SessionID; |
42 | { | 39 | public UUID UserID; |
43 | } | 40 | public Dictionary<string, string> Data; |
44 | |||
45 | public bool Init() | ||
46 | { | ||
47 | return true; | ||
48 | } | ||
49 | |||
50 | public PhysicsScene GetScene(string sceneIdentifier) | ||
51 | { | ||
52 | return new BasicScene(sceneIdentifier); | ||
53 | } | ||
54 | 41 | ||
55 | public string GetName() | 42 | public HGTravelingData() |
56 | { | 43 | { |
57 | return ("basicphysics"); | 44 | Data = new Dictionary<string, string>(); |
58 | } | 45 | } |
46 | } | ||
59 | 47 | ||
60 | public void Dispose() | 48 | /// <summary> |
61 | { | 49 | /// An interface for connecting to the user grid datastore |
62 | } | 50 | /// </summary> |
51 | public interface IHGTravelingData | ||
52 | { | ||
53 | HGTravelingData Get(UUID sessionID); | ||
54 | HGTravelingData[] GetSessions(UUID userID); | ||
55 | bool Store(HGTravelingData data); | ||
56 | bool Delete(UUID sessionID); | ||
57 | void DeleteOld(); | ||
63 | } | 58 | } |
64 | } | 59 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs b/OpenSim/Data/IOfflineIMData.cs index f3be028..58501a3 100644 --- a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs +++ b/OpenSim/Data/IOfflineIMData.cs | |||
@@ -25,22 +25,26 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
29 | using OpenSim.Data; | ||
28 | using OpenMetaverse; | 30 | using OpenMetaverse; |
29 | 31 | ||
30 | namespace OpenSim.Region.Framework.Scenes.Scripting | 32 | namespace OpenSim.Data |
31 | { | 33 | { |
32 | public interface IScriptHost | 34 | public class OfflineIMData |
33 | { | 35 | { |
34 | string Name { get; set; } | 36 | public UUID PrincipalID; |
35 | string Description { get; set; } | 37 | public UUID FromID; |
38 | public Dictionary<string, string> Data; | ||
39 | } | ||
36 | 40 | ||
37 | UUID UUID { get; } | ||
38 | UUID OwnerID { get; } | ||
39 | UUID CreatorID { get; } | ||
40 | Vector3 AbsolutePosition { get; } | ||
41 | 41 | ||
42 | string SitName { get; set; } | 42 | public interface IOfflineIMData |
43 | string TouchName { get; set; } | 43 | { |
44 | void SetText(string text, Vector3 color, double alpha); | 44 | OfflineIMData[] Get(string field, string val); |
45 | long GetCount(string field, string key); | ||
46 | bool Store(OfflineIMData data); | ||
47 | bool Delete(string field, string val); | ||
48 | void DeleteOld(); | ||
45 | } | 49 | } |
46 | } | 50 | } |
diff --git a/OpenSim/Data/IProfilesData.cs b/OpenSim/Data/IProfilesData.cs new file mode 100644 index 0000000..7fb075d --- /dev/null +++ b/OpenSim/Data/IProfilesData.cs | |||
@@ -0,0 +1,58 @@ | |||
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 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | using OpenMetaverse.StructuredData; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | |||
36 | public interface IProfilesData | ||
37 | { | ||
38 | OSDArray GetClassifiedRecords(UUID creatorId); | ||
39 | bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result); | ||
40 | bool DeleteClassifiedRecord(UUID recordId); | ||
41 | OSDArray GetAvatarPicks(UUID avatarId); | ||
42 | UserProfilePick GetPickInfo(UUID avatarId, UUID pickId); | ||
43 | bool UpdatePicksRecord(UserProfilePick pick); | ||
44 | bool DeletePicksRecord(UUID pickId); | ||
45 | bool GetAvatarNotes(ref UserProfileNotes note); | ||
46 | bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result); | ||
47 | bool GetAvatarProperties(ref UserProfileProperties props, ref string result); | ||
48 | bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); | ||
49 | bool UpdateAvatarInterests(UserProfileProperties up, ref string result); | ||
50 | bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); | ||
51 | bool UpdateUserPreferences(ref UserPreferences pref, ref string result); | ||
52 | bool GetUserPreferences(ref UserPreferences pref, ref string result); | ||
53 | bool GetUserAppData(ref UserAppData props, ref string result); | ||
54 | bool SetUserAppData(UserAppData props, ref string result); | ||
55 | OSDArray GetUserImageAssets(UUID avatarId); | ||
56 | } | ||
57 | } | ||
58 | |||
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 70e1065..ca9b327 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs | |||
@@ -52,14 +52,14 @@ namespace OpenSim.Data | |||
52 | public int sizeY; | 52 | public int sizeY; |
53 | 53 | ||
54 | /// <summary> | 54 | /// <summary> |
55 | /// Return the x-coordinate of this region. | 55 | /// Return the x-coordinate of this region in region units. |
56 | /// </summary> | 56 | /// </summary> |
57 | public int coordX { get { return posX / (int)Constants.RegionSize; } } | 57 | public int coordX { get { return (int)Util.WorldToRegionLoc((uint)posX); } } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Return the y-coordinate of this region. | 60 | /// Return the y-coordinate of this region in region units. |
61 | /// </summary> | 61 | /// </summary> |
62 | public int coordY { get { return posY / (int)Constants.RegionSize; } } | 62 | public int coordY { get { return (int)Util.WorldToRegionLoc((uint)posY); } } |
63 | 63 | ||
64 | public Dictionary<string, object> Data; | 64 | public Dictionary<string, object> Data; |
65 | } | 65 | } |
@@ -81,6 +81,7 @@ namespace OpenSim.Data | |||
81 | bool Delete(UUID regionID); | 81 | bool Delete(UUID regionID); |
82 | 82 | ||
83 | List<RegionData> GetDefaultRegions(UUID scopeID); | 83 | List<RegionData> GetDefaultRegions(UUID scopeID); |
84 | List<RegionData> GetDefaultHypergridRegions(UUID scopeID); | ||
84 | List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y); | 85 | List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y); |
85 | List<RegionData> GetHyperlinks(UUID scopeID); | 86 | List<RegionData> GetHyperlinks(UUID scopeID); |
86 | } | 87 | } |
diff --git a/OpenSim/Data/IXAssetDataPlugin.cs b/OpenSim/Data/IXAssetDataPlugin.cs index 74ad6f4..2d24797 100644 --- a/OpenSim/Data/IXAssetDataPlugin.cs +++ b/OpenSim/Data/IXAssetDataPlugin.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Data | |||
39 | { | 39 | { |
40 | AssetBase GetAsset(UUID uuid); | 40 | AssetBase GetAsset(UUID uuid); |
41 | void StoreAsset(AssetBase asset); | 41 | void StoreAsset(AssetBase asset); |
42 | bool ExistsAsset(UUID uuid); | 42 | bool[] AssetsExist(UUID[] uuids); |
43 | List<AssetMetadata> FetchAssetMetadataSet(int start, int count); | 43 | List<AssetMetadata> FetchAssetMetadataSet(int start, int count); |
44 | void Initialise(string connect); | 44 | void Initialise(string connect); |
45 | bool Delete(string id); | 45 | bool Delete(string id); |
diff --git a/OpenSim/Data/IXGroupData.cs b/OpenSim/Data/IXGroupData.cs index 2965e8c..e5821ef 100644 --- a/OpenSim/Data/IXGroupData.cs +++ b/OpenSim/Data/IXGroupData.cs | |||
@@ -48,9 +48,57 @@ namespace OpenSim.Data | |||
48 | public ulong everyonePowers; | 48 | public ulong everyonePowers; |
49 | public ulong ownersPowers; | 49 | public ulong ownersPowers; |
50 | 50 | ||
51 | public Dictionary<UUID, XGroupMember> members = new Dictionary<UUID, XGroupMember>(); | ||
52 | public Dictionary<UUID, XGroupNotice> notices = new Dictionary<UUID, XGroupNotice>(); | ||
53 | |||
51 | public XGroup Clone() | 54 | public XGroup Clone() |
52 | { | 55 | { |
53 | return (XGroup)MemberwiseClone(); | 56 | XGroup clone = (XGroup)MemberwiseClone(); |
57 | clone.members = new Dictionary<UUID, XGroupMember>(); | ||
58 | clone.notices = new Dictionary<UUID, XGroupNotice>(); | ||
59 | |||
60 | foreach (KeyValuePair<UUID, XGroupMember> kvp in members) | ||
61 | clone.members[kvp.Key] = kvp.Value.Clone(); | ||
62 | |||
63 | foreach (KeyValuePair<UUID, XGroupNotice> kvp in notices) | ||
64 | clone.notices[kvp.Key] = kvp.Value.Clone(); | ||
65 | |||
66 | return clone; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | public class XGroupMember | ||
71 | { | ||
72 | public UUID agentID; | ||
73 | public UUID groupID; | ||
74 | public UUID roleID; | ||
75 | public bool acceptNotices = true; | ||
76 | public bool listInProfile = true; | ||
77 | |||
78 | public XGroupMember Clone() | ||
79 | { | ||
80 | return (XGroupMember)MemberwiseClone(); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public class XGroupNotice | ||
85 | { | ||
86 | public UUID groupID; | ||
87 | public UUID noticeID; | ||
88 | public uint timestamp; | ||
89 | public string fromName; | ||
90 | public string subject; | ||
91 | public string message; | ||
92 | public byte[] binaryBucket; | ||
93 | public bool hasAttachment; | ||
94 | public int assetType; | ||
95 | |||
96 | public XGroupNotice Clone() | ||
97 | { | ||
98 | XGroupNotice clone = (XGroupNotice)MemberwiseClone(); | ||
99 | clone.binaryBucket = (byte[])binaryBucket.Clone(); | ||
100 | |||
101 | return clone; | ||
54 | } | 102 | } |
55 | } | 103 | } |
56 | 104 | ||
@@ -58,14 +106,13 @@ namespace OpenSim.Data | |||
58 | /// Early stub interface for groups data, not final. | 106 | /// Early stub interface for groups data, not final. |
59 | /// </summary> | 107 | /// </summary> |
60 | /// <remarks> | 108 | /// <remarks> |
61 | /// Currently in-use only for regression test purposes. Needs to be filled out over time. | 109 | /// Currently in-use only for regression test purposes. |
62 | /// </remarks> | 110 | /// </remarks> |
63 | public interface IXGroupData | 111 | public interface IXGroupData |
64 | { | 112 | { |
65 | bool StoreGroup(XGroup group); | 113 | bool StoreGroup(XGroup group); |
66 | XGroup[] GetGroups(string field, string val); | 114 | XGroup GetGroup(UUID groupID); |
67 | XGroup[] GetGroups(string[] fields, string[] vals); | 115 | Dictionary<UUID, XGroup> GetGroups(); |
68 | bool DeleteGroups(string field, string val); | 116 | bool DeleteGroup(UUID groupID); |
69 | bool DeleteGroups(string[] fields, string[] vals); | ||
70 | } | 117 | } |
71 | } \ No newline at end of file | 118 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs deleted file mode 100644 index 7feec91..0000000 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ /dev/null | |||
@@ -1,246 +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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using System.Data.SqlClient; | ||
35 | using System.Text; | ||
36 | |||
37 | namespace OpenSim.Data.MSSQL | ||
38 | { | ||
39 | public class MSSQLUserAccountData : MSSQLGenericTableHandler<UserAccountData>,IUserAccountData | ||
40 | { | ||
41 | public MSSQLUserAccountData(string connectionString, string realm) : | ||
42 | base(connectionString, realm, "UserAccount") | ||
43 | { | ||
44 | } | ||
45 | //private string m_Realm; | ||
46 | //private List<string> m_ColumnNames = null; | ||
47 | //private MSSQLManager m_database; | ||
48 | |||
49 | //public MSSQLUserAccountData(string connectionString, string realm) | ||
50 | //{ | ||
51 | // m_Realm = realm; | ||
52 | // m_ConnectionString = connectionString; | ||
53 | // m_database = new MSSQLManager(connectionString); | ||
54 | |||
55 | // using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
56 | // { | ||
57 | // conn.Open(); | ||
58 | // Migration m = new Migration(conn, GetType().Assembly, "UserStore"); | ||
59 | // m.Update(); | ||
60 | // } | ||
61 | //} | ||
62 | |||
63 | //public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query) | ||
64 | //{ | ||
65 | // return null; | ||
66 | //} | ||
67 | |||
68 | //public UserAccountData Get(UUID principalID, UUID scopeID) | ||
69 | //{ | ||
70 | // UserAccountData ret = new UserAccountData(); | ||
71 | // ret.Data = new Dictionary<string, string>(); | ||
72 | |||
73 | // string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); | ||
74 | // if (scopeID != UUID.Zero) | ||
75 | // sql += " and ScopeID = @scopeID"; | ||
76 | |||
77 | // using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
78 | // using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
79 | // { | ||
80 | // cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); | ||
81 | // cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | ||
82 | |||
83 | // conn.Open(); | ||
84 | // using (SqlDataReader result = cmd.ExecuteReader()) | ||
85 | // { | ||
86 | // if (result.Read()) | ||
87 | // { | ||
88 | // ret.PrincipalID = principalID; | ||
89 | // UUID scope; | ||
90 | // UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
91 | // ret.ScopeID = scope; | ||
92 | |||
93 | // if (m_ColumnNames == null) | ||
94 | // { | ||
95 | // m_ColumnNames = new List<string>(); | ||
96 | |||
97 | // DataTable schemaTable = result.GetSchemaTable(); | ||
98 | // foreach (DataRow row in schemaTable.Rows) | ||
99 | // m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
100 | // } | ||
101 | |||
102 | // foreach (string s in m_ColumnNames) | ||
103 | // { | ||
104 | // if (s == "UUID") | ||
105 | // continue; | ||
106 | // if (s == "ScopeID") | ||
107 | // continue; | ||
108 | |||
109 | // ret.Data[s] = result[s].ToString(); | ||
110 | // } | ||
111 | // return ret; | ||
112 | // } | ||
113 | // } | ||
114 | // } | ||
115 | // return null; | ||
116 | //} | ||
117 | |||
118 | //public bool Store(UserAccountData data) | ||
119 | //{ | ||
120 | // if (data.Data.ContainsKey("UUID")) | ||
121 | // data.Data.Remove("UUID"); | ||
122 | // if (data.Data.ContainsKey("ScopeID")) | ||
123 | // data.Data.Remove("ScopeID"); | ||
124 | |||
125 | // string[] fields = new List<string>(data.Data.Keys).ToArray(); | ||
126 | |||
127 | // using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
128 | // using (SqlCommand cmd = new SqlCommand()) | ||
129 | // { | ||
130 | // StringBuilder updateBuilder = new StringBuilder(); | ||
131 | // updateBuilder.AppendFormat("update {0} set ", m_Realm); | ||
132 | // bool first = true; | ||
133 | // foreach (string field in fields) | ||
134 | // { | ||
135 | // if (!first) | ||
136 | // updateBuilder.Append(", "); | ||
137 | // updateBuilder.AppendFormat("{0} = @{0}", field); | ||
138 | |||
139 | // first = false; | ||
140 | // cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); | ||
141 | // } | ||
142 | |||
143 | // updateBuilder.Append(" where UUID = @principalID"); | ||
144 | |||
145 | // if (data.ScopeID != UUID.Zero) | ||
146 | // updateBuilder.Append(" and ScopeID = @scopeID"); | ||
147 | |||
148 | // cmd.CommandText = updateBuilder.ToString(); | ||
149 | // cmd.Connection = conn; | ||
150 | // cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID)); | ||
151 | // cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID)); | ||
152 | // conn.Open(); | ||
153 | |||
154 | // if (cmd.ExecuteNonQuery() < 1) | ||
155 | // { | ||
156 | // StringBuilder insertBuilder = new StringBuilder(); | ||
157 | // insertBuilder.AppendFormat("insert into {0} (UUID, ScopeID, ", m_Realm); | ||
158 | // insertBuilder.Append(String.Join(", ", fields)); | ||
159 | // insertBuilder.Append(") values (@principalID, @scopeID, @"); | ||
160 | // insertBuilder.Append(String.Join(", @", fields)); | ||
161 | // insertBuilder.Append(")"); | ||
162 | |||
163 | // cmd.CommandText = insertBuilder.ToString(); | ||
164 | |||
165 | // if (cmd.ExecuteNonQuery() < 1) | ||
166 | // { | ||
167 | // return false; | ||
168 | // } | ||
169 | // } | ||
170 | // } | ||
171 | // return true; | ||
172 | //} | ||
173 | |||
174 | //public bool Store(UserAccountData data, UUID principalID, string token) | ||
175 | //{ | ||
176 | // return false; | ||
177 | //} | ||
178 | |||
179 | //public bool SetDataItem(UUID principalID, string item, string value) | ||
180 | //{ | ||
181 | // string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); | ||
182 | // using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
183 | // using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
184 | // { | ||
185 | // cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); | ||
186 | // cmd.Parameters.Add(m_database.CreateParameter("@UUID", principalID)); | ||
187 | |||
188 | // conn.Open(); | ||
189 | |||
190 | // if (cmd.ExecuteNonQuery() > 0) | ||
191 | // return true; | ||
192 | // } | ||
193 | // return false; | ||
194 | //} | ||
195 | |||
196 | //public UserAccountData[] Get(string[] keys, string[] vals) | ||
197 | //{ | ||
198 | // return null; | ||
199 | //} | ||
200 | |||
201 | public UserAccountData[] GetUsers(UUID scopeID, string query) | ||
202 | { | ||
203 | string[] words = query.Split(new char[] { ' ' }); | ||
204 | |||
205 | for (int i = 0; i < words.Length; i++) | ||
206 | { | ||
207 | if (words[i].Length < 3) | ||
208 | { | ||
209 | if (i != words.Length - 1) | ||
210 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
211 | Array.Resize(ref words, words.Length - 1); | ||
212 | } | ||
213 | } | ||
214 | |||
215 | if (words.Length == 0) | ||
216 | return new UserAccountData[0]; | ||
217 | |||
218 | if (words.Length > 2) | ||
219 | return new UserAccountData[0]; | ||
220 | |||
221 | string sql = ""; | ||
222 | |||
223 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
224 | using (SqlCommand cmd = new SqlCommand()) | ||
225 | { | ||
226 | if (words.Length == 1) | ||
227 | { | ||
228 | sql = 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); | ||
229 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | ||
230 | cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%")); | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | sql = 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); | ||
235 | cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%")); | ||
236 | cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%")); | ||
237 | cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString())); | ||
238 | } | ||
239 | cmd.Connection = conn; | ||
240 | cmd.CommandText = sql; | ||
241 | conn.Open(); | ||
242 | return DoQuery(cmd); | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | } | ||
diff --git a/OpenSim/Data/MSSQL/Resources/AssetStore.migrations b/OpenSim/Data/MSSQL/Resources/AssetStore.migrations deleted file mode 100644 index 8664ce9..0000000 --- a/OpenSim/Data/MSSQL/Resources/AssetStore.migrations +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE [assets] ( | ||
4 | [id] [varchar](36) NOT NULL, | ||
5 | [name] [varchar](64) NOT NULL, | ||
6 | [description] [varchar](64) NOT NULL, | ||
7 | [assetType] [tinyint] NOT NULL, | ||
8 | [local] [tinyint] NOT NULL, | ||
9 | [temporary] [tinyint] NOT NULL, | ||
10 | [data] [image] NOT NULL, | ||
11 | PRIMARY KEY CLUSTERED | ||
12 | ( | ||
13 | [id] ASC | ||
14 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
15 | ) ON [PRIMARY] | ||
16 | |||
17 | |||
18 | :VERSION 2 | ||
19 | |||
20 | BEGIN TRANSACTION | ||
21 | |||
22 | CREATE TABLE Tmp_assets | ||
23 | ( | ||
24 | id varchar(36) NOT NULL, | ||
25 | name varchar(64) NOT NULL, | ||
26 | description varchar(64) NOT NULL, | ||
27 | assetType tinyint NOT NULL, | ||
28 | local bit NOT NULL, | ||
29 | temporary bit NOT NULL, | ||
30 | data image NOT NULL | ||
31 | ) ON [PRIMARY] | ||
32 | TEXTIMAGE_ON [PRIMARY] | ||
33 | |||
34 | IF EXISTS(SELECT * FROM assets) | ||
35 | EXEC('INSERT INTO Tmp_assets (id, name, description, assetType, local, temporary, data) | ||
36 | SELECT id, name, description, assetType, CONVERT(bit, local), CONVERT(bit, temporary), data FROM assets WITH (HOLDLOCK TABLOCKX)') | ||
37 | |||
38 | DROP TABLE assets | ||
39 | |||
40 | EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT' | ||
41 | |||
42 | ALTER TABLE dbo.assets ADD CONSTRAINT | ||
43 | PK__assets__id PRIMARY KEY CLUSTERED | ||
44 | ( | ||
45 | id | ||
46 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
47 | |||
48 | COMMIT | ||
49 | |||
50 | |||
51 | :VERSION 3 | ||
52 | |||
53 | BEGIN TRANSACTION | ||
54 | |||
55 | ALTER TABLE assets add create_time integer default 0 | ||
56 | ALTER TABLE assets add access_time integer default 0 | ||
57 | |||
58 | COMMIT | ||
59 | |||
60 | |||
61 | :VERSION 4 | ||
62 | |||
63 | BEGIN TRANSACTION | ||
64 | |||
65 | CREATE TABLE dbo.Tmp_assets | ||
66 | ( | ||
67 | id uniqueidentifier NOT NULL, | ||
68 | name varchar(64) NOT NULL, | ||
69 | description varchar(64) NOT NULL, | ||
70 | assetType tinyint NOT NULL, | ||
71 | local bit NOT NULL, | ||
72 | temporary bit NOT NULL, | ||
73 | data image NOT NULL, | ||
74 | create_time int NULL, | ||
75 | access_time int NULL | ||
76 | ) ON [PRIMARY] | ||
77 | TEXTIMAGE_ON [PRIMARY] | ||
78 | |||
79 | IF EXISTS(SELECT * FROM dbo.assets) | ||
80 | EXEC('INSERT INTO dbo.Tmp_assets (id, name, description, assetType, local, temporary, data, create_time, access_time) | ||
81 | SELECT CONVERT(uniqueidentifier, id), name, description, assetType, local, temporary, data, create_time, access_time FROM dbo.assets WITH (HOLDLOCK TABLOCKX)') | ||
82 | |||
83 | DROP TABLE assets | ||
84 | |||
85 | EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT' | ||
86 | |||
87 | ALTER TABLE dbo.assets ADD CONSTRAINT | ||
88 | PK__assets__id PRIMARY KEY CLUSTERED | ||
89 | ( | ||
90 | id | ||
91 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
92 | |||
93 | COMMIT | ||
94 | |||
95 | |||
96 | :VERSION 5 | ||
97 | |||
98 | DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621'; | ||
99 | |||
100 | :VERSION 6 | ||
101 | |||
102 | ALTER TABLE assets ADD asset_flags INTEGER NOT NULL DEFAULT 0; | ||
103 | |||
104 | :VERSION 7 | ||
105 | |||
106 | alter table assets add creatorid varchar(36) not null default ''; | ||
diff --git a/OpenSim/Data/MSSQL/Resources/AuthStore.migrations b/OpenSim/Data/MSSQL/Resources/AuthStore.migrations deleted file mode 100644 index eb91296..0000000 --- a/OpenSim/Data/MSSQL/Resources/AuthStore.migrations +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [auth] ( | ||
6 | [uuid] [uniqueidentifier] NOT NULL default '00000000-0000-0000-0000-000000000000', | ||
7 | [passwordHash] [varchar](32) NOT NULL, | ||
8 | [passwordSalt] [varchar](32) NOT NULL, | ||
9 | [webLoginKey] [varchar](255) NOT NULL, | ||
10 | [accountType] VARCHAR(32) NOT NULL DEFAULT 'UserAccount', | ||
11 | ) ON [PRIMARY] | ||
12 | |||
13 | CREATE TABLE [tokens] ( | ||
14 | [uuid] [uniqueidentifier] NOT NULL default '00000000-0000-0000-0000-000000000000', | ||
15 | [token] [varchar](255) NOT NULL, | ||
16 | [validity] [datetime] NOT NULL ) | ||
17 | ON [PRIMARY] | ||
18 | |||
19 | COMMIT | ||
20 | |||
21 | :VERSION 2 | ||
22 | |||
23 | BEGIN TRANSACTION | ||
24 | |||
25 | IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U')) | ||
26 | INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey, accountType) SELECT [UUID] AS UUID, [passwordHash] AS passwordHash, [passwordSalt] AS passwordSalt, [webLoginKey] AS webLoginKey, 'UserAccount' as [accountType] FROM users; | ||
27 | |||
28 | COMMIT | ||
29 | |||
30 | |||
31 | |||
32 | |||
diff --git a/OpenSim/Data/MSSQL/Resources/Avatar.migrations b/OpenSim/Data/MSSQL/Resources/Avatar.migrations deleted file mode 100644 index 61f7b56..0000000 --- a/OpenSim/Data/MSSQL/Resources/Avatar.migrations +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [Avatars] ( | ||
6 | [PrincipalID] uniqueidentifier NOT NULL, | ||
7 | [Name] varchar(32) NOT NULL, | ||
8 | [Value] varchar(255) NOT NULL DEFAULT '', | ||
9 | PRIMARY KEY CLUSTERED | ||
10 | ( | ||
11 | [PrincipalID] ASC, [Name] ASC | ||
12 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
13 | ) ON [PRIMARY] | ||
14 | |||
15 | |||
16 | COMMIT | ||
17 | |||
18 | :VERSION 2 | ||
19 | |||
20 | BEGIN TRANSACTION | ||
21 | |||
22 | CREATE TABLE dbo.Tmp_Avatars | ||
23 | ( | ||
24 | PrincipalID uniqueidentifier NOT NULL, | ||
25 | [Name] varchar(32) NOT NULL, | ||
26 | Value text NOT NULL DEFAULT '', | ||
27 | ) ON [PRIMARY] | ||
28 | TEXTIMAGE_ON [PRIMARY] | ||
29 | |||
30 | IF EXISTS(SELECT * FROM dbo.Avatars) | ||
31 | EXEC('INSERT INTO dbo.Tmp_Avatars (PrincipalID, Name, Value) | ||
32 | SELECT PrincipalID, CONVERT(text, Name), Value FROM dbo.Avatars WITH (HOLDLOCK TABLOCKX)') | ||
33 | |||
34 | DROP TABLE dbo.Avatars | ||
35 | |||
36 | EXECUTE sp_rename N'dbo.Tmp_Avatars', N'Avatars', 'OBJECT' | ||
37 | |||
38 | COMMIT | ||
39 | |||
40 | :VERSION 3 | ||
41 | |||
42 | BEGIN TRANSACTION | ||
43 | |||
44 | CREATE TABLE dbo.Tmp_Avatars | ||
45 | ( | ||
46 | PrincipalID uniqueidentifier NOT NULL, | ||
47 | [Name] varchar(32) NOT NULL, | ||
48 | Value text NOT NULL DEFAULT '', | ||
49 | PRIMARY KEY CLUSTERED | ||
50 | ( | ||
51 | [PrincipalID] ASC, [Name] ASC | ||
52 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
53 | ) ON [PRIMARY] | ||
54 | TEXTIMAGE_ON [PRIMARY] | ||
55 | |||
56 | IF EXISTS(SELECT * FROM dbo.Avatars) | ||
57 | EXEC('INSERT INTO dbo.Tmp_Avatars (PrincipalID, Name, Value) | ||
58 | SELECT PrincipalID, CONVERT(text, Name), Value FROM dbo.Avatars WITH (HOLDLOCK TABLOCKX)') | ||
59 | |||
60 | DROP TABLE dbo.Avatars | ||
61 | |||
62 | EXECUTE sp_rename N'dbo.Tmp_Avatars', N'Avatars', 'OBJECT' | ||
63 | COMMIT | ||
64 | |||
diff --git a/OpenSim/Data/MSSQL/Resources/EstateStore.migrations b/OpenSim/Data/MSSQL/Resources/EstateStore.migrations deleted file mode 100644 index 64b2d2b..0000000 --- a/OpenSim/Data/MSSQL/Resources/EstateStore.migrations +++ /dev/null | |||
@@ -1,334 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [dbo].[estate_managers]( | ||
6 | [EstateID] [int] NOT NULL, | ||
7 | [uuid] [varchar](36) NOT NULL, | ||
8 | CONSTRAINT [PK_estate_managers] PRIMARY KEY CLUSTERED | ||
9 | ( | ||
10 | [EstateID] ASC | ||
11 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
12 | ) ON [PRIMARY]; | ||
13 | |||
14 | CREATE TABLE [dbo].[estate_groups]( | ||
15 | [EstateID] [int] NOT NULL, | ||
16 | [uuid] [varchar](36) NOT NULL, | ||
17 | CONSTRAINT [PK_estate_groups] PRIMARY KEY CLUSTERED | ||
18 | ( | ||
19 | [EstateID] ASC | ||
20 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
21 | ) ON [PRIMARY]; | ||
22 | |||
23 | |||
24 | CREATE TABLE [dbo].[estate_users]( | ||
25 | [EstateID] [int] NOT NULL, | ||
26 | [uuid] [varchar](36) NOT NULL, | ||
27 | CONSTRAINT [PK_estate_users] PRIMARY KEY CLUSTERED | ||
28 | ( | ||
29 | [EstateID] ASC | ||
30 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
31 | ) ON [PRIMARY]; | ||
32 | |||
33 | |||
34 | CREATE TABLE [dbo].[estateban]( | ||
35 | [EstateID] [int] NOT NULL, | ||
36 | [bannedUUID] [varchar](36) NOT NULL, | ||
37 | [bannedIp] [varchar](16) NOT NULL, | ||
38 | [bannedIpHostMask] [varchar](16) NOT NULL, | ||
39 | [bannedNameMask] [varchar](64) NULL DEFAULT (NULL), | ||
40 | CONSTRAINT [PK_estateban] PRIMARY KEY CLUSTERED | ||
41 | ( | ||
42 | [EstateID] ASC | ||
43 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
44 | ) ON [PRIMARY]; | ||
45 | |||
46 | CREATE TABLE [dbo].[estate_settings]( | ||
47 | [EstateID] [int] IDENTITY(1,100) NOT NULL, | ||
48 | [EstateName] [varchar](64) NULL DEFAULT (NULL), | ||
49 | [AbuseEmailToEstateOwner] [bit] NOT NULL, | ||
50 | [DenyAnonymous] [bit] NOT NULL, | ||
51 | [ResetHomeOnTeleport] [bit] NOT NULL, | ||
52 | [FixedSun] [bit] NOT NULL, | ||
53 | [DenyTransacted] [bit] NOT NULL, | ||
54 | [BlockDwell] [bit] NOT NULL, | ||
55 | [DenyIdentified] [bit] NOT NULL, | ||
56 | [AllowVoice] [bit] NOT NULL, | ||
57 | [UseGlobalTime] [bit] NOT NULL, | ||
58 | [PricePerMeter] [int] NOT NULL, | ||
59 | [TaxFree] [bit] NOT NULL, | ||
60 | [AllowDirectTeleport] [bit] NOT NULL, | ||
61 | [RedirectGridX] [int] NOT NULL, | ||
62 | [RedirectGridY] [int] NOT NULL, | ||
63 | [ParentEstateID] [int] NOT NULL, | ||
64 | [SunPosition] [float] NOT NULL, | ||
65 | [EstateSkipScripts] [bit] NOT NULL, | ||
66 | [BillableFactor] [float] NOT NULL, | ||
67 | [PublicAccess] [bit] NOT NULL, | ||
68 | [AbuseEmail] [varchar](255) NOT NULL, | ||
69 | [EstateOwner] [varchar](36) NOT NULL, | ||
70 | [DenyMinors] [bit] NOT NULL, | ||
71 | CONSTRAINT [PK_estate_settings] PRIMARY KEY CLUSTERED | ||
72 | ( | ||
73 | [EstateID] ASC | ||
74 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
75 | ) ON [PRIMARY]; | ||
76 | |||
77 | |||
78 | CREATE TABLE [dbo].[estate_map]( | ||
79 | [RegionID] [varchar](36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
80 | [EstateID] [int] NOT NULL, | ||
81 | CONSTRAINT [PK_estate_map] PRIMARY KEY CLUSTERED | ||
82 | ( | ||
83 | [RegionID] ASC | ||
84 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
85 | ) ON [PRIMARY]; | ||
86 | |||
87 | COMMIT | ||
88 | |||
89 | :VERSION 2 | ||
90 | |||
91 | BEGIN TRANSACTION | ||
92 | |||
93 | ALTER TABLE dbo.estate_managers DROP CONSTRAINT PK_estate_managers | ||
94 | |||
95 | CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers | ||
96 | ( | ||
97 | EstateID | ||
98 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
99 | |||
100 | ALTER TABLE dbo.estate_groups DROP CONSTRAINT PK_estate_groups | ||
101 | |||
102 | CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups | ||
103 | ( | ||
104 | EstateID | ||
105 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
106 | |||
107 | |||
108 | ALTER TABLE dbo.estate_users DROP CONSTRAINT PK_estate_users | ||
109 | |||
110 | CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users | ||
111 | ( | ||
112 | EstateID | ||
113 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
114 | |||
115 | COMMIT | ||
116 | |||
117 | |||
118 | :VERSION 3 | ||
119 | |||
120 | BEGIN TRANSACTION | ||
121 | |||
122 | CREATE TABLE dbo.Tmp_estateban | ||
123 | ( | ||
124 | EstateID int NOT NULL, | ||
125 | bannedUUID varchar(36) NOT NULL, | ||
126 | bannedIp varchar(16) NULL, | ||
127 | bannedIpHostMask varchar(16) NULL, | ||
128 | bannedNameMask varchar(64) NULL | ||
129 | ) ON [PRIMARY] | ||
130 | |||
131 | IF EXISTS(SELECT * FROM dbo.estateban) | ||
132 | EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) | ||
133 | SELECT EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban') | ||
134 | |||
135 | DROP TABLE dbo.estateban | ||
136 | |||
137 | EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT' | ||
138 | |||
139 | CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban | ||
140 | ( | ||
141 | EstateID | ||
142 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
143 | |||
144 | COMMIT | ||
145 | |||
146 | |||
147 | :VERSION 4 | ||
148 | |||
149 | BEGIN TRANSACTION | ||
150 | |||
151 | CREATE TABLE dbo.Tmp_estate_managers | ||
152 | ( | ||
153 | EstateID int NOT NULL, | ||
154 | uuid uniqueidentifier NOT NULL | ||
155 | ) ON [PRIMARY] | ||
156 | |||
157 | IF EXISTS(SELECT * FROM dbo.estate_managers) | ||
158 | EXEC('INSERT INTO dbo.Tmp_estate_managers (EstateID, uuid) | ||
159 | SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_managers WITH (HOLDLOCK TABLOCKX)') | ||
160 | |||
161 | DROP TABLE dbo.estate_managers | ||
162 | |||
163 | EXECUTE sp_rename N'dbo.Tmp_estate_managers', N'estate_managers', 'OBJECT' | ||
164 | |||
165 | CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers | ||
166 | ( | ||
167 | EstateID | ||
168 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
169 | |||
170 | COMMIT | ||
171 | |||
172 | |||
173 | :VERSION 5 | ||
174 | |||
175 | BEGIN TRANSACTION | ||
176 | |||
177 | CREATE TABLE dbo.Tmp_estate_groups | ||
178 | ( | ||
179 | EstateID int NOT NULL, | ||
180 | uuid uniqueidentifier NOT NULL | ||
181 | ) ON [PRIMARY] | ||
182 | |||
183 | IF EXISTS(SELECT * FROM dbo.estate_groups) | ||
184 | EXEC('INSERT INTO dbo.Tmp_estate_groups (EstateID, uuid) | ||
185 | SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_groups WITH (HOLDLOCK TABLOCKX)') | ||
186 | |||
187 | DROP TABLE dbo.estate_groups | ||
188 | |||
189 | EXECUTE sp_rename N'dbo.Tmp_estate_groups', N'estate_groups', 'OBJECT' | ||
190 | |||
191 | CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups | ||
192 | ( | ||
193 | EstateID | ||
194 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
195 | |||
196 | COMMIT | ||
197 | |||
198 | |||
199 | :VERSION 6 | ||
200 | |||
201 | BEGIN TRANSACTION | ||
202 | |||
203 | CREATE TABLE dbo.Tmp_estate_users | ||
204 | ( | ||
205 | EstateID int NOT NULL, | ||
206 | uuid uniqueidentifier NOT NULL | ||
207 | ) ON [PRIMARY] | ||
208 | |||
209 | IF EXISTS(SELECT * FROM dbo.estate_users) | ||
210 | EXEC('INSERT INTO dbo.Tmp_estate_users (EstateID, uuid) | ||
211 | SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_users WITH (HOLDLOCK TABLOCKX)') | ||
212 | |||
213 | DROP TABLE dbo.estate_users | ||
214 | |||
215 | EXECUTE sp_rename N'dbo.Tmp_estate_users', N'estate_users', 'OBJECT' | ||
216 | |||
217 | CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users | ||
218 | ( | ||
219 | EstateID | ||
220 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
221 | |||
222 | COMMIT | ||
223 | |||
224 | |||
225 | :VERSION 7 | ||
226 | |||
227 | BEGIN TRANSACTION | ||
228 | |||
229 | CREATE TABLE dbo.Tmp_estateban | ||
230 | ( | ||
231 | EstateID int NOT NULL, | ||
232 | bannedUUID uniqueidentifier NOT NULL, | ||
233 | bannedIp varchar(16) NULL, | ||
234 | bannedIpHostMask varchar(16) NULL, | ||
235 | bannedNameMask varchar(64) NULL | ||
236 | ) ON [PRIMARY] | ||
237 | |||
238 | IF EXISTS(SELECT * FROM dbo.estateban) | ||
239 | EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) | ||
240 | SELECT EstateID, CONVERT(uniqueidentifier, bannedUUID), bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban WITH (HOLDLOCK TABLOCKX)') | ||
241 | |||
242 | DROP TABLE dbo.estateban | ||
243 | |||
244 | EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT' | ||
245 | |||
246 | CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban | ||
247 | ( | ||
248 | EstateID | ||
249 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
250 | |||
251 | COMMIT | ||
252 | |||
253 | |||
254 | :VERSION 8 | ||
255 | |||
256 | BEGIN TRANSACTION | ||
257 | |||
258 | CREATE TABLE dbo.Tmp_estate_settings | ||
259 | ( | ||
260 | EstateID int NOT NULL IDENTITY (1, 100), | ||
261 | EstateName varchar(64) NULL DEFAULT (NULL), | ||
262 | AbuseEmailToEstateOwner bit NOT NULL, | ||
263 | DenyAnonymous bit NOT NULL, | ||
264 | ResetHomeOnTeleport bit NOT NULL, | ||
265 | FixedSun bit NOT NULL, | ||
266 | DenyTransacted bit NOT NULL, | ||
267 | BlockDwell bit NOT NULL, | ||
268 | DenyIdentified bit NOT NULL, | ||
269 | AllowVoice bit NOT NULL, | ||
270 | UseGlobalTime bit NOT NULL, | ||
271 | PricePerMeter int NOT NULL, | ||
272 | TaxFree bit NOT NULL, | ||
273 | AllowDirectTeleport bit NOT NULL, | ||
274 | RedirectGridX int NOT NULL, | ||
275 | RedirectGridY int NOT NULL, | ||
276 | ParentEstateID int NOT NULL, | ||
277 | SunPosition float(53) NOT NULL, | ||
278 | EstateSkipScripts bit NOT NULL, | ||
279 | BillableFactor float(53) NOT NULL, | ||
280 | PublicAccess bit NOT NULL, | ||
281 | AbuseEmail varchar(255) NOT NULL, | ||
282 | EstateOwner uniqueidentifier NOT NULL, | ||
283 | DenyMinors bit NOT NULL | ||
284 | ) ON [PRIMARY] | ||
285 | |||
286 | SET IDENTITY_INSERT dbo.Tmp_estate_settings ON | ||
287 | |||
288 | IF EXISTS(SELECT * FROM dbo.estate_settings) | ||
289 | EXEC('INSERT INTO dbo.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) | ||
290 | SELECT EstateID, EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, PublicAccess, AbuseEmail, CONVERT(uniqueidentifier, EstateOwner), DenyMinors FROM dbo.estate_settings WITH (HOLDLOCK TABLOCKX)') | ||
291 | |||
292 | SET IDENTITY_INSERT dbo.Tmp_estate_settings OFF | ||
293 | |||
294 | DROP TABLE dbo.estate_settings | ||
295 | |||
296 | EXECUTE sp_rename N'dbo.Tmp_estate_settings', N'estate_settings', 'OBJECT' | ||
297 | |||
298 | ALTER TABLE dbo.estate_settings ADD CONSTRAINT | ||
299 | PK_estate_settings PRIMARY KEY CLUSTERED | ||
300 | ( | ||
301 | EstateID | ||
302 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
303 | |||
304 | COMMIT | ||
305 | |||
306 | |||
307 | :VERSION 9 | ||
308 | |||
309 | BEGIN TRANSACTION | ||
310 | |||
311 | CREATE TABLE dbo.Tmp_estate_map | ||
312 | ( | ||
313 | RegionID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
314 | EstateID int NOT NULL | ||
315 | ) ON [PRIMARY] | ||
316 | |||
317 | IF EXISTS(SELECT * FROM dbo.estate_map) | ||
318 | EXEC('INSERT INTO dbo.Tmp_estate_map (RegionID, EstateID) | ||
319 | SELECT CONVERT(uniqueidentifier, RegionID), EstateID FROM dbo.estate_map WITH (HOLDLOCK TABLOCKX)') | ||
320 | |||
321 | DROP TABLE dbo.estate_map | ||
322 | |||
323 | EXECUTE sp_rename N'dbo.Tmp_estate_map', N'estate_map', 'OBJECT' | ||
324 | |||
325 | ALTER TABLE dbo.estate_map ADD CONSTRAINT | ||
326 | PK_estate_map PRIMARY KEY CLUSTERED | ||
327 | ( | ||
328 | RegionID | ||
329 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
330 | |||
331 | |||
332 | COMMIT | ||
333 | |||
334 | |||
diff --git a/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations b/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations deleted file mode 100644 index cc94c4e..0000000 --- a/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [Friends] ( | ||
6 | [PrincipalID] uniqueidentifier NOT NULL, | ||
7 | [Friend] varchar(255) NOT NULL, | ||
8 | [Flags] char(16) NOT NULL DEFAULT '0', | ||
9 | [Offered] varchar(32) NOT NULL DEFAULT 0) | ||
10 | ON [PRIMARY] | ||
11 | |||
12 | COMMIT | ||
13 | |||
14 | :VERSION 2 | ||
15 | |||
16 | BEGIN TRANSACTION | ||
17 | |||
18 | IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[userfriends]') AND type in (N'U')) | ||
19 | INSERT INTO Friends (PrincipalID, Friend, Flags, Offered) | ||
20 | SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends; | ||
21 | |||
22 | COMMIT | ||
23 | |||
24 | :VERSION 3 | ||
25 | |||
26 | BEGIN TRANSACTION | ||
27 | |||
28 | CREATE TABLE [Tmp_Friends] | ||
29 | ([PrincipalID] varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
30 | [Friend] varchar(255) NOT NULL, | ||
31 | [Flags] char(16) NOT NULL DEFAULT '0', | ||
32 | [Offered] varchar(32) NOT NULL DEFAULT 0) | ||
33 | ON [PRIMARY] | ||
34 | |||
35 | |||
36 | IF EXISTS(SELECT * FROM dbo.Friends) | ||
37 | EXEC('INSERT INTO dbo.Tmp_Friends (PrincipalID, Friend, Flags, Offered) | ||
38 | SELECT CONVERT(varchar(255),PrincipalID), Friend, Flags, Offered FROM dbo.Friends WITH (HOLDLOCK TABLOCKX)') | ||
39 | |||
40 | DROP TABLE dbo.Friends | ||
41 | |||
42 | EXECUTE sp_rename N'dbo.Tmp_Friends', N'Friends', 'OBJECT' | ||
43 | |||
44 | ALTER TABLE dbo.Friends ADD | ||
45 | PRIMARY KEY CLUSTERED | ||
46 | ( | ||
47 | [PrincipalID] ASC, [Friend] ASC | ||
48 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
49 | |||
50 | COMMIT \ No newline at end of file | ||
diff --git a/OpenSim/Data/MSSQL/Resources/GridStore.migrations b/OpenSim/Data/MSSQL/Resources/GridStore.migrations deleted file mode 100644 index de0cea7..0000000 --- a/OpenSim/Data/MSSQL/Resources/GridStore.migrations +++ /dev/null | |||
@@ -1,245 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [dbo].[regions]( | ||
6 | [regionHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
7 | [regionName] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
8 | [uuid] [varchar](255) COLLATE Latin1_General_CI_AS NOT NULL, | ||
9 | [regionRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
10 | [regionSecret] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
11 | [regionSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
12 | [regionDataURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
13 | [serverIP] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
14 | [serverPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
15 | [serverURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
16 | [locX] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
17 | [locY] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
18 | [locZ] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
19 | [eastOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
20 | [westOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
21 | [southOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
22 | [northOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
23 | [regionAssetURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
24 | [regionAssetRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
25 | [regionAssetSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
26 | [regionUserURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
27 | [regionUserRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
28 | [regionUserSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
29 | [regionMapTexture] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
30 | [serverHttpPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
31 | [serverRemotingPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL, | ||
32 | [owner_uuid] [varchar](36) COLLATE Latin1_General_CI_AS NULL, | ||
33 | PRIMARY KEY CLUSTERED | ||
34 | ( | ||
35 | [uuid] ASC | ||
36 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
37 | ) ON [PRIMARY] | ||
38 | |||
39 | COMMIT | ||
40 | |||
41 | |||
42 | :VERSION 2 | ||
43 | |||
44 | BEGIN TRANSACTION | ||
45 | |||
46 | CREATE TABLE Tmp_regions | ||
47 | ( | ||
48 | uuid varchar(36) COLLATE Latin1_General_CI_AS NOT NULL, | ||
49 | regionHandle bigint NULL, | ||
50 | regionName varchar(20) NULL, | ||
51 | regionRecvKey varchar(128) NULL, | ||
52 | regionSendKey varchar(128) NULL, | ||
53 | regionSecret varchar(128) NULL, | ||
54 | regionDataURI varchar(128) NULL, | ||
55 | serverIP varchar(64) NULL, | ||
56 | serverPort int NULL, | ||
57 | serverURI varchar(255) NULL, | ||
58 | locX int NULL, | ||
59 | locY int NULL, | ||
60 | locZ int NULL, | ||
61 | eastOverrideHandle bigint NULL, | ||
62 | westOverrideHandle bigint NULL, | ||
63 | southOverrideHandle bigint NULL, | ||
64 | northOverrideHandle bigint NULL, | ||
65 | regionAssetURI varchar(255) NULL, | ||
66 | regionAssetRecvKey varchar(128) NULL, | ||
67 | regionAssetSendKey varchar(128) NULL, | ||
68 | regionUserURI varchar(255) NULL, | ||
69 | regionUserRecvKey varchar(128) NULL, | ||
70 | regionUserSendKey varchar(128) NULL, | ||
71 | regionMapTexture varchar(36) NULL, | ||
72 | serverHttpPort int NULL, | ||
73 | serverRemotingPort int NULL, | ||
74 | owner_uuid varchar(36) NULL, | ||
75 | originUUID varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000') | ||
76 | ) ON [PRIMARY] | ||
77 | |||
78 | IF EXISTS(SELECT * FROM regions) | ||
79 | EXEC('INSERT INTO Tmp_regions (uuid, regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid) | ||
80 | SELECT CONVERT(varchar(36), uuid), CONVERT(bigint, regionHandle), CONVERT(varchar(20), regionName), CONVERT(varchar(128), regionRecvKey), CONVERT(varchar(128), regionSendKey), CONVERT(varchar(128), regionSecret), CONVERT(varchar(128), regionDataURI), CONVERT(varchar(64), serverIP), CONVERT(int, serverPort), serverURI, CONVERT(int, locX), CONVERT(int, locY), CONVERT(int, locZ), CONVERT(bigint, eastOverrideHandle), CONVERT(bigint, westOverrideHandle), CONVERT(bigint, southOverrideHandle), CONVERT(bigint, northOverrideHandle), regionAssetURI, CONVERT(varchar(128), regionAssetRecvKey), CONVERT(varchar(128), regionAssetSendKey), regionUserURI, CONVERT(varchar(128), regionUserRecvKey), CONVERT(varchar(128), regionUserSendKey), CONVERT(varchar(36), regionMapTexture), CONVERT(int, serverHttpPort), CONVERT(int, serverRemotingPort), owner_uuid FROM regions') | ||
81 | |||
82 | DROP TABLE regions | ||
83 | |||
84 | EXECUTE sp_rename N'Tmp_regions', N'regions', 'OBJECT' | ||
85 | |||
86 | ALTER TABLE regions ADD CONSTRAINT | ||
87 | PK__regions__uuid PRIMARY KEY CLUSTERED | ||
88 | ( | ||
89 | uuid | ||
90 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
91 | |||
92 | COMMIT | ||
93 | |||
94 | :VERSION 3 | ||
95 | |||
96 | BEGIN TRANSACTION | ||
97 | |||
98 | CREATE NONCLUSTERED INDEX IX_regions_name ON dbo.regions | ||
99 | ( | ||
100 | regionName | ||
101 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
102 | |||
103 | CREATE NONCLUSTERED INDEX IX_regions_handle ON dbo.regions | ||
104 | ( | ||
105 | regionHandle | ||
106 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
107 | |||
108 | |||
109 | CREATE NONCLUSTERED INDEX IX_regions_override ON dbo.regions | ||
110 | ( | ||
111 | eastOverrideHandle, | ||
112 | westOverrideHandle, | ||
113 | southOverrideHandle, | ||
114 | northOverrideHandle | ||
115 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
116 | |||
117 | COMMIT | ||
118 | |||
119 | |||
120 | :VERSION 4 | ||
121 | |||
122 | /* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/ | ||
123 | BEGIN TRANSACTION | ||
124 | |||
125 | CREATE TABLE dbo.Tmp_regions | ||
126 | ( | ||
127 | uuid uniqueidentifier NOT NULL, | ||
128 | regionHandle bigint NULL, | ||
129 | regionName varchar(20) NULL, | ||
130 | regionRecvKey varchar(128) NULL, | ||
131 | regionSendKey varchar(128) NULL, | ||
132 | regionSecret varchar(128) NULL, | ||
133 | regionDataURI varchar(128) NULL, | ||
134 | serverIP varchar(64) NULL, | ||
135 | serverPort int NULL, | ||
136 | serverURI varchar(255) NULL, | ||
137 | locX int NULL, | ||
138 | locY int NULL, | ||
139 | locZ int NULL, | ||
140 | eastOverrideHandle bigint NULL, | ||
141 | westOverrideHandle bigint NULL, | ||
142 | southOverrideHandle bigint NULL, | ||
143 | northOverrideHandle bigint NULL, | ||
144 | regionAssetURI varchar(255) NULL, | ||
145 | regionAssetRecvKey varchar(128) NULL, | ||
146 | regionAssetSendKey varchar(128) NULL, | ||
147 | regionUserURI varchar(255) NULL, | ||
148 | regionUserRecvKey varchar(128) NULL, | ||
149 | regionUserSendKey varchar(128) NULL, | ||
150 | regionMapTexture uniqueidentifier NULL, | ||
151 | serverHttpPort int NULL, | ||
152 | serverRemotingPort int NULL, | ||
153 | owner_uuid uniqueidentifier NOT NULL, | ||
154 | originUUID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000') | ||
155 | ) ON [PRIMARY] | ||
156 | |||
157 | IF EXISTS(SELECT * FROM dbo.regions) | ||
158 | EXEC('INSERT INTO dbo.Tmp_regions (uuid, regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID) | ||
159 | SELECT CONVERT(uniqueidentifier, uuid), regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, CONVERT(uniqueidentifier, regionMapTexture), serverHttpPort, serverRemotingPort, CONVERT(uniqueidentifier, owner_uuid), CONVERT(uniqueidentifier, originUUID) FROM dbo.regions WITH (HOLDLOCK TABLOCKX)') | ||
160 | |||
161 | DROP TABLE dbo.regions | ||
162 | |||
163 | EXECUTE sp_rename N'dbo.Tmp_regions', N'regions', 'OBJECT' | ||
164 | |||
165 | ALTER TABLE dbo.regions ADD CONSTRAINT | ||
166 | PK__regions__uuid PRIMARY KEY CLUSTERED | ||
167 | ( | ||
168 | uuid | ||
169 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
170 | |||
171 | CREATE NONCLUSTERED INDEX IX_regions_name ON dbo.regions | ||
172 | ( | ||
173 | regionName | ||
174 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
175 | |||
176 | CREATE NONCLUSTERED INDEX IX_regions_handle ON dbo.regions | ||
177 | ( | ||
178 | regionHandle | ||
179 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
180 | |||
181 | CREATE NONCLUSTERED INDEX IX_regions_override ON dbo.regions | ||
182 | ( | ||
183 | eastOverrideHandle, | ||
184 | westOverrideHandle, | ||
185 | southOverrideHandle, | ||
186 | northOverrideHandle | ||
187 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
188 | |||
189 | COMMIT | ||
190 | |||
191 | |||
192 | :VERSION 5 | ||
193 | |||
194 | BEGIN TRANSACTION | ||
195 | |||
196 | ALTER TABLE regions ADD access int default 0; | ||
197 | |||
198 | COMMIT | ||
199 | |||
200 | |||
201 | :VERSION 6 | ||
202 | |||
203 | BEGIN TRANSACTION | ||
204 | |||
205 | ALTER TABLE regions ADD scopeid uniqueidentifier default '00000000-0000-0000-0000-000000000000'; | ||
206 | ALTER TABLE regions ADD DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [owner_uuid]; | ||
207 | ALTER TABLE regions ADD sizeX integer not null default 0; | ||
208 | ALTER TABLE regions ADD sizeY integer not null default 0; | ||
209 | |||
210 | COMMIT | ||
211 | |||
212 | |||
213 | :VERSION 7 | ||
214 | |||
215 | BEGIN TRANSACTION | ||
216 | |||
217 | ALTER TABLE regions ADD [flags] integer NOT NULL DEFAULT 0; | ||
218 | CREATE INDEX [flags] ON regions(flags); | ||
219 | ALTER TABLE [regions] ADD [last_seen] integer NOT NULL DEFAULT 0; | ||
220 | ALTER TABLE [regions] ADD [PrincipalID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
221 | ALTER TABLE [regions] ADD [Token] varchar(255) NOT NULL DEFAULT 0; | ||
222 | |||
223 | COMMIT | ||
224 | |||
225 | :VERSION 8 | ||
226 | |||
227 | BEGIN TRANSACTION | ||
228 | ALTER TABLE regions ALTER COLUMN regionName VarChar(128) | ||
229 | |||
230 | DROP INDEX IX_regions_name ON dbo.regions | ||
231 | ALTER TABLE regions ALTER COLUMN regionName VarChar(128) null | ||
232 | |||
233 | CREATE NONCLUSTERED INDEX IX_regions_name ON dbo.regions | ||
234 | ( | ||
235 | regionName | ||
236 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
237 | |||
238 | COMMIT | ||
239 | |||
240 | :VERSION 9 | ||
241 | |||
242 | BEGIN TRANSACTION | ||
243 | ALTER TABLE regions ADD parcelMapTexture uniqueidentifier NULL; | ||
244 | |||
245 | COMMIT | ||
diff --git a/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations b/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations deleted file mode 100644 index ecd3f4d..0000000 --- a/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE "GridUser" ( | ||
6 | "UserID" VARCHAR(255) NOT NULL, | ||
7 | "HomeRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
8 | "HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
9 | "HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
10 | "LastRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
11 | "LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
12 | "LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
13 | "Online" CHAR(5) NOT NULL DEFAULT 'false', | ||
14 | "Login" CHAR(16) NOT NULL DEFAULT '0', | ||
15 | "Logout" CHAR(16) NOT NULL DEFAULT '0', | ||
16 | PRIMARY KEY ("UserID") | ||
17 | ) | ||
18 | |||
19 | COMMIT | ||
20 | |||
21 | :VERSION 2 # -------------------------- | ||
22 | |||
23 | BEGIN TRANSACTION | ||
24 | |||
25 | CREATE TABLE [GridUser_tmp] ( | ||
26 | [UserID] VARCHAR(255) NOT NULL, | ||
27 | [HomeRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
28 | [HomePosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
29 | [HomeLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
30 | [LastRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
31 | [LastPosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
32 | [LastLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
33 | [Online] CHAR(5) NOT NULL DEFAULT 'false', | ||
34 | [Login] CHAR(16) NOT NULL DEFAULT '0', | ||
35 | [Logout] CHAR(16) NOT NULL DEFAULT '0', | ||
36 | |||
37 | PRIMARY KEY CLUSTERED | ||
38 | ( | ||
39 | [UserID] ASC | ||
40 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
41 | ) ON [PRIMARY] | ||
42 | |||
43 | COMMIT | ||
44 | |||
45 | IF EXISTS(SELECT * FROM dbo.GridUser) | ||
46 | EXEC('INSERT INTO dbo.GridUser_tmp ([UserID] | ||
47 | ,[HomeRegionID] | ||
48 | ,[HomePosition] | ||
49 | ,[HomeLookAt] | ||
50 | ,[LastRegionID] | ||
51 | ,[LastPosition] | ||
52 | ,[LastLookAt] | ||
53 | ,[Online] | ||
54 | ,[Login] | ||
55 | ,[Logout]) | ||
56 | SELECT CONVERT(varchar(36), [HomeRegionID]), [HomePosition] ,[HomeLookAt] , CONVERT(varchar(36),[LastRegionID]) | ||
57 | ,[LastPosition] | ||
58 | ,[LastLookAt] | ||
59 | ,[Online] | ||
60 | ,[Login] | ||
61 | ,[Logout] FROM dbo.GridUser WITH (HOLDLOCK TABLOCKX)') | ||
62 | |||
63 | DROP TABLE dbo.GridUser | ||
64 | |||
65 | EXECUTE sp_rename N'dbo.GridUser_tmp', N'GridUser', 'OBJECT' \ No newline at end of file | ||
diff --git a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations deleted file mode 100644 index 4e43653..0000000 --- a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations +++ /dev/null | |||
@@ -1,279 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [inventoryfolders] ( | ||
6 | [folderID] [varchar](36) NOT NULL default '', | ||
7 | [agentID] [varchar](36) default NULL, | ||
8 | [parentFolderID] [varchar](36) default NULL, | ||
9 | [folderName] [varchar](64) default NULL, | ||
10 | [type] [smallint] NOT NULL default 0, | ||
11 | [version] [int] NOT NULL default 0, | ||
12 | PRIMARY KEY CLUSTERED | ||
13 | ( | ||
14 | [folderID] ASC | ||
15 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
16 | ) ON [PRIMARY] | ||
17 | |||
18 | CREATE NONCLUSTERED INDEX [owner] ON [inventoryfolders] | ||
19 | ( | ||
20 | [agentID] ASC | ||
21 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
22 | |||
23 | CREATE NONCLUSTERED INDEX [parent] ON [inventoryfolders] | ||
24 | ( | ||
25 | [parentFolderID] ASC | ||
26 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
27 | |||
28 | |||
29 | CREATE TABLE [inventoryitems] ( | ||
30 | [inventoryID] [varchar](36) NOT NULL default '', | ||
31 | [assetID] [varchar](36) default NULL, | ||
32 | [assetType] [int] default NULL, | ||
33 | [parentFolderID] [varchar](36) default NULL, | ||
34 | [avatarID] [varchar](36) default NULL, | ||
35 | [inventoryName] [varchar](64) default NULL, | ||
36 | [inventoryDescription] [varchar](128) default NULL, | ||
37 | [inventoryNextPermissions] [int] default NULL, | ||
38 | [inventoryCurrentPermissions] [int] default NULL, | ||
39 | [invType] [int] default NULL, | ||
40 | [creatorID] [varchar](36) default NULL, | ||
41 | [inventoryBasePermissions] [int] NOT NULL default 0, | ||
42 | [inventoryEveryOnePermissions] [int] NOT NULL default 0, | ||
43 | [salePrice] [int] default NULL, | ||
44 | [saleType] [tinyint] default NULL, | ||
45 | [creationDate] [int] default NULL, | ||
46 | [groupID] [varchar](36) default NULL, | ||
47 | [groupOwned] [bit] default NULL, | ||
48 | [flags] [int] default NULL, | ||
49 | PRIMARY KEY CLUSTERED | ||
50 | ( | ||
51 | [inventoryID] ASC | ||
52 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
53 | ) ON [PRIMARY] | ||
54 | |||
55 | |||
56 | CREATE NONCLUSTERED INDEX [owner] ON [inventoryitems] | ||
57 | ( | ||
58 | [avatarID] ASC | ||
59 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
60 | |||
61 | CREATE NONCLUSTERED INDEX [folder] ON [inventoryitems] | ||
62 | ( | ||
63 | [parentFolderID] ASC | ||
64 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
65 | |||
66 | COMMIT | ||
67 | |||
68 | |||
69 | :VERSION 2 | ||
70 | |||
71 | BEGIN TRANSACTION | ||
72 | |||
73 | ALTER TABLE inventoryitems ADD inventoryGroupPermissions INTEGER NOT NULL default 0 | ||
74 | |||
75 | COMMIT | ||
76 | |||
77 | :VERSION 3 | ||
78 | |||
79 | /* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/ | ||
80 | BEGIN TRANSACTION | ||
81 | |||
82 | CREATE TABLE dbo.Tmp_inventoryfolders | ||
83 | ( | ||
84 | folderID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
85 | agentID uniqueidentifier NULL DEFAULT (NULL), | ||
86 | parentFolderID uniqueidentifier NULL DEFAULT (NULL), | ||
87 | folderName varchar(64) NULL DEFAULT (NULL), | ||
88 | type smallint NOT NULL DEFAULT ((0)), | ||
89 | version int NOT NULL DEFAULT ((0)) | ||
90 | ) ON [PRIMARY] | ||
91 | |||
92 | IF EXISTS(SELECT * FROM dbo.inventoryfolders) | ||
93 | EXEC('INSERT INTO dbo.Tmp_inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) | ||
94 | SELECT CONVERT(uniqueidentifier, folderID), CONVERT(uniqueidentifier, agentID), CONVERT(uniqueidentifier, parentFolderID), folderName, type, version FROM dbo.inventoryfolders WITH (HOLDLOCK TABLOCKX)') | ||
95 | |||
96 | DROP TABLE dbo.inventoryfolders | ||
97 | |||
98 | EXECUTE sp_rename N'dbo.Tmp_inventoryfolders', N'inventoryfolders', 'OBJECT' | ||
99 | |||
100 | ALTER TABLE dbo.inventoryfolders ADD CONSTRAINT | ||
101 | PK__inventor__C2FABFB3173876EA PRIMARY KEY CLUSTERED | ||
102 | ( | ||
103 | folderID | ||
104 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
105 | |||
106 | CREATE NONCLUSTERED INDEX owner ON dbo.inventoryfolders | ||
107 | ( | ||
108 | agentID | ||
109 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
110 | |||
111 | CREATE NONCLUSTERED INDEX parent ON dbo.inventoryfolders | ||
112 | ( | ||
113 | parentFolderID | ||
114 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
115 | |||
116 | COMMIT | ||
117 | |||
118 | |||
119 | :VERSION 4 | ||
120 | |||
121 | BEGIN TRANSACTION | ||
122 | |||
123 | CREATE TABLE dbo.Tmp_inventoryitems | ||
124 | ( | ||
125 | inventoryID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
126 | assetID uniqueidentifier NULL DEFAULT (NULL), | ||
127 | assetType int NULL DEFAULT (NULL), | ||
128 | parentFolderID uniqueidentifier NULL DEFAULT (NULL), | ||
129 | avatarID uniqueidentifier NULL DEFAULT (NULL), | ||
130 | inventoryName varchar(64) NULL DEFAULT (NULL), | ||
131 | inventoryDescription varchar(128) NULL DEFAULT (NULL), | ||
132 | inventoryNextPermissions int NULL DEFAULT (NULL), | ||
133 | inventoryCurrentPermissions int NULL DEFAULT (NULL), | ||
134 | invType int NULL DEFAULT (NULL), | ||
135 | creatorID uniqueidentifier NULL DEFAULT (NULL), | ||
136 | inventoryBasePermissions int NOT NULL DEFAULT ((0)), | ||
137 | inventoryEveryOnePermissions int NOT NULL DEFAULT ((0)), | ||
138 | salePrice int NULL DEFAULT (NULL), | ||
139 | saleType tinyint NULL DEFAULT (NULL), | ||
140 | creationDate int NULL DEFAULT (NULL), | ||
141 | groupID uniqueidentifier NULL DEFAULT (NULL), | ||
142 | groupOwned bit NULL DEFAULT (NULL), | ||
143 | flags int NULL DEFAULT (NULL), | ||
144 | inventoryGroupPermissions int NOT NULL DEFAULT ((0)) | ||
145 | ) ON [PRIMARY] | ||
146 | |||
147 | IF EXISTS(SELECT * FROM dbo.inventoryitems) | ||
148 | EXEC('INSERT INTO dbo.Tmp_inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, groupID, groupOwned, flags, inventoryGroupPermissions) | ||
149 | SELECT CONVERT(uniqueidentifier, inventoryID), CONVERT(uniqueidentifier, assetID), assetType, CONVERT(uniqueidentifier, parentFolderID), CONVERT(uniqueidentifier, avatarID), inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, CONVERT(uniqueidentifier, creatorID), inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, CONVERT(uniqueidentifier, groupID), groupOwned, flags, inventoryGroupPermissions FROM dbo.inventoryitems WITH (HOLDLOCK TABLOCKX)') | ||
150 | |||
151 | DROP TABLE dbo.inventoryitems | ||
152 | |||
153 | EXECUTE sp_rename N'dbo.Tmp_inventoryitems', N'inventoryitems', 'OBJECT' | ||
154 | |||
155 | ALTER TABLE dbo.inventoryitems ADD CONSTRAINT | ||
156 | PK__inventor__C4B7BC2220C1E124 PRIMARY KEY CLUSTERED | ||
157 | ( | ||
158 | inventoryID | ||
159 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
160 | |||
161 | |||
162 | CREATE NONCLUSTERED INDEX owner ON dbo.inventoryitems | ||
163 | ( | ||
164 | avatarID | ||
165 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
166 | |||
167 | CREATE NONCLUSTERED INDEX folder ON dbo.inventoryitems | ||
168 | ( | ||
169 | parentFolderID | ||
170 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
171 | |||
172 | COMMIT | ||
173 | |||
174 | :VERSION 5 | ||
175 | |||
176 | # It would be totally crazy to have to recreate the whole table just to change one column type, | ||
177 | # just because MS SQL treats each DEFAULT as a constraint object that must be dropped | ||
178 | # before anything can be done to the column. Since all defaults here are unnamed, there is | ||
179 | # no easy way to drop them! The hairy piece of code below removes all DEFAULT constraints | ||
180 | # from InventoryItems. | ||
181 | |||
182 | # SO: anything that's NULLable is by default NULL, so please don't declare DEFAULT(NULL), | ||
183 | # they do nothing but prevent changes to the columns. If you really | ||
184 | # need to have DEFAULTs or other constraints, give them names so they can be dropped when needed! | ||
185 | |||
186 | BEGIN TRANSACTION | ||
187 | DECLARE @nm varchar(80); | ||
188 | DECLARE x CURSOR LOCAL FORWARD_ONLY READ_ONLY | ||
189 | FOR SELECT name FROM sys.default_constraints where parent_object_id = OBJECT_ID('inventoryitems'); | ||
190 | OPEN x; | ||
191 | FETCH NEXT FROM x INTO @nm; | ||
192 | WHILE @@FETCH_STATUS = 0 | ||
193 | BEGIN | ||
194 | EXEC('alter table inventoryitems drop ' + @nm); | ||
195 | FETCH NEXT FROM x INTO @nm; | ||
196 | END | ||
197 | CLOSE x | ||
198 | DEALLOCATE x | ||
199 | COMMIT | ||
200 | |||
201 | # all DEFAULTs dropped! | ||
202 | |||
203 | :GO | ||
204 | |||
205 | BEGIN TRANSACTION | ||
206 | |||
207 | # Restoring defaults: | ||
208 | # NOTE: [inventoryID] does NOT need one: it's NOT NULL PK and a unique Guid must be provided every time anyway! | ||
209 | |||
210 | alter table inventoryitems | ||
211 | add constraint def_baseperm default 0 for inventoryBasePermissions | ||
212 | alter table inventoryitems | ||
213 | add constraint def_allperm default 0 for inventoryEveryOnePermissions | ||
214 | alter table inventoryitems | ||
215 | add constraint def_grpperm default 0 for inventoryGroupPermissions | ||
216 | |||
217 | COMMIT | ||
218 | |||
219 | :VERSION 7 | ||
220 | |||
221 | BEGIN TRANSACTION | ||
222 | |||
223 | # CreatorID goes back to VARCHAR(36) (???) | ||
224 | |||
225 | exec sp_rename 'inventoryitems.CreatorID', 'cr_old', 'COLUMN' | ||
226 | |||
227 | :GO | ||
228 | |||
229 | alter table inventoryitems | ||
230 | add creatorID varchar(36) NULL | ||
231 | |||
232 | :GO | ||
233 | |||
234 | update inventoryitems set creatorID = CONVERT(VARCHAR(36), cr_old) | ||
235 | |||
236 | alter table inventoryitems | ||
237 | drop column cr_old | ||
238 | |||
239 | COMMIT | ||
240 | |||
241 | :VERSION 8 | ||
242 | |||
243 | ALTER TABLE inventoryitems | ||
244 | ADD CONSTRAINT DF_inventoryitems_creatorID | ||
245 | DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID | ||
246 | |||
247 | :GO | ||
248 | |||
249 | :VERSION 9 | ||
250 | |||
251 | BEGIN TRANSACTION | ||
252 | |||
253 | # CreatorID goes up to VARCHAR(255) | ||
254 | |||
255 | exec sp_rename 'inventoryitems.CreatorID', 'cr_old', 'COLUMN' | ||
256 | |||
257 | :GO | ||
258 | |||
259 | alter table inventoryitems | ||
260 | add creatorID varchar(255) NULL | ||
261 | |||
262 | :GO | ||
263 | |||
264 | update inventoryitems set creatorID = cr_old | ||
265 | |||
266 | alter table inventoryitems | ||
267 | drop CONSTRAINT DF_inventoryitems_creatorID | ||
268 | :GO | ||
269 | |||
270 | alter table inventoryitems | ||
271 | drop column cr_old | ||
272 | :GO | ||
273 | COMMIT | ||
274 | |||
275 | ALTER TABLE inventoryitems | ||
276 | ADD CONSTRAINT DF_inventoryitems_creatorID | ||
277 | DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID | ||
278 | |||
279 | :GO \ No newline at end of file | ||
diff --git a/OpenSim/Data/MSSQL/Resources/LogStore.migrations b/OpenSim/Data/MSSQL/Resources/LogStore.migrations deleted file mode 100644 index 1430d8d..0000000 --- a/OpenSim/Data/MSSQL/Resources/LogStore.migrations +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [logs] ( | ||
6 | [logID] [int] NOT NULL, | ||
7 | [target] [varchar](36) default NULL, | ||
8 | [server] [varchar](64) default NULL, | ||
9 | [method] [varchar](64) default NULL, | ||
10 | [arguments] [varchar](255) default NULL, | ||
11 | [priority] [int] default NULL, | ||
12 | [message] [ntext], | ||
13 | PRIMARY KEY CLUSTERED | ||
14 | ( | ||
15 | [logID] ASC | ||
16 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
17 | ) ON [PRIMARY] | ||
18 | |||
19 | COMMIT | ||
diff --git a/OpenSim/Data/MSSQL/Resources/Presence.migrations b/OpenSim/Data/MSSQL/Resources/Presence.migrations deleted file mode 100644 index bcb6328..0000000 --- a/OpenSim/Data/MSSQL/Resources/Presence.migrations +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION | ||
4 | |||
5 | CREATE TABLE [Presence] ( | ||
6 | [UserID] varchar(255) NOT NULL, | ||
7 | [RegionID] uniqueidentifier NOT NULL, | ||
8 | [SessionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
9 | [SecureSessionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
10 | |||
11 | ) | ||
12 | ON [PRIMARY] | ||
13 | |||
14 | COMMIT | ||
15 | |||
16 | :VERSION 2 | ||
17 | |||
18 | BEGIN TRANSACTION | ||
19 | |||
20 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); | ||
21 | CREATE INDEX UserID ON Presence(UserID); | ||
22 | |||
23 | COMMIT | ||
24 | |||
25 | :VERSION 2 | ||
26 | |||
27 | BEGIN TRANSACTION | ||
28 | |||
29 | ALTER TABLE Presence ADD LastSeen DateTime | ||
30 | |||
31 | COMMIT \ No newline at end of file | ||
diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations deleted file mode 100644 index 350e548..0000000 --- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations +++ /dev/null | |||
@@ -1,1150 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE [dbo].[prims]( | ||
4 | [UUID] [varchar](255) NOT NULL, | ||
5 | [RegionUUID] [varchar](255) NULL, | ||
6 | [ParentID] [int] NULL, | ||
7 | [CreationDate] [int] NULL, | ||
8 | [Name] [varchar](255) NULL, | ||
9 | [SceneGroupID] [varchar](255) NULL, | ||
10 | [Text] [varchar](255) NULL, | ||
11 | [Description] [varchar](255) NULL, | ||
12 | [SitName] [varchar](255) NULL, | ||
13 | [TouchName] [varchar](255) NULL, | ||
14 | [ObjectFlags] [int] NULL, | ||
15 | [CreatorID] [varchar](255) NULL, | ||
16 | [OwnerID] [varchar](255) NULL, | ||
17 | [GroupID] [varchar](255) NULL, | ||
18 | [LastOwnerID] [varchar](255) NULL, | ||
19 | [OwnerMask] [int] NULL, | ||
20 | [NextOwnerMask] [int] NULL, | ||
21 | [GroupMask] [int] NULL, | ||
22 | [EveryoneMask] [int] NULL, | ||
23 | [BaseMask] [int] NULL, | ||
24 | [PositionX] [float] NULL, | ||
25 | [PositionY] [float] NULL, | ||
26 | [PositionZ] [float] NULL, | ||
27 | [GroupPositionX] [float] NULL, | ||
28 | [GroupPositionY] [float] NULL, | ||
29 | [GroupPositionZ] [float] NULL, | ||
30 | [VelocityX] [float] NULL, | ||
31 | [VelocityY] [float] NULL, | ||
32 | [VelocityZ] [float] NULL, | ||
33 | [AngularVelocityX] [float] NULL, | ||
34 | [AngularVelocityY] [float] NULL, | ||
35 | [AngularVelocityZ] [float] NULL, | ||
36 | [AccelerationX] [float] NULL, | ||
37 | [AccelerationY] [float] NULL, | ||
38 | [AccelerationZ] [float] NULL, | ||
39 | [RotationX] [float] NULL, | ||
40 | [RotationY] [float] NULL, | ||
41 | [RotationZ] [float] NULL, | ||
42 | [RotationW] [float] NULL, | ||
43 | [SitTargetOffsetX] [float] NULL, | ||
44 | [SitTargetOffsetY] [float] NULL, | ||
45 | [SitTargetOffsetZ] [float] NULL, | ||
46 | [SitTargetOrientW] [float] NULL, | ||
47 | [SitTargetOrientX] [float] NULL, | ||
48 | [SitTargetOrientY] [float] NULL, | ||
49 | [SitTargetOrientZ] [float] NULL, | ||
50 | PRIMARY KEY CLUSTERED | ||
51 | ( | ||
52 | [UUID] ASC | ||
53 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
54 | ) ON [PRIMARY] | ||
55 | |||
56 | CREATE TABLE [dbo].[primshapes]( | ||
57 | [UUID] [varchar](255) NOT NULL, | ||
58 | [Shape] [int] NULL, | ||
59 | [ScaleX] [float] NULL, | ||
60 | [ScaleY] [float] NULL, | ||
61 | [ScaleZ] [float] NULL, | ||
62 | [PCode] [int] NULL, | ||
63 | [PathBegin] [int] NULL, | ||
64 | [PathEnd] [int] NULL, | ||
65 | [PathScaleX] [int] NULL, | ||
66 | [PathScaleY] [int] NULL, | ||
67 | [PathShearX] [int] NULL, | ||
68 | [PathShearY] [int] NULL, | ||
69 | [PathSkew] [int] NULL, | ||
70 | [PathCurve] [int] NULL, | ||
71 | [PathRadiusOffset] [int] NULL, | ||
72 | [PathRevolutions] [int] NULL, | ||
73 | [PathTaperX] [int] NULL, | ||
74 | [PathTaperY] [int] NULL, | ||
75 | [PathTwist] [int] NULL, | ||
76 | [PathTwistBegin] [int] NULL, | ||
77 | [ProfileBegin] [int] NULL, | ||
78 | [ProfileEnd] [int] NULL, | ||
79 | [ProfileCurve] [int] NULL, | ||
80 | [ProfileHollow] [int] NULL, | ||
81 | [State] [int] NULL, | ||
82 | [Texture] [image] NULL, | ||
83 | [ExtraParams] [image] NULL, | ||
84 | PRIMARY KEY CLUSTERED | ||
85 | ( | ||
86 | [UUID] ASC | ||
87 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
88 | ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] | ||
89 | |||
90 | CREATE TABLE [dbo].[primitems]( | ||
91 | [itemID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
92 | [primID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
93 | [assetID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
94 | [parentFolderID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
95 | [invType] [int] NULL, | ||
96 | [assetType] [int] NULL, | ||
97 | [name] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
98 | [description] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
99 | [creationDate] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
100 | [creatorID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
101 | [ownerID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
102 | [lastOwnerID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
103 | [groupID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
104 | [nextPermissions] [int] NULL, | ||
105 | [currentPermissions] [int] NULL, | ||
106 | [basePermissions] [int] NULL, | ||
107 | [everyonePermissions] [int] NULL, | ||
108 | [groupPermissions] [int] NULL, | ||
109 | PRIMARY KEY CLUSTERED | ||
110 | ( | ||
111 | [itemID] ASC | ||
112 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
113 | ) ON [PRIMARY] | ||
114 | |||
115 | CREATE TABLE [dbo].[terrain]( | ||
116 | [RegionUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
117 | [Revision] [int] NULL, | ||
118 | [Heightfield] [image] NULL | ||
119 | ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] | ||
120 | |||
121 | CREATE TABLE [dbo].[land]( | ||
122 | [UUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
123 | [RegionUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
124 | [LocalLandID] [int] NULL, | ||
125 | [Bitmap] [image] NULL, | ||
126 | [Name] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
127 | [Description] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
128 | [OwnerUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
129 | [IsGroupOwned] [int] NULL, | ||
130 | [Area] [int] NULL, | ||
131 | [AuctionID] [int] NULL, | ||
132 | [Category] [int] NULL, | ||
133 | [ClaimDate] [int] NULL, | ||
134 | [ClaimPrice] [int] NULL, | ||
135 | [GroupUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
136 | [SalePrice] [int] NULL, | ||
137 | [LandStatus] [int] NULL, | ||
138 | [LandFlags] [int] NULL, | ||
139 | [LandingType] [int] NULL, | ||
140 | [MediaAutoScale] [int] NULL, | ||
141 | [MediaTextureUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
142 | [MediaURL] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
143 | [MusicURL] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
144 | [PassHours] [float] NULL, | ||
145 | [PassPrice] [int] NULL, | ||
146 | [SnapshotUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
147 | [UserLocationX] [float] NULL, | ||
148 | [UserLocationY] [float] NULL, | ||
149 | [UserLocationZ] [float] NULL, | ||
150 | [UserLookAtX] [float] NULL, | ||
151 | [UserLookAtY] [float] NULL, | ||
152 | [UserLookAtZ] [float] NULL, | ||
153 | PRIMARY KEY CLUSTERED | ||
154 | ( | ||
155 | [UUID] ASC | ||
156 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
157 | ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] | ||
158 | |||
159 | CREATE TABLE [dbo].[landaccesslist]( | ||
160 | [LandUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
161 | [AccessUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, | ||
162 | [Flags] [int] NULL | ||
163 | ) ON [PRIMARY] | ||
164 | |||
165 | :VERSION 2 | ||
166 | |||
167 | BEGIN TRANSACTION | ||
168 | |||
169 | CREATE TABLE regionban ( | ||
170 | [regionUUID] VARCHAR(36) NOT NULL, | ||
171 | [bannedUUID] VARCHAR(36) NOT NULL, | ||
172 | [bannedIp] VARCHAR(16) NOT NULL, | ||
173 | [bannedIpHostMask] VARCHAR(16) NOT NULL) | ||
174 | |||
175 | create table [dbo].[regionsettings] ( | ||
176 | [regionUUID] [varchar](36) not null, | ||
177 | [block_terraform] [bit] not null, | ||
178 | [block_fly] [bit] not null, | ||
179 | [allow_damage] [bit] not null, | ||
180 | [restrict_pushing] [bit] not null, | ||
181 | [allow_land_resell] [bit] not null, | ||
182 | [allow_land_join_divide] [bit] not null, | ||
183 | [block_show_in_search] [bit] not null, | ||
184 | [agent_limit] [int] not null, | ||
185 | [object_bonus] [float] not null, | ||
186 | [maturity] [int] not null, | ||
187 | [disable_scripts] [bit] not null, | ||
188 | [disable_collisions] [bit] not null, | ||
189 | [disable_physics] [bit] not null, | ||
190 | [terrain_texture_1] [varchar](36) not null, | ||
191 | [terrain_texture_2] [varchar](36) not null, | ||
192 | [terrain_texture_3] [varchar](36) not null, | ||
193 | [terrain_texture_4] [varchar](36) not null, | ||
194 | [elevation_1_nw] [float] not null, | ||
195 | [elevation_2_nw] [float] not null, | ||
196 | [elevation_1_ne] [float] not null, | ||
197 | [elevation_2_ne] [float] not null, | ||
198 | [elevation_1_se] [float] not null, | ||
199 | [elevation_2_se] [float] not null, | ||
200 | [elevation_1_sw] [float] not null, | ||
201 | [elevation_2_sw] [float] not null, | ||
202 | [water_height] [float] not null, | ||
203 | [terrain_raise_limit] [float] not null, | ||
204 | [terrain_lower_limit] [float] not null, | ||
205 | [use_estate_sun] [bit] not null, | ||
206 | [fixed_sun] [bit] not null, | ||
207 | [sun_position] [float] not null, | ||
208 | [covenant] [varchar](36) default NULL, | ||
209 | [Sandbox] [bit] NOT NULL, | ||
210 | PRIMARY KEY CLUSTERED | ||
211 | ( | ||
212 | [regionUUID] ASC | ||
213 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
214 | ) ON [PRIMARY] | ||
215 | |||
216 | COMMIT | ||
217 | |||
218 | :VERSION 3 | ||
219 | |||
220 | BEGIN TRANSACTION | ||
221 | |||
222 | CREATE TABLE dbo.Tmp_prims | ||
223 | ( | ||
224 | UUID varchar(36) NOT NULL, | ||
225 | RegionUUID varchar(36) NULL, | ||
226 | ParentID int NULL, | ||
227 | CreationDate int NULL, | ||
228 | Name varchar(255) NULL, | ||
229 | SceneGroupID varchar(36) NULL, | ||
230 | Text varchar(255) NULL, | ||
231 | Description varchar(255) NULL, | ||
232 | SitName varchar(255) NULL, | ||
233 | TouchName varchar(255) NULL, | ||
234 | ObjectFlags int NULL, | ||
235 | CreatorID varchar(36) NULL, | ||
236 | OwnerID varchar(36) NULL, | ||
237 | GroupID varchar(36) NULL, | ||
238 | LastOwnerID varchar(36) NULL, | ||
239 | OwnerMask int NULL, | ||
240 | NextOwnerMask int NULL, | ||
241 | GroupMask int NULL, | ||
242 | EveryoneMask int NULL, | ||
243 | BaseMask int NULL, | ||
244 | PositionX float(53) NULL, | ||
245 | PositionY float(53) NULL, | ||
246 | PositionZ float(53) NULL, | ||
247 | GroupPositionX float(53) NULL, | ||
248 | GroupPositionY float(53) NULL, | ||
249 | GroupPositionZ float(53) NULL, | ||
250 | VelocityX float(53) NULL, | ||
251 | VelocityY float(53) NULL, | ||
252 | VelocityZ float(53) NULL, | ||
253 | AngularVelocityX float(53) NULL, | ||
254 | AngularVelocityY float(53) NULL, | ||
255 | AngularVelocityZ float(53) NULL, | ||
256 | AccelerationX float(53) NULL, | ||
257 | AccelerationY float(53) NULL, | ||
258 | AccelerationZ float(53) NULL, | ||
259 | RotationX float(53) NULL, | ||
260 | RotationY float(53) NULL, | ||
261 | RotationZ float(53) NULL, | ||
262 | RotationW float(53) NULL, | ||
263 | SitTargetOffsetX float(53) NULL, | ||
264 | SitTargetOffsetY float(53) NULL, | ||
265 | SitTargetOffsetZ float(53) NULL, | ||
266 | SitTargetOrientW float(53) NULL, | ||
267 | SitTargetOrientX float(53) NULL, | ||
268 | SitTargetOrientY float(53) NULL, | ||
269 | SitTargetOrientZ float(53) NULL | ||
270 | ) ON [PRIMARY] | ||
271 | |||
272 | IF EXISTS(SELECT * FROM dbo.prims) | ||
273 | EXEC('INSERT INTO dbo.Tmp_prims (UUID, RegionUUID, ParentID, CreationDate, Name, SceneGroupID, Text, Description, SitName, TouchName, ObjectFlags, 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, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ) | ||
274 | SELECT CONVERT(varchar(36), UUID), CONVERT(varchar(36), RegionUUID), ParentID, CreationDate, Name, CONVERT(varchar(36), SceneGroupID), Text, Description, SitName, TouchName, ObjectFlags, CONVERT(varchar(36), CreatorID), CONVERT(varchar(36), OwnerID), CONVERT(varchar(36), GroupID), CONVERT(varchar(36), 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, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ FROM dbo.prims WITH (HOLDLOCK TABLOCKX)') | ||
275 | |||
276 | DROP TABLE dbo.prims | ||
277 | |||
278 | EXECUTE sp_rename N'dbo.Tmp_prims', N'prims', 'OBJECT' | ||
279 | |||
280 | ALTER TABLE dbo.prims ADD CONSTRAINT | ||
281 | PK__prims__10566F31 PRIMARY KEY CLUSTERED | ||
282 | ( | ||
283 | UUID | ||
284 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
285 | |||
286 | COMMIT | ||
287 | |||
288 | :VERSION 4 | ||
289 | |||
290 | BEGIN TRANSACTION | ||
291 | |||
292 | CREATE TABLE Tmp_primitems | ||
293 | ( | ||
294 | itemID varchar(36) NOT NULL, | ||
295 | primID varchar(36) NULL, | ||
296 | assetID varchar(36) NULL, | ||
297 | parentFolderID varchar(36) NULL, | ||
298 | invType int NULL, | ||
299 | assetType int NULL, | ||
300 | name varchar(255) NULL, | ||
301 | description varchar(255) NULL, | ||
302 | creationDate varchar(255) NULL, | ||
303 | creatorID varchar(36) NULL, | ||
304 | ownerID varchar(36) NULL, | ||
305 | lastOwnerID varchar(36) NULL, | ||
306 | groupID varchar(36) NULL, | ||
307 | nextPermissions int NULL, | ||
308 | currentPermissions int NULL, | ||
309 | basePermissions int NULL, | ||
310 | everyonePermissions int NULL, | ||
311 | groupPermissions int NULL | ||
312 | ) ON [PRIMARY] | ||
313 | |||
314 | IF EXISTS(SELECT * FROM primitems) | ||
315 | EXEC('INSERT INTO Tmp_primitems (itemID, primID, assetID, parentFolderID, invType, assetType, name, description, creationDate, creatorID, ownerID, lastOwnerID, groupID, nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions) | ||
316 | SELECT CONVERT(varchar(36), itemID), CONVERT(varchar(36), primID), CONVERT(varchar(36), assetID), CONVERT(varchar(36), parentFolderID), invType, assetType, name, description, creationDate, CONVERT(varchar(36), creatorID), CONVERT(varchar(36), ownerID), CONVERT(varchar(36), lastOwnerID), CONVERT(varchar(36), groupID), nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions') | ||
317 | |||
318 | DROP TABLE primitems | ||
319 | |||
320 | EXECUTE sp_rename N'Tmp_primitems', N'primitems', 'OBJECT' | ||
321 | |||
322 | ALTER TABLE primitems ADD CONSTRAINT | ||
323 | PK__primitems__0A688BB1 PRIMARY KEY CLUSTERED | ||
324 | ( | ||
325 | itemID | ||
326 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
327 | |||
328 | |||
329 | COMMIT | ||
330 | |||
331 | |||
332 | :VERSION 5 | ||
333 | |||
334 | BEGIN TRANSACTION | ||
335 | |||
336 | CREATE TABLE Tmp_primshapes | ||
337 | ( | ||
338 | UUID varchar(36) NOT NULL, | ||
339 | Shape int NULL, | ||
340 | ScaleX float(53) NULL, | ||
341 | ScaleY float(53) NULL, | ||
342 | ScaleZ float(53) NULL, | ||
343 | PCode int NULL, | ||
344 | PathBegin int NULL, | ||
345 | PathEnd int NULL, | ||
346 | PathScaleX int NULL, | ||
347 | PathScaleY int NULL, | ||
348 | PathShearX int NULL, | ||
349 | PathShearY int NULL, | ||
350 | PathSkew int NULL, | ||
351 | PathCurve int NULL, | ||
352 | PathRadiusOffset int NULL, | ||
353 | PathRevolutions int NULL, | ||
354 | PathTaperX int NULL, | ||
355 | PathTaperY int NULL, | ||
356 | PathTwist int NULL, | ||
357 | PathTwistBegin int NULL, | ||
358 | ProfileBegin int NULL, | ||
359 | ProfileEnd int NULL, | ||
360 | ProfileCurve int NULL, | ||
361 | ProfileHollow int NULL, | ||
362 | State int NULL, | ||
363 | Texture image NULL, | ||
364 | ExtraParams image NULL | ||
365 | ) ON [PRIMARY] | ||
366 | TEXTIMAGE_ON [PRIMARY] | ||
367 | |||
368 | IF EXISTS(SELECT * FROM primshapes) | ||
369 | EXEC('INSERT INTO Tmp_primshapes (UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams) | ||
370 | SELECT CONVERT(varchar(36), UUID), Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams FROM primshapes WITH (HOLDLOCK TABLOCKX)') | ||
371 | |||
372 | DROP TABLE primshapes | ||
373 | |||
374 | EXECUTE sp_rename N'Tmp_primshapes', N'primshapes', 'OBJECT' | ||
375 | |||
376 | ALTER TABLE primshapes ADD CONSTRAINT | ||
377 | PK__primshapes__0880433F PRIMARY KEY CLUSTERED | ||
378 | ( | ||
379 | UUID | ||
380 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
381 | |||
382 | COMMIT | ||
383 | |||
384 | |||
385 | :VERSION 6 | ||
386 | |||
387 | BEGIN TRANSACTION | ||
388 | |||
389 | ALTER TABLE prims ADD PayPrice int not null default 0 | ||
390 | ALTER TABLE prims ADD PayButton1 int not null default 0 | ||
391 | ALTER TABLE prims ADD PayButton2 int not null default 0 | ||
392 | ALTER TABLE prims ADD PayButton3 int not null default 0 | ||
393 | ALTER TABLE prims ADD PayButton4 int not null default 0 | ||
394 | ALTER TABLE prims ADD LoopedSound varchar(36) not null default '00000000-0000-0000-0000-000000000000'; | ||
395 | ALTER TABLE prims ADD LoopedSoundGain float not null default 0.0; | ||
396 | ALTER TABLE prims ADD TextureAnimation image | ||
397 | ALTER TABLE prims ADD OmegaX float not null default 0.0 | ||
398 | ALTER TABLE prims ADD OmegaY float not null default 0.0 | ||
399 | ALTER TABLE prims ADD OmegaZ float not null default 0.0 | ||
400 | ALTER TABLE prims ADD CameraEyeOffsetX float not null default 0.0 | ||
401 | ALTER TABLE prims ADD CameraEyeOffsetY float not null default 0.0 | ||
402 | ALTER TABLE prims ADD CameraEyeOffsetZ float not null default 0.0 | ||
403 | ALTER TABLE prims ADD CameraAtOffsetX float not null default 0.0 | ||
404 | ALTER TABLE prims ADD CameraAtOffsetY float not null default 0.0 | ||
405 | ALTER TABLE prims ADD CameraAtOffsetZ float not null default 0.0 | ||
406 | ALTER TABLE prims ADD ForceMouselook tinyint not null default 0 | ||
407 | ALTER TABLE prims ADD ScriptAccessPin int not null default 0 | ||
408 | ALTER TABLE prims ADD AllowedDrop tinyint not null default 0 | ||
409 | ALTER TABLE prims ADD DieAtEdge tinyint not null default 0 | ||
410 | ALTER TABLE prims ADD SalePrice int not null default 10 | ||
411 | ALTER TABLE prims ADD SaleType tinyint not null default 0 | ||
412 | |||
413 | ALTER TABLE primitems add flags integer not null default 0 | ||
414 | |||
415 | ALTER TABLE land ADD AuthbuyerID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000' | ||
416 | |||
417 | CREATE index prims_regionuuid on prims(RegionUUID) | ||
418 | CREATE index prims_parentid on prims(ParentID) | ||
419 | |||
420 | CREATE index primitems_primid on primitems(primID) | ||
421 | |||
422 | COMMIT | ||
423 | |||
424 | |||
425 | :VERSION 7 | ||
426 | |||
427 | BEGIN TRANSACTION | ||
428 | |||
429 | ALTER TABLE prims ADD ColorR int not null default 0; | ||
430 | ALTER TABLE prims ADD ColorG int not null default 0; | ||
431 | ALTER TABLE prims ADD ColorB int not null default 0; | ||
432 | ALTER TABLE prims ADD ColorA int not null default 0; | ||
433 | ALTER TABLE prims ADD ParticleSystem IMAGE; | ||
434 | ALTER TABLE prims ADD ClickAction tinyint NOT NULL default 0; | ||
435 | |||
436 | COMMIT | ||
437 | |||
438 | |||
439 | :VERSION 8 | ||
440 | |||
441 | BEGIN TRANSACTION | ||
442 | |||
443 | ALTER TABLE land ADD OtherCleanTime integer NOT NULL default 0; | ||
444 | ALTER TABLE land ADD Dwell integer NOT NULL default 0; | ||
445 | |||
446 | COMMIT | ||
447 | |||
448 | :VERSION 9 | ||
449 | |||
450 | BEGIN TRANSACTION | ||
451 | |||
452 | ALTER TABLE prims ADD Material tinyint NOT NULL default 3 | ||
453 | |||
454 | COMMIT | ||
455 | |||
456 | |||
457 | :VERSION 10 | ||
458 | |||
459 | BEGIN TRANSACTION | ||
460 | |||
461 | ALTER TABLE regionsettings ADD sunvectorx float NOT NULL default 0; | ||
462 | ALTER TABLE regionsettings ADD sunvectory float NOT NULL default 0; | ||
463 | ALTER TABLE regionsettings ADD sunvectorz float NOT NULL default 0; | ||
464 | |||
465 | COMMIT | ||
466 | |||
467 | |||
468 | :VERSION 11 | ||
469 | |||
470 | BEGIN TRANSACTION | ||
471 | |||
472 | ALTER TABLE prims ADD CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000' | ||
473 | ALTER TABLE prims ADD CollisionSoundVolume float not null default 0.0 | ||
474 | |||
475 | COMMIT | ||
476 | |||
477 | |||
478 | :VERSION 12 | ||
479 | |||
480 | BEGIN TRANSACTION | ||
481 | |||
482 | ALTER TABLE prims ADD LinkNumber integer not null default 0 | ||
483 | |||
484 | COMMIT | ||
485 | |||
486 | |||
487 | :VERSION 13 | ||
488 | |||
489 | BEGIN TRANSACTION | ||
490 | |||
491 | CREATE TABLE dbo.Tmp_prims | ||
492 | ( | ||
493 | UUID uniqueidentifier NOT NULL, | ||
494 | RegionUUID uniqueidentifier NULL, | ||
495 | ParentID int NULL, | ||
496 | CreationDate int NULL, | ||
497 | Name varchar(255) NULL, | ||
498 | SceneGroupID uniqueidentifier NULL, | ||
499 | Text varchar(255) NULL, | ||
500 | Description varchar(255) NULL, | ||
501 | SitName varchar(255) NULL, | ||
502 | TouchName varchar(255) NULL, | ||
503 | ObjectFlags int NULL, | ||
504 | CreatorID uniqueidentifier NULL, | ||
505 | OwnerID uniqueidentifier NULL, | ||
506 | GroupID uniqueidentifier NULL, | ||
507 | LastOwnerID uniqueidentifier NULL, | ||
508 | OwnerMask int NULL, | ||
509 | NextOwnerMask int NULL, | ||
510 | GroupMask int NULL, | ||
511 | EveryoneMask int NULL, | ||
512 | BaseMask int NULL, | ||
513 | PositionX float(53) NULL, | ||
514 | PositionY float(53) NULL, | ||
515 | PositionZ float(53) NULL, | ||
516 | GroupPositionX float(53) NULL, | ||
517 | GroupPositionY float(53) NULL, | ||
518 | GroupPositionZ float(53) NULL, | ||
519 | VelocityX float(53) NULL, | ||
520 | VelocityY float(53) NULL, | ||
521 | VelocityZ float(53) NULL, | ||
522 | AngularVelocityX float(53) NULL, | ||
523 | AngularVelocityY float(53) NULL, | ||
524 | AngularVelocityZ float(53) NULL, | ||
525 | AccelerationX float(53) NULL, | ||
526 | AccelerationY float(53) NULL, | ||
527 | AccelerationZ float(53) NULL, | ||
528 | RotationX float(53) NULL, | ||
529 | RotationY float(53) NULL, | ||
530 | RotationZ float(53) NULL, | ||
531 | RotationW float(53) NULL, | ||
532 | SitTargetOffsetX float(53) NULL, | ||
533 | SitTargetOffsetY float(53) NULL, | ||
534 | SitTargetOffsetZ float(53) NULL, | ||
535 | SitTargetOrientW float(53) NULL, | ||
536 | SitTargetOrientX float(53) NULL, | ||
537 | SitTargetOrientY float(53) NULL, | ||
538 | SitTargetOrientZ float(53) NULL, | ||
539 | PayPrice int NOT NULL DEFAULT ((0)), | ||
540 | PayButton1 int NOT NULL DEFAULT ((0)), | ||
541 | PayButton2 int NOT NULL DEFAULT ((0)), | ||
542 | PayButton3 int NOT NULL DEFAULT ((0)), | ||
543 | PayButton4 int NOT NULL DEFAULT ((0)), | ||
544 | LoopedSound uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
545 | LoopedSoundGain float(53) NOT NULL DEFAULT ((0.0)), | ||
546 | TextureAnimation image NULL, | ||
547 | OmegaX float(53) NOT NULL DEFAULT ((0.0)), | ||
548 | OmegaY float(53) NOT NULL DEFAULT ((0.0)), | ||
549 | OmegaZ float(53) NOT NULL DEFAULT ((0.0)), | ||
550 | CameraEyeOffsetX float(53) NOT NULL DEFAULT ((0.0)), | ||
551 | CameraEyeOffsetY float(53) NOT NULL DEFAULT ((0.0)), | ||
552 | CameraEyeOffsetZ float(53) NOT NULL DEFAULT ((0.0)), | ||
553 | CameraAtOffsetX float(53) NOT NULL DEFAULT ((0.0)), | ||
554 | CameraAtOffsetY float(53) NOT NULL DEFAULT ((0.0)), | ||
555 | CameraAtOffsetZ float(53) NOT NULL DEFAULT ((0.0)), | ||
556 | ForceMouselook tinyint NOT NULL DEFAULT ((0)), | ||
557 | ScriptAccessPin int NOT NULL DEFAULT ((0)), | ||
558 | AllowedDrop tinyint NOT NULL DEFAULT ((0)), | ||
559 | DieAtEdge tinyint NOT NULL DEFAULT ((0)), | ||
560 | SalePrice int NOT NULL DEFAULT ((10)), | ||
561 | SaleType tinyint NOT NULL DEFAULT ((0)), | ||
562 | ColorR int NOT NULL DEFAULT ((0)), | ||
563 | ColorG int NOT NULL DEFAULT ((0)), | ||
564 | ColorB int NOT NULL DEFAULT ((0)), | ||
565 | ColorA int NOT NULL DEFAULT ((0)), | ||
566 | ParticleSystem image NULL, | ||
567 | ClickAction tinyint NOT NULL DEFAULT ((0)), | ||
568 | Material tinyint NOT NULL DEFAULT ((3)), | ||
569 | CollisionSound uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
570 | CollisionSoundVolume float(53) NOT NULL DEFAULT ((0.0)), | ||
571 | LinkNumber int NOT NULL DEFAULT ((0)) | ||
572 | ) ON [PRIMARY] | ||
573 | TEXTIMAGE_ON [PRIMARY] | ||
574 | |||
575 | IF EXISTS(SELECT * FROM dbo.prims) | ||
576 | EXEC('INSERT INTO dbo.Tmp_prims (UUID, RegionUUID, ParentID, CreationDate, Name, SceneGroupID, Text, Description, SitName, TouchName, ObjectFlags, 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, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, LinkNumber) | ||
577 | SELECT CONVERT(uniqueidentifier, UUID), CONVERT(uniqueidentifier, RegionUUID), ParentID, CreationDate, Name, CONVERT(uniqueidentifier, SceneGroupID), Text, Description, SitName, TouchName, ObjectFlags, CONVERT(uniqueidentifier, CreatorID), CONVERT(uniqueidentifier, OwnerID), CONVERT(uniqueidentifier, GroupID), CONVERT(uniqueidentifier, 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, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, CONVERT(uniqueidentifier, LoopedSound), LoopedSoundGain, TextureAnimation, OmegaX, OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, ParticleSystem, ClickAction, Material, CONVERT(uniqueidentifier, CollisionSound), CollisionSoundVolume, LinkNumber FROM dbo.prims WITH (HOLDLOCK TABLOCKX)') | ||
578 | |||
579 | DROP TABLE dbo.prims | ||
580 | |||
581 | EXECUTE sp_rename N'dbo.Tmp_prims', N'prims', 'OBJECT' | ||
582 | |||
583 | ALTER TABLE dbo.prims ADD CONSTRAINT | ||
584 | PK__prims__10566F31 PRIMARY KEY CLUSTERED | ||
585 | ( | ||
586 | UUID | ||
587 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
588 | |||
589 | |||
590 | CREATE NONCLUSTERED INDEX prims_regionuuid ON dbo.prims | ||
591 | ( | ||
592 | RegionUUID | ||
593 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
594 | |||
595 | CREATE NONCLUSTERED INDEX prims_parentid ON dbo.prims | ||
596 | ( | ||
597 | ParentID | ||
598 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
599 | |||
600 | COMMIT | ||
601 | |||
602 | |||
603 | :VERSION 14 | ||
604 | |||
605 | BEGIN TRANSACTION | ||
606 | |||
607 | CREATE TABLE dbo.Tmp_primshapes | ||
608 | ( | ||
609 | UUID uniqueidentifier NOT NULL, | ||
610 | Shape int NULL, | ||
611 | ScaleX float(53) NULL, | ||
612 | ScaleY float(53) NULL, | ||
613 | ScaleZ float(53) NULL, | ||
614 | PCode int NULL, | ||
615 | PathBegin int NULL, | ||
616 | PathEnd int NULL, | ||
617 | PathScaleX int NULL, | ||
618 | PathScaleY int NULL, | ||
619 | PathShearX int NULL, | ||
620 | PathShearY int NULL, | ||
621 | PathSkew int NULL, | ||
622 | PathCurve int NULL, | ||
623 | PathRadiusOffset int NULL, | ||
624 | PathRevolutions int NULL, | ||
625 | PathTaperX int NULL, | ||
626 | PathTaperY int NULL, | ||
627 | PathTwist int NULL, | ||
628 | PathTwistBegin int NULL, | ||
629 | ProfileBegin int NULL, | ||
630 | ProfileEnd int NULL, | ||
631 | ProfileCurve int NULL, | ||
632 | ProfileHollow int NULL, | ||
633 | State int NULL, | ||
634 | Texture image NULL, | ||
635 | ExtraParams image NULL | ||
636 | ) ON [PRIMARY] | ||
637 | TEXTIMAGE_ON [PRIMARY] | ||
638 | |||
639 | IF EXISTS(SELECT * FROM dbo.primshapes) | ||
640 | EXEC('INSERT INTO dbo.Tmp_primshapes (UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams) | ||
641 | SELECT CONVERT(uniqueidentifier, UUID), Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams FROM dbo.primshapes WITH (HOLDLOCK TABLOCKX)') | ||
642 | |||
643 | DROP TABLE dbo.primshapes | ||
644 | |||
645 | EXECUTE sp_rename N'dbo.Tmp_primshapes', N'primshapes', 'OBJECT' | ||
646 | |||
647 | ALTER TABLE dbo.primshapes ADD CONSTRAINT | ||
648 | PK__primshapes__0880433F PRIMARY KEY CLUSTERED | ||
649 | ( | ||
650 | UUID | ||
651 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
652 | |||
653 | COMMIT | ||
654 | |||
655 | |||
656 | :VERSION 15 | ||
657 | |||
658 | BEGIN TRANSACTION | ||
659 | |||
660 | CREATE TABLE dbo.Tmp_primitems | ||
661 | ( | ||
662 | itemID uniqueidentifier NOT NULL, | ||
663 | primID uniqueidentifier NULL, | ||
664 | assetID uniqueidentifier NULL, | ||
665 | parentFolderID uniqueidentifier NULL, | ||
666 | invType int NULL, | ||
667 | assetType int NULL, | ||
668 | name varchar(255) NULL, | ||
669 | description varchar(255) NULL, | ||
670 | creationDate varchar(255) NULL, | ||
671 | creatorID uniqueidentifier NULL, | ||
672 | ownerID uniqueidentifier NULL, | ||
673 | lastOwnerID uniqueidentifier NULL, | ||
674 | groupID uniqueidentifier NULL, | ||
675 | nextPermissions int NULL, | ||
676 | currentPermissions int NULL, | ||
677 | basePermissions int NULL, | ||
678 | everyonePermissions int NULL, | ||
679 | groupPermissions int NULL, | ||
680 | flags int NOT NULL DEFAULT ((0)) | ||
681 | ) ON [PRIMARY] | ||
682 | |||
683 | IF EXISTS(SELECT * FROM dbo.primitems) | ||
684 | EXEC('INSERT INTO dbo.Tmp_primitems (itemID, primID, assetID, parentFolderID, invType, assetType, name, description, creationDate, creatorID, ownerID, lastOwnerID, groupID, nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions, flags) | ||
685 | SELECT CONVERT(uniqueidentifier, itemID), CONVERT(uniqueidentifier, primID), CONVERT(uniqueidentifier, assetID), CONVERT(uniqueidentifier, parentFolderID), invType, assetType, name, description, creationDate, CONVERT(uniqueidentifier, creatorID), CONVERT(uniqueidentifier, ownerID), CONVERT(uniqueidentifier, lastOwnerID), CONVERT(uniqueidentifier, groupID), nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions, flags FROM dbo.primitems WITH (HOLDLOCK TABLOCKX)') | ||
686 | |||
687 | DROP TABLE dbo.primitems | ||
688 | |||
689 | EXECUTE sp_rename N'dbo.Tmp_primitems', N'primitems', 'OBJECT' | ||
690 | |||
691 | ALTER TABLE dbo.primitems ADD CONSTRAINT | ||
692 | PK__primitems__0A688BB1 PRIMARY KEY CLUSTERED | ||
693 | ( | ||
694 | itemID | ||
695 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
696 | |||
697 | CREATE NONCLUSTERED INDEX primitems_primid ON dbo.primitems | ||
698 | ( | ||
699 | primID | ||
700 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
701 | |||
702 | COMMIT | ||
703 | |||
704 | |||
705 | :VERSION 16 | ||
706 | |||
707 | |||
708 | BEGIN TRANSACTION | ||
709 | |||
710 | CREATE TABLE dbo.Tmp_terrain | ||
711 | ( | ||
712 | RegionUUID uniqueidentifier NULL, | ||
713 | Revision int NULL, | ||
714 | Heightfield image NULL | ||
715 | ) ON [PRIMARY] | ||
716 | TEXTIMAGE_ON [PRIMARY] | ||
717 | |||
718 | IF EXISTS(SELECT * FROM dbo.terrain) | ||
719 | EXEC('INSERT INTO dbo.Tmp_terrain (RegionUUID, Revision, Heightfield) | ||
720 | SELECT CONVERT(uniqueidentifier, RegionUUID), Revision, Heightfield FROM dbo.terrain WITH (HOLDLOCK TABLOCKX)') | ||
721 | |||
722 | DROP TABLE dbo.terrain | ||
723 | |||
724 | EXECUTE sp_rename N'dbo.Tmp_terrain', N'terrain', 'OBJECT' | ||
725 | |||
726 | COMMIT | ||
727 | |||
728 | |||
729 | :VERSION 17 | ||
730 | |||
731 | BEGIN TRANSACTION | ||
732 | |||
733 | CREATE TABLE dbo.Tmp_land | ||
734 | ( | ||
735 | UUID uniqueidentifier NOT NULL, | ||
736 | RegionUUID uniqueidentifier NULL, | ||
737 | LocalLandID int NULL, | ||
738 | Bitmap image NULL, | ||
739 | Name varchar(255) NULL, | ||
740 | Description varchar(255) NULL, | ||
741 | OwnerUUID uniqueidentifier NULL, | ||
742 | IsGroupOwned int NULL, | ||
743 | Area int NULL, | ||
744 | AuctionID int NULL, | ||
745 | Category int NULL, | ||
746 | ClaimDate int NULL, | ||
747 | ClaimPrice int NULL, | ||
748 | GroupUUID uniqueidentifier NULL, | ||
749 | SalePrice int NULL, | ||
750 | LandStatus int NULL, | ||
751 | LandFlags int NULL, | ||
752 | LandingType int NULL, | ||
753 | MediaAutoScale int NULL, | ||
754 | MediaTextureUUID uniqueidentifier NULL, | ||
755 | MediaURL varchar(255) NULL, | ||
756 | MusicURL varchar(255) NULL, | ||
757 | PassHours float(53) NULL, | ||
758 | PassPrice int NULL, | ||
759 | SnapshotUUID uniqueidentifier NULL, | ||
760 | UserLocationX float(53) NULL, | ||
761 | UserLocationY float(53) NULL, | ||
762 | UserLocationZ float(53) NULL, | ||
763 | UserLookAtX float(53) NULL, | ||
764 | UserLookAtY float(53) NULL, | ||
765 | UserLookAtZ float(53) NULL, | ||
766 | AuthbuyerID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
767 | OtherCleanTime int NOT NULL DEFAULT ((0)), | ||
768 | Dwell int NOT NULL DEFAULT ((0)) | ||
769 | ) ON [PRIMARY] | ||
770 | TEXTIMAGE_ON [PRIMARY] | ||
771 | |||
772 | IF EXISTS(SELECT * FROM dbo.land) | ||
773 | EXEC('INSERT INTO dbo.Tmp_land (UUID, RegionUUID, LocalLandID, Bitmap, Name, Description, OwnerUUID, IsGroupOwned, Area, AuctionID, Category, ClaimDate, ClaimPrice, GroupUUID, SalePrice, LandStatus, LandFlags, LandingType, MediaAutoScale, MediaTextureUUID, MediaURL, MusicURL, PassHours, PassPrice, SnapshotUUID, UserLocationX, UserLocationY, UserLocationZ, UserLookAtX, UserLookAtY, UserLookAtZ, AuthbuyerID, OtherCleanTime, Dwell) | ||
774 | SELECT CONVERT(uniqueidentifier, UUID), CONVERT(uniqueidentifier, RegionUUID), LocalLandID, Bitmap, Name, Description, CONVERT(uniqueidentifier, OwnerUUID), IsGroupOwned, Area, AuctionID, Category, ClaimDate, ClaimPrice, CONVERT(uniqueidentifier, GroupUUID), SalePrice, LandStatus, LandFlags, LandingType, MediaAutoScale, CONVERT(uniqueidentifier, MediaTextureUUID), MediaURL, MusicURL, PassHours, PassPrice, CONVERT(uniqueidentifier, SnapshotUUID), UserLocationX, UserLocationY, UserLocationZ, UserLookAtX, UserLookAtY, UserLookAtZ, CONVERT(uniqueidentifier, AuthbuyerID), OtherCleanTime, Dwell FROM dbo.land WITH (HOLDLOCK TABLOCKX)') | ||
775 | |||
776 | DROP TABLE dbo.land | ||
777 | |||
778 | EXECUTE sp_rename N'dbo.Tmp_land', N'land', 'OBJECT' | ||
779 | |||
780 | ALTER TABLE dbo.land ADD CONSTRAINT | ||
781 | PK__land__65A475E71BFD2C07 PRIMARY KEY CLUSTERED | ||
782 | ( | ||
783 | UUID | ||
784 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
785 | |||
786 | COMMIT | ||
787 | |||
788 | |||
789 | |||
790 | :VERSION 18 | ||
791 | |||
792 | BEGIN TRANSACTION | ||
793 | |||
794 | CREATE TABLE dbo.Tmp_landaccesslist | ||
795 | ( | ||
796 | LandUUID uniqueidentifier NULL, | ||
797 | AccessUUID uniqueidentifier NULL, | ||
798 | Flags int NULL | ||
799 | ) ON [PRIMARY] | ||
800 | |||
801 | IF EXISTS(SELECT * FROM dbo.landaccesslist) | ||
802 | EXEC('INSERT INTO dbo.Tmp_landaccesslist (LandUUID, AccessUUID, Flags) | ||
803 | SELECT CONVERT(uniqueidentifier, LandUUID), CONVERT(uniqueidentifier, AccessUUID), Flags FROM dbo.landaccesslist WITH (HOLDLOCK TABLOCKX)') | ||
804 | |||
805 | DROP TABLE dbo.landaccesslist | ||
806 | |||
807 | EXECUTE sp_rename N'dbo.Tmp_landaccesslist', N'landaccesslist', 'OBJECT' | ||
808 | |||
809 | COMMIT | ||
810 | |||
811 | |||
812 | |||
813 | :VERSION 19 | ||
814 | |||
815 | BEGIN TRANSACTION | ||
816 | |||
817 | CREATE TABLE dbo.Tmp_regionban | ||
818 | ( | ||
819 | regionUUID uniqueidentifier NOT NULL, | ||
820 | bannedUUID uniqueidentifier NOT NULL, | ||
821 | bannedIp varchar(16) NOT NULL, | ||
822 | bannedIpHostMask varchar(16) NOT NULL | ||
823 | ) ON [PRIMARY] | ||
824 | |||
825 | IF EXISTS(SELECT * FROM dbo.regionban) | ||
826 | EXEC('INSERT INTO dbo.Tmp_regionban (regionUUID, bannedUUID, bannedIp, bannedIpHostMask) | ||
827 | SELECT CONVERT(uniqueidentifier, regionUUID), CONVERT(uniqueidentifier, bannedUUID), bannedIp, bannedIpHostMask FROM dbo.regionban WITH (HOLDLOCK TABLOCKX)') | ||
828 | |||
829 | DROP TABLE dbo.regionban | ||
830 | |||
831 | EXECUTE sp_rename N'dbo.Tmp_regionban', N'regionban', 'OBJECT' | ||
832 | |||
833 | COMMIT | ||
834 | |||
835 | |||
836 | :VERSION 20 | ||
837 | |||
838 | BEGIN TRANSACTION | ||
839 | |||
840 | CREATE TABLE dbo.Tmp_regionsettings | ||
841 | ( | ||
842 | regionUUID uniqueidentifier NOT NULL, | ||
843 | block_terraform bit NOT NULL, | ||
844 | block_fly bit NOT NULL, | ||
845 | allow_damage bit NOT NULL, | ||
846 | restrict_pushing bit NOT NULL, | ||
847 | allow_land_resell bit NOT NULL, | ||
848 | allow_land_join_divide bit NOT NULL, | ||
849 | block_show_in_search bit NOT NULL, | ||
850 | agent_limit int NOT NULL, | ||
851 | object_bonus float(53) NOT NULL, | ||
852 | maturity int NOT NULL, | ||
853 | disable_scripts bit NOT NULL, | ||
854 | disable_collisions bit NOT NULL, | ||
855 | disable_physics bit NOT NULL, | ||
856 | terrain_texture_1 uniqueidentifier NOT NULL, | ||
857 | terrain_texture_2 uniqueidentifier NOT NULL, | ||
858 | terrain_texture_3 uniqueidentifier NOT NULL, | ||
859 | terrain_texture_4 uniqueidentifier NOT NULL, | ||
860 | elevation_1_nw float(53) NOT NULL, | ||
861 | elevation_2_nw float(53) NOT NULL, | ||
862 | elevation_1_ne float(53) NOT NULL, | ||
863 | elevation_2_ne float(53) NOT NULL, | ||
864 | elevation_1_se float(53) NOT NULL, | ||
865 | elevation_2_se float(53) NOT NULL, | ||
866 | elevation_1_sw float(53) NOT NULL, | ||
867 | elevation_2_sw float(53) NOT NULL, | ||
868 | water_height float(53) NOT NULL, | ||
869 | terrain_raise_limit float(53) NOT NULL, | ||
870 | terrain_lower_limit float(53) NOT NULL, | ||
871 | use_estate_sun bit NOT NULL, | ||
872 | fixed_sun bit NOT NULL, | ||
873 | sun_position float(53) NOT NULL, | ||
874 | covenant uniqueidentifier NULL DEFAULT (NULL), | ||
875 | Sandbox bit NOT NULL, | ||
876 | sunvectorx float(53) NOT NULL DEFAULT ((0)), | ||
877 | sunvectory float(53) NOT NULL DEFAULT ((0)), | ||
878 | sunvectorz float(53) NOT NULL DEFAULT ((0)) | ||
879 | ) ON [PRIMARY] | ||
880 | |||
881 | IF EXISTS(SELECT * FROM dbo.regionsettings) | ||
882 | EXEC('INSERT INTO dbo.Tmp_regionsettings (regionUUID, block_terraform, block_fly, allow_damage, restrict_pushing, allow_land_resell, allow_land_join_divide, block_show_in_search, agent_limit, object_bonus, maturity, disable_scripts, disable_collisions, disable_physics, terrain_texture_1, terrain_texture_2, terrain_texture_3, terrain_texture_4, elevation_1_nw, elevation_2_nw, elevation_1_ne, elevation_2_ne, elevation_1_se, elevation_2_se, elevation_1_sw, elevation_2_sw, water_height, terrain_raise_limit, terrain_lower_limit, use_estate_sun, fixed_sun, sun_position, covenant, Sandbox, sunvectorx, sunvectory, sunvectorz) | ||
883 | SELECT CONVERT(uniqueidentifier, regionUUID), block_terraform, block_fly, allow_damage, restrict_pushing, allow_land_resell, allow_land_join_divide, block_show_in_search, agent_limit, object_bonus, maturity, disable_scripts, disable_collisions, disable_physics, CONVERT(uniqueidentifier, terrain_texture_1), CONVERT(uniqueidentifier, terrain_texture_2), CONVERT(uniqueidentifier, terrain_texture_3), CONVERT(uniqueidentifier, terrain_texture_4), elevation_1_nw, elevation_2_nw, elevation_1_ne, elevation_2_ne, elevation_1_se, elevation_2_se, elevation_1_sw, elevation_2_sw, water_height, terrain_raise_limit, terrain_lower_limit, use_estate_sun, fixed_sun, sun_position, CONVERT(uniqueidentifier, covenant), Sandbox, sunvectorx, sunvectory, sunvectorz FROM dbo.regionsettings WITH (HOLDLOCK TABLOCKX)') | ||
884 | |||
885 | DROP TABLE dbo.regionsettings | ||
886 | |||
887 | EXECUTE sp_rename N'dbo.Tmp_regionsettings', N'regionsettings', 'OBJECT' | ||
888 | |||
889 | ALTER TABLE dbo.regionsettings ADD CONSTRAINT | ||
890 | PK__regionse__5B35159D21B6055D PRIMARY KEY CLUSTERED | ||
891 | ( | ||
892 | regionUUID | ||
893 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
894 | |||
895 | COMMIT | ||
896 | |||
897 | |||
898 | :VERSION 21 | ||
899 | |||
900 | BEGIN TRANSACTION | ||
901 | |||
902 | ALTER TABLE prims ADD PassTouches bit not null default 0 | ||
903 | |||
904 | COMMIT | ||
905 | |||
906 | |||
907 | :VERSION 22 | ||
908 | |||
909 | BEGIN TRANSACTION | ||
910 | |||
911 | ALTER TABLE regionsettings ADD loaded_creation_date varchar(20) | ||
912 | ALTER TABLE regionsettings ADD loaded_creation_time varchar(20) | ||
913 | ALTER TABLE regionsettings ADD loaded_creation_id varchar(64) | ||
914 | |||
915 | COMMIT | ||
916 | |||
917 | :VERSION 23 | ||
918 | |||
919 | BEGIN TRANSACTION | ||
920 | |||
921 | ALTER TABLE regionsettings DROP COLUMN loaded_creation_date | ||
922 | ALTER TABLE regionsettings DROP COLUMN loaded_creation_time | ||
923 | ALTER TABLE regionsettings ADD loaded_creation_datetime int NOT NULL default 0 | ||
924 | |||
925 | COMMIT | ||
926 | |||
927 | :VERSION 24 | ||
928 | |||
929 | BEGIN TRANSACTION | ||
930 | |||
931 | ALTER TABLE prims ADD MediaURL varchar(255) | ||
932 | ALTER TABLE primshapes ADD Media TEXT NULL | ||
933 | |||
934 | COMMIT | ||
935 | |||
936 | :VERSION 25 | ||
937 | |||
938 | BEGIN TRANSACTION | ||
939 | CREATE TABLE "regionwindlight" ( | ||
940 | "region_id" varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000', | ||
941 | "water_color_r" [float] NOT NULL DEFAULT '4.000000', | ||
942 | "water_color_g" [float] NOT NULL DEFAULT '38.000000', | ||
943 | "water_color_b" [float] NOT NULL DEFAULT '64.000000', | ||
944 | "water_fog_density_exponent" [float] NOT NULL DEFAULT '4.0', | ||
945 | "underwater_fog_modifier" [float] NOT NULL DEFAULT '0.25', | ||
946 | "reflection_wavelet_scale_1" [float] NOT NULL DEFAULT '2.0', | ||
947 | "reflection_wavelet_scale_2" [float] NOT NULL DEFAULT '2.0', | ||
948 | "reflection_wavelet_scale_3" [float] NOT NULL DEFAULT '2.0', | ||
949 | "fresnel_scale" [float] NOT NULL DEFAULT '0.40', | ||
950 | "fresnel_offset" [float] NOT NULL DEFAULT '0.50', | ||
951 | "refract_scale_above" [float] NOT NULL DEFAULT '0.03', | ||
952 | "refract_scale_below" [float] NOT NULL DEFAULT '0.20', | ||
953 | "blur_multiplier" [float] NOT NULL DEFAULT '0.040', | ||
954 | "big_wave_direction_x" [float] NOT NULL DEFAULT '1.05', | ||
955 | "big_wave_direction_y" [float] NOT NULL DEFAULT '-0.42', | ||
956 | "little_wave_direction_x" [float] NOT NULL DEFAULT '1.11', | ||
957 | "little_wave_direction_y" [float] NOT NULL DEFAULT '-1.16', | ||
958 | "normal_map_texture" varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4', | ||
959 | "horizon_r" [float] NOT NULL DEFAULT '0.25', | ||
960 | "horizon_g" [float] NOT NULL DEFAULT '0.25', | ||
961 | "horizon_b" [float] NOT NULL DEFAULT '0.32', | ||
962 | "horizon_i" [float] NOT NULL DEFAULT '0.32', | ||
963 | "haze_horizon" [float] NOT NULL DEFAULT '0.19', | ||
964 | "blue_density_r" [float] NOT NULL DEFAULT '0.12', | ||
965 | "blue_density_g" [float] NOT NULL DEFAULT '0.22', | ||
966 | "blue_density_b" [float] NOT NULL DEFAULT '0.38', | ||
967 | "blue_density_i" [float] NOT NULL DEFAULT '0.38', | ||
968 | "haze_density" [float] NOT NULL DEFAULT '0.70', | ||
969 | "density_multiplier" [float] NOT NULL DEFAULT '0.18', | ||
970 | "distance_multiplier" [float] NOT NULL DEFAULT '0.8', | ||
971 | "max_altitude" int NOT NULL DEFAULT '1605', | ||
972 | "sun_moon_color_r" [float] NOT NULL DEFAULT '0.24', | ||
973 | "sun_moon_color_g" [float] NOT NULL DEFAULT '0.26', | ||
974 | "sun_moon_color_b" [float] NOT NULL DEFAULT '0.30', | ||
975 | "sun_moon_color_i" [float] NOT NULL DEFAULT '0.30', | ||
976 | "sun_moon_position" [float] NOT NULL DEFAULT '0.317', | ||
977 | "ambient_r" [float] NOT NULL DEFAULT '0.35', | ||
978 | "ambient_g" [float] NOT NULL DEFAULT '0.35', | ||
979 | "ambient_b" [float] NOT NULL DEFAULT '0.35', | ||
980 | "ambient_i" [float] NOT NULL DEFAULT '0.35', | ||
981 | "east_angle" [float] NOT NULL DEFAULT '0.00', | ||
982 | "sun_glow_focus" [float] NOT NULL DEFAULT '0.10', | ||
983 | "sun_glow_size" [float] NOT NULL DEFAULT '1.75', | ||
984 | "scene_gamma" [float] NOT NULL DEFAULT '1.00', | ||
985 | "star_brightness" [float] NOT NULL DEFAULT '0.00', | ||
986 | "cloud_color_r" [float] NOT NULL DEFAULT '0.41', | ||
987 | "cloud_color_g" [float] NOT NULL DEFAULT '0.41', | ||
988 | "cloud_color_b" [float] NOT NULL DEFAULT '0.41', | ||
989 | "cloud_color_i" [float] NOT NULL DEFAULT '0.41', | ||
990 | "cloud_x" [float] NOT NULL DEFAULT '1.00', | ||
991 | "cloud_y" [float] NOT NULL DEFAULT '0.53', | ||
992 | "cloud_density" [float] NOT NULL DEFAULT '1.00', | ||
993 | "cloud_coverage" [float] NOT NULL DEFAULT '0.27', | ||
994 | "cloud_scale" [float] NOT NULL DEFAULT '0.42', | ||
995 | "cloud_detail_x" [float] NOT NULL DEFAULT '1.00', | ||
996 | "cloud_detail_y" [float] NOT NULL DEFAULT '0.53', | ||
997 | "cloud_detail_density" [float] NOT NULL DEFAULT '0.12', | ||
998 | "cloud_scroll_x" [float] NOT NULL DEFAULT '0.20', | ||
999 | "cloud_scroll_x_lock" tinyint NOT NULL DEFAULT '0', | ||
1000 | "cloud_scroll_y" [float] NOT NULL DEFAULT '0.01', | ||
1001 | "cloud_scroll_y_lock" tinyint NOT NULL DEFAULT '0', | ||
1002 | "draw_classic_clouds" tinyint NOT NULL DEFAULT '1', | ||
1003 | PRIMARY KEY ("region_id") | ||
1004 | ) | ||
1005 | |||
1006 | COMMIT | ||
1007 | |||
1008 | :VERSION 26 | ||
1009 | |||
1010 | BEGIN TRANSACTION | ||
1011 | |||
1012 | ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' | ||
1013 | |||
1014 | COMMIT | ||
1015 | |||
1016 | :VERSION 27 #--------------------- | ||
1017 | |||
1018 | BEGIN TRANSACTION | ||
1019 | ALTER TABLE land ADD MediaType VARCHAR(32) NOT NULL DEFAULT 'none/none' | ||
1020 | ALTER TABLE land ADD MediaDescription VARCHAR(255) NOT NULL DEFAULT '' | ||
1021 | ALTER TABLE land ADD MediaSize VARCHAR(16) NOT NULL DEFAULT '0,0' | ||
1022 | ALTER TABLE land ADD MediaLoop bit NOT NULL DEFAULT 0 | ||
1023 | ALTER TABLE land ADD ObscureMusic bit NOT NULL DEFAULT 0 | ||
1024 | ALTER TABLE land ADD ObscureMedia bit NOT NULL DEFAULT 0 | ||
1025 | COMMIT | ||
1026 | |||
1027 | :VERSION 28 #--------------------- | ||
1028 | |||
1029 | BEGIN TRANSACTION | ||
1030 | |||
1031 | ALTER TABLE prims | ||
1032 | ADD CONSTRAINT DF_prims_CreatorID | ||
1033 | DEFAULT '00000000-0000-0000-0000-000000000000' | ||
1034 | FOR CreatorID | ||
1035 | |||
1036 | ALTER TABLE prims ALTER COLUMN CreatorID uniqueidentifier NOT NULL | ||
1037 | |||
1038 | ALTER TABLE primitems | ||
1039 | ADD CONSTRAINT DF_primitems_CreatorID | ||
1040 | DEFAULT '00000000-0000-0000-0000-000000000000' | ||
1041 | FOR CreatorID | ||
1042 | |||
1043 | ALTER TABLE primitems ALTER COLUMN CreatorID uniqueidentifier NOT NULL | ||
1044 | |||
1045 | COMMIT | ||
1046 | |||
1047 | :VERSION 29 #----------------- Region Covenant changed time | ||
1048 | |||
1049 | BEGIN TRANSACTION | ||
1050 | |||
1051 | ALTER TABLE regionsettings ADD covenant_datetime int NOT NULL default 0 | ||
1052 | |||
1053 | COMMIT | ||
1054 | |||
1055 | :VERSION 30 #------------------Migrate creatorID storage to varchars instead of UUIDs for HG support | ||
1056 | |||
1057 | BEGIN TRANSACTION | ||
1058 | |||
1059 | EXECUTE sp_rename N'dbo.prims.creatorid', N'creatoridold', 'COLUMN' | ||
1060 | EXECUTE sp_rename N'dbo.primitems.creatorid', N'creatoridold', 'COLUMN' | ||
1061 | |||
1062 | COMMIT | ||
1063 | |||
1064 | :VERSION 31 #--------------------- | ||
1065 | |||
1066 | BEGIN TRANSACTION | ||
1067 | |||
1068 | ALTER TABLE prims ADD CreatorID varchar(255) | ||
1069 | ALTER TABLE primitems ADD CreatorID varchar(255) | ||
1070 | |||
1071 | COMMIT | ||
1072 | |||
1073 | :VERSION 32 #--------------------- | ||
1074 | |||
1075 | BEGIN TRANSACTION | ||
1076 | |||
1077 | UPDATE prims SET prims.CreatorID = CONVERT(varchar(255), creatoridold) | ||
1078 | UPDATE primitems SET primitems.CreatorID = CONVERT(varchar(255), creatoridold) | ||
1079 | |||
1080 | COMMIT | ||
1081 | |||
1082 | :VERSION 33 #--------------------- | ||
1083 | |||
1084 | BEGIN TRANSACTION | ||
1085 | |||
1086 | ALTER TABLE prims | ||
1087 | ADD CONSTRAINT DF_prims_CreatorIDNew | ||
1088 | DEFAULT '00000000-0000-0000-0000-000000000000' | ||
1089 | FOR CreatorID | ||
1090 | |||
1091 | ALTER TABLE prims ALTER COLUMN CreatorID varchar(255) NOT NULL | ||
1092 | |||
1093 | ALTER TABLE primitems | ||
1094 | ADD CONSTRAINT DF_primitems_CreatorIDNew | ||
1095 | DEFAULT '00000000-0000-0000-0000-000000000000' | ||
1096 | FOR CreatorID | ||
1097 | |||
1098 | ALTER TABLE primitems ALTER COLUMN CreatorID varchar(255) NOT NULL | ||
1099 | |||
1100 | COMMIT | ||
1101 | |||
1102 | :VERSION 34 #--------------- Telehub support | ||
1103 | |||
1104 | BEGIN TRANSACTION | ||
1105 | |||
1106 | CREATE TABLE [dbo].[Spawn_Points]( | ||
1107 | [RegionUUID] [uniqueidentifier] NOT NULL, | ||
1108 | [Yaw] [float] NOT NULL, | ||
1109 | [Pitch] [float] NOT NULL, | ||
1110 | [Distance] [float] NOT NULL, | ||
1111 | PRIMARY KEY CLUSTERED | ||
1112 | ( | ||
1113 | [RegionUUID] ASC | ||
1114 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
1115 | ) ON [PRIMARY] | ||
1116 | |||
1117 | ALTER TABLE regionsettings ADD TelehubObject uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
1118 | |||
1119 | COMMIT | ||
1120 | |||
1121 | :VERSION 35 #---------------- Parcels for sale | ||
1122 | |||
1123 | BEGIN TRANSACTION | ||
1124 | |||
1125 | ALTER TABLE regionsettings ADD parcel_tile_ID uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
1126 | |||
1127 | COMMIT | ||
1128 | |||
1129 | :VERSION 36 #---------------- Timed bans/access | ||
1130 | |||
1131 | BEGIN TRANSACTION | ||
1132 | |||
1133 | ALTER TABLE landaccesslist ADD Expires integer NOT NULL DEFAULT 0; | ||
1134 | |||
1135 | COMMIT | ||
1136 | |||
1137 | :VERSION 37 #---------------- Environment Settings | ||
1138 | |||
1139 | BEGIN TRANSACTION | ||
1140 | |||
1141 | CREATE TABLE [dbo].[regionenvironment]( | ||
1142 | [region_id] [uniqueidentifier] NOT NULL, | ||
1143 | [llsd_settings] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
1144 | PRIMARY KEY CLUSTERED | ||
1145 | ( | ||
1146 | [region_id] ASC | ||
1147 | )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] | ||
1148 | ) ON [PRIMARY] | ||
1149 | |||
1150 | COMMIT | ||
diff --git a/OpenSim/Data/MSSQL/Resources/UserAccount.migrations b/OpenSim/Data/MSSQL/Resources/UserAccount.migrations deleted file mode 100644 index a81704d..0000000 --- a/OpenSim/Data/MSSQL/Resources/UserAccount.migrations +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE [UserAccounts] ( | ||
4 | [PrincipalID] uniqueidentifier NOT NULL, | ||
5 | [ScopeID] uniqueidentifier NOT NULL, | ||
6 | [FirstName] [varchar](64) NOT NULL, | ||
7 | [LastName] [varchar](64) NOT NULL, | ||
8 | [Email] [varchar](64) NULL, | ||
9 | [ServiceURLs] [text] NULL, | ||
10 | [Created] [int] default NULL, | ||
11 | |||
12 | PRIMARY KEY CLUSTERED | ||
13 | ( | ||
14 | [PrincipalID] ASC | ||
15 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
16 | ) ON [PRIMARY] | ||
17 | |||
18 | |||
19 | :VERSION 2 | ||
20 | |||
21 | BEGIN TRANSACTION | ||
22 | IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U')) | ||
23 | INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT [UUID] AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, | ||
24 | username AS FirstName, | ||
25 | lastname AS LastName, | ||
26 | email as Email, ( | ||
27 | 'AssetServerURI=' + | ||
28 | userAssetURI + ' InventoryServerURI=' + userInventoryURI + ' GatewayURI= HomeURI=') AS ServiceURLs, | ||
29 | created as Created FROM users; | ||
30 | |||
31 | |||
32 | COMMIT | ||
33 | |||
34 | :VERSION 3 | ||
35 | |||
36 | BEGIN TRANSACTION | ||
37 | |||
38 | CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); | ||
39 | CREATE INDEX Email ON UserAccounts(Email); | ||
40 | CREATE INDEX FirstName ON UserAccounts(FirstName); | ||
41 | CREATE INDEX LastName ON UserAccounts(LastName); | ||
42 | CREATE INDEX Name ON UserAccounts(FirstName,LastName); | ||
43 | |||
44 | COMMIT | ||
45 | |||
46 | :VERSION 4 | ||
47 | |||
48 | BEGIN TRANSACTION | ||
49 | |||
50 | ALTER TABLE UserAccounts ADD UserLevel integer NOT NULL DEFAULT 0; | ||
51 | ALTER TABLE UserAccounts ADD UserFlags integer NOT NULL DEFAULT 0; | ||
52 | ALTER TABLE UserAccounts ADD UserTitle varchar(64) NOT NULL DEFAULT ''; | ||
53 | |||
54 | COMMIT | ||
55 | |||
diff --git a/OpenSim/Data/MSSQL/Resources/UserStore.migrations b/OpenSim/Data/MSSQL/Resources/UserStore.migrations deleted file mode 100644 index 050c544..0000000 --- a/OpenSim/Data/MSSQL/Resources/UserStore.migrations +++ /dev/null | |||
@@ -1,421 +0,0 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE [users] ( | ||
4 | [UUID] [varchar](36) NOT NULL default '', | ||
5 | [username] [varchar](32) NOT NULL, | ||
6 | [lastname] [varchar](32) NOT NULL, | ||
7 | [passwordHash] [varchar](32) NOT NULL, | ||
8 | [passwordSalt] [varchar](32) NOT NULL, | ||
9 | [homeRegion] [bigint] default NULL, | ||
10 | [homeLocationX] [float] default NULL, | ||
11 | [homeLocationY] [float] default NULL, | ||
12 | [homeLocationZ] [float] default NULL, | ||
13 | [homeLookAtX] [float] default NULL, | ||
14 | [homeLookAtY] [float] default NULL, | ||
15 | [homeLookAtZ] [float] default NULL, | ||
16 | [created] [int] NOT NULL, | ||
17 | [lastLogin] [int] NOT NULL, | ||
18 | [userInventoryURI] [varchar](255) default NULL, | ||
19 | [userAssetURI] [varchar](255) default NULL, | ||
20 | [profileCanDoMask] [int] default NULL, | ||
21 | [profileWantDoMask] [int] default NULL, | ||
22 | [profileAboutText] [ntext], | ||
23 | [profileFirstText] [ntext], | ||
24 | [profileImage] [varchar](36) default NULL, | ||
25 | [profileFirstImage] [varchar](36) default NULL, | ||
26 | [webLoginKey] [varchar](36) default NULL, | ||
27 | PRIMARY KEY CLUSTERED | ||
28 | ( | ||
29 | [UUID] ASC | ||
30 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
31 | ) ON [PRIMARY] | ||
32 | |||
33 | |||
34 | CREATE NONCLUSTERED INDEX [usernames] ON [users] | ||
35 | ( | ||
36 | [username] ASC, | ||
37 | [lastname] ASC | ||
38 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
39 | |||
40 | |||
41 | CREATE TABLE [agents] ( | ||
42 | [UUID] [varchar](36) NOT NULL, | ||
43 | [sessionID] [varchar](36) NOT NULL, | ||
44 | [secureSessionID] [varchar](36) NOT NULL, | ||
45 | [agentIP] [varchar](16) NOT NULL, | ||
46 | [agentPort] [int] NOT NULL, | ||
47 | [agentOnline] [tinyint] NOT NULL, | ||
48 | [loginTime] [int] NOT NULL, | ||
49 | [logoutTime] [int] NOT NULL, | ||
50 | [currentRegion] [varchar](36) NOT NULL, | ||
51 | [currentHandle] [bigint] NOT NULL, | ||
52 | [currentPos] [varchar](64) NOT NULL, | ||
53 | PRIMARY KEY CLUSTERED | ||
54 | ( | ||
55 | [UUID] ASC | ||
56 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
57 | ) ON [PRIMARY] | ||
58 | |||
59 | |||
60 | CREATE NONCLUSTERED INDEX [session] ON [agents] | ||
61 | ( | ||
62 | [sessionID] ASC | ||
63 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
64 | |||
65 | CREATE NONCLUSTERED INDEX [ssession] ON [agents] | ||
66 | ( | ||
67 | [secureSessionID] ASC | ||
68 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
69 | |||
70 | |||
71 | CREATE TABLE [dbo].[userfriends]( | ||
72 | [ownerID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, | ||
73 | [friendID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, | ||
74 | [friendPerms] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | ||
75 | [datetimestamp] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL | ||
76 | ) ON [PRIMARY] | ||
77 | |||
78 | CREATE TABLE [avatarappearance] ( | ||
79 | [Owner] [varchar](36) NOT NULL, | ||
80 | [Serial] int NOT NULL, | ||
81 | [Visual_Params] [image] NOT NULL, | ||
82 | [Texture] [image] NOT NULL, | ||
83 | [Avatar_Height] float NOT NULL, | ||
84 | [Body_Item] [varchar](36) NOT NULL, | ||
85 | [Body_Asset] [varchar](36) NOT NULL, | ||
86 | [Skin_Item] [varchar](36) NOT NULL, | ||
87 | [Skin_Asset] [varchar](36) NOT NULL, | ||
88 | [Hair_Item] [varchar](36) NOT NULL, | ||
89 | [Hair_Asset] [varchar](36) NOT NULL, | ||
90 | [Eyes_Item] [varchar](36) NOT NULL, | ||
91 | [Eyes_Asset] [varchar](36) NOT NULL, | ||
92 | [Shirt_Item] [varchar](36) NOT NULL, | ||
93 | [Shirt_Asset] [varchar](36) NOT NULL, | ||
94 | [Pants_Item] [varchar](36) NOT NULL, | ||
95 | [Pants_Asset] [varchar](36) NOT NULL, | ||
96 | [Shoes_Item] [varchar](36) NOT NULL, | ||
97 | [Shoes_Asset] [varchar](36) NOT NULL, | ||
98 | [Socks_Item] [varchar](36) NOT NULL, | ||
99 | [Socks_Asset] [varchar](36) NOT NULL, | ||
100 | [Jacket_Item] [varchar](36) NOT NULL, | ||
101 | [Jacket_Asset] [varchar](36) NOT NULL, | ||
102 | [Gloves_Item] [varchar](36) NOT NULL, | ||
103 | [Gloves_Asset] [varchar](36) NOT NULL, | ||
104 | [Undershirt_Item] [varchar](36) NOT NULL, | ||
105 | [Undershirt_Asset] [varchar](36) NOT NULL, | ||
106 | [Underpants_Item] [varchar](36) NOT NULL, | ||
107 | [Underpants_Asset] [varchar](36) NOT NULL, | ||
108 | [Skirt_Item] [varchar](36) NOT NULL, | ||
109 | [Skirt_Asset] [varchar](36) NOT NULL, | ||
110 | |||
111 | PRIMARY KEY CLUSTERED ( | ||
112 | [Owner] | ||
113 | ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
114 | ) ON [PRIMARY] | ||
115 | |||
116 | :VERSION 2 | ||
117 | |||
118 | BEGIN TRANSACTION | ||
119 | |||
120 | ALTER TABLE users ADD homeRegionID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; | ||
121 | ALTER TABLE users ADD userFlags int NOT NULL default 0; | ||
122 | ALTER TABLE users ADD godLevel int NOT NULL default 0; | ||
123 | ALTER TABLE users ADD customType varchar(32) not null default ''; | ||
124 | ALTER TABLE users ADD partner varchar(36) not null default '00000000-0000-0000-0000-000000000000'; | ||
125 | |||
126 | COMMIT | ||
127 | |||
128 | |||
129 | :VERSION 3 | ||
130 | |||
131 | BEGIN TRANSACTION | ||
132 | |||
133 | CREATE TABLE [avatarattachments] ( | ||
134 | [UUID] varchar(36) NOT NULL | ||
135 | , [attachpoint] int NOT NULL | ||
136 | , [item] varchar(36) NOT NULL | ||
137 | , [asset] varchar(36) NOT NULL) | ||
138 | |||
139 | CREATE NONCLUSTERED INDEX IX_avatarattachments ON dbo.avatarattachments | ||
140 | ( | ||
141 | UUID | ||
142 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
143 | |||
144 | |||
145 | COMMIT | ||
146 | |||
147 | |||
148 | :VERSION 4 | ||
149 | |||
150 | BEGIN TRANSACTION | ||
151 | |||
152 | CREATE TABLE Tmp_userfriends | ||
153 | ( | ||
154 | ownerID varchar(36) NOT NULL, | ||
155 | friendID varchar(36) NOT NULL, | ||
156 | friendPerms int NOT NULL, | ||
157 | datetimestamp int NOT NULL | ||
158 | ) ON [PRIMARY] | ||
159 | |||
160 | IF EXISTS(SELECT * FROM userfriends) | ||
161 | EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp) | ||
162 | SELECT CONVERT(varchar(36), ownerID), CONVERT(varchar(36), friendID), CONVERT(int, friendPerms), CONVERT(int, datetimestamp) FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)') | ||
163 | |||
164 | DROP TABLE dbo.userfriends | ||
165 | |||
166 | EXECUTE sp_rename N'Tmp_userfriends', N'userfriends', 'OBJECT' | ||
167 | |||
168 | CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON userfriends | ||
169 | ( | ||
170 | ownerID | ||
171 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
172 | |||
173 | CREATE NONCLUSTERED INDEX IX_userfriends_friendID ON userfriends | ||
174 | ( | ||
175 | friendID | ||
176 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
177 | |||
178 | COMMIT | ||
179 | |||
180 | |||
181 | :VERSION 5 | ||
182 | |||
183 | BEGIN TRANSACTION | ||
184 | |||
185 | ALTER TABLE users add email varchar(250); | ||
186 | |||
187 | COMMIT | ||
188 | |||
189 | |||
190 | :VERSION 6 | ||
191 | |||
192 | BEGIN TRANSACTION | ||
193 | |||
194 | CREATE TABLE dbo.Tmp_users | ||
195 | ( | ||
196 | UUID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
197 | username varchar(32) NOT NULL, | ||
198 | lastname varchar(32) NOT NULL, | ||
199 | passwordHash varchar(32) NOT NULL, | ||
200 | passwordSalt varchar(32) NOT NULL, | ||
201 | homeRegion bigint NULL DEFAULT (NULL), | ||
202 | homeLocationX float(53) NULL DEFAULT (NULL), | ||
203 | homeLocationY float(53) NULL DEFAULT (NULL), | ||
204 | homeLocationZ float(53) NULL DEFAULT (NULL), | ||
205 | homeLookAtX float(53) NULL DEFAULT (NULL), | ||
206 | homeLookAtY float(53) NULL DEFAULT (NULL), | ||
207 | homeLookAtZ float(53) NULL DEFAULT (NULL), | ||
208 | created int NOT NULL, | ||
209 | lastLogin int NOT NULL, | ||
210 | userInventoryURI varchar(255) NULL DEFAULT (NULL), | ||
211 | userAssetURI varchar(255) NULL DEFAULT (NULL), | ||
212 | profileCanDoMask int NULL DEFAULT (NULL), | ||
213 | profileWantDoMask int NULL DEFAULT (NULL), | ||
214 | profileAboutText ntext NULL, | ||
215 | profileFirstText ntext NULL, | ||
216 | profileImage uniqueidentifier NULL DEFAULT (NULL), | ||
217 | profileFirstImage uniqueidentifier NULL DEFAULT (NULL), | ||
218 | webLoginKey uniqueidentifier NULL DEFAULT (NULL), | ||
219 | homeRegionID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
220 | userFlags int NOT NULL DEFAULT ((0)), | ||
221 | godLevel int NOT NULL DEFAULT ((0)), | ||
222 | customType varchar(32) NOT NULL DEFAULT (''), | ||
223 | partner uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
224 | email varchar(250) NULL | ||
225 | ) ON [PRIMARY] | ||
226 | TEXTIMAGE_ON [PRIMARY] | ||
227 | |||
228 | IF EXISTS(SELECT * FROM dbo.users) | ||
229 | EXEC('INSERT INTO dbo.Tmp_users (UUID, username, lastname, passwordHash, passwordSalt, homeRegion, homeLocationX, homeLocationY, homeLocationZ, homeLookAtX, homeLookAtY, homeLookAtZ, created, lastLogin, userInventoryURI, userAssetURI, profileCanDoMask, profileWantDoMask, profileAboutText, profileFirstText, profileImage, profileFirstImage, webLoginKey, homeRegionID, userFlags, godLevel, customType, partner, email) | ||
230 | SELECT CONVERT(uniqueidentifier, UUID), username, lastname, passwordHash, passwordSalt, homeRegion, homeLocationX, homeLocationY, homeLocationZ, homeLookAtX, homeLookAtY, homeLookAtZ, created, lastLogin, userInventoryURI, userAssetURI, profileCanDoMask, profileWantDoMask, profileAboutText, profileFirstText, CONVERT(uniqueidentifier, profileImage), CONVERT(uniqueidentifier, profileFirstImage), CONVERT(uniqueidentifier, webLoginKey), CONVERT(uniqueidentifier, homeRegionID), userFlags, godLevel, customType, CONVERT(uniqueidentifier, partner), email FROM dbo.users WITH (HOLDLOCK TABLOCKX)') | ||
231 | |||
232 | DROP TABLE dbo.users | ||
233 | |||
234 | EXECUTE sp_rename N'dbo.Tmp_users', N'users', 'OBJECT' | ||
235 | |||
236 | ALTER TABLE dbo.users ADD CONSTRAINT | ||
237 | PK__users__65A475E737A5467C PRIMARY KEY CLUSTERED | ||
238 | ( | ||
239 | UUID | ||
240 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
241 | |||
242 | CREATE NONCLUSTERED INDEX usernames ON dbo.users | ||
243 | ( | ||
244 | username, | ||
245 | lastname | ||
246 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
247 | |||
248 | COMMIT | ||
249 | |||
250 | |||
251 | :VERSION 7 | ||
252 | |||
253 | BEGIN TRANSACTION | ||
254 | |||
255 | CREATE TABLE dbo.Tmp_agents | ||
256 | ( | ||
257 | UUID uniqueidentifier NOT NULL, | ||
258 | sessionID uniqueidentifier NOT NULL, | ||
259 | secureSessionID uniqueidentifier NOT NULL, | ||
260 | agentIP varchar(16) NOT NULL, | ||
261 | agentPort int NOT NULL, | ||
262 | agentOnline tinyint NOT NULL, | ||
263 | loginTime int NOT NULL, | ||
264 | logoutTime int NOT NULL, | ||
265 | currentRegion uniqueidentifier NOT NULL, | ||
266 | currentHandle bigint NOT NULL, | ||
267 | currentPos varchar(64) NOT NULL | ||
268 | ) ON [PRIMARY] | ||
269 | |||
270 | IF EXISTS(SELECT * FROM dbo.agents) | ||
271 | EXEC('INSERT INTO dbo.Tmp_agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) | ||
272 | SELECT CONVERT(uniqueidentifier, UUID), CONVERT(uniqueidentifier, sessionID), CONVERT(uniqueidentifier, secureSessionID), agentIP, agentPort, agentOnline, loginTime, logoutTime, CONVERT(uniqueidentifier, currentRegion), currentHandle, currentPos FROM dbo.agents WITH (HOLDLOCK TABLOCKX)') | ||
273 | |||
274 | DROP TABLE dbo.agents | ||
275 | |||
276 | EXECUTE sp_rename N'dbo.Tmp_agents', N'agents', 'OBJECT' | ||
277 | |||
278 | ALTER TABLE dbo.agents ADD CONSTRAINT | ||
279 | PK__agents__65A475E749C3F6B7 PRIMARY KEY CLUSTERED | ||
280 | ( | ||
281 | UUID | ||
282 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
283 | |||
284 | CREATE NONCLUSTERED INDEX session ON dbo.agents | ||
285 | ( | ||
286 | sessionID | ||
287 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
288 | |||
289 | CREATE NONCLUSTERED INDEX ssession ON dbo.agents | ||
290 | ( | ||
291 | secureSessionID | ||
292 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
293 | |||
294 | COMMIT | ||
295 | |||
296 | |||
297 | :VERSION 8 | ||
298 | |||
299 | BEGIN TRANSACTION | ||
300 | |||
301 | CREATE TABLE dbo.Tmp_userfriends | ||
302 | ( | ||
303 | ownerID uniqueidentifier NOT NULL, | ||
304 | friendID uniqueidentifier NOT NULL, | ||
305 | friendPerms int NOT NULL, | ||
306 | datetimestamp int NOT NULL | ||
307 | ) ON [PRIMARY] | ||
308 | |||
309 | IF EXISTS(SELECT * FROM dbo.userfriends) | ||
310 | EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp) | ||
311 | SELECT CONVERT(uniqueidentifier, ownerID), CONVERT(uniqueidentifier, friendID), friendPerms, datetimestamp FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)') | ||
312 | |||
313 | DROP TABLE dbo.userfriends | ||
314 | |||
315 | EXECUTE sp_rename N'dbo.Tmp_userfriends', N'userfriends', 'OBJECT' | ||
316 | |||
317 | CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON dbo.userfriends | ||
318 | ( | ||
319 | ownerID | ||
320 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
321 | |||
322 | CREATE NONCLUSTERED INDEX IX_userfriends_friendID ON dbo.userfriends | ||
323 | ( | ||
324 | friendID | ||
325 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
326 | |||
327 | COMMIT | ||
328 | |||
329 | |||
330 | :VERSION 9 | ||
331 | |||
332 | BEGIN TRANSACTION | ||
333 | |||
334 | CREATE TABLE dbo.Tmp_avatarappearance | ||
335 | ( | ||
336 | Owner uniqueidentifier NOT NULL, | ||
337 | Serial int NOT NULL, | ||
338 | Visual_Params image NOT NULL, | ||
339 | Texture image NOT NULL, | ||
340 | Avatar_Height float(53) NOT NULL, | ||
341 | Body_Item uniqueidentifier NOT NULL, | ||
342 | Body_Asset uniqueidentifier NOT NULL, | ||
343 | Skin_Item uniqueidentifier NOT NULL, | ||
344 | Skin_Asset uniqueidentifier NOT NULL, | ||
345 | Hair_Item uniqueidentifier NOT NULL, | ||
346 | Hair_Asset uniqueidentifier NOT NULL, | ||
347 | Eyes_Item uniqueidentifier NOT NULL, | ||
348 | Eyes_Asset uniqueidentifier NOT NULL, | ||
349 | Shirt_Item uniqueidentifier NOT NULL, | ||
350 | Shirt_Asset uniqueidentifier NOT NULL, | ||
351 | Pants_Item uniqueidentifier NOT NULL, | ||
352 | Pants_Asset uniqueidentifier NOT NULL, | ||
353 | Shoes_Item uniqueidentifier NOT NULL, | ||
354 | Shoes_Asset uniqueidentifier NOT NULL, | ||
355 | Socks_Item uniqueidentifier NOT NULL, | ||
356 | Socks_Asset uniqueidentifier NOT NULL, | ||
357 | Jacket_Item uniqueidentifier NOT NULL, | ||
358 | Jacket_Asset uniqueidentifier NOT NULL, | ||
359 | Gloves_Item uniqueidentifier NOT NULL, | ||
360 | Gloves_Asset uniqueidentifier NOT NULL, | ||
361 | Undershirt_Item uniqueidentifier NOT NULL, | ||
362 | Undershirt_Asset uniqueidentifier NOT NULL, | ||
363 | Underpants_Item uniqueidentifier NOT NULL, | ||
364 | Underpants_Asset uniqueidentifier NOT NULL, | ||
365 | Skirt_Item uniqueidentifier NOT NULL, | ||
366 | Skirt_Asset uniqueidentifier NOT NULL | ||
367 | ) ON [PRIMARY] | ||
368 | TEXTIMAGE_ON [PRIMARY] | ||
369 | |||
370 | IF EXISTS(SELECT * FROM dbo.avatarappearance) | ||
371 | EXEC('INSERT INTO dbo.Tmp_avatarappearance (Owner, Serial, Visual_Params, Texture, Avatar_Height, Body_Item, Body_Asset, Skin_Item, Skin_Asset, Hair_Item, Hair_Asset, Eyes_Item, Eyes_Asset, Shirt_Item, Shirt_Asset, Pants_Item, Pants_Asset, Shoes_Item, Shoes_Asset, Socks_Item, Socks_Asset, Jacket_Item, Jacket_Asset, Gloves_Item, Gloves_Asset, Undershirt_Item, Undershirt_Asset, Underpants_Item, Underpants_Asset, Skirt_Item, Skirt_Asset) | ||
372 | SELECT CONVERT(uniqueidentifier, Owner), Serial, Visual_Params, Texture, Avatar_Height, CONVERT(uniqueidentifier, Body_Item), CONVERT(uniqueidentifier, Body_Asset), CONVERT(uniqueidentifier, Skin_Item), CONVERT(uniqueidentifier, Skin_Asset), CONVERT(uniqueidentifier, Hair_Item), CONVERT(uniqueidentifier, Hair_Asset), CONVERT(uniqueidentifier, Eyes_Item), CONVERT(uniqueidentifier, Eyes_Asset), CONVERT(uniqueidentifier, Shirt_Item), CONVERT(uniqueidentifier, Shirt_Asset), CONVERT(uniqueidentifier, Pants_Item), CONVERT(uniqueidentifier, Pants_Asset), CONVERT(uniqueidentifier, Shoes_Item), CONVERT(uniqueidentifier, Shoes_Asset), CONVERT(uniqueidentifier, Socks_Item), CONVERT(uniqueidentifier, Socks_Asset), CONVERT(uniqueidentifier, Jacket_Item), CONVERT(uniqueidentifier, Jacket_Asset), CONVERT(uniqueidentifier, Gloves_Item), CONVERT(uniqueidentifier, Gloves_Asset), CONVERT(uniqueidentifier, Undershirt_Item), CONVERT(uniqueidentifier, Undershirt_Asset), CONVERT(uniqueidentifier, Underpants_Item), CONVERT(uniqueidentifier, Underpants_Asset), CONVERT(uniqueidentifier, Skirt_Item), CONVERT(uniqueidentifier, Skirt_Asset) FROM dbo.avatarappearance WITH (HOLDLOCK TABLOCKX)') | ||
373 | |||
374 | DROP TABLE dbo.avatarappearance | ||
375 | |||
376 | EXECUTE sp_rename N'dbo.Tmp_avatarappearance', N'avatarappearance', 'OBJECT' | ||
377 | |||
378 | ALTER TABLE dbo.avatarappearance ADD CONSTRAINT | ||
379 | PK__avatarap__7DD115CC4E88ABD4 PRIMARY KEY CLUSTERED | ||
380 | ( | ||
381 | Owner | ||
382 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
383 | |||
384 | COMMIT | ||
385 | |||
386 | |||
387 | :VERSION 10 | ||
388 | |||
389 | BEGIN TRANSACTION | ||
390 | |||
391 | CREATE TABLE dbo.Tmp_avatarattachments | ||
392 | ( | ||
393 | UUID uniqueidentifier NOT NULL, | ||
394 | attachpoint int NOT NULL, | ||
395 | item uniqueidentifier NOT NULL, | ||
396 | asset uniqueidentifier NOT NULL | ||
397 | ) ON [PRIMARY] | ||
398 | |||
399 | IF EXISTS(SELECT * FROM dbo.avatarattachments) | ||
400 | EXEC('INSERT INTO dbo.Tmp_avatarattachments (UUID, attachpoint, item, asset) | ||
401 | SELECT CONVERT(uniqueidentifier, UUID), attachpoint, CONVERT(uniqueidentifier, item), CONVERT(uniqueidentifier, asset) FROM dbo.avatarattachments WITH (HOLDLOCK TABLOCKX)') | ||
402 | |||
403 | DROP TABLE dbo.avatarattachments | ||
404 | |||
405 | EXECUTE sp_rename N'dbo.Tmp_avatarattachments', N'avatarattachments', 'OBJECT' | ||
406 | |||
407 | CREATE NONCLUSTERED INDEX IX_avatarattachments ON dbo.avatarattachments | ||
408 | ( | ||
409 | UUID | ||
410 | ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
411 | |||
412 | COMMIT | ||
413 | |||
414 | |||
415 | :VERSION 11 | ||
416 | |||
417 | BEGIN TRANSACTION | ||
418 | |||
419 | ALTER TABLE users ADD scopeID uniqueidentifier not null default '00000000-0000-0000-0000-000000000000' | ||
420 | |||
421 | COMMIT | ||
diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs new file mode 100644 index 0000000..ed0ab98 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | |||
@@ -0,0 +1,56 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using MySql.Data.MySqlClient; | ||
35 | |||
36 | namespace OpenSim.Data.MySQL | ||
37 | { | ||
38 | public class MySQLAgentPreferencesData : MySQLGenericTableHandler<AgentPreferencesData>, IAgentPreferencesData | ||
39 | { | ||
40 | public MySQLAgentPreferencesData(string connectionString, string realm) | ||
41 | : base(connectionString, realm, "AgentPrefs") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public AgentPreferencesData GetPrefs(UUID agentID) | ||
46 | { | ||
47 | AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString()); | ||
48 | |||
49 | if (ret.Length == 0) | ||
50 | return null; | ||
51 | |||
52 | return ret[0]; | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | |||
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 73de64b..5d8da17 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -45,7 +45,6 @@ namespace OpenSim.Data.MySQL | |||
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 | private string m_connectionString; | 47 | private string m_connectionString; |
48 | private object m_dbLock = new object(); | ||
49 | 48 | ||
50 | protected virtual Assembly Assembly | 49 | protected virtual Assembly Assembly |
51 | { | 50 | { |
@@ -107,46 +106,46 @@ namespace OpenSim.Data.MySQL | |||
107 | override public AssetBase GetAsset(UUID assetID) | 106 | override public AssetBase GetAsset(UUID assetID) |
108 | { | 107 | { |
109 | AssetBase asset = null; | 108 | AssetBase asset = null; |
110 | lock (m_dbLock) | 109 | |
110 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
111 | { | 111 | { |
112 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 112 | dbcon.Open(); |
113 | |||
114 | using (MySqlCommand cmd = new MySqlCommand( | ||
115 | "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", | ||
116 | dbcon)) | ||
113 | { | 117 | { |
114 | dbcon.Open(); | 118 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); |
115 | 119 | ||
116 | using (MySqlCommand cmd = new MySqlCommand( | 120 | try |
117 | "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", | ||
118 | dbcon)) | ||
119 | { | 121 | { |
120 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 122 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
121 | |||
122 | try | ||
123 | { | 123 | { |
124 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 124 | if (dbReader.Read()) |
125 | { | 125 | { |
126 | if (dbReader.Read()) | 126 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); |
127 | { | 127 | asset.Data = (byte[])dbReader["data"]; |
128 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); | 128 | asset.Description = (string)dbReader["description"]; |
129 | asset.Data = (byte[])dbReader["data"]; | 129 | |
130 | asset.Description = (string)dbReader["description"]; | 130 | string local = dbReader["local"].ToString(); |
131 | 131 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | |
132 | string local = dbReader["local"].ToString(); | 132 | asset.Local = true; |
133 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 133 | else |
134 | asset.Local = true; | 134 | asset.Local = false; |
135 | else | 135 | |
136 | asset.Local = false; | 136 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
137 | 137 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | |
138 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
139 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | ||
140 | } | ||
141 | } | 138 | } |
142 | } | 139 | } |
143 | catch (Exception e) | 140 | } |
144 | { | 141 | catch (Exception e) |
145 | m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message); | 142 | { |
146 | } | 143 | m_log.Error( |
144 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); | ||
147 | } | 145 | } |
148 | } | 146 | } |
149 | } | 147 | } |
148 | |||
150 | return asset; | 149 | return asset; |
151 | } | 150 | } |
152 | 151 | ||
@@ -157,137 +156,134 @@ namespace OpenSim.Data.MySQL | |||
157 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | 156 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> |
158 | override public void StoreAsset(AssetBase asset) | 157 | override public void StoreAsset(AssetBase asset) |
159 | { | 158 | { |
160 | lock (m_dbLock) | 159 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
161 | { | 160 | { |
162 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 161 | dbcon.Open(); |
162 | |||
163 | using (MySqlCommand cmd = | ||
164 | new MySqlCommand( | ||
165 | "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)", | ||
167 | dbcon)) | ||
163 | { | 168 | { |
164 | dbcon.Open(); | 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 | } | ||
165 | 177 | ||
166 | using (MySqlCommand cmd = | 178 | string assetDescription = asset.Description; |
167 | new MySqlCommand( | 179 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) |
168 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + | ||
169 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", | ||
170 | dbcon)) | ||
171 | { | 180 | { |
172 | string assetName = asset.Name; | 181 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
173 | if (asset.Name.Length > 64) | 182 | m_log.WarnFormat( |
174 | { | 183 | "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
175 | assetName = asset.Name.Substring(0, 64); | 184 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
176 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | 185 | } |
177 | } | 186 | |
178 | 187 | try | |
179 | string assetDescription = asset.Description; | 188 | { |
180 | if (asset.Description.Length > 64) | 189 | using (cmd) |
181 | { | ||
182 | assetDescription = asset.Description.Substring(0, 64); | ||
183 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | ||
184 | } | ||
185 | |||
186 | try | ||
187 | { | ||
188 | using (cmd) | ||
189 | { | ||
190 | // create unix epoch time | ||
191 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
192 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
193 | cmd.Parameters.AddWithValue("?name", assetName); | ||
194 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
195 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
196 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
197 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
198 | cmd.Parameters.AddWithValue("?create_time", now); | ||
199 | cmd.Parameters.AddWithValue("?access_time", now); | ||
200 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
201 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
202 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
203 | cmd.ExecuteNonQuery(); | ||
204 | } | ||
205 | } | ||
206 | catch (Exception e) | ||
207 | { | 190 | { |
208 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | 191 | // create unix epoch time |
209 | asset.FullID, asset.Name, e.Message); | 192 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
193 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
194 | cmd.Parameters.AddWithValue("?name", assetName); | ||
195 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
196 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
197 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
198 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
199 | cmd.Parameters.AddWithValue("?create_time", now); | ||
200 | cmd.Parameters.AddWithValue("?access_time", now); | ||
201 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
202 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
203 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
204 | cmd.ExecuteNonQuery(); | ||
210 | } | 205 | } |
211 | } | 206 | } |
207 | catch (Exception e) | ||
208 | { | ||
209 | m_log.Error( | ||
210 | string.Format( | ||
211 | "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", | ||
212 | asset.FullID, asset.Name) | ||
213 | , e); | ||
214 | } | ||
212 | } | 215 | } |
213 | } | 216 | } |
214 | } | 217 | } |
215 | 218 | ||
216 | private void UpdateAccessTime(AssetBase asset) | 219 | private void UpdateAccessTime(AssetBase asset) |
217 | { | 220 | { |
218 | lock (m_dbLock) | 221 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
219 | { | 222 | { |
220 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 223 | dbcon.Open(); |
221 | { | ||
222 | dbcon.Open(); | ||
223 | 224 | ||
224 | using (MySqlCommand cmd | 225 | using (MySqlCommand cmd |
225 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) | 226 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) |
227 | { | ||
228 | try | ||
226 | { | 229 | { |
227 | try | 230 | using (cmd) |
228 | { | ||
229 | using (cmd) | ||
230 | { | ||
231 | // create unix epoch time | ||
232 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
233 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
234 | cmd.Parameters.AddWithValue("?access_time", now); | ||
235 | cmd.ExecuteNonQuery(); | ||
236 | } | ||
237 | } | ||
238 | catch (Exception e) | ||
239 | { | 231 | { |
240 | m_log.ErrorFormat( | 232 | // create unix epoch time |
241 | "[ASSETS DB]: " + | 233 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
242 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | 234 | cmd.Parameters.AddWithValue("?id", asset.ID); |
243 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | 235 | cmd.Parameters.AddWithValue("?access_time", now); |
236 | cmd.ExecuteNonQuery(); | ||
244 | } | 237 | } |
245 | } | 238 | } |
239 | catch (Exception e) | ||
240 | { | ||
241 | m_log.Error( | ||
242 | string.Format( | ||
243 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", | ||
244 | asset.FullID, asset.Name), | ||
245 | e); | ||
246 | } | ||
246 | } | 247 | } |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | /// <summary> | 251 | /// <summary> |
251 | /// Check if the asset exists in the database | 252 | /// Check if the assets exist in the database. |
252 | /// </summary> | 253 | /// </summary> |
253 | /// <param name="uuid">The asset UUID</param> | 254 | /// <param name="uuidss">The assets' IDs</param> |
254 | /// <returns>true if it exists, false otherwise.</returns> | 255 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
255 | override public bool ExistsAsset(UUID uuid) | 256 | public override bool[] AssetsExist(UUID[] uuids) |
256 | { | 257 | { |
257 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | 258 | if (uuids.Length == 0) |
259 | return new bool[0]; | ||
258 | 260 | ||
259 | bool assetExists = false; | 261 | HashSet<UUID> exist = new HashSet<UUID>(); |
260 | 262 | ||
261 | lock (m_dbLock) | 263 | string ids = "'" + string.Join("','", uuids) + "'"; |
264 | string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); | ||
265 | |||
266 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
262 | { | 267 | { |
263 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 268 | dbcon.Open(); |
269 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
264 | { | 270 | { |
265 | dbcon.Open(); | 271 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
266 | using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) | ||
267 | { | 272 | { |
268 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | 273 | while (dbReader.Read()) |
269 | |||
270 | try | ||
271 | { | ||
272 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
273 | { | ||
274 | if (dbReader.Read()) | ||
275 | { | ||
276 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
277 | assetExists = true; | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | catch (Exception e) | ||
282 | { | 274 | { |
283 | m_log.ErrorFormat( | 275 | UUID id = DBGuid.FromDB(dbReader["id"]); |
284 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); | 276 | exist.Add(id); |
285 | } | 277 | } |
286 | } | 278 | } |
287 | } | 279 | } |
288 | } | 280 | } |
289 | 281 | ||
290 | return assetExists; | 282 | bool[] results = new bool[uuids.Length]; |
283 | for (int i = 0; i < uuids.Length; i++) | ||
284 | results[i] = exist.Contains(uuids[i]); | ||
285 | |||
286 | return results; | ||
291 | } | 287 | } |
292 | 288 | ||
293 | /// <summary> | 289 | /// <summary> |
@@ -302,46 +298,47 @@ namespace OpenSim.Data.MySQL | |||
302 | { | 298 | { |
303 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 299 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
304 | 300 | ||
305 | lock (m_dbLock) | 301 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
306 | { | 302 | { |
307 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 303 | dbcon.Open(); |
304 | |||
305 | using (MySqlCommand cmd | ||
306 | = new MySqlCommand( | ||
307 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
308 | dbcon)) | ||
308 | { | 309 | { |
309 | dbcon.Open(); | 310 | cmd.Parameters.AddWithValue("?start", start); |
311 | cmd.Parameters.AddWithValue("?count", count); | ||
310 | 312 | ||
311 | using (MySqlCommand cmd | 313 | try |
312 | = new MySqlCommand( | ||
313 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
314 | dbcon)) | ||
315 | { | 314 | { |
316 | cmd.Parameters.AddWithValue("?start", start); | 315 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
317 | cmd.Parameters.AddWithValue("?count", count); | ||
318 | |||
319 | try | ||
320 | { | 316 | { |
321 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 317 | while (dbReader.Read()) |
322 | { | 318 | { |
323 | while (dbReader.Read()) | 319 | AssetMetadata metadata = new AssetMetadata(); |
324 | { | 320 | metadata.Name = (string)dbReader["name"]; |
325 | AssetMetadata metadata = new AssetMetadata(); | 321 | metadata.Description = (string)dbReader["description"]; |
326 | metadata.Name = (string)dbReader["name"]; | 322 | metadata.Type = (sbyte)dbReader["assetType"]; |
327 | metadata.Description = (string)dbReader["description"]; | 323 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. |
328 | metadata.Type = (sbyte)dbReader["assetType"]; | 324 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
329 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 325 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); |
330 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 326 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
331 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 327 | |
332 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 328 | // Current SHA1s are not stored/computed. |
333 | 329 | metadata.SHA1 = new byte[] { }; | |
334 | // Current SHA1s are not stored/computed. | 330 | |
335 | metadata.SHA1 = new byte[] { }; | 331 | retList.Add(metadata); |
336 | |||
337 | retList.Add(metadata); | ||
338 | } | ||
339 | } | 332 | } |
340 | } | 333 | } |
341 | catch (Exception e) | 334 | } |
342 | { | 335 | catch (Exception e) |
343 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 336 | { |
344 | } | 337 | m_log.Error( |
338 | string.Format( | ||
339 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", | ||
340 | start, count), | ||
341 | e); | ||
345 | } | 342 | } |
346 | } | 343 | } |
347 | } | 344 | } |
@@ -351,17 +348,14 @@ namespace OpenSim.Data.MySQL | |||
351 | 348 | ||
352 | public override bool Delete(string id) | 349 | public override bool Delete(string id) |
353 | { | 350 | { |
354 | lock (m_dbLock) | 351 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
355 | { | 352 | { |
356 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 353 | dbcon.Open(); |
357 | { | ||
358 | dbcon.Open(); | ||
359 | 354 | ||
360 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) | 355 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) |
361 | { | 356 | { |
362 | cmd.Parameters.AddWithValue("?id", id); | 357 | cmd.Parameters.AddWithValue("?id", id); |
363 | cmd.ExecuteNonQuery(); | 358 | cmd.ExecuteNonQuery(); |
364 | } | ||
365 | } | 359 | } |
366 | } | 360 | } |
367 | 361 | ||
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3dd46cb..fe1487b 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -43,12 +43,7 @@ namespace OpenSim.Data.MySQL | |||
43 | private static readonly ILog m_log = | 43 | private static readonly ILog m_log = |
44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; | ||
47 | |||
48 | private string m_connectionString; | 46 | private string m_connectionString; |
49 | private long m_waitTimeout; | ||
50 | private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; | ||
51 | // private long m_lastConnectionUse; | ||
52 | 47 | ||
53 | private FieldInfo[] m_Fields; | 48 | private FieldInfo[] m_Fields; |
54 | private Dictionary<string, FieldInfo> m_FieldMap = | 49 | private Dictionary<string, FieldInfo> m_FieldMap = |
@@ -81,8 +76,6 @@ namespace OpenSim.Data.MySQL | |||
81 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); | 76 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); |
82 | } | 77 | } |
83 | 78 | ||
84 | GetWaitTimeout(); | ||
85 | |||
86 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 79 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
87 | { | 80 | { |
88 | dbcon.Open(); | 81 | dbcon.Open(); |
@@ -108,33 +101,6 @@ namespace OpenSim.Data.MySQL | |||
108 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } | 101 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } |
109 | } | 102 | } |
110 | 103 | ||
111 | protected void GetWaitTimeout() | ||
112 | { | ||
113 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
114 | { | ||
115 | dbcon.Open(); | ||
116 | |||
117 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | ||
118 | { | ||
119 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
120 | { | ||
121 | if (dbReader.Read()) | ||
122 | { | ||
123 | m_waitTimeout | ||
124 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | ||
125 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | // m_lastConnectionUse = DateTime.Now.Ticks; | ||
131 | |||
132 | m_log.DebugFormat( | ||
133 | "[REGION DB]: Connection wait timeout {0} seconds", | ||
134 | m_waitTimeout / TimeSpan.TicksPerSecond); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 104 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
139 | { | 105 | { |
140 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + | 106 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + |
@@ -145,7 +111,11 @@ namespace OpenSim.Data.MySQL | |||
145 | cmd.CommandText = sql; | 111 | cmd.CommandText = sql; |
146 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 112 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
147 | 113 | ||
148 | return DoLoad(cmd, regionID, create); | 114 | EstateSettings e = DoLoad(cmd, regionID, create); |
115 | if (!create && e.EstateID == 0) // Not found | ||
116 | return null; | ||
117 | |||
118 | return e; | ||
149 | } | 119 | } |
150 | } | 120 | } |
151 | 121 | ||
@@ -427,7 +397,10 @@ namespace OpenSim.Data.MySQL | |||
427 | cmd.CommandText = sql; | 397 | cmd.CommandText = sql; |
428 | cmd.Parameters.AddWithValue("?EstateID", estateID); | 398 | cmd.Parameters.AddWithValue("?EstateID", estateID); |
429 | 399 | ||
430 | return DoLoad(cmd, UUID.Zero, false); | 400 | EstateSettings e = DoLoad(cmd, UUID.Zero, false); |
401 | if (e.EstateID != estateID) | ||
402 | return null; | ||
403 | return e; | ||
431 | } | 404 | } |
432 | } | 405 | } |
433 | 406 | ||
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs new file mode 100644 index 0000000..19e23b5 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs | |||
@@ -0,0 +1,414 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Console; | ||
34 | using log4net; | ||
35 | using MySql.Data.MySqlClient; | ||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class MySQLFSAssetData : IFSAssetDataPlugin | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected MySqlConnection m_Connection = null; | ||
45 | protected string m_ConnectionString; | ||
46 | protected string m_Table; | ||
47 | protected Object m_connLock = new Object(); | ||
48 | |||
49 | /// <summary> | ||
50 | /// Number of days that must pass before we update the access time on an asset when it has been fetched | ||
51 | /// Config option to change this is "DaysBetweenAccessTimeUpdates" | ||
52 | /// </summary> | ||
53 | private int DaysBetweenAccessTimeUpdates = 0; | ||
54 | |||
55 | protected virtual Assembly Assembly | ||
56 | { | ||
57 | get { return GetType().Assembly; } | ||
58 | } | ||
59 | |||
60 | public MySQLFSAssetData() | ||
61 | { | ||
62 | } | ||
63 | |||
64 | #region IPlugin Members | ||
65 | |||
66 | public string Version { get { return "1.0.0.0"; } } | ||
67 | |||
68 | // Loads and initialises the MySQL storage plugin and checks for migrations | ||
69 | public void Initialise(string connect, string realm, int UpdateAccessTime) | ||
70 | { | ||
71 | m_ConnectionString = connect; | ||
72 | m_Table = realm; | ||
73 | |||
74 | DaysBetweenAccessTimeUpdates = UpdateAccessTime; | ||
75 | |||
76 | try | ||
77 | { | ||
78 | OpenDatabase(); | ||
79 | |||
80 | Migration m = new Migration(m_Connection, Assembly, "FSAssetStore"); | ||
81 | m.Update(); | ||
82 | } | ||
83 | catch (MySqlException e) | ||
84 | { | ||
85 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", e.Message.ToString()); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public void Initialise() | ||
90 | { | ||
91 | throw new NotImplementedException(); | ||
92 | } | ||
93 | |||
94 | public void Dispose() { } | ||
95 | |||
96 | public string Name | ||
97 | { | ||
98 | get { return "MySQL FSAsset storage engine"; } | ||
99 | } | ||
100 | |||
101 | #endregion | ||
102 | |||
103 | private bool OpenDatabase() | ||
104 | { | ||
105 | try | ||
106 | { | ||
107 | m_Connection = new MySqlConnection(m_ConnectionString); | ||
108 | |||
109 | m_Connection.Open(); | ||
110 | } | ||
111 | catch (MySqlException e) | ||
112 | { | ||
113 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | ||
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 | { | ||
142 | try | ||
143 | { | ||
144 | c.ExecuteNonQuery(); | ||
145 | } | ||
146 | catch (MySqlException) | ||
147 | { | ||
148 | System.Threading.Thread.Sleep(500); | ||
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 | |||
164 | break; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | #region IFSAssetDataPlugin Members | ||
170 | |||
171 | public AssetMetadata Get(string id, out string hash) | ||
172 | { | ||
173 | hash = String.Empty; | ||
174 | |||
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(); | ||
190 | |||
191 | hash = reader["hash"].ToString(); | ||
192 | |||
193 | meta.ID = id; | ||
194 | meta.FullID = new UUID(id); | ||
195 | |||
196 | meta.Name = reader["name"].ToString(); | ||
197 | meta.Description = reader["description"].ToString(); | ||
198 | meta.Type = (sbyte)Convert.ToInt32(reader["type"]); | ||
199 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | ||
200 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | ||
201 | meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); | ||
202 | |||
203 | int AccessTime = Convert.ToInt32(reader["access_time"]); | ||
204 | |||
205 | reader.Close(); | ||
206 | |||
207 | UpdateAccessTime(AccessTime, cmd); | ||
208 | |||
209 | FreeCommand(cmd); | ||
210 | |||
211 | return meta; | ||
212 | } | ||
213 | |||
214 | private void UpdateAccessTime(int AccessTime, MySqlCommand cmd) | ||
215 | { | ||
216 | // Reduce DB work by only updating access time if asset hasn't recently been accessed | ||
217 | // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" | ||
218 | if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) | ||
219 | return; | ||
220 | |||
221 | cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); | ||
222 | |||
223 | cmd.ExecuteNonQuery(); | ||
224 | } | ||
225 | |||
226 | protected void FreeCommand(MySqlCommand cmd) | ||
227 | { | ||
228 | MySqlConnection c = cmd.Connection; | ||
229 | cmd.Dispose(); | ||
230 | c.Close(); | ||
231 | c.Dispose(); | ||
232 | } | ||
233 | |||
234 | public bool Store(AssetMetadata meta, string hash) | ||
235 | { | ||
236 | try | ||
237 | { | ||
238 | string oldhash; | ||
239 | AssetMetadata existingAsset = Get(meta.ID, out oldhash); | ||
240 | |||
241 | MySqlCommand cmd = m_Connection.CreateCommand(); | ||
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 | { | ||
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); | ||
253 | |||
254 | ExecuteNonQuery(cmd); | ||
255 | |||
256 | cmd.Dispose(); | ||
257 | |||
258 | return true; | ||
259 | } | ||
260 | |||
261 | //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); | ||
262 | |||
263 | //ExecuteNonQuery(cmd); | ||
264 | |||
265 | cmd.Dispose(); | ||
266 | return false; | ||
267 | } | ||
268 | catch(Exception e) | ||
269 | { | ||
270 | m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); | ||
271 | m_log.Error(e.ToString()); | ||
272 | return false; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | /// <summary> | ||
277 | /// Check if the assets exist in the database. | ||
278 | /// </summary> | ||
279 | /// <param name="uuids">The asset UUID's</param> | ||
280 | /// <returns>For each asset: true if it exists, false otherwise</returns> | ||
281 | public bool[] AssetsExist(UUID[] uuids) | ||
282 | { | ||
283 | if (uuids.Length == 0) | ||
284 | return new bool[0]; | ||
285 | |||
286 | HashSet<UUID> exists = new HashSet<UUID>(); | ||
287 | |||
288 | string ids = "'" + string.Join("','", uuids) + "'"; | ||
289 | string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table); | ||
290 | |||
291 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
292 | { | ||
293 | cmd.CommandText = sql; | ||
294 | |||
295 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
296 | { | ||
297 | while (dbReader.Read()) | ||
298 | { | ||
299 | UUID id = DBGuid.FromDB(dbReader["ID"]); | ||
300 | exists.Add(id); | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | |||
305 | bool[] results = new bool[uuids.Length]; | ||
306 | for (int i = 0; i < uuids.Length; i++) | ||
307 | results[i] = exists.Contains(uuids[i]); | ||
308 | return results; | ||
309 | } | ||
310 | |||
311 | public int Count() | ||
312 | { | ||
313 | MySqlCommand cmd = m_Connection.CreateCommand(); | ||
314 | |||
315 | cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table); | ||
316 | |||
317 | IDataReader reader = ExecuteReader(cmd); | ||
318 | |||
319 | reader.Read(); | ||
320 | |||
321 | int count = Convert.ToInt32(reader["count"]); | ||
322 | |||
323 | reader.Close(); | ||
324 | FreeCommand(cmd); | ||
325 | |||
326 | return count; | ||
327 | } | ||
328 | |||
329 | public bool Delete(string id) | ||
330 | { | ||
331 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
332 | { | ||
333 | cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); | ||
334 | |||
335 | cmd.Parameters.AddWithValue("?id", id); | ||
336 | |||
337 | ExecuteNonQuery(cmd); | ||
338 | } | ||
339 | |||
340 | return true; | ||
341 | } | ||
342 | |||
343 | public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) | ||
344 | { | ||
345 | MySqlConnection importConn; | ||
346 | |||
347 | try | ||
348 | { | ||
349 | importConn = new MySqlConnection(conn); | ||
350 | |||
351 | importConn.Open(); | ||
352 | } | ||
353 | catch (MySqlException e) | ||
354 | { | ||
355 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | ||
356 | e.Message.ToString()); | ||
357 | |||
358 | return; | ||
359 | } | ||
360 | |||
361 | int imported = 0; | ||
362 | |||
363 | MySqlCommand cmd = importConn.CreateCommand(); | ||
364 | |||
365 | string limit = String.Empty; | ||
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 | |||
373 | MainConsole.Instance.Output("Querying database"); | ||
374 | IDataReader reader = cmd.ExecuteReader(); | ||
375 | |||
376 | MainConsole.Instance.Output("Reading data"); | ||
377 | |||
378 | while (reader.Read()) | ||
379 | { | ||
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 | |||
388 | meta.ID = reader["id"].ToString(); | ||
389 | meta.FullID = new UUID(meta.ID); | ||
390 | |||
391 | meta.Name = reader["name"].ToString(); | ||
392 | meta.Description = reader["description"].ToString(); | ||
393 | meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]); | ||
394 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | ||
395 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | ||
396 | |||
397 | asset.Metadata = meta; | ||
398 | asset.Data = (byte[])reader["data"]; | ||
399 | |||
400 | store(asset, force); | ||
401 | |||
402 | imported++; | ||
403 | } | ||
404 | |||
405 | reader.Close(); | ||
406 | cmd.Dispose(); | ||
407 | importConn.Close(); | ||
408 | |||
409 | MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); | ||
410 | } | ||
411 | |||
412 | #endregion | ||
413 | } | ||
414 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 3fdcf1e..5820a90 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -45,38 +45,29 @@ namespace OpenSim.Data.MySQL | |||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected string m_connectionString; | 47 | protected string m_connectionString; |
48 | protected object m_dbLock = new object(); | ||
49 | 48 | ||
50 | protected MySqlFramework(string connectionString) | 49 | protected MySqlFramework(string connectionString) |
51 | { | 50 | { |
52 | m_connectionString = connectionString; | 51 | m_connectionString = connectionString; |
53 | } | 52 | } |
54 | 53 | ||
55 | ////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | // All non queries are funneled through one connection | ||
58 | // to increase performance a little | ||
59 | // | ||
60 | protected int ExecuteNonQuery(MySqlCommand cmd) | 54 | protected int ExecuteNonQuery(MySqlCommand cmd) |
61 | { | 55 | { |
62 | lock (m_dbLock) | 56 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
63 | { | 57 | { |
64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 58 | dbcon.Open(); |
65 | { | 59 | cmd.Connection = dbcon; |
66 | dbcon.Open(); | ||
67 | cmd.Connection = dbcon; | ||
68 | 60 | ||
69 | try | 61 | try |
70 | { | 62 | { |
71 | return cmd.ExecuteNonQuery(); | 63 | return cmd.ExecuteNonQuery(); |
72 | } | 64 | } |
73 | catch (Exception e) | 65 | catch (Exception e) |
74 | { | 66 | { |
75 | m_log.Error(e.Message, e); | 67 | m_log.Error(e.Message, e); |
76 | return 0; | 68 | return 0; |
77 | } | ||
78 | } | 69 | } |
79 | } | 70 | } |
80 | } | 71 | } |
81 | } | 72 | } |
82 | } | 73 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 3cd6b8f..6ba9fbd 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Data.MySQL | |||
47 | return Delete(principalID.ToString(), friend); | 47 | return Delete(principalID.ToString(), friend); |
48 | } | 48 | } |
49 | 49 | ||
50 | public bool Delete(string principalID, string friend) | 50 | public override bool Delete(string principalID, string friend) |
51 | { | 51 | { |
52 | using (MySqlCommand cmd = new MySqlCommand()) | 52 | using (MySqlCommand cmd = new MySqlCommand()) |
53 | { | 53 | { |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 995c6a5..35fa89f 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -301,5 +301,65 @@ namespace OpenSim.Data.MySQL | |||
301 | return ExecuteNonQuery(cmd) > 0; | 301 | return ExecuteNonQuery(cmd) > 0; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | |||
305 | public long GetCount(string field, string key) | ||
306 | { | ||
307 | return GetCount(new string[] { field }, new string[] { key }); | ||
308 | } | ||
309 | |||
310 | public long GetCount(string[] fields, string[] keys) | ||
311 | { | ||
312 | if (fields.Length != keys.Length) | ||
313 | return 0; | ||
314 | |||
315 | List<string> terms = new List<string>(); | ||
316 | |||
317 | using (MySqlCommand cmd = new MySqlCommand()) | ||
318 | { | ||
319 | for (int i = 0; i < fields.Length; i++) | ||
320 | { | ||
321 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | ||
322 | terms.Add("`" + fields[i] + "` = ?" + fields[i]); | ||
323 | } | ||
324 | |||
325 | string where = String.Join(" and ", terms.ToArray()); | ||
326 | |||
327 | string query = String.Format("select count(*) from {0} where {1}", | ||
328 | m_Realm, where); | ||
329 | |||
330 | cmd.CommandText = query; | ||
331 | |||
332 | Object result = DoQueryScalar(cmd); | ||
333 | |||
334 | return Convert.ToInt64(result); | ||
335 | } | ||
336 | } | ||
337 | |||
338 | public long GetCount(string where) | ||
339 | { | ||
340 | using (MySqlCommand cmd = new MySqlCommand()) | ||
341 | { | ||
342 | string query = String.Format("select count(*) from {0} where {1}", | ||
343 | m_Realm, where); | ||
344 | |||
345 | cmd.CommandText = query; | ||
346 | |||
347 | object result = DoQueryScalar(cmd); | ||
348 | |||
349 | return Convert.ToInt64(result); | ||
350 | } | ||
351 | } | ||
352 | |||
353 | public object DoQueryScalar(MySqlCommand cmd) | ||
354 | { | ||
355 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
356 | { | ||
357 | dbcon.Open(); | ||
358 | cmd.Connection = dbcon; | ||
359 | |||
360 | return cmd.ExecuteScalar(); | ||
361 | } | ||
362 | } | ||
363 | |||
304 | } | 364 | } |
305 | } \ No newline at end of file | 365 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index a9ce94d..00560c1 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Data.MySQL | |||
46 | 46 | ||
47 | public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} | 47 | public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} |
48 | 48 | ||
49 | public GridUserData Get(string userID) | 49 | public new GridUserData Get(string userID) |
50 | { | 50 | { |
51 | GridUserData[] ret = Get("UserID", userID); | 51 | GridUserData[] ret = Get("UserID", userID); |
52 | 52 | ||
@@ -56,6 +56,9 @@ namespace OpenSim.Data.MySQL | |||
56 | return ret[0]; | 56 | return ret[0]; |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | public GridUserData[] GetAll(string userID) | |
60 | { | ||
61 | return base.Get(String.Format("UserID LIKE '{0}%'", userID)); | ||
62 | } | ||
60 | } | 63 | } |
61 | } \ No newline at end of file | 64 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs new file mode 100644 index 0000000..afa499e --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs | |||
@@ -0,0 +1,484 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data.MySQL; | ||
35 | |||
36 | using OpenMetaverse; | ||
37 | using MySql.Data.MySqlClient; | ||
38 | |||
39 | namespace OpenSim.Data.MySQL | ||
40 | { | ||
41 | public class MySQLGroupsData : IGroupsData | ||
42 | { | ||
43 | private MySqlGroupsGroupsHandler m_Groups; | ||
44 | private MySqlGroupsMembershipHandler m_Membership; | ||
45 | private MySqlGroupsRolesHandler m_Roles; | ||
46 | private MySqlGroupsRoleMembershipHandler m_RoleMembership; | ||
47 | private MySqlGroupsInvitesHandler m_Invites; | ||
48 | private MySqlGroupsNoticesHandler m_Notices; | ||
49 | private MySqlGroupsPrincipalsHandler m_Principals; | ||
50 | |||
51 | public MySQLGroupsData(string connectionString, string realm) | ||
52 | { | ||
53 | m_Groups = new MySqlGroupsGroupsHandler(connectionString, realm + "_groups", realm + "_Store"); | ||
54 | m_Membership = new MySqlGroupsMembershipHandler(connectionString, realm + "_membership"); | ||
55 | m_Roles = new MySqlGroupsRolesHandler(connectionString, realm + "_roles"); | ||
56 | m_RoleMembership = new MySqlGroupsRoleMembershipHandler(connectionString, realm + "_rolemembership"); | ||
57 | m_Invites = new MySqlGroupsInvitesHandler(connectionString, realm + "_invites"); | ||
58 | m_Notices = new MySqlGroupsNoticesHandler(connectionString, realm + "_notices"); | ||
59 | m_Principals = new MySqlGroupsPrincipalsHandler(connectionString, realm + "_principals"); | ||
60 | } | ||
61 | |||
62 | #region groups table | ||
63 | public bool StoreGroup(GroupData data) | ||
64 | { | ||
65 | return m_Groups.Store(data); | ||
66 | } | ||
67 | |||
68 | public GroupData RetrieveGroup(UUID groupID) | ||
69 | { | ||
70 | GroupData[] groups = m_Groups.Get("GroupID", groupID.ToString()); | ||
71 | if (groups.Length > 0) | ||
72 | return groups[0]; | ||
73 | |||
74 | return null; | ||
75 | } | ||
76 | |||
77 | public GroupData RetrieveGroup(string name) | ||
78 | { | ||
79 | GroupData[] groups = m_Groups.Get("Name", name); | ||
80 | if (groups.Length > 0) | ||
81 | return groups[0]; | ||
82 | |||
83 | return null; | ||
84 | } | ||
85 | |||
86 | public GroupData[] RetrieveGroups(string pattern) | ||
87 | { | ||
88 | if (string.IsNullOrEmpty(pattern)) | ||
89 | pattern = "1"; | ||
90 | else | ||
91 | pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern)); | ||
92 | |||
93 | return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); | ||
94 | } | ||
95 | |||
96 | public bool DeleteGroup(UUID groupID) | ||
97 | { | ||
98 | return m_Groups.Delete("GroupID", groupID.ToString()); | ||
99 | } | ||
100 | |||
101 | public int GroupsCount() | ||
102 | { | ||
103 | return (int)m_Groups.GetCount("Location=\"\""); | ||
104 | } | ||
105 | |||
106 | #endregion | ||
107 | |||
108 | #region membership table | ||
109 | public MembershipData[] RetrieveMembers(UUID groupID) | ||
110 | { | ||
111 | return m_Membership.Get("GroupID", groupID.ToString()); | ||
112 | } | ||
113 | |||
114 | public MembershipData RetrieveMember(UUID groupID, string pricipalID) | ||
115 | { | ||
116 | MembershipData[] m = m_Membership.Get(new string[] { "GroupID", "PrincipalID" }, | ||
117 | new string[] { groupID.ToString(), pricipalID }); | ||
118 | if (m != null && m.Length > 0) | ||
119 | return m[0]; | ||
120 | |||
121 | return null; | ||
122 | } | ||
123 | |||
124 | public MembershipData[] RetrieveMemberships(string pricipalID) | ||
125 | { | ||
126 | return m_Membership.Get("PrincipalID", pricipalID.ToString()); | ||
127 | } | ||
128 | |||
129 | public bool StoreMember(MembershipData data) | ||
130 | { | ||
131 | return m_Membership.Store(data); | ||
132 | } | ||
133 | |||
134 | public bool DeleteMember(UUID groupID, string pricipalID) | ||
135 | { | ||
136 | return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" }, | ||
137 | new string[] { groupID.ToString(), pricipalID }); | ||
138 | } | ||
139 | |||
140 | public int MemberCount(UUID groupID) | ||
141 | { | ||
142 | return (int)m_Membership.GetCount("GroupID", groupID.ToString()); | ||
143 | } | ||
144 | #endregion | ||
145 | |||
146 | #region roles table | ||
147 | public bool StoreRole(RoleData data) | ||
148 | { | ||
149 | return m_Roles.Store(data); | ||
150 | } | ||
151 | |||
152 | public RoleData RetrieveRole(UUID groupID, UUID roleID) | ||
153 | { | ||
154 | RoleData[] data = m_Roles.Get(new string[] { "GroupID", "RoleID" }, | ||
155 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
156 | |||
157 | if (data != null && data.Length > 0) | ||
158 | return data[0]; | ||
159 | |||
160 | return null; | ||
161 | } | ||
162 | |||
163 | public RoleData[] RetrieveRoles(UUID groupID) | ||
164 | { | ||
165 | //return m_Roles.RetrieveRoles(groupID); | ||
166 | return m_Roles.Get("GroupID", groupID.ToString()); | ||
167 | } | ||
168 | |||
169 | public bool DeleteRole(UUID groupID, UUID roleID) | ||
170 | { | ||
171 | return m_Roles.Delete(new string[] { "GroupID", "RoleID" }, | ||
172 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
173 | } | ||
174 | |||
175 | public int RoleCount(UUID groupID) | ||
176 | { | ||
177 | return (int)m_Roles.GetCount("GroupID", groupID.ToString()); | ||
178 | } | ||
179 | |||
180 | |||
181 | #endregion | ||
182 | |||
183 | #region rolememberhip table | ||
184 | public RoleMembershipData[] RetrieveRolesMembers(UUID groupID) | ||
185 | { | ||
186 | RoleMembershipData[] data = m_RoleMembership.Get("GroupID", groupID.ToString()); | ||
187 | |||
188 | return data; | ||
189 | } | ||
190 | |||
191 | public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID) | ||
192 | { | ||
193 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID" }, | ||
194 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
195 | |||
196 | return data; | ||
197 | } | ||
198 | |||
199 | public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID) | ||
200 | { | ||
201 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "PrincipalID" }, | ||
202 | new string[] { groupID.ToString(), principalID.ToString() }); | ||
203 | |||
204 | return data; | ||
205 | } | ||
206 | |||
207 | public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID) | ||
208 | { | ||
209 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID", "PrincipalID" }, | ||
210 | new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() }); | ||
211 | |||
212 | if (data != null && data.Length > 0) | ||
213 | return data[0]; | ||
214 | |||
215 | return null; | ||
216 | } | ||
217 | |||
218 | public int RoleMemberCount(UUID groupID, UUID roleID) | ||
219 | { | ||
220 | return (int)m_RoleMembership.GetCount(new string[] { "GroupID", "RoleID" }, | ||
221 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
222 | } | ||
223 | |||
224 | public bool StoreRoleMember(RoleMembershipData data) | ||
225 | { | ||
226 | return m_RoleMembership.Store(data); | ||
227 | } | ||
228 | |||
229 | public bool DeleteRoleMember(RoleMembershipData data) | ||
230 | { | ||
231 | return m_RoleMembership.Delete(new string[] { "GroupID", "RoleID", "PrincipalID"}, | ||
232 | new string[] { data.GroupID.ToString(), data.RoleID.ToString(), data.PrincipalID }); | ||
233 | } | ||
234 | |||
235 | public bool DeleteMemberAllRoles(UUID groupID, string principalID) | ||
236 | { | ||
237 | return m_RoleMembership.Delete(new string[] { "GroupID", "PrincipalID" }, | ||
238 | new string[] { groupID.ToString(), principalID }); | ||
239 | } | ||
240 | |||
241 | #endregion | ||
242 | |||
243 | #region principals table | ||
244 | public bool StorePrincipal(PrincipalData data) | ||
245 | { | ||
246 | return m_Principals.Store(data); | ||
247 | } | ||
248 | |||
249 | public PrincipalData RetrievePrincipal(string principalID) | ||
250 | { | ||
251 | PrincipalData[] p = m_Principals.Get("PrincipalID", principalID); | ||
252 | if (p != null && p.Length > 0) | ||
253 | return p[0]; | ||
254 | |||
255 | return null; | ||
256 | } | ||
257 | |||
258 | public bool DeletePrincipal(string principalID) | ||
259 | { | ||
260 | return m_Principals.Delete("PrincipalID", principalID); | ||
261 | } | ||
262 | #endregion | ||
263 | |||
264 | #region invites table | ||
265 | |||
266 | public bool StoreInvitation(InvitationData data) | ||
267 | { | ||
268 | return m_Invites.Store(data); | ||
269 | } | ||
270 | |||
271 | public InvitationData RetrieveInvitation(UUID inviteID) | ||
272 | { | ||
273 | InvitationData[] invites = m_Invites.Get("InviteID", inviteID.ToString()); | ||
274 | |||
275 | if (invites != null && invites.Length > 0) | ||
276 | return invites[0]; | ||
277 | |||
278 | return null; | ||
279 | } | ||
280 | |||
281 | public InvitationData RetrieveInvitation(UUID groupID, string principalID) | ||
282 | { | ||
283 | InvitationData[] invites = m_Invites.Get(new string[] { "GroupID", "PrincipalID" }, | ||
284 | new string[] { groupID.ToString(), principalID }); | ||
285 | |||
286 | if (invites != null && invites.Length > 0) | ||
287 | return invites[0]; | ||
288 | |||
289 | return null; | ||
290 | } | ||
291 | |||
292 | public bool DeleteInvite(UUID inviteID) | ||
293 | { | ||
294 | return m_Invites.Delete("InviteID", inviteID.ToString()); | ||
295 | } | ||
296 | |||
297 | public void DeleteOldInvites() | ||
298 | { | ||
299 | m_Invites.DeleteOld(); | ||
300 | } | ||
301 | |||
302 | #endregion | ||
303 | |||
304 | #region notices table | ||
305 | |||
306 | public bool StoreNotice(NoticeData data) | ||
307 | { | ||
308 | return m_Notices.Store(data); | ||
309 | } | ||
310 | |||
311 | public NoticeData RetrieveNotice(UUID noticeID) | ||
312 | { | ||
313 | NoticeData[] notices = m_Notices.Get("NoticeID", noticeID.ToString()); | ||
314 | |||
315 | if (notices != null && notices.Length > 0) | ||
316 | return notices[0]; | ||
317 | |||
318 | return null; | ||
319 | } | ||
320 | |||
321 | public NoticeData[] RetrieveNotices(UUID groupID) | ||
322 | { | ||
323 | NoticeData[] notices = m_Notices.Get("GroupID", groupID.ToString()); | ||
324 | |||
325 | return notices; | ||
326 | } | ||
327 | |||
328 | public bool DeleteNotice(UUID noticeID) | ||
329 | { | ||
330 | return m_Notices.Delete("NoticeID", noticeID.ToString()); | ||
331 | } | ||
332 | |||
333 | public void DeleteOldNotices() | ||
334 | { | ||
335 | m_Notices.DeleteOld(); | ||
336 | } | ||
337 | |||
338 | #endregion | ||
339 | |||
340 | #region combinations | ||
341 | public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID) | ||
342 | { | ||
343 | // TODO | ||
344 | return null; | ||
345 | } | ||
346 | public MembershipData[] RetrievePrincipalGroupMemberships(string principalID) | ||
347 | { | ||
348 | // TODO | ||
349 | return null; | ||
350 | } | ||
351 | |||
352 | #endregion | ||
353 | } | ||
354 | |||
355 | public class MySqlGroupsGroupsHandler : MySQLGenericTableHandler<GroupData> | ||
356 | { | ||
357 | protected override Assembly Assembly | ||
358 | { | ||
359 | // WARNING! Moving migrations to this assembly!!! | ||
360 | get { return GetType().Assembly; } | ||
361 | } | ||
362 | |||
363 | public MySqlGroupsGroupsHandler(string connectionString, string realm, string store) | ||
364 | : base(connectionString, realm, store) | ||
365 | { | ||
366 | } | ||
367 | |||
368 | } | ||
369 | |||
370 | public class MySqlGroupsMembershipHandler : MySQLGenericTableHandler<MembershipData> | ||
371 | { | ||
372 | protected override Assembly Assembly | ||
373 | { | ||
374 | // WARNING! Moving migrations to this assembly!!! | ||
375 | get { return GetType().Assembly; } | ||
376 | } | ||
377 | |||
378 | public MySqlGroupsMembershipHandler(string connectionString, string realm) | ||
379 | : base(connectionString, realm, string.Empty) | ||
380 | { | ||
381 | } | ||
382 | |||
383 | } | ||
384 | |||
385 | public class MySqlGroupsRolesHandler : MySQLGenericTableHandler<RoleData> | ||
386 | { | ||
387 | protected override Assembly Assembly | ||
388 | { | ||
389 | // WARNING! Moving migrations to this assembly!!! | ||
390 | get { return GetType().Assembly; } | ||
391 | } | ||
392 | |||
393 | public MySqlGroupsRolesHandler(string connectionString, string realm) | ||
394 | : base(connectionString, realm, string.Empty) | ||
395 | { | ||
396 | } | ||
397 | |||
398 | } | ||
399 | |||
400 | public class MySqlGroupsRoleMembershipHandler : MySQLGenericTableHandler<RoleMembershipData> | ||
401 | { | ||
402 | protected override Assembly Assembly | ||
403 | { | ||
404 | // WARNING! Moving migrations to this assembly!!! | ||
405 | get { return GetType().Assembly; } | ||
406 | } | ||
407 | |||
408 | public MySqlGroupsRoleMembershipHandler(string connectionString, string realm) | ||
409 | : base(connectionString, realm, string.Empty) | ||
410 | { | ||
411 | } | ||
412 | |||
413 | } | ||
414 | |||
415 | public class MySqlGroupsInvitesHandler : MySQLGenericTableHandler<InvitationData> | ||
416 | { | ||
417 | protected override Assembly Assembly | ||
418 | { | ||
419 | // WARNING! Moving migrations to this assembly!!! | ||
420 | get { return GetType().Assembly; } | ||
421 | } | ||
422 | |||
423 | public MySqlGroupsInvitesHandler(string connectionString, string realm) | ||
424 | : base(connectionString, realm, string.Empty) | ||
425 | { | ||
426 | } | ||
427 | |||
428 | public void DeleteOld() | ||
429 | { | ||
430 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
431 | |||
432 | using (MySqlCommand cmd = new MySqlCommand()) | ||
433 | { | ||
434 | cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); | ||
435 | cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | ||
436 | |||
437 | ExecuteNonQuery(cmd); | ||
438 | } | ||
439 | |||
440 | } | ||
441 | } | ||
442 | |||
443 | public class MySqlGroupsNoticesHandler : MySQLGenericTableHandler<NoticeData> | ||
444 | { | ||
445 | protected override Assembly Assembly | ||
446 | { | ||
447 | // WARNING! Moving migrations to this assembly!!! | ||
448 | get { return GetType().Assembly; } | ||
449 | } | ||
450 | |||
451 | public MySqlGroupsNoticesHandler(string connectionString, string realm) | ||
452 | : base(connectionString, realm, string.Empty) | ||
453 | { | ||
454 | } | ||
455 | |||
456 | public void DeleteOld() | ||
457 | { | ||
458 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
459 | |||
460 | using (MySqlCommand cmd = new MySqlCommand()) | ||
461 | { | ||
462 | cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); | ||
463 | cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | ||
464 | |||
465 | ExecuteNonQuery(cmd); | ||
466 | } | ||
467 | |||
468 | } | ||
469 | } | ||
470 | |||
471 | public class MySqlGroupsPrincipalsHandler : MySQLGenericTableHandler<PrincipalData> | ||
472 | { | ||
473 | protected override Assembly Assembly | ||
474 | { | ||
475 | // WARNING! Moving migrations to this assembly!!! | ||
476 | get { return GetType().Assembly; } | ||
477 | } | ||
478 | |||
479 | public MySqlGroupsPrincipalsHandler(string connectionString, string realm) | ||
480 | : base(connectionString, realm, string.Empty) | ||
481 | { | ||
482 | } | ||
483 | } | ||
484 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLHGTravelData.cs b/OpenSim/Data/MySQL/MySQLHGTravelData.cs new file mode 100644 index 0000000..e81b880 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLHGTravelData.cs | |||
@@ -0,0 +1,80 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for user grid data | ||
42 | /// </summary> | ||
43 | public class MySQLHGTravelData : MySQLGenericTableHandler<HGTravelingData>, IHGTravelingData | ||
44 | { | ||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | public MySQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { } | ||
48 | |||
49 | public HGTravelingData Get(UUID sessionID) | ||
50 | { | ||
51 | HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); | ||
52 | |||
53 | if (ret.Length == 0) | ||
54 | return null; | ||
55 | |||
56 | return ret[0]; | ||
57 | } | ||
58 | |||
59 | public HGTravelingData[] GetSessions(UUID userID) | ||
60 | { | ||
61 | return base.Get("UserID", userID.ToString()); | ||
62 | } | ||
63 | |||
64 | public bool Delete(UUID sessionID) | ||
65 | { | ||
66 | return Delete("SessionID", sessionID.ToString()); | ||
67 | } | ||
68 | |||
69 | public void DeleteOld() | ||
70 | { | ||
71 | using (MySqlCommand cmd = new MySqlCommand()) | ||
72 | { | ||
73 | cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm); | ||
74 | |||
75 | ExecuteNonQuery(cmd); | ||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
80 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs new file mode 100644 index 0000000..bafd204 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs | |||
@@ -0,0 +1,59 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data.MySQL; | ||
35 | |||
36 | using OpenMetaverse; | ||
37 | using MySql.Data.MySqlClient; | ||
38 | |||
39 | namespace OpenSim.Data.MySQL | ||
40 | { | ||
41 | public class MySQLOfflineIMData : MySQLGenericTableHandler<OfflineIMData>, IOfflineIMData | ||
42 | { | ||
43 | public MySQLOfflineIMData(string connectionString, string realm) | ||
44 | : base(connectionString, realm, "IM_Store") | ||
45 | { | ||
46 | } | ||
47 | |||
48 | public void DeleteOld() | ||
49 | { | ||
50 | using (MySqlCommand cmd = new MySqlCommand()) | ||
51 | { | ||
52 | cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm); | ||
53 | |||
54 | ExecuteNonQuery(cmd); | ||
55 | } | ||
56 | |||
57 | } | ||
58 | } | ||
59 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a2d4ae4..2ad7590 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL | |||
310 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 310 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
311 | } | 311 | } |
312 | 312 | ||
313 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
314 | { | ||
315 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
316 | } | ||
317 | |||
313 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 318 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
314 | { | 319 | { |
315 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 320 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index d562783..bb0ab75 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -48,8 +48,18 @@ namespace OpenSim.Data.MySQL | |||
48 | public class MySQLSimulationData : ISimulationDataStore | 48 | public class MySQLSimulationData : ISimulationDataStore |
49 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | private static string LogHeader = "[REGION DB MYSQL]"; | ||
51 | 52 | ||
52 | private string m_connectionString; | 53 | private string m_connectionString; |
54 | |||
55 | /// <summary> | ||
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. | ||
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 | ||
60 | /// unrelated operations to block each other or unrelated operations on the same tables from blocking each | ||
61 | /// other. | ||
62 | /// </summary> | ||
53 | private object m_dbLock = new object(); | 63 | private object m_dbLock = new object(); |
54 | 64 | ||
55 | protected virtual Assembly Assembly | 65 | protected virtual Assembly Assembly |
@@ -91,7 +101,7 @@ namespace OpenSim.Data.MySQL | |||
91 | } | 101 | } |
92 | catch (Exception e) | 102 | catch (Exception e) |
93 | { | 103 | { |
94 | m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); | 104 | m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e); |
95 | throw; | 105 | throw; |
96 | } | 106 | } |
97 | 107 | ||
@@ -119,8 +129,10 @@ namespace OpenSim.Data.MySQL | |||
119 | 129 | ||
120 | // Eligibility check | 130 | // Eligibility check |
121 | // | 131 | // |
122 | if ((flags & (uint)PrimFlags.Temporary) != 0) | 132 | // PrimFlags.Temporary is not used in OpenSim code and cannot |
123 | return; | 133 | // be guaranteed to always be clear. Don't check it. |
134 | // if ((flags & (uint)PrimFlags.Temporary) != 0) | ||
135 | // return; | ||
124 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | 136 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) |
125 | return; | 137 | return; |
126 | 138 | ||
@@ -135,7 +147,7 @@ namespace OpenSim.Data.MySQL | |||
135 | foreach (SceneObjectPart prim in obj.Parts) | 147 | foreach (SceneObjectPart prim in obj.Parts) |
136 | { | 148 | { |
137 | cmd.Parameters.Clear(); | 149 | cmd.Parameters.Clear(); |
138 | 150 | ||
139 | cmd.CommandText = "replace into prims (" + | 151 | cmd.CommandText = "replace into prims (" + |
140 | "UUID, CreationDate, " + | 152 | "UUID, CreationDate, " + |
141 | "Name, Text, Description, " + | 153 | "Name, Text, Description, " + |
@@ -171,7 +183,11 @@ namespace OpenSim.Data.MySQL | |||
171 | "ParticleSystem, ClickAction, Material, " + | 183 | "ParticleSystem, ClickAction, Material, " + |
172 | "CollisionSound, CollisionSoundVolume, " + | 184 | "CollisionSound, CollisionSoundVolume, " + |
173 | "PassTouches, " + | 185 | "PassTouches, " + |
174 | "LinkNumber, MediaURL) values (" + "?UUID, " + | 186 | "LinkNumber, MediaURL, AttachedPosX, " + |
187 | "AttachedPosY, AttachedPosZ, KeyframeMotion, " + | ||
188 | "PhysicsShapeType, Density, GravityModifier, " + | ||
189 | "Friction, Restitution, DynAttrs " + | ||
190 | ") values (" + "?UUID, " + | ||
175 | "?CreationDate, ?Name, ?Text, " + | 191 | "?CreationDate, ?Name, ?Text, " + |
176 | "?Description, ?SitName, ?TouchName, " + | 192 | "?Description, ?SitName, ?TouchName, " + |
177 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + | 193 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
@@ -202,14 +218,18 @@ namespace OpenSim.Data.MySQL | |||
202 | "?SaleType, ?ColorR, ?ColorG, " + | 218 | "?SaleType, ?ColorR, ?ColorG, " + |
203 | "?ColorB, ?ColorA, ?ParticleSystem, " + | 219 | "?ColorB, ?ColorA, ?ParticleSystem, " + |
204 | "?ClickAction, ?Material, ?CollisionSound, " + | 220 | "?ClickAction, ?Material, ?CollisionSound, " + |
205 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; | 221 | "?CollisionSoundVolume, ?PassTouches, " + |
206 | 222 | "?LinkNumber, ?MediaURL, ?AttachedPosX, " + | |
223 | "?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " + | ||
224 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + | ||
225 | "?Friction, ?Restitution, ?DynAttrs)"; | ||
226 | |||
207 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 227 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); |
208 | 228 | ||
209 | ExecuteNonQuery(cmd); | 229 | ExecuteNonQuery(cmd); |
210 | 230 | ||
211 | cmd.Parameters.Clear(); | 231 | cmd.Parameters.Clear(); |
212 | 232 | ||
213 | cmd.CommandText = "replace into primshapes (" + | 233 | cmd.CommandText = "replace into primshapes (" + |
214 | "UUID, Shape, ScaleX, ScaleY, " + | 234 | "UUID, Shape, ScaleX, ScaleY, " + |
215 | "ScaleZ, PCode, PathBegin, PathEnd, " + | 235 | "ScaleZ, PCode, PathBegin, PathEnd, " + |
@@ -219,7 +239,8 @@ namespace OpenSim.Data.MySQL | |||
219 | "PathTaperX, PathTaperY, PathTwist, " + | 239 | "PathTaperX, PathTaperY, PathTwist, " + |
220 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + | 240 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + |
221 | "ProfileCurve, ProfileHollow, Texture, " + | 241 | "ProfileCurve, ProfileHollow, Texture, " + |
222 | "ExtraParams, State, Media) values (?UUID, " + | 242 | "ExtraParams, State, LastAttachPoint, Media) " + |
243 | "values (?UUID, " + | ||
223 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + | 244 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + |
224 | "?PCode, ?PathBegin, ?PathEnd, " + | 245 | "?PCode, ?PathBegin, ?PathEnd, " + |
225 | "?PathScaleX, ?PathScaleY, " + | 246 | "?PathScaleX, ?PathScaleY, " + |
@@ -230,10 +251,10 @@ namespace OpenSim.Data.MySQL | |||
230 | "?PathTwistBegin, ?ProfileBegin, " + | 251 | "?PathTwistBegin, ?ProfileBegin, " + |
231 | "?ProfileEnd, ?ProfileCurve, " + | 252 | "?ProfileEnd, ?ProfileCurve, " + |
232 | "?ProfileHollow, ?Texture, ?ExtraParams, " + | 253 | "?ProfileHollow, ?Texture, ?ExtraParams, " + |
233 | "?State, ?Media)"; | 254 | "?State, ?LastAttachPoint, ?Media)"; |
234 | 255 | ||
235 | FillShapeCommand(cmd, prim); | 256 | FillShapeCommand(cmd, prim); |
236 | 257 | ||
237 | ExecuteNonQuery(cmd); | 258 | ExecuteNonQuery(cmd); |
238 | } | 259 | } |
239 | } | 260 | } |
@@ -446,7 +467,9 @@ namespace OpenSim.Data.MySQL | |||
446 | foreach (SceneObjectPart prim in prims.Values) | 467 | foreach (SceneObjectPart prim in prims.Values) |
447 | { | 468 | { |
448 | if (prim.ParentUUID == UUID.Zero) | 469 | if (prim.ParentUUID == UUID.Zero) |
470 | { | ||
449 | objects[prim.UUID] = new SceneObjectGroup(prim); | 471 | objects[prim.UUID] = new SceneObjectGroup(prim); |
472 | } | ||
450 | } | 473 | } |
451 | 474 | ||
452 | // Add all of the children objects to the SOGs | 475 | // Add all of the children objects to the SOGs |
@@ -559,10 +582,14 @@ namespace OpenSim.Data.MySQL | |||
559 | } | 582 | } |
560 | } | 583 | } |
561 | 584 | ||
585 | // Legacy entry point for when terrain was always a 256x256 hieghtmap | ||
562 | public void StoreTerrain(double[,] ter, UUID regionID) | 586 | public void StoreTerrain(double[,] ter, UUID regionID) |
563 | { | 587 | { |
564 | m_log.Info("[REGION DB]: Storing terrain"); | 588 | StoreTerrain(new HeightmapTerrainData(ter), regionID); |
589 | } | ||
565 | 590 | ||
591 | public void StoreTerrain(TerrainData terrData, UUID regionID) | ||
592 | { | ||
566 | lock (m_dbLock) | 593 | lock (m_dbLock) |
567 | { | 594 | { |
568 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 595 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
@@ -576,11 +603,18 @@ namespace OpenSim.Data.MySQL | |||
576 | 603 | ||
577 | ExecuteNonQuery(cmd); | 604 | ExecuteNonQuery(cmd); |
578 | 605 | ||
579 | cmd.CommandText = "insert into terrain (RegionUUID, " + | 606 | int terrainDBRevision; |
580 | "Revision, Heightfield) values (?RegionUUID, " + | 607 | Array terrainDBblob; |
581 | "1, ?Heightfield)"; | 608 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); |
609 | |||
610 | m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}", | ||
611 | LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision); | ||
582 | 612 | ||
583 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | 613 | cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" |
614 | + "values (?RegionUUID, ?Revision, ?Heightfield)"; | ||
615 | |||
616 | cmd.Parameters.AddWithValue("Revision", terrainDBRevision); | ||
617 | cmd.Parameters.AddWithValue("Heightfield", terrainDBblob); | ||
584 | 618 | ||
585 | ExecuteNonQuery(cmd); | 619 | ExecuteNonQuery(cmd); |
586 | } | 620 | } |
@@ -588,9 +622,20 @@ namespace OpenSim.Data.MySQL | |||
588 | } | 622 | } |
589 | } | 623 | } |
590 | 624 | ||
625 | // Legacy region loading | ||
591 | public double[,] LoadTerrain(UUID regionID) | 626 | public double[,] LoadTerrain(UUID regionID) |
592 | { | 627 | { |
593 | double[,] terrain = null; | 628 | double[,] ret = null; |
629 | TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); | ||
630 | if (terrData != null) | ||
631 | ret = terrData.GetDoubles(); | ||
632 | return ret; | ||
633 | } | ||
634 | |||
635 | // Returns 'null' if region not found | ||
636 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
637 | { | ||
638 | TerrainData terrData = null; | ||
594 | 639 | ||
595 | lock (m_dbLock) | 640 | lock (m_dbLock) |
596 | { | 641 | { |
@@ -610,32 +655,15 @@ namespace OpenSim.Data.MySQL | |||
610 | while (reader.Read()) | 655 | while (reader.Read()) |
611 | { | 656 | { |
612 | int rev = Convert.ToInt32(reader["Revision"]); | 657 | int rev = Convert.ToInt32(reader["Revision"]); |
613 | 658 | byte[] blob = (byte[])reader["Heightfield"]; | |
614 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 659 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); |
615 | terrain.Initialize(); | ||
616 | |||
617 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) | ||
618 | { | ||
619 | using (BinaryReader br = new BinaryReader(mstr)) | ||
620 | { | ||
621 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
622 | { | ||
623 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
624 | { | ||
625 | terrain[x, y] = br.ReadDouble(); | ||
626 | } | ||
627 | } | ||
628 | } | ||
629 | |||
630 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); | ||
631 | } | ||
632 | } | 660 | } |
633 | } | 661 | } |
634 | } | 662 | } |
635 | } | 663 | } |
636 | } | 664 | } |
637 | 665 | ||
638 | return terrain; | 666 | return terrData; |
639 | } | 667 | } |
640 | 668 | ||
641 | public void RemoveLandObject(UUID globalID) | 669 | public void RemoveLandObject(UUID globalID) |
@@ -676,7 +704,7 @@ namespace OpenSim.Data.MySQL | |||
676 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | 704 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + |
677 | "UserLocationX, UserLocationY, UserLocationZ, " + | 705 | "UserLocationX, UserLocationY, UserLocationZ, " + |
678 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | 706 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + |
679 | "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + | 707 | "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + |
680 | "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + | 708 | "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + |
681 | "?UUID, ?RegionUUID, " + | 709 | "?UUID, ?RegionUUID, " + |
682 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + | 710 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + |
@@ -687,7 +715,7 @@ namespace OpenSim.Data.MySQL | |||
687 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | 715 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + |
688 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | 716 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + |
689 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | 717 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + |
690 | "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ | 718 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ |
691 | "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; | 719 | "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; |
692 | 720 | ||
693 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | 721 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); |
@@ -719,95 +747,92 @@ namespace OpenSim.Data.MySQL | |||
719 | RegionLightShareData nWP = new RegionLightShareData(); | 747 | RegionLightShareData nWP = new RegionLightShareData(); |
720 | nWP.OnSave += StoreRegionWindlightSettings; | 748 | nWP.OnSave += StoreRegionWindlightSettings; |
721 | 749 | ||
722 | lock (m_dbLock) | 750 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
723 | { | 751 | { |
724 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 752 | dbcon.Open(); |
753 | |||
754 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
755 | |||
756 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
725 | { | 757 | { |
726 | dbcon.Open(); | 758 | cmd.Connection = dbcon; |
727 | 759 | ||
728 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | 760 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); |
729 | 761 | ||
730 | using (MySqlCommand cmd = new MySqlCommand(command)) | 762 | IDataReader result = ExecuteReader(cmd); |
763 | if (!result.Read()) | ||
731 | { | 764 | { |
732 | cmd.Connection = dbcon; | 765 | //No result, so store our default windlight profile and return it |
733 | 766 | nWP.regionID = regionUUID; | |
734 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | 767 | // StoreRegionWindlightSettings(nWP); |
735 | 768 | return nWP; | |
736 | IDataReader result = ExecuteReader(cmd); | 769 | } |
737 | if (!result.Read()) | 770 | else |
738 | { | 771 | { |
739 | //No result, so store our default windlight profile and return it | 772 | nWP.regionID = DBGuid.FromDB(result["region_id"]); |
740 | nWP.regionID = regionUUID; | 773 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); |
741 | StoreRegionWindlightSettings(nWP); | 774 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); |
742 | return nWP; | 775 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); |
743 | } | 776 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); |
744 | else | 777 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); |
745 | { | 778 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); |
746 | nWP.regionID = DBGuid.FromDB(result["region_id"]); | 779 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); |
747 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | 780 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); |
748 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | 781 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); |
749 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | 782 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); |
750 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | 783 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); |
751 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | 784 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); |
752 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | 785 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); |
753 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | 786 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); |
754 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | 787 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); |
755 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | 788 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); |
756 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | 789 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); |
757 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | 790 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); |
758 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | 791 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); |
759 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | 792 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); |
760 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | 793 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); |
761 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | 794 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); |
762 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | 795 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); |
763 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | 796 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); |
764 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | 797 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); |
765 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | 798 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); |
766 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | 799 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); |
767 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | 800 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); |
768 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | 801 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); |
769 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | 802 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); |
770 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | 803 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); |
771 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | 804 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); |
772 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | 805 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); |
773 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | 806 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); |
774 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | 807 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); |
775 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | 808 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); |
776 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | 809 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); |
777 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | 810 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); |
778 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | 811 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); |
779 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | 812 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); |
780 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | 813 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); |
781 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | 814 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); |
782 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | 815 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); |
783 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | 816 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); |
784 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | 817 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); |
785 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | 818 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); |
786 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | 819 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); |
787 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | 820 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); |
788 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | 821 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); |
789 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | 822 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); |
790 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | 823 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); |
791 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | 824 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); |
792 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | 825 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); |
793 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | 826 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); |
794 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | 827 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); |
795 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | 828 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); |
796 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | 829 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); |
797 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | 830 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); |
798 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | 831 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); |
799 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | 832 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); |
800 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | 833 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); |
801 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | 834 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); |
802 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | 835 | nWP.valid = true; |
803 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | ||
804 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | ||
805 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | ||
806 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | ||
807 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | ||
808 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | ||
809 | nWP.valid = true; | ||
810 | } | ||
811 | } | 836 | } |
812 | } | 837 | } |
813 | } | 838 | } |
@@ -857,124 +882,118 @@ namespace OpenSim.Data.MySQL | |||
857 | 882 | ||
858 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | 883 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
859 | { | 884 | { |
860 | lock (m_dbLock) | 885 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
861 | { | 886 | { |
862 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 887 | dbcon.Open(); |
888 | |||
889 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
863 | { | 890 | { |
864 | dbcon.Open(); | 891 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; |
865 | 892 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | |
866 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 893 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; |
867 | { | 894 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; |
868 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; | 895 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; |
869 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | 896 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; |
870 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; | 897 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; |
871 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; | 898 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; |
872 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; | 899 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; |
873 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; | 900 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; |
874 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; | 901 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; |
875 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; | 902 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; |
876 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; | 903 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; |
877 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; | 904 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; |
878 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; | 905 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; |
879 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; | 906 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; |
880 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; | 907 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; |
881 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; | 908 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; |
882 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; | 909 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; |
883 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; | 910 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; |
884 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; | 911 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; |
885 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; | 912 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; |
886 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; | 913 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; |
887 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; | 914 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; |
888 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; | 915 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; |
889 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | 916 | |
890 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; | 917 | cmd.Parameters.AddWithValue("region_id", wl.regionID); |
891 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; | 918 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); |
892 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; | 919 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); |
893 | 920 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | |
894 | cmd.Parameters.AddWithValue("region_id", wl.regionID); | 921 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); |
895 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); | 922 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); |
896 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); | 923 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); |
897 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | 924 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); |
898 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); | 925 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); |
899 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); | 926 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); |
900 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); | 927 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); |
901 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); | 928 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); |
902 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); | 929 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); |
903 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); | 930 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); |
904 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); | 931 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); |
905 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); | 932 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); |
906 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); | 933 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); |
907 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); | 934 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); |
908 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); | 935 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); |
909 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); | 936 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); |
910 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); | 937 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); |
911 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); | 938 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); |
912 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); | 939 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); |
913 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); | 940 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); |
914 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); | 941 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); |
915 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); | 942 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); |
916 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); | 943 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); |
917 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); | 944 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); |
918 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); | 945 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); |
919 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); | 946 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); |
920 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); | 947 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); |
921 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); | 948 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); |
922 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); | 949 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); |
923 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); | 950 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); |
924 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); | 951 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); |
925 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); | 952 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); |
926 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); | 953 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); |
927 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); | 954 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); |
928 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); | 955 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); |
929 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); | 956 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); |
930 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); | 957 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); |
931 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); | 958 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); |
932 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); | 959 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); |
933 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); | 960 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); |
934 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); | 961 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); |
935 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); | 962 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); |
936 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); | 963 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); |
937 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); | 964 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); |
938 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); | 965 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); |
939 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); | 966 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); |
940 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); | 967 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); |
941 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); | 968 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); |
942 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); | 969 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); |
943 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); | 970 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); |
944 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); | 971 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); |
945 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); | 972 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); |
946 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); | 973 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); |
947 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); | 974 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); |
948 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); | 975 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); |
949 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); | 976 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); |
950 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); | 977 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); |
951 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); | 978 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); |
952 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); | 979 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); |
953 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | 980 | |
954 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); | 981 | ExecuteNonQuery(cmd); |
955 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | ||
956 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | ||
957 | |||
958 | ExecuteNonQuery(cmd); | ||
959 | } | ||
960 | } | 982 | } |
961 | } | 983 | } |
962 | } | 984 | } |
963 | 985 | ||
964 | public void RemoveRegionWindlightSettings(UUID regionID) | 986 | public void RemoveRegionWindlightSettings(UUID regionID) |
965 | { | 987 | { |
966 | lock (m_dbLock) | 988 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
967 | { | 989 | { |
968 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 990 | dbcon.Open(); |
991 | |||
992 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
969 | { | 993 | { |
970 | dbcon.Open(); | 994 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; |
971 | 995 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | |
972 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 996 | ExecuteNonQuery(cmd); |
973 | { | ||
974 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; | ||
975 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
976 | ExecuteNonQuery(cmd); | ||
977 | } | ||
978 | } | 997 | } |
979 | } | 998 | } |
980 | } | 999 | } |
@@ -982,29 +1001,26 @@ namespace OpenSim.Data.MySQL | |||
982 | #region RegionEnvironmentSettings | 1001 | #region RegionEnvironmentSettings |
983 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1002 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
984 | { | 1003 | { |
985 | lock (m_dbLock) | 1004 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
986 | { | 1005 | { |
987 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1006 | dbcon.Open(); |
1007 | |||
1008 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | ||
1009 | |||
1010 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
988 | { | 1011 | { |
989 | dbcon.Open(); | 1012 | cmd.Connection = dbcon; |
990 | 1013 | ||
991 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | 1014 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); |
992 | 1015 | ||
993 | using (MySqlCommand cmd = new MySqlCommand(command)) | 1016 | IDataReader result = ExecuteReader(cmd); |
1017 | if (!result.Read()) | ||
994 | { | 1018 | { |
995 | cmd.Connection = dbcon; | 1019 | return String.Empty; |
996 | 1020 | } | |
997 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1021 | else |
998 | 1022 | { | |
999 | IDataReader result = ExecuteReader(cmd); | 1023 | return Convert.ToString(result["llsd_settings"]); |
1000 | if (!result.Read()) | ||
1001 | { | ||
1002 | return String.Empty; | ||
1003 | } | ||
1004 | else | ||
1005 | { | ||
1006 | return Convert.ToString(result["llsd_settings"]); | ||
1007 | } | ||
1008 | } | 1024 | } |
1009 | } | 1025 | } |
1010 | } | 1026 | } |
@@ -1012,39 +1028,33 @@ namespace OpenSim.Data.MySQL | |||
1012 | 1028 | ||
1013 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1029 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1014 | { | 1030 | { |
1015 | lock (m_dbLock) | 1031 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1016 | { | 1032 | { |
1017 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1033 | dbcon.Open(); |
1034 | |||
1035 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1018 | { | 1036 | { |
1019 | dbcon.Open(); | 1037 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; |
1020 | 1038 | ||
1021 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1039 | cmd.Parameters.AddWithValue("region_id", regionUUID); |
1022 | { | 1040 | cmd.Parameters.AddWithValue("llsd_settings", settings); |
1023 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | 1041 | |
1024 | 1042 | ExecuteNonQuery(cmd); | |
1025 | cmd.Parameters.AddWithValue("region_id", regionUUID); | ||
1026 | cmd.Parameters.AddWithValue("llsd_settings", settings); | ||
1027 | |||
1028 | ExecuteNonQuery(cmd); | ||
1029 | } | ||
1030 | } | 1043 | } |
1031 | } | 1044 | } |
1032 | } | 1045 | } |
1033 | 1046 | ||
1034 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1047 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1035 | { | 1048 | { |
1036 | lock (m_dbLock) | 1049 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1037 | { | 1050 | { |
1038 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1051 | dbcon.Open(); |
1052 | |||
1053 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1039 | { | 1054 | { |
1040 | dbcon.Open(); | 1055 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; |
1041 | 1056 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | |
1042 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1057 | ExecuteNonQuery(cmd); |
1043 | { | ||
1044 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | ||
1045 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1046 | ExecuteNonQuery(cmd); | ||
1047 | } | ||
1048 | } | 1058 | } |
1049 | } | 1059 | } |
1050 | } | 1060 | } |
@@ -1052,56 +1062,55 @@ namespace OpenSim.Data.MySQL | |||
1052 | 1062 | ||
1053 | public void StoreRegionSettings(RegionSettings rs) | 1063 | public void StoreRegionSettings(RegionSettings rs) |
1054 | { | 1064 | { |
1055 | lock (m_dbLock) | 1065 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1056 | { | 1066 | { |
1057 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1067 | dbcon.Open(); |
1058 | { | ||
1059 | dbcon.Open(); | ||
1060 | |||
1061 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1062 | { | ||
1063 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | ||
1064 | "block_terraform, block_fly, allow_damage, " + | ||
1065 | "restrict_pushing, allow_land_resell, " + | ||
1066 | "allow_land_join_divide, block_show_in_search, " + | ||
1067 | "agent_limit, object_bonus, maturity, " + | ||
1068 | "disable_scripts, disable_collisions, " + | ||
1069 | "disable_physics, terrain_texture_1, " + | ||
1070 | "terrain_texture_2, terrain_texture_3, " + | ||
1071 | "terrain_texture_4, elevation_1_nw, " + | ||
1072 | "elevation_2_nw, elevation_1_ne, " + | ||
1073 | "elevation_2_ne, elevation_1_se, " + | ||
1074 | "elevation_2_se, elevation_1_sw, " + | ||
1075 | "elevation_2_sw, water_height, " + | ||
1076 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1077 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1078 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1079 | "sunvectorz, loaded_creation_datetime, " + | ||
1080 | "loaded_creation_id, map_tile_ID, " + | ||
1081 | "TelehubObject, parcel_tile_ID) " + | ||
1082 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1083 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1084 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1085 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1086 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1087 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1088 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1089 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1090 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1091 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1092 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1093 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1094 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1095 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1096 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1097 | "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; | ||
1098 | |||
1099 | FillRegionSettingsCommand(cmd, rs); | ||
1100 | 1068 | ||
1101 | ExecuteNonQuery(cmd); | 1069 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1102 | } | 1070 | { |
1071 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | ||
1072 | "block_terraform, block_fly, allow_damage, " + | ||
1073 | "restrict_pushing, allow_land_resell, " + | ||
1074 | "allow_land_join_divide, block_show_in_search, " + | ||
1075 | "agent_limit, object_bonus, maturity, " + | ||
1076 | "disable_scripts, disable_collisions, " + | ||
1077 | "disable_physics, terrain_texture_1, " + | ||
1078 | "terrain_texture_2, terrain_texture_3, " + | ||
1079 | "terrain_texture_4, elevation_1_nw, " + | ||
1080 | "elevation_2_nw, elevation_1_ne, " + | ||
1081 | "elevation_2_ne, elevation_1_se, " + | ||
1082 | "elevation_2_se, elevation_1_sw, " + | ||
1083 | "elevation_2_sw, water_height, " + | ||
1084 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1085 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1086 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1087 | "sunvectorz, loaded_creation_datetime, " + | ||
1088 | "loaded_creation_id, map_tile_ID, " + | ||
1089 | "TelehubObject, parcel_tile_ID) " + | ||
1090 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1091 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1092 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1093 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1094 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1095 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1096 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1097 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1098 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1099 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1100 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1101 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1102 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1103 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1104 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1105 | "?TerrainImageID, " + | ||
1106 | "?TelehubObject, ?ParcelImageID)"; | ||
1107 | |||
1108 | FillRegionSettingsCommand(cmd, rs); | ||
1109 | |||
1110 | ExecuteNonQuery(cmd); | ||
1103 | } | 1111 | } |
1104 | } | 1112 | } |
1113 | |||
1105 | SaveSpawnPoints(rs); | 1114 | SaveSpawnPoints(rs); |
1106 | } | 1115 | } |
1107 | 1116 | ||
@@ -1292,6 +1301,39 @@ namespace OpenSim.Data.MySQL | |||
1292 | if (!(row["MediaURL"] is System.DBNull)) | 1301 | if (!(row["MediaURL"] is System.DBNull)) |
1293 | prim.MediaUrl = (string)row["MediaURL"]; | 1302 | prim.MediaUrl = (string)row["MediaURL"]; |
1294 | 1303 | ||
1304 | if (!(row["AttachedPosX"] is System.DBNull)) | ||
1305 | { | ||
1306 | prim.AttachedPos = new Vector3( | ||
1307 | (float)(double)row["AttachedPosX"], | ||
1308 | (float)(double)row["AttachedPosY"], | ||
1309 | (float)(double)row["AttachedPosZ"] | ||
1310 | ); | ||
1311 | } | ||
1312 | |||
1313 | if (!(row["DynAttrs"] is System.DBNull)) | ||
1314 | prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); | ||
1315 | else | ||
1316 | prim.DynAttrs = new DAMap(); | ||
1317 | |||
1318 | if (!(row["KeyframeMotion"] is DBNull)) | ||
1319 | { | ||
1320 | Byte[] data = (byte[])row["KeyframeMotion"]; | ||
1321 | if (data.Length > 0) | ||
1322 | prim.KeyframeMotion = KeyframeMotion.FromData(null, data); | ||
1323 | else | ||
1324 | prim.KeyframeMotion = null; | ||
1325 | } | ||
1326 | else | ||
1327 | { | ||
1328 | prim.KeyframeMotion = null; | ||
1329 | } | ||
1330 | |||
1331 | prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString()); | ||
1332 | prim.Density = (float)(double)row["Density"]; | ||
1333 | prim.GravityModifier = (float)(double)row["GravityModifier"]; | ||
1334 | prim.Friction = (float)(double)row["Friction"]; | ||
1335 | prim.Restitution = (float)(double)row["Restitution"]; | ||
1336 | |||
1295 | return prim; | 1337 | return prim; |
1296 | } | 1338 | } |
1297 | 1339 | ||
@@ -1431,6 +1473,7 @@ namespace OpenSim.Data.MySQL | |||
1431 | UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); | 1473 | UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); |
1432 | UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); | 1474 | UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); |
1433 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); | 1475 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); |
1476 | newData.Dwell = Convert.ToSingle(row["Dwell"]); | ||
1434 | 1477 | ||
1435 | newData.AuthBuyerID = authedbuyer; | 1478 | newData.AuthBuyerID = authedbuyer; |
1436 | newData.SnapshotID = snapshotID; | 1479 | newData.SnapshotID = snapshotID; |
@@ -1478,30 +1521,6 @@ namespace OpenSim.Data.MySQL | |||
1478 | } | 1521 | } |
1479 | 1522 | ||
1480 | /// <summary> | 1523 | /// <summary> |
1481 | /// | ||
1482 | /// </summary> | ||
1483 | /// <param name="val"></param> | ||
1484 | /// <returns></returns> | ||
1485 | private static Array SerializeTerrain(double[,] val) | ||
1486 | { | ||
1487 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); | ||
1488 | BinaryWriter bw = new BinaryWriter(str); | ||
1489 | |||
1490 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1491 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1492 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1493 | { | ||
1494 | double height = val[x, y]; | ||
1495 | if (height == 0.0) | ||
1496 | height = double.Epsilon; | ||
1497 | |||
1498 | bw.Write(height); | ||
1499 | } | ||
1500 | |||
1501 | return str.ToArray(); | ||
1502 | } | ||
1503 | |||
1504 | /// <summary> | ||
1505 | /// Fill the prim command with prim values | 1524 | /// Fill the prim command with prim values |
1506 | /// </summary> | 1525 | /// </summary> |
1507 | /// <param name="row"></param> | 1526 | /// <param name="row"></param> |
@@ -1637,6 +1656,28 @@ namespace OpenSim.Data.MySQL | |||
1637 | 1656 | ||
1638 | cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); | 1657 | cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); |
1639 | cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); | 1658 | cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); |
1659 | if (prim.AttachedPos != null) | ||
1660 | { | ||
1661 | cmd.Parameters.AddWithValue("AttachedPosX", (double)prim.AttachedPos.X); | ||
1662 | cmd.Parameters.AddWithValue("AttachedPosY", (double)prim.AttachedPos.Y); | ||
1663 | cmd.Parameters.AddWithValue("AttachedPosZ", (double)prim.AttachedPos.Z); | ||
1664 | } | ||
1665 | |||
1666 | if (prim.KeyframeMotion != null) | ||
1667 | cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize()); | ||
1668 | else | ||
1669 | cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); | ||
1670 | |||
1671 | if (prim.DynAttrs.CountNamespaces > 0) | ||
1672 | cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); | ||
1673 | else | ||
1674 | cmd.Parameters.AddWithValue("DynAttrs", null); | ||
1675 | |||
1676 | cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType); | ||
1677 | cmd.Parameters.AddWithValue("Density", (double)prim.Density); | ||
1678 | cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); | ||
1679 | cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); | ||
1680 | cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution); | ||
1640 | } | 1681 | } |
1641 | 1682 | ||
1642 | /// <summary> | 1683 | /// <summary> |
@@ -1715,6 +1756,7 @@ namespace OpenSim.Data.MySQL | |||
1715 | cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); | 1756 | cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); |
1716 | cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); | 1757 | cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); |
1717 | cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); | 1758 | cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); |
1759 | |||
1718 | cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); | 1760 | cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); |
1719 | cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); | 1761 | cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); |
1720 | } | 1762 | } |
@@ -1763,6 +1805,7 @@ namespace OpenSim.Data.MySQL | |||
1763 | cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); | 1805 | cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); |
1764 | cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); | 1806 | cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); |
1765 | cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); | 1807 | cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); |
1808 | cmd.Parameters.AddWithValue("Dwell", land.Dwell); | ||
1766 | cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); | 1809 | cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); |
1767 | cmd.Parameters.AddWithValue("MediaType", land.MediaType); | 1810 | cmd.Parameters.AddWithValue("MediaType", land.MediaType); |
1768 | cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); | 1811 | cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); |
@@ -1770,7 +1813,6 @@ namespace OpenSim.Data.MySQL | |||
1770 | cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); | 1813 | cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); |
1771 | cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); | 1814 | cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); |
1772 | cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); | 1815 | cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); |
1773 | |||
1774 | } | 1816 | } |
1775 | 1817 | ||
1776 | /// <summary> | 1818 | /// <summary> |
@@ -1826,6 +1868,7 @@ namespace OpenSim.Data.MySQL | |||
1826 | s.ExtraParams = (byte[])row["ExtraParams"]; | 1868 | s.ExtraParams = (byte[])row["ExtraParams"]; |
1827 | 1869 | ||
1828 | s.State = (byte)(int)row["State"]; | 1870 | s.State = (byte)(int)row["State"]; |
1871 | s.LastAttachPoint = (byte)(int)row["LastAttachPoint"]; | ||
1829 | 1872 | ||
1830 | if (!(row["Media"] is System.DBNull)) | 1873 | if (!(row["Media"] is System.DBNull)) |
1831 | s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); | 1874 | s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); |
@@ -1872,6 +1915,7 @@ namespace OpenSim.Data.MySQL | |||
1872 | cmd.Parameters.AddWithValue("Texture", s.TextureEntry); | 1915 | cmd.Parameters.AddWithValue("Texture", s.TextureEntry); |
1873 | cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); | 1916 | cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); |
1874 | cmd.Parameters.AddWithValue("State", s.State); | 1917 | cmd.Parameters.AddWithValue("State", s.State); |
1918 | cmd.Parameters.AddWithValue("LastAttachPoint", s.LastAttachPoint); | ||
1875 | cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); | 1919 | cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); |
1876 | } | 1920 | } |
1877 | 1921 | ||
@@ -1988,41 +2032,35 @@ namespace OpenSim.Data.MySQL | |||
1988 | 2032 | ||
1989 | public void SaveExtra(UUID regionID, string name, string val) | 2033 | public void SaveExtra(UUID regionID, string name, string val) |
1990 | { | 2034 | { |
1991 | lock (m_dbLock) | 2035 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1992 | { | 2036 | { |
1993 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2037 | dbcon.Open(); |
1994 | { | ||
1995 | dbcon.Open(); | ||
1996 | 2038 | ||
1997 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2039 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1998 | { | 2040 | { |
1999 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; | 2041 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; |
2000 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2042 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2001 | cmd.Parameters.AddWithValue("?Name", name); | 2043 | cmd.Parameters.AddWithValue("?Name", name); |
2002 | cmd.Parameters.AddWithValue("?value", val); | 2044 | cmd.Parameters.AddWithValue("?value", val); |
2003 | 2045 | ||
2004 | cmd.ExecuteNonQuery(); | 2046 | cmd.ExecuteNonQuery(); |
2005 | } | ||
2006 | } | 2047 | } |
2007 | } | 2048 | } |
2008 | } | 2049 | } |
2009 | 2050 | ||
2010 | public void RemoveExtra(UUID regionID, string name) | 2051 | public void RemoveExtra(UUID regionID, string name) |
2011 | { | 2052 | { |
2012 | lock (m_dbLock) | 2053 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2013 | { | 2054 | { |
2014 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2055 | dbcon.Open(); |
2015 | { | ||
2016 | dbcon.Open(); | ||
2017 | 2056 | ||
2018 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2057 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2019 | { | 2058 | { |
2020 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; | 2059 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; |
2021 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2060 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2022 | cmd.Parameters.AddWithValue("?Name", name); | 2061 | cmd.Parameters.AddWithValue("?Name", name); |
2023 | 2062 | ||
2024 | cmd.ExecuteNonQuery(); | 2063 | cmd.ExecuteNonQuery(); |
2025 | } | ||
2026 | } | 2064 | } |
2027 | } | 2065 | } |
2028 | } | 2066 | } |
@@ -2031,22 +2069,19 @@ namespace OpenSim.Data.MySQL | |||
2031 | { | 2069 | { |
2032 | Dictionary<string, string> ret = new Dictionary<string, string>(); | 2070 | Dictionary<string, string> ret = new Dictionary<string, string>(); |
2033 | 2071 | ||
2034 | lock (m_dbLock) | 2072 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2035 | { | 2073 | { |
2036 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2074 | dbcon.Open(); |
2037 | { | ||
2038 | dbcon.Open(); | ||
2039 | 2075 | ||
2040 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2076 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2077 | { | ||
2078 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | ||
2079 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2080 | using (IDataReader r = cmd.ExecuteReader()) | ||
2041 | { | 2081 | { |
2042 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | 2082 | while (r.Read()) |
2043 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2044 | using (IDataReader r = cmd.ExecuteReader()) | ||
2045 | { | 2083 | { |
2046 | while (r.Read()) | 2084 | ret[r["Name"].ToString()] = r["value"].ToString(); |
2047 | { | ||
2048 | ret[r["Name"].ToString()] = r["value"].ToString(); | ||
2049 | } | ||
2050 | } | 2085 | } |
2051 | } | 2086 | } |
2052 | } | 2087 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs new file mode 100644 index 0000000..b35595d --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -0,0 +1,1086 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Data; | ||
30 | using System.Reflection; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Framework; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class UserProfilesData: IProfilesData | ||
41 | { | ||
42 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | #region Properites | ||
45 | string ConnectionString | ||
46 | { | ||
47 | get; set; | ||
48 | } | ||
49 | |||
50 | protected virtual Assembly Assembly | ||
51 | { | ||
52 | get { return GetType().Assembly; } | ||
53 | } | ||
54 | |||
55 | #endregion Properties | ||
56 | |||
57 | #region class Member Functions | ||
58 | public UserProfilesData(string connectionString) | ||
59 | { | ||
60 | ConnectionString = connectionString; | ||
61 | Init(); | ||
62 | } | ||
63 | |||
64 | void Init() | ||
65 | { | ||
66 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
67 | { | ||
68 | dbcon.Open(); | ||
69 | |||
70 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); | ||
71 | m.Update(); | ||
72 | } | ||
73 | } | ||
74 | #endregion Member Functions | ||
75 | |||
76 | #region Classifieds Queries | ||
77 | /// <summary> | ||
78 | /// Gets the classified records. | ||
79 | /// </summary> | ||
80 | /// <returns> | ||
81 | /// Array of classified records | ||
82 | /// </returns> | ||
83 | /// <param name='creatorId'> | ||
84 | /// Creator identifier. | ||
85 | /// </param> | ||
86 | public OSDArray GetClassifiedRecords(UUID creatorId) | ||
87 | { | ||
88 | OSDArray data = new OSDArray(); | ||
89 | |||
90 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
91 | { | ||
92 | string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; | ||
93 | dbcon.Open(); | ||
94 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
95 | { | ||
96 | cmd.Parameters.AddWithValue("?Id", creatorId); | ||
97 | using( MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) | ||
98 | { | ||
99 | if(reader.HasRows) | ||
100 | { | ||
101 | while (reader.Read()) | ||
102 | { | ||
103 | OSDMap n = new OSDMap(); | ||
104 | UUID Id = UUID.Zero; | ||
105 | |||
106 | string Name = null; | ||
107 | try | ||
108 | { | ||
109 | UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id); | ||
110 | Name = Convert.ToString(reader["name"]); | ||
111 | } | ||
112 | catch (Exception e) | ||
113 | { | ||
114 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
115 | ": UserAccount exception {0}", e.Message); | ||
116 | } | ||
117 | n.Add("classifieduuid", OSD.FromUUID(Id)); | ||
118 | n.Add("name", OSD.FromString(Name)); | ||
119 | data.Add(n); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | return data; | ||
126 | } | ||
127 | |||
128 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | ||
129 | { | ||
130 | string query = string.Empty; | ||
131 | |||
132 | |||
133 | query += "INSERT INTO classifieds ("; | ||
134 | query += "`classifieduuid`,"; | ||
135 | query += "`creatoruuid`,"; | ||
136 | query += "`creationdate`,"; | ||
137 | query += "`expirationdate`,"; | ||
138 | query += "`category`,"; | ||
139 | query += "`name`,"; | ||
140 | query += "`description`,"; | ||
141 | query += "`parceluuid`,"; | ||
142 | query += "`parentestate`,"; | ||
143 | query += "`snapshotuuid`,"; | ||
144 | query += "`simname`,"; | ||
145 | query += "`posglobal`,"; | ||
146 | query += "`parcelname`,"; | ||
147 | query += "`classifiedflags`,"; | ||
148 | query += "`priceforlisting`) "; | ||
149 | query += "VALUES ("; | ||
150 | query += "?ClassifiedId,"; | ||
151 | query += "?CreatorId,"; | ||
152 | query += "?CreatedDate,"; | ||
153 | query += "?ExpirationDate,"; | ||
154 | query += "?Category,"; | ||
155 | query += "?Name,"; | ||
156 | query += "?Description,"; | ||
157 | query += "?ParcelId,"; | ||
158 | query += "?ParentEstate,"; | ||
159 | query += "?SnapshotId,"; | ||
160 | query += "?SimName,"; | ||
161 | query += "?GlobalPos,"; | ||
162 | query += "?ParcelName,"; | ||
163 | query += "?Flags,"; | ||
164 | query += "?ListingPrice ) "; | ||
165 | query += "ON DUPLICATE KEY UPDATE "; | ||
166 | query += "category=?Category, "; | ||
167 | query += "expirationdate=?ExpirationDate, "; | ||
168 | query += "name=?Name, "; | ||
169 | query += "description=?Description, "; | ||
170 | query += "parentestate=?ParentEstate, "; | ||
171 | query += "posglobal=?GlobalPos, "; | ||
172 | query += "parcelname=?ParcelName, "; | ||
173 | query += "classifiedflags=?Flags, "; | ||
174 | query += "priceforlisting=?ListingPrice, "; | ||
175 | query += "snapshotuuid=?SnapshotId"; | ||
176 | |||
177 | if(string.IsNullOrEmpty(ad.ParcelName)) | ||
178 | ad.ParcelName = "Unknown"; | ||
179 | if(ad.ParcelId == null) | ||
180 | ad.ParcelId = UUID.Zero; | ||
181 | if(string.IsNullOrEmpty(ad.Description)) | ||
182 | ad.Description = "No Description"; | ||
183 | |||
184 | DateTime epoch = new DateTime(1970, 1, 1); | ||
185 | DateTime now = DateTime.Now; | ||
186 | TimeSpan epochnow = now - epoch; | ||
187 | TimeSpan duration; | ||
188 | DateTime expiration; | ||
189 | TimeSpan epochexp; | ||
190 | |||
191 | if(ad.Flags == 2) | ||
192 | { | ||
193 | duration = new TimeSpan(7,0,0,0); | ||
194 | expiration = now.Add(duration); | ||
195 | epochexp = expiration - epoch; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | duration = new TimeSpan(365,0,0,0); | ||
200 | expiration = now.Add(duration); | ||
201 | epochexp = expiration - epoch; | ||
202 | } | ||
203 | ad.CreationDate = (int)epochnow.TotalSeconds; | ||
204 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | ||
205 | |||
206 | try | ||
207 | { | ||
208 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
209 | { | ||
210 | dbcon.Open(); | ||
211 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
212 | { | ||
213 | cmd.Parameters.AddWithValue("?ClassifiedId", ad.ClassifiedId.ToString()); | ||
214 | cmd.Parameters.AddWithValue("?CreatorId", ad.CreatorId.ToString()); | ||
215 | cmd.Parameters.AddWithValue("?CreatedDate", ad.CreationDate.ToString()); | ||
216 | cmd.Parameters.AddWithValue("?ExpirationDate", ad.ExpirationDate.ToString()); | ||
217 | cmd.Parameters.AddWithValue("?Category", ad.Category.ToString()); | ||
218 | cmd.Parameters.AddWithValue("?Name", ad.Name.ToString()); | ||
219 | cmd.Parameters.AddWithValue("?Description", ad.Description.ToString()); | ||
220 | cmd.Parameters.AddWithValue("?ParcelId", ad.ParcelId.ToString()); | ||
221 | cmd.Parameters.AddWithValue("?ParentEstate", ad.ParentEstate.ToString()); | ||
222 | cmd.Parameters.AddWithValue("?SnapshotId", ad.SnapshotId.ToString ()); | ||
223 | cmd.Parameters.AddWithValue("?SimName", ad.SimName.ToString()); | ||
224 | cmd.Parameters.AddWithValue("?GlobalPos", ad.GlobalPos.ToString()); | ||
225 | cmd.Parameters.AddWithValue("?ParcelName", ad.ParcelName.ToString()); | ||
226 | cmd.Parameters.AddWithValue("?Flags", ad.Flags.ToString()); | ||
227 | cmd.Parameters.AddWithValue("?ListingPrice", ad.Price.ToString ()); | ||
228 | |||
229 | cmd.ExecuteNonQuery(); | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | catch (Exception e) | ||
234 | { | ||
235 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
236 | ": ClassifiedesUpdate exception {0}", e.Message); | ||
237 | result = e.Message; | ||
238 | return false; | ||
239 | } | ||
240 | return true; | ||
241 | } | ||
242 | |||
243 | public bool DeleteClassifiedRecord(UUID recordId) | ||
244 | { | ||
245 | string query = string.Empty; | ||
246 | |||
247 | query += "DELETE FROM classifieds WHERE "; | ||
248 | query += "classifieduuid = ?recordId"; | ||
249 | |||
250 | try | ||
251 | { | ||
252 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
253 | { | ||
254 | dbcon.Open(); | ||
255 | |||
256 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
257 | { | ||
258 | cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); | ||
259 | cmd.ExecuteNonQuery(); | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | catch (Exception e) | ||
264 | { | ||
265 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
266 | ": DeleteClassifiedRecord exception {0}", e.Message); | ||
267 | return false; | ||
268 | } | ||
269 | return true; | ||
270 | } | ||
271 | |||
272 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | ||
273 | { | ||
274 | string query = string.Empty; | ||
275 | |||
276 | query += "SELECT * FROM classifieds WHERE "; | ||
277 | query += "classifieduuid = ?AdId"; | ||
278 | |||
279 | try | ||
280 | { | ||
281 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
282 | { | ||
283 | dbcon.Open(); | ||
284 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
285 | { | ||
286 | cmd.Parameters.AddWithValue("?AdId", ad.ClassifiedId.ToString()); | ||
287 | |||
288 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
289 | { | ||
290 | if(reader.Read ()) | ||
291 | { | ||
292 | ad.CreatorId = new UUID(reader.GetGuid("creatoruuid")); | ||
293 | ad.ParcelId = new UUID(reader.GetGuid("parceluuid")); | ||
294 | ad.SnapshotId = new UUID(reader.GetGuid("snapshotuuid")); | ||
295 | ad.CreationDate = Convert.ToInt32(reader["creationdate"]); | ||
296 | ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); | ||
297 | ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); | ||
298 | ad.Flags = (byte)reader.GetUInt32("classifiedflags"); | ||
299 | ad.Category = reader.GetInt32("category"); | ||
300 | ad.Price = reader.GetInt16("priceforlisting"); | ||
301 | ad.Name = reader.GetString("name"); | ||
302 | ad.Description = reader.GetString("description"); | ||
303 | ad.SimName = reader.GetString("simname"); | ||
304 | ad.GlobalPos = reader.GetString("posglobal"); | ||
305 | ad.ParcelName = reader.GetString("parcelname"); | ||
306 | |||
307 | } | ||
308 | } | ||
309 | } | ||
310 | dbcon.Close(); | ||
311 | } | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
316 | ": GetPickInfo exception {0}", e.Message); | ||
317 | } | ||
318 | return true; | ||
319 | } | ||
320 | #endregion Classifieds Queries | ||
321 | |||
322 | #region Picks Queries | ||
323 | public OSDArray GetAvatarPicks(UUID avatarId) | ||
324 | { | ||
325 | string query = string.Empty; | ||
326 | |||
327 | query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; | ||
328 | query += "creatoruuid = ?Id"; | ||
329 | OSDArray data = new OSDArray(); | ||
330 | |||
331 | try | ||
332 | { | ||
333 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
334 | { | ||
335 | dbcon.Open(); | ||
336 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
337 | { | ||
338 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
339 | |||
340 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
341 | { | ||
342 | if(reader.HasRows) | ||
343 | { | ||
344 | while (reader.Read()) | ||
345 | { | ||
346 | OSDMap record = new OSDMap(); | ||
347 | |||
348 | record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); | ||
349 | record.Add("name",OSD.FromString((string)reader["name"])); | ||
350 | data.Add(record); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | catch (Exception e) | ||
358 | { | ||
359 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
360 | ": GetAvatarPicks exception {0}", e.Message); | ||
361 | } | ||
362 | return data; | ||
363 | } | ||
364 | |||
365 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | ||
366 | { | ||
367 | string query = string.Empty; | ||
368 | UserProfilePick pick = new UserProfilePick(); | ||
369 | |||
370 | query += "SELECT * FROM userpicks WHERE "; | ||
371 | query += "creatoruuid = ?CreatorId AND "; | ||
372 | query += "pickuuid = ?PickId"; | ||
373 | |||
374 | try | ||
375 | { | ||
376 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
377 | { | ||
378 | dbcon.Open(); | ||
379 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
380 | { | ||
381 | cmd.Parameters.AddWithValue("?CreatorId", avatarId.ToString()); | ||
382 | cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); | ||
383 | |||
384 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
385 | { | ||
386 | if(reader.HasRows) | ||
387 | { | ||
388 | reader.Read(); | ||
389 | |||
390 | string description = (string)reader["description"]; | ||
391 | |||
392 | if (string.IsNullOrEmpty(description)) | ||
393 | description = "No description given."; | ||
394 | |||
395 | UUID.TryParse((string)reader["pickuuid"], out pick.PickId); | ||
396 | UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); | ||
397 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); | ||
398 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); | ||
399 | pick.GlobalPos = (string)reader["posglobal"]; | ||
400 | pick.Gatekeeper = (string)reader["gatekeeper"]; | ||
401 | bool.TryParse((string)reader["toppick"], out pick.TopPick); | ||
402 | bool.TryParse((string)reader["enabled"], out pick.Enabled); | ||
403 | pick.Name = (string)reader["name"]; | ||
404 | pick.Desc = description; | ||
405 | pick.ParcelName = (string)reader["user"]; | ||
406 | pick.OriginalName = (string)reader["originalname"]; | ||
407 | pick.SimName = (string)reader["simname"]; | ||
408 | pick.SortOrder = (int)reader["sortorder"]; | ||
409 | } | ||
410 | } | ||
411 | } | ||
412 | dbcon.Close(); | ||
413 | } | ||
414 | } | ||
415 | catch (Exception e) | ||
416 | { | ||
417 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
418 | ": GetPickInfo exception {0}", e.Message); | ||
419 | } | ||
420 | return pick; | ||
421 | } | ||
422 | |||
423 | public bool UpdatePicksRecord(UserProfilePick pick) | ||
424 | { | ||
425 | string query = string.Empty; | ||
426 | |||
427 | query += "INSERT INTO userpicks VALUES ("; | ||
428 | query += "?PickId,"; | ||
429 | query += "?CreatorId,"; | ||
430 | query += "?TopPick,"; | ||
431 | query += "?ParcelId,"; | ||
432 | query += "?Name,"; | ||
433 | query += "?Desc,"; | ||
434 | query += "?SnapshotId,"; | ||
435 | query += "?User,"; | ||
436 | query += "?Original,"; | ||
437 | query += "?SimName,"; | ||
438 | query += "?GlobalPos,"; | ||
439 | query += "?SortOrder,"; | ||
440 | query += "?Enabled,"; | ||
441 | query += "?Gatekeeper)"; | ||
442 | query += "ON DUPLICATE KEY UPDATE "; | ||
443 | query += "parceluuid=?ParcelId,"; | ||
444 | query += "name=?Name,"; | ||
445 | query += "description=?Desc,"; | ||
446 | query += "user=?User,"; | ||
447 | query += "simname=?SimName,"; | ||
448 | query += "snapshotuuid=?SnapshotId,"; | ||
449 | query += "pickuuid=?PickId,"; | ||
450 | query += "posglobal=?GlobalPos,"; | ||
451 | query += "gatekeeper=?Gatekeeper"; | ||
452 | |||
453 | try | ||
454 | { | ||
455 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
456 | { | ||
457 | dbcon.Open(); | ||
458 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
459 | { | ||
460 | cmd.Parameters.AddWithValue("?PickId", pick.PickId.ToString()); | ||
461 | cmd.Parameters.AddWithValue("?CreatorId", pick.CreatorId.ToString()); | ||
462 | cmd.Parameters.AddWithValue("?TopPick", pick.TopPick.ToString()); | ||
463 | cmd.Parameters.AddWithValue("?ParcelId", pick.ParcelId.ToString()); | ||
464 | cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); | ||
465 | cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); | ||
466 | cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); | ||
467 | cmd.Parameters.AddWithValue("?User", pick.ParcelName.ToString()); | ||
468 | cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); | ||
469 | cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); | ||
470 | cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); | ||
471 | cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper); | ||
472 | cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); | ||
473 | cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); | ||
474 | |||
475 | cmd.ExecuteNonQuery(); | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | catch (Exception e) | ||
480 | { | ||
481 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
482 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
483 | return false; | ||
484 | } | ||
485 | return true; | ||
486 | } | ||
487 | |||
488 | public bool DeletePicksRecord(UUID pickId) | ||
489 | { | ||
490 | string query = string.Empty; | ||
491 | |||
492 | query += "DELETE FROM userpicks WHERE "; | ||
493 | query += "pickuuid = ?PickId"; | ||
494 | |||
495 | try | ||
496 | { | ||
497 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
498 | { | ||
499 | dbcon.Open(); | ||
500 | |||
501 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
502 | { | ||
503 | cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); | ||
504 | |||
505 | cmd.ExecuteNonQuery(); | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | catch (Exception e) | ||
510 | { | ||
511 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
512 | ": DeleteUserPickRecord exception {0}", e.Message); | ||
513 | return false; | ||
514 | } | ||
515 | return true; | ||
516 | } | ||
517 | #endregion Picks Queries | ||
518 | |||
519 | #region Avatar Notes Queries | ||
520 | public bool GetAvatarNotes(ref UserProfileNotes notes) | ||
521 | { // WIP | ||
522 | string query = string.Empty; | ||
523 | |||
524 | query += "SELECT `notes` FROM usernotes WHERE "; | ||
525 | query += "useruuid = ?Id AND "; | ||
526 | query += "targetuuid = ?TargetId"; | ||
527 | OSDArray data = new OSDArray(); | ||
528 | |||
529 | try | ||
530 | { | ||
531 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
532 | { | ||
533 | dbcon.Open(); | ||
534 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
535 | { | ||
536 | cmd.Parameters.AddWithValue("?Id", notes.UserId.ToString()); | ||
537 | cmd.Parameters.AddWithValue("?TargetId", notes.TargetId.ToString()); | ||
538 | |||
539 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
540 | { | ||
541 | if(reader.HasRows) | ||
542 | { | ||
543 | reader.Read(); | ||
544 | notes.Notes = OSD.FromString((string)reader["notes"]); | ||
545 | } | ||
546 | else | ||
547 | { | ||
548 | notes.Notes = OSD.FromString(""); | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | } | ||
554 | catch (Exception e) | ||
555 | { | ||
556 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
557 | ": GetAvatarNotes exception {0}", e.Message); | ||
558 | } | ||
559 | return true; | ||
560 | } | ||
561 | |||
562 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | ||
563 | { | ||
564 | string query = string.Empty; | ||
565 | bool remove; | ||
566 | |||
567 | if(string.IsNullOrEmpty(note.Notes)) | ||
568 | { | ||
569 | remove = true; | ||
570 | query += "DELETE FROM usernotes WHERE "; | ||
571 | query += "useruuid=?UserId AND "; | ||
572 | query += "targetuuid=?TargetId"; | ||
573 | } | ||
574 | else | ||
575 | { | ||
576 | remove = false; | ||
577 | query += "INSERT INTO usernotes VALUES ( "; | ||
578 | query += "?UserId,"; | ||
579 | query += "?TargetId,"; | ||
580 | query += "?Notes )"; | ||
581 | query += "ON DUPLICATE KEY "; | ||
582 | query += "UPDATE "; | ||
583 | query += "notes=?Notes"; | ||
584 | } | ||
585 | |||
586 | try | ||
587 | { | ||
588 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
589 | { | ||
590 | dbcon.Open(); | ||
591 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
592 | { | ||
593 | if(!remove) | ||
594 | cmd.Parameters.AddWithValue("?Notes", note.Notes); | ||
595 | cmd.Parameters.AddWithValue("?TargetId", note.TargetId.ToString ()); | ||
596 | cmd.Parameters.AddWithValue("?UserId", note.UserId.ToString()); | ||
597 | |||
598 | cmd.ExecuteNonQuery(); | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | catch (Exception e) | ||
603 | { | ||
604 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
605 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
606 | return false; | ||
607 | } | ||
608 | return true; | ||
609 | |||
610 | } | ||
611 | #endregion Avatar Notes Queries | ||
612 | |||
613 | #region Avatar Properties | ||
614 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | ||
615 | { | ||
616 | string query = string.Empty; | ||
617 | |||
618 | query += "SELECT * FROM userprofile WHERE "; | ||
619 | query += "useruuid = ?Id"; | ||
620 | |||
621 | try | ||
622 | { | ||
623 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
624 | { | ||
625 | dbcon.Open(); | ||
626 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
627 | { | ||
628 | cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
629 | |||
630 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
631 | { | ||
632 | if(reader.HasRows) | ||
633 | { | ||
634 | reader.Read(); | ||
635 | props.WebUrl = (string)reader["profileURL"]; | ||
636 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | ||
637 | props.AboutText = (string)reader["profileAboutText"]; | ||
638 | UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); | ||
639 | props.FirstLifeText = (string)reader["profileFirstText"]; | ||
640 | UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); | ||
641 | props.WantToMask = (int)reader["profileWantToMask"]; | ||
642 | props.WantToText = (string)reader["profileWantToText"]; | ||
643 | props.SkillsMask = (int)reader["profileSkillsMask"]; | ||
644 | props.SkillsText = (string)reader["profileSkillsText"]; | ||
645 | props.Language = (string)reader["profileLanguages"]; | ||
646 | } | ||
647 | else | ||
648 | { | ||
649 | props.WebUrl = string.Empty; | ||
650 | props.ImageId = UUID.Zero; | ||
651 | props.AboutText = string.Empty; | ||
652 | props.FirstLifeImageId = UUID.Zero; | ||
653 | props.FirstLifeText = string.Empty; | ||
654 | props.PartnerId = UUID.Zero; | ||
655 | props.WantToMask = 0; | ||
656 | props.WantToText = string.Empty; | ||
657 | props.SkillsMask = 0; | ||
658 | props.SkillsText = string.Empty; | ||
659 | props.Language = string.Empty; | ||
660 | props.PublishProfile = false; | ||
661 | props.PublishMature = false; | ||
662 | |||
663 | query = "INSERT INTO userprofile ("; | ||
664 | query += "useruuid, "; | ||
665 | query += "profilePartner, "; | ||
666 | query += "profileAllowPublish, "; | ||
667 | query += "profileMaturePublish, "; | ||
668 | query += "profileURL, "; | ||
669 | query += "profileWantToMask, "; | ||
670 | query += "profileWantToText, "; | ||
671 | query += "profileSkillsMask, "; | ||
672 | query += "profileSkillsText, "; | ||
673 | query += "profileLanguages, "; | ||
674 | query += "profileImage, "; | ||
675 | query += "profileAboutText, "; | ||
676 | query += "profileFirstImage, "; | ||
677 | query += "profileFirstText) VALUES ("; | ||
678 | query += "?userId, "; | ||
679 | query += "?profilePartner, "; | ||
680 | query += "?profileAllowPublish, "; | ||
681 | query += "?profileMaturePublish, "; | ||
682 | query += "?profileURL, "; | ||
683 | query += "?profileWantToMask, "; | ||
684 | query += "?profileWantToText, "; | ||
685 | query += "?profileSkillsMask, "; | ||
686 | query += "?profileSkillsText, "; | ||
687 | query += "?profileLanguages, "; | ||
688 | query += "?profileImage, "; | ||
689 | query += "?profileAboutText, "; | ||
690 | query += "?profileFirstImage, "; | ||
691 | query += "?profileFirstText)"; | ||
692 | |||
693 | dbcon.Close(); | ||
694 | dbcon.Open(); | ||
695 | |||
696 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
697 | { | ||
698 | put.Parameters.AddWithValue("?userId", props.UserId.ToString()); | ||
699 | put.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); | ||
700 | put.Parameters.AddWithValue("?profileAllowPublish", props.PublishProfile); | ||
701 | put.Parameters.AddWithValue("?profileMaturePublish", props.PublishMature); | ||
702 | put.Parameters.AddWithValue("?profileURL", props.WebUrl); | ||
703 | put.Parameters.AddWithValue("?profileWantToMask", props.WantToMask); | ||
704 | put.Parameters.AddWithValue("?profileWantToText", props.WantToText); | ||
705 | put.Parameters.AddWithValue("?profileSkillsMask", props.SkillsMask); | ||
706 | put.Parameters.AddWithValue("?profileSkillsText", props.SkillsText); | ||
707 | put.Parameters.AddWithValue("?profileLanguages", props.Language); | ||
708 | put.Parameters.AddWithValue("?profileImage", props.ImageId.ToString()); | ||
709 | put.Parameters.AddWithValue("?profileAboutText", props.AboutText); | ||
710 | put.Parameters.AddWithValue("?profileFirstImage", props.FirstLifeImageId.ToString()); | ||
711 | put.Parameters.AddWithValue("?profileFirstText", props.FirstLifeText); | ||
712 | |||
713 | put.ExecuteNonQuery(); | ||
714 | } | ||
715 | } | ||
716 | } | ||
717 | } | ||
718 | } | ||
719 | } | ||
720 | catch (Exception e) | ||
721 | { | ||
722 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
723 | ": Requst properties exception {0}", e.Message); | ||
724 | result = e.Message; | ||
725 | return false; | ||
726 | } | ||
727 | return true; | ||
728 | } | ||
729 | |||
730 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | ||
731 | { | ||
732 | string query = string.Empty; | ||
733 | |||
734 | query += "UPDATE userprofile SET "; | ||
735 | query += "profileURL=?profileURL, "; | ||
736 | query += "profileImage=?image, "; | ||
737 | query += "profileAboutText=?abouttext,"; | ||
738 | query += "profileFirstImage=?firstlifeimage,"; | ||
739 | query += "profileFirstText=?firstlifetext "; | ||
740 | query += "WHERE useruuid=?uuid"; | ||
741 | |||
742 | try | ||
743 | { | ||
744 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
745 | { | ||
746 | dbcon.Open(); | ||
747 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
748 | { | ||
749 | cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); | ||
750 | cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); | ||
751 | cmd.Parameters.AddWithValue("?abouttext", props.AboutText); | ||
752 | cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); | ||
753 | cmd.Parameters.AddWithValue("?firstlifetext", props.FirstLifeText); | ||
754 | cmd.Parameters.AddWithValue("?uuid", props.UserId.ToString()); | ||
755 | |||
756 | cmd.ExecuteNonQuery(); | ||
757 | } | ||
758 | } | ||
759 | } | ||
760 | catch (Exception e) | ||
761 | { | ||
762 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
763 | ": AgentPropertiesUpdate exception {0}", e.Message); | ||
764 | |||
765 | return false; | ||
766 | } | ||
767 | return true; | ||
768 | } | ||
769 | #endregion Avatar Properties | ||
770 | |||
771 | #region Avatar Interests | ||
772 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | ||
773 | { | ||
774 | string query = string.Empty; | ||
775 | |||
776 | query += "UPDATE userprofile SET "; | ||
777 | query += "profileWantToMask=?WantMask, "; | ||
778 | query += "profileWantToText=?WantText,"; | ||
779 | query += "profileSkillsMask=?SkillsMask,"; | ||
780 | query += "profileSkillsText=?SkillsText, "; | ||
781 | query += "profileLanguages=?Languages "; | ||
782 | query += "WHERE useruuid=?uuid"; | ||
783 | |||
784 | try | ||
785 | { | ||
786 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
787 | { | ||
788 | dbcon.Open(); | ||
789 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
790 | { | ||
791 | cmd.Parameters.AddWithValue("?WantMask", up.WantToMask); | ||
792 | cmd.Parameters.AddWithValue("?WantText", up.WantToText); | ||
793 | cmd.Parameters.AddWithValue("?SkillsMask", up.SkillsMask); | ||
794 | cmd.Parameters.AddWithValue("?SkillsText", up.SkillsText); | ||
795 | cmd.Parameters.AddWithValue("?Languages", up.Language); | ||
796 | cmd.Parameters.AddWithValue("?uuid", up.UserId.ToString()); | ||
797 | |||
798 | cmd.ExecuteNonQuery(); | ||
799 | } | ||
800 | } | ||
801 | } | ||
802 | catch (Exception e) | ||
803 | { | ||
804 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
805 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
806 | result = e.Message; | ||
807 | return false; | ||
808 | } | ||
809 | return true; | ||
810 | } | ||
811 | #endregion Avatar Interests | ||
812 | |||
813 | public OSDArray GetUserImageAssets(UUID avatarId) | ||
814 | { | ||
815 | OSDArray data = new OSDArray(); | ||
816 | string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; | ||
817 | |||
818 | // Get classified image assets | ||
819 | |||
820 | |||
821 | try | ||
822 | { | ||
823 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
824 | { | ||
825 | dbcon.Open(); | ||
826 | |||
827 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) | ||
828 | { | ||
829 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
830 | |||
831 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
832 | { | ||
833 | if(reader.HasRows) | ||
834 | { | ||
835 | while (reader.Read()) | ||
836 | { | ||
837 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
838 | } | ||
839 | } | ||
840 | } | ||
841 | } | ||
842 | |||
843 | dbcon.Close(); | ||
844 | dbcon.Open(); | ||
845 | |||
846 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | ||
847 | { | ||
848 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
849 | |||
850 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
851 | { | ||
852 | if(reader.HasRows) | ||
853 | { | ||
854 | while (reader.Read()) | ||
855 | { | ||
856 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
857 | } | ||
858 | } | ||
859 | } | ||
860 | } | ||
861 | |||
862 | dbcon.Close(); | ||
863 | dbcon.Open(); | ||
864 | |||
865 | query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; | ||
866 | |||
867 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | ||
868 | { | ||
869 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
870 | |||
871 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
872 | { | ||
873 | if(reader.HasRows) | ||
874 | { | ||
875 | while (reader.Read()) | ||
876 | { | ||
877 | data.Add(new OSDString((string)reader["profileImage"].ToString ())); | ||
878 | data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); | ||
879 | } | ||
880 | } | ||
881 | } | ||
882 | } | ||
883 | } | ||
884 | } | ||
885 | catch (Exception e) | ||
886 | { | ||
887 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
888 | ": GetAvatarNotes exception {0}", e.Message); | ||
889 | } | ||
890 | return data; | ||
891 | } | ||
892 | |||
893 | #region User Preferences | ||
894 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | ||
895 | { | ||
896 | string query = string.Empty; | ||
897 | |||
898 | query += "SELECT imviaemail,visible,email FROM "; | ||
899 | query += "usersettings WHERE "; | ||
900 | query += "useruuid = ?Id"; | ||
901 | |||
902 | OSDArray data = new OSDArray(); | ||
903 | |||
904 | try | ||
905 | { | ||
906 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
907 | { | ||
908 | dbcon.Open(); | ||
909 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
910 | { | ||
911 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); | ||
912 | |||
913 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
914 | { | ||
915 | if(reader.HasRows) | ||
916 | { | ||
917 | reader.Read(); | ||
918 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | ||
919 | bool.TryParse((string)reader["visible"], out pref.Visible); | ||
920 | pref.EMail = (string)reader["email"]; | ||
921 | } | ||
922 | else | ||
923 | { | ||
924 | dbcon.Close(); | ||
925 | dbcon.Open(); | ||
926 | |||
927 | query = "INSERT INTO usersettings VALUES "; | ||
928 | query += "(?uuid,'false','false', ?Email)"; | ||
929 | |||
930 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
931 | { | ||
932 | |||
933 | put.Parameters.AddWithValue("?Email", pref.EMail); | ||
934 | put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); | ||
935 | |||
936 | put.ExecuteNonQuery(); | ||
937 | } | ||
938 | } | ||
939 | } | ||
940 | } | ||
941 | } | ||
942 | } | ||
943 | catch (Exception e) | ||
944 | { | ||
945 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
946 | ": Get preferences exception {0}", e.Message); | ||
947 | result = e.Message; | ||
948 | return false; | ||
949 | } | ||
950 | return true; | ||
951 | } | ||
952 | |||
953 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | ||
954 | { | ||
955 | string query = string.Empty; | ||
956 | |||
957 | query += "UPDATE usersettings SET "; | ||
958 | query += "imviaemail=?ImViaEmail, "; | ||
959 | query += "visible=?Visible, "; | ||
960 | query += "email=?EMail "; | ||
961 | query += "WHERE useruuid=?uuid"; | ||
962 | |||
963 | try | ||
964 | { | ||
965 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
966 | { | ||
967 | dbcon.Open(); | ||
968 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
969 | { | ||
970 | cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower()); | ||
971 | cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower()); | ||
972 | cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); | ||
973 | cmd.Parameters.AddWithValue("?EMail", pref.EMail.ToString().ToLower()); | ||
974 | |||
975 | cmd.ExecuteNonQuery(); | ||
976 | } | ||
977 | } | ||
978 | } | ||
979 | catch (Exception e) | ||
980 | { | ||
981 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
982 | ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); | ||
983 | result = e.Message; | ||
984 | return false; | ||
985 | } | ||
986 | return true; | ||
987 | } | ||
988 | #endregion User Preferences | ||
989 | |||
990 | #region Integration | ||
991 | public bool GetUserAppData(ref UserAppData props, ref string result) | ||
992 | { | ||
993 | string query = string.Empty; | ||
994 | |||
995 | query += "SELECT * FROM `userdata` WHERE "; | ||
996 | query += "UserId = ?Id AND "; | ||
997 | query += "TagId = ?TagId"; | ||
998 | |||
999 | try | ||
1000 | { | ||
1001 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
1002 | { | ||
1003 | dbcon.Open(); | ||
1004 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
1005 | { | ||
1006 | cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
1007 | cmd.Parameters.AddWithValue ("?TagId", props.TagId.ToString()); | ||
1008 | |||
1009 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
1010 | { | ||
1011 | if(reader.HasRows) | ||
1012 | { | ||
1013 | reader.Read(); | ||
1014 | props.DataKey = (string)reader["DataKey"]; | ||
1015 | props.DataVal = (string)reader["DataVal"]; | ||
1016 | } | ||
1017 | else | ||
1018 | { | ||
1019 | query += "INSERT INTO userdata VALUES ( "; | ||
1020 | query += "?UserId,"; | ||
1021 | query += "?TagId,"; | ||
1022 | query += "?DataKey,"; | ||
1023 | query += "?DataVal) "; | ||
1024 | |||
1025 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
1026 | { | ||
1027 | put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | ||
1028 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | ||
1029 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | ||
1030 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); | ||
1031 | |||
1032 | put.ExecuteNonQuery(); | ||
1033 | } | ||
1034 | } | ||
1035 | } | ||
1036 | } | ||
1037 | } | ||
1038 | } | ||
1039 | catch (Exception e) | ||
1040 | { | ||
1041 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
1042 | ": Requst application data exception {0}", e.Message); | ||
1043 | result = e.Message; | ||
1044 | return false; | ||
1045 | } | ||
1046 | return true; | ||
1047 | } | ||
1048 | |||
1049 | public bool SetUserAppData(UserAppData props, ref string result) | ||
1050 | { | ||
1051 | string query = string.Empty; | ||
1052 | |||
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 | ||
1061 | { | ||
1062 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
1063 | { | ||
1064 | dbcon.Open(); | ||
1065 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
1066 | { | ||
1067 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | ||
1068 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | ||
1069 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | ||
1070 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString()); | ||
1071 | |||
1072 | cmd.ExecuteNonQuery(); | ||
1073 | } | ||
1074 | } | ||
1075 | } | ||
1076 | catch (Exception e) | ||
1077 | { | ||
1078 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
1079 | ": SetUserData exception {0}", e.Message); | ||
1080 | return false; | ||
1081 | } | ||
1082 | return true; | ||
1083 | } | ||
1084 | #endregion Integration | ||
1085 | } | ||
1086 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index e6ac22e..af7e876 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs | |||
@@ -50,9 +50,13 @@ namespace OpenSim.Data.MySQL | |||
50 | get { return GetType().Assembly; } | 50 | get { return GetType().Assembly; } |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | ||
54 | /// Number of days that must pass before we update the access time on an asset when it has been fetched. | ||
55 | /// </summary> | ||
56 | private const int DaysBetweenAccessTimeUpdates = 30; | ||
57 | |||
53 | private bool m_enableCompression = false; | 58 | private bool m_enableCompression = false; |
54 | private string m_connectionString; | 59 | private string m_connectionString; |
55 | private object m_dbLock = new object(); | ||
56 | 60 | ||
57 | /// <summary> | 61 | /// <summary> |
58 | /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock | 62 | /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock |
@@ -126,58 +130,58 @@ namespace OpenSim.Data.MySQL | |||
126 | // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); | 130 | // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); |
127 | 131 | ||
128 | AssetBase asset = null; | 132 | AssetBase asset = null; |
129 | lock (m_dbLock) | 133 | |
134 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
130 | { | 135 | { |
131 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 136 | dbcon.Open(); |
137 | |||
138 | using (MySqlCommand cmd = new MySqlCommand( | ||
139 | "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID", | ||
140 | dbcon)) | ||
132 | { | 141 | { |
133 | dbcon.Open(); | 142 | cmd.Parameters.AddWithValue("?ID", assetID.ToString()); |
134 | 143 | ||
135 | using (MySqlCommand cmd = new MySqlCommand( | 144 | try |
136 | "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", | ||
137 | dbcon)) | ||
138 | { | 145 | { |
139 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 146 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
140 | |||
141 | try | ||
142 | { | 147 | { |
143 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 148 | if (dbReader.Read()) |
144 | { | 149 | { |
145 | if (dbReader.Read()) | 150 | asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); |
146 | { | 151 | asset.Data = (byte[])dbReader["Data"]; |
147 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); | 152 | asset.Description = (string)dbReader["Description"]; |
148 | asset.Data = (byte[])dbReader["data"]; | ||
149 | asset.Description = (string)dbReader["description"]; | ||
150 | 153 | ||
151 | string local = dbReader["local"].ToString(); | 154 | string local = dbReader["Local"].ToString(); |
152 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 155 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) |
153 | asset.Local = true; | 156 | asset.Local = true; |
154 | else | 157 | else |
155 | asset.Local = false; | 158 | asset.Local = false; |
156 | 159 | ||
157 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | 160 | asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); |
158 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 161 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
159 | 162 | ||
160 | if (m_enableCompression) | 163 | if (m_enableCompression) |
164 | { | ||
165 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | ||
161 | { | 166 | { |
162 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | 167 | MemoryStream outputStream = new MemoryStream(); |
163 | { | 168 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); |
164 | MemoryStream outputStream = new MemoryStream(); | 169 | // int compressedLength = asset.Data.Length; |
165 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); | 170 | asset.Data = outputStream.ToArray(); |
166 | // int compressedLength = asset.Data.Length; | 171 | |
167 | asset.Data = outputStream.ToArray(); | 172 | // m_log.DebugFormat( |
168 | 173 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | |
169 | // m_log.DebugFormat( | 174 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); |
170 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | ||
171 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); | ||
172 | } | ||
173 | } | 175 | } |
174 | } | 176 | } |
177 | |||
178 | UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); | ||
175 | } | 179 | } |
176 | } | 180 | } |
177 | catch (Exception e) | 181 | } |
178 | { | 182 | catch (Exception e) |
179 | m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); | 183 | { |
180 | } | 184 | m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); |
181 | } | 185 | } |
182 | } | 186 | } |
183 | } | 187 | } |
@@ -192,148 +196,156 @@ namespace OpenSim.Data.MySQL | |||
192 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | 196 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> |
193 | public void StoreAsset(AssetBase asset) | 197 | public void StoreAsset(AssetBase asset) |
194 | { | 198 | { |
195 | lock (m_dbLock) | 199 | // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); |
200 | |||
201 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
196 | { | 202 | { |
197 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 203 | dbcon.Open(); |
204 | |||
205 | using (MySqlTransaction transaction = dbcon.BeginTransaction()) | ||
198 | { | 206 | { |
199 | dbcon.Open(); | 207 | string assetName = asset.Name; |
208 | if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) | ||
209 | { | ||
210 | assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); | ||
211 | m_log.WarnFormat( | ||
212 | "[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); | ||
214 | } | ||
200 | 215 | ||
201 | using (MySqlTransaction transaction = dbcon.BeginTransaction()) | 216 | string assetDescription = asset.Description; |
217 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) | ||
202 | { | 218 | { |
203 | string assetName = asset.Name; | 219 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
204 | if (asset.Name.Length > 64) | 220 | m_log.WarnFormat( |
205 | { | 221 | "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
206 | assetName = asset.Name.Substring(0, 64); | 222 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
207 | m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | 223 | } |
208 | } | ||
209 | |||
210 | string assetDescription = asset.Description; | ||
211 | if (asset.Description.Length > 64) | ||
212 | { | ||
213 | assetDescription = asset.Description.Substring(0, 64); | ||
214 | m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | ||
215 | } | ||
216 | 224 | ||
217 | if (m_enableCompression) | 225 | if (m_enableCompression) |
218 | { | 226 | { |
219 | MemoryStream outputStream = new MemoryStream(); | 227 | MemoryStream outputStream = new MemoryStream(); |
220 | 228 | ||
221 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) | 229 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) |
222 | { | 230 | { |
223 | // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); | 231 | // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); |
224 | // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. | 232 | // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. |
225 | compressionStream.Close(); | 233 | compressionStream.Close(); |
226 | byte[] compressedData = outputStream.ToArray(); | 234 | byte[] compressedData = outputStream.ToArray(); |
227 | asset.Data = compressedData; | 235 | asset.Data = compressedData; |
228 | } | ||
229 | } | 236 | } |
237 | } | ||
230 | 238 | ||
231 | byte[] hash = hasher.ComputeHash(asset.Data); | 239 | byte[] hash = hasher.ComputeHash(asset.Data); |
232 | 240 | ||
233 | // m_log.DebugFormat( | 241 | // m_log.DebugFormat( |
234 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", | 242 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", |
235 | // asset.ID, asset.Name, hash, compressedData.Length); | 243 | // asset.ID, asset.Name, hash, compressedData.Length); |
236 | 244 | ||
245 | try | ||
246 | { | ||
247 | using (MySqlCommand cmd = | ||
248 | new MySqlCommand( | ||
249 | "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" + | ||
250 | "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)", | ||
251 | dbcon)) | ||
252 | { | ||
253 | // create unix epoch time | ||
254 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
255 | cmd.Parameters.AddWithValue("?ID", asset.ID); | ||
256 | cmd.Parameters.AddWithValue("?Hash", hash); | ||
257 | cmd.Parameters.AddWithValue("?Name", assetName); | ||
258 | cmd.Parameters.AddWithValue("?Description", assetDescription); | ||
259 | cmd.Parameters.AddWithValue("?AssetType", asset.Type); | ||
260 | cmd.Parameters.AddWithValue("?Local", asset.Local); | ||
261 | cmd.Parameters.AddWithValue("?Temporary", asset.Temporary); | ||
262 | cmd.Parameters.AddWithValue("?CreateTime", now); | ||
263 | cmd.Parameters.AddWithValue("?AccessTime", now); | ||
264 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
265 | cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags); | ||
266 | cmd.ExecuteNonQuery(); | ||
267 | } | ||
268 | } | ||
269 | catch (Exception e) | ||
270 | { | ||
271 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", | ||
272 | asset.FullID, asset.Name, e.Message); | ||
273 | |||
274 | transaction.Rollback(); | ||
275 | |||
276 | return; | ||
277 | } | ||
278 | |||
279 | if (!ExistsData(dbcon, transaction, hash)) | ||
280 | { | ||
237 | try | 281 | try |
238 | { | 282 | { |
239 | using (MySqlCommand cmd = | 283 | using (MySqlCommand cmd = |
240 | new MySqlCommand( | 284 | new MySqlCommand( |
241 | "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + | 285 | "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", |
242 | "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", | ||
243 | dbcon)) | 286 | dbcon)) |
244 | { | 287 | { |
245 | // create unix epoch time | 288 | cmd.Parameters.AddWithValue("?Hash", hash); |
246 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 289 | cmd.Parameters.AddWithValue("?Data", asset.Data); |
247 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
248 | cmd.Parameters.AddWithValue("?hash", hash); | ||
249 | cmd.Parameters.AddWithValue("?name", assetName); | ||
250 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
251 | cmd.Parameters.AddWithValue("?asset_type", asset.Type); | ||
252 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
253 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
254 | cmd.Parameters.AddWithValue("?create_time", now); | ||
255 | cmd.Parameters.AddWithValue("?access_time", now); | ||
256 | cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); | ||
257 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
258 | cmd.ExecuteNonQuery(); | 290 | cmd.ExecuteNonQuery(); |
259 | } | 291 | } |
260 | } | 292 | } |
261 | catch (Exception e) | 293 | catch (Exception e) |
262 | { | 294 | { |
263 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", | 295 | m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", |
264 | asset.FullID, asset.Name, e.Message); | 296 | asset.FullID, asset.Name, e.Message); |
265 | 297 | ||
266 | transaction.Rollback(); | 298 | transaction.Rollback(); |
267 | 299 | ||
268 | return; | 300 | return; |
269 | } | 301 | } |
270 | |||
271 | if (!ExistsData(dbcon, transaction, hash)) | ||
272 | { | ||
273 | try | ||
274 | { | ||
275 | using (MySqlCommand cmd = | ||
276 | new MySqlCommand( | ||
277 | "INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)", | ||
278 | dbcon)) | ||
279 | { | ||
280 | cmd.Parameters.AddWithValue("?hash", hash); | ||
281 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
282 | cmd.ExecuteNonQuery(); | ||
283 | } | ||
284 | } | ||
285 | catch (Exception e) | ||
286 | { | ||
287 | m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", | ||
288 | asset.FullID, asset.Name, e.Message); | ||
289 | |||
290 | transaction.Rollback(); | ||
291 | |||
292 | return; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | transaction.Commit(); | ||
297 | } | 302 | } |
303 | |||
304 | transaction.Commit(); | ||
298 | } | 305 | } |
299 | } | 306 | } |
300 | } | 307 | } |
301 | 308 | ||
302 | // private void UpdateAccessTime(AssetBase asset) | 309 | /// <summary> |
303 | // { | 310 | /// Updates the access time of the asset if it was accessed above a given threshhold amount of time. |
304 | // lock (m_dbLock) | 311 | /// </summary> |
305 | // { | 312 | /// <remarks> |
306 | // using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 313 | /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done |
307 | // { | 314 | /// over the threshold time to avoid excessive database writes as assets are fetched. |
308 | // dbcon.Open(); | 315 | /// </remarks> |
309 | // MySqlCommand cmd = | 316 | /// <param name='asset'></param> |
310 | // new MySqlCommand("update assets set access_time=?access_time where id=?id", | 317 | /// <param name='accessTime'></param> |
311 | // dbcon); | 318 | private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime) |
312 | // | 319 | { |
313 | // // need to ensure we dispose | 320 | DateTime now = DateTime.UtcNow; |
314 | // try | 321 | |
315 | // { | 322 | if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) |
316 | // using (cmd) | 323 | return; |
317 | // { | 324 | |
318 | // // create unix epoch time | 325 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
319 | // int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 326 | { |
320 | // cmd.Parameters.AddWithValue("?id", asset.ID); | 327 | dbcon.Open(); |
321 | // cmd.Parameters.AddWithValue("?access_time", now); | 328 | MySqlCommand cmd = |
322 | // cmd.ExecuteNonQuery(); | 329 | new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); |
323 | // cmd.Dispose(); | 330 | |
324 | // } | 331 | try |
325 | // } | 332 | { |
326 | // catch (Exception e) | 333 | using (cmd) |
327 | // { | 334 | { |
328 | // m_log.ErrorFormat( | 335 | // create unix epoch time |
329 | // "[ASSETS DB]: " + | 336 | cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); |
330 | // "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | 337 | cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); |
331 | // + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | 338 | cmd.ExecuteNonQuery(); |
332 | // } | 339 | } |
333 | // } | 340 | } |
334 | // } | 341 | catch (Exception) |
335 | // | 342 | { |
336 | // } | 343 | m_log.ErrorFormat( |
344 | "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", | ||
345 | assetMetadata.ID, assetMetadata.Name); | ||
346 | } | ||
347 | } | ||
348 | } | ||
337 | 349 | ||
338 | /// <summary> | 350 | /// <summary> |
339 | /// We assume we already have the m_dbLock. | 351 | /// We assume we already have the m_dbLock. |
@@ -349,9 +361,9 @@ namespace OpenSim.Data.MySQL | |||
349 | 361 | ||
350 | bool exists = false; | 362 | bool exists = false; |
351 | 363 | ||
352 | using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) | 364 | using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon)) |
353 | { | 365 | { |
354 | cmd.Parameters.AddWithValue("?hash", hash); | 366 | cmd.Parameters.AddWithValue("?Hash", hash); |
355 | 367 | ||
356 | try | 368 | try |
357 | { | 369 | { |
@@ -376,48 +388,43 @@ namespace OpenSim.Data.MySQL | |||
376 | } | 388 | } |
377 | 389 | ||
378 | /// <summary> | 390 | /// <summary> |
379 | /// Check if the asset exists in the database | 391 | /// Check if the assets exist in the database. |
380 | /// </summary> | 392 | /// </summary> |
381 | /// <param name="uuid">The asset UUID</param> | 393 | /// <param name="uuids">The asset UUID's</param> |
382 | /// <returns>true if it exists, false otherwise.</returns> | 394 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
383 | public bool ExistsAsset(UUID uuid) | 395 | public bool[] AssetsExist(UUID[] uuids) |
384 | { | 396 | { |
385 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | 397 | if (uuids.Length == 0) |
398 | return new bool[0]; | ||
399 | |||
400 | HashSet<UUID> exists = new HashSet<UUID>(); | ||
386 | 401 | ||
387 | bool assetExists = false; | 402 | string ids = "'" + string.Join("','", uuids) + "'"; |
403 | string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); | ||
388 | 404 | ||
389 | lock (m_dbLock) | 405 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
390 | { | 406 | { |
391 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 407 | dbcon.Open(); |
408 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
392 | { | 409 | { |
393 | dbcon.Open(); | 410 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
394 | using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon)) | ||
395 | { | 411 | { |
396 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | 412 | while (dbReader.Read()) |
397 | |||
398 | try | ||
399 | { | ||
400 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
401 | { | ||
402 | if (dbReader.Read()) | ||
403 | { | ||
404 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
405 | assetExists = true; | ||
406 | } | ||
407 | } | ||
408 | } | ||
409 | catch (Exception e) | ||
410 | { | 413 | { |
411 | m_log.ErrorFormat( | 414 | UUID id = DBGuid.FromDB(dbReader["ID"]); |
412 | "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); | 415 | exists.Add(id); |
413 | } | 416 | } |
414 | } | 417 | } |
415 | } | 418 | } |
416 | } | 419 | } |
417 | 420 | ||
418 | return assetExists; | 421 | bool[] results = new bool[uuids.Length]; |
422 | for (int i = 0; i < uuids.Length; i++) | ||
423 | results[i] = exists.Contains(uuids[i]); | ||
424 | return results; | ||
419 | } | 425 | } |
420 | 426 | ||
427 | |||
421 | /// <summary> | 428 | /// <summary> |
422 | /// Returns a list of AssetMetadata objects. The list is a subset of | 429 | /// Returns a list of AssetMetadata objects. The list is a subset of |
423 | /// the entire data set offset by <paramref name="start" /> containing | 430 | /// the entire data set offset by <paramref name="start" /> containing |
@@ -430,41 +437,40 @@ namespace OpenSim.Data.MySQL | |||
430 | { | 437 | { |
431 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 438 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
432 | 439 | ||
433 | lock (m_dbLock) | 440 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
434 | { | 441 | { |
435 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 442 | dbcon.Open(); |
436 | { | 443 | MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); |
437 | dbcon.Open(); | 444 | cmd.Parameters.AddWithValue("?start", start); |
438 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); | 445 | cmd.Parameters.AddWithValue("?count", count); |
439 | cmd.Parameters.AddWithValue("?start", start); | ||
440 | cmd.Parameters.AddWithValue("?count", count); | ||
441 | 446 | ||
442 | try | 447 | try |
448 | { | ||
449 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
443 | { | 450 | { |
444 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 451 | while (dbReader.Read()) |
445 | { | 452 | { |
446 | while (dbReader.Read()) | 453 | AssetMetadata metadata = new AssetMetadata(); |
447 | { | 454 | metadata.Name = (string)dbReader["Name"]; |
448 | AssetMetadata metadata = new AssetMetadata(); | 455 | metadata.Description = (string)dbReader["Description"]; |
449 | metadata.Name = (string)dbReader["name"]; | 456 | metadata.Type = (sbyte)dbReader["AssetType"]; |
450 | metadata.Description = (string)dbReader["description"]; | 457 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. |
451 | metadata.Type = (sbyte)dbReader["asset_type"]; | 458 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
452 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 459 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); |
453 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 460 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
454 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 461 | |
455 | metadata.CreatorID = dbReader["creator_id"].ToString(); | 462 | // We'll ignore this for now - it appears unused! |
456 | |||
457 | // We'll ignore this for now - it appears unused! | ||
458 | // metadata.SHA1 = dbReader["hash"]); | 463 | // metadata.SHA1 = dbReader["hash"]); |
459 | 464 | ||
460 | retList.Add(metadata); | 465 | UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); |
461 | } | 466 | |
467 | retList.Add(metadata); | ||
462 | } | 468 | } |
463 | } | 469 | } |
464 | catch (Exception e) | 470 | } |
465 | { | 471 | catch (Exception e) |
466 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 472 | { |
467 | } | 473 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
468 | } | 474 | } |
469 | } | 475 | } |
470 | 476 | ||
@@ -475,21 +481,18 @@ namespace OpenSim.Data.MySQL | |||
475 | { | 481 | { |
476 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); | 482 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); |
477 | 483 | ||
478 | lock (m_dbLock) | 484 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
479 | { | 485 | { |
480 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 486 | dbcon.Open(); |
481 | { | ||
482 | dbcon.Open(); | ||
483 | |||
484 | using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon)) | ||
485 | { | ||
486 | cmd.Parameters.AddWithValue("?id", id); | ||
487 | cmd.ExecuteNonQuery(); | ||
488 | } | ||
489 | 487 | ||
490 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | 488 | using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) |
491 | // keep a reference count (?) | 489 | { |
490 | cmd.Parameters.AddWithValue("?ID", id); | ||
491 | cmd.ExecuteNonQuery(); | ||
492 | } | 492 | } |
493 | |||
494 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | ||
495 | // keep a reference count (?) | ||
493 | } | 496 | } |
494 | 497 | ||
495 | return true; | 498 | return true; |
diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index ab3fe36..b46d175 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.7.5.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | |
diff --git a/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations new file mode 100644 index 0000000..e496f72 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 1 # ------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `AgentPrefs` ( | ||
6 | `PrincipalID` CHAR(36) NOT NULL, | ||
7 | `AccessPrefs` CHAR(2) NOT NULL DEFAULT 'M', | ||
8 | `HoverHeight` DOUBLE(30, 27) NOT NULL DEFAULT 0, | ||
9 | `Language` CHAR(5) NOT NULL DEFAULT 'en-us', | ||
10 | `LanguageIsPublic` BOOLEAN NOT NULL DEFAULT 1, | ||
11 | `PermEveryone` INT(6) NOT NULL DEFAULT 0, | ||
12 | `PermGroup` INT(6) NOT NULL DEFAULT 0, | ||
13 | `PermNextOwner` INT(6) NOT NULL DEFAULT 532480, | ||
14 | UNIQUE KEY `PrincipalID` (`PrincipalID`), | ||
15 | PRIMARY KEY(`PrincipalID`) | ||
16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
17 | |||
18 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index f7211c2..661d825 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations | |||
@@ -13,7 +13,7 @@ CREATE TABLE `assets` ( | |||
13 | `temporary` tinyint(1) NOT NULL, | 13 | `temporary` tinyint(1) NOT NULL, |
14 | `data` longblob NOT NULL, | 14 | `data` longblob NOT NULL, |
15 | PRIMARY KEY (`id`) | 15 | PRIMARY KEY (`id`) |
16 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; | 16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; |
17 | 17 | ||
18 | COMMIT; | 18 | COMMIT; |
19 | 19 | ||
@@ -75,3 +75,7 @@ ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; | |||
75 | 75 | ||
76 | ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; | 76 | ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; |
77 | 77 | ||
78 | :VERSION 9 | ||
79 | |||
80 | BEGIN; | ||
81 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/AuthStore.migrations b/OpenSim/Data/MySQL/Resources/AuthStore.migrations index 9450940..023c786 100644 --- a/OpenSim/Data/MySQL/Resources/AuthStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AuthStore.migrations | |||
@@ -8,7 +8,7 @@ CREATE TABLE `auth` ( | |||
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 | PRIMARY KEY (`UUID`) |
11 | ) ENGINE=MyISAM; | 11 | ) ENGINE=InnoDB; |
12 | 12 | ||
13 | CREATE TABLE `tokens` ( | 13 | CREATE TABLE `tokens` ( |
14 | `UUID` char(36) NOT NULL, | 14 | `UUID` char(36) NOT NULL, |
@@ -18,7 +18,7 @@ CREATE TABLE `tokens` ( | |||
18 | KEY `UUID` (`UUID`), | 18 | KEY `UUID` (`UUID`), |
19 | KEY `token` (`token`), | 19 | KEY `token` (`token`), |
20 | KEY `validity` (`validity`) | 20 | KEY `validity` (`validity`) |
21 | ) ENGINE=MyISAM; | 21 | ) ENGINE=InnoDB; |
22 | 22 | ||
23 | commit; | 23 | commit; |
24 | 24 | ||
diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index 6ef92ee..2d1c2b5 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations | |||
@@ -10,19 +10,19 @@ CREATE TABLE IF NOT EXISTS `estate_managers` ( | |||
10 | `EstateID` int(10) unsigned NOT NULL, | 10 | `EstateID` int(10) unsigned NOT NULL, |
11 | `uuid` char(36) NOT NULL, | 11 | `uuid` char(36) NOT NULL, |
12 | KEY `EstateID` (`EstateID`) | 12 | KEY `EstateID` (`EstateID`) |
13 | ) ENGINE=MyISAM; | 13 | ) ENGINE=InnoDB; |
14 | 14 | ||
15 | CREATE TABLE IF NOT EXISTS `estate_groups` ( | 15 | CREATE TABLE IF NOT EXISTS `estate_groups` ( |
16 | `EstateID` int(10) unsigned NOT NULL, | 16 | `EstateID` int(10) unsigned NOT NULL, |
17 | `uuid` char(36) NOT NULL, | 17 | `uuid` char(36) NOT NULL, |
18 | KEY `EstateID` (`EstateID`) | 18 | KEY `EstateID` (`EstateID`) |
19 | ) ENGINE=MyISAM; | 19 | ) ENGINE=InnoDB; |
20 | 20 | ||
21 | CREATE TABLE IF NOT EXISTS `estate_users` ( | 21 | CREATE TABLE IF NOT EXISTS `estate_users` ( |
22 | `EstateID` int(10) unsigned NOT NULL, | 22 | `EstateID` int(10) unsigned NOT NULL, |
23 | `uuid` char(36) NOT NULL, | 23 | `uuid` char(36) NOT NULL, |
24 | KEY `EstateID` (`EstateID`) | 24 | KEY `EstateID` (`EstateID`) |
25 | ) ENGINE=MyISAM; | 25 | ) ENGINE=InnoDB; |
26 | 26 | ||
27 | CREATE TABLE IF NOT EXISTS `estateban` ( | 27 | CREATE TABLE IF NOT EXISTS `estateban` ( |
28 | `EstateID` int(10) unsigned NOT NULL, | 28 | `EstateID` int(10) unsigned NOT NULL, |
@@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `estateban` ( | |||
31 | `bannedIpHostMask` varchar(16) NOT NULL, | 31 | `bannedIpHostMask` varchar(16) NOT NULL, |
32 | `bannedNameMask` varchar(64) default NULL, | 32 | `bannedNameMask` varchar(64) default NULL, |
33 | KEY `estateban_EstateID` (`EstateID`) | 33 | KEY `estateban_EstateID` (`EstateID`) |
34 | ) ENGINE=MyISAM; | 34 | ) ENGINE=InnoDB; |
35 | 35 | ||
36 | CREATE TABLE IF NOT EXISTS `estate_settings` ( | 36 | CREATE TABLE IF NOT EXISTS `estate_settings` ( |
37 | `EstateID` int(10) unsigned NOT NULL auto_increment, | 37 | `EstateID` int(10) unsigned NOT NULL auto_increment, |
@@ -60,14 +60,14 @@ CREATE TABLE IF NOT EXISTS `estate_settings` ( | |||
60 | `DenyMinors` tinyint not null, | 60 | `DenyMinors` tinyint not null, |
61 | 61 | ||
62 | PRIMARY KEY (`EstateID`) | 62 | PRIMARY KEY (`EstateID`) |
63 | ) ENGINE=MyISAM AUTO_INCREMENT=100; | 63 | ) ENGINE=InnoDB AUTO_INCREMENT=100; |
64 | 64 | ||
65 | CREATE TABLE IF NOT EXISTS `estate_map` ( | 65 | CREATE TABLE IF NOT EXISTS `estate_map` ( |
66 | `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', | 66 | `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', |
67 | `EstateID` int(11) NOT NULL, | 67 | `EstateID` int(11) NOT NULL, |
68 | PRIMARY KEY (`RegionID`), | 68 | PRIMARY KEY (`RegionID`), |
69 | KEY `EstateID` (`EstateID`) | 69 | KEY `EstateID` (`EstateID`) |
70 | ) ENGINE=MyISAM; | 70 | ) ENGINE=InnoDB; |
71 | 71 | ||
72 | COMMIT; | 72 | COMMIT; |
73 | 73 | ||
@@ -77,5 +77,11 @@ BEGIN; | |||
77 | ALTER TABLE estate_settings AUTO_INCREMENT = 100; | 77 | ALTER TABLE estate_settings AUTO_INCREMENT = 100; |
78 | COMMIT; | 78 | COMMIT; |
79 | 79 | ||
80 | :VERSION 33 #--------------------- | ||
80 | 81 | ||
82 | BEGIN; | ||
83 | ALTER TABLE estate_settings ADD COLUMN `AllowLandmark` tinyint(4) NOT NULL default '1'; | ||
84 | ALTER TABLE estate_settings ADD COLUMN `AllowParcelChanges` tinyint(4) NOT NULL default '1'; | ||
85 | ALTER TABLE estate_settings ADD COLUMN `AllowSetHome` tinyint(4) NOT NULL default '1'; | ||
86 | COMMIT; | ||
81 | 87 | ||
diff --git a/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations new file mode 100644 index 0000000..87d08c6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | # ----------------- | ||
2 | :VERSION 1 | ||
3 | |||
4 | BEGIN; | ||
5 | |||
6 | CREATE TABLE `fsassets` ( | ||
7 | `id` char(36) NOT NULL, | ||
8 | `name` varchar(64) NOT NULL DEFAULT '', | ||
9 | `description` varchar(64) NOT NULL DEFAULT '', | ||
10 | `type` int(11) NOT NULL, | ||
11 | `hash` char(80) NOT NULL, | ||
12 | `create_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', | ||
15 | PRIMARY KEY (`id`) | ||
16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
17 | |||
18 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 55d82ec..5faf956 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations | |||
@@ -9,7 +9,7 @@ CREATE TABLE `Friends` ( | |||
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`, `Friend`), |
11 | KEY(`PrincipalID`) | 11 | KEY(`PrincipalID`) |
12 | ); | 12 | ) ENGINE=InnoDB; |
13 | 13 | ||
14 | COMMIT; | 14 | COMMIT; |
15 | 15 | ||
diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations index b010c63..b8d287a 100644 --- a/OpenSim/Data/MySQL/Resources/GridStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations | |||
@@ -1,5 +1,7 @@ | |||
1 | :VERSION 1 | 1 | :VERSION 1 |
2 | 2 | ||
3 | BEGIN; | ||
4 | |||
3 | CREATE TABLE `regions` ( | 5 | CREATE TABLE `regions` ( |
4 | `uuid` varchar(36) NOT NULL, | 6 | `uuid` varchar(36) NOT NULL, |
5 | `regionHandle` bigint(20) unsigned NOT NULL, | 7 | `regionHandle` bigint(20) unsigned NOT NULL, |
@@ -31,7 +33,9 @@ CREATE TABLE `regions` ( | |||
31 | KEY `regionName` (`regionName`), | 33 | KEY `regionName` (`regionName`), |
32 | KEY `regionHandle` (`regionHandle`), | 34 | KEY `regionHandle` (`regionHandle`), |
33 | KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) | 35 | KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) |
34 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; | 36 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
37 | |||
38 | COMMIT; | ||
35 | 39 | ||
36 | :VERSION 2 | 40 | :VERSION 2 |
37 | 41 | ||
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 | ||
19 | COMMIT; | 19 | COMMIT; |
20 | 20 | ||
diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..b4e4422 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `hg_traveling_data` ( | ||
6 | `SessionID` VARCHAR(36) NOT NULL, | ||
7 | `UserID` VARCHAR(36) NOT NULL, | ||
8 | `GridExternalName` VARCHAR(255) NOT NULL DEFAULT '', | ||
9 | `ServiceToken` VARCHAR(255) NOT NULL DEFAULT '', | ||
10 | `ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '', | ||
11 | `MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '', | ||
12 | `TMStamp` timestamp NOT NULL, | ||
13 | PRIMARY KEY (`SessionID`), | ||
14 | KEY (`UserID`) | ||
15 | ) ENGINE=InnoDB; | ||
16 | |||
17 | COMMIT; | ||
18 | |||
diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations new file mode 100644 index 0000000..79ead98 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations | |||
@@ -0,0 +1,42 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `im_offline` ( | ||
6 | `ID` MEDIUMINT NOT NULL AUTO_INCREMENT, | ||
7 | `PrincipalID` char(36) NOT NULL default '', | ||
8 | `Message` text NOT NULL, | ||
9 | `TMStamp` timestamp NOT NULL, | ||
10 | PRIMARY KEY (`ID`), | ||
11 | KEY `PrincipalID` (`PrincipalID`) | ||
12 | ) ENGINE=MyISAM; | ||
13 | |||
14 | COMMIT; | ||
15 | |||
16 | :VERSION 2 # -------------------------- | ||
17 | |||
18 | BEGIN; | ||
19 | |||
20 | INSERT INTO `im_offline` SELECT * from `diva_im_offline`; | ||
21 | DROP TABLE `diva_im_offline`; | ||
22 | DELETE FROM `migrations` WHERE name='diva_im_Store'; | ||
23 | |||
24 | COMMIT; | ||
25 | |||
26 | :VERSION 3 # -------------------------- | ||
27 | |||
28 | BEGIN; | ||
29 | |||
30 | ALTER TABLE `im_offline` | ||
31 | ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`, | ||
32 | ADD KEY `FromID` (`FromID`); | ||
33 | |||
34 | COMMIT; | ||
35 | |||
36 | :VERSION 4 # -------------------------- | ||
37 | |||
38 | BEGIN; | ||
39 | |||
40 | ALTER TABLE im_offline CONVERT TO CHARACTER SET utf8; | ||
41 | |||
42 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations index ca2fe11..993a5a0 100644 --- a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations | |||
@@ -11,7 +11,7 @@ CREATE TABLE `inventoryfolders` ( | |||
11 | PRIMARY KEY (`folderID`), | 11 | PRIMARY KEY (`folderID`), |
12 | KEY `owner` (`agentID`), | 12 | KEY `owner` (`agentID`), |
13 | KEY `parent` (`parentFolderID`) | 13 | KEY `parent` (`parentFolderID`) |
14 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 14 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
15 | 15 | ||
16 | CREATE TABLE `inventoryitems` ( | 16 | CREATE TABLE `inventoryitems` ( |
17 | `inventoryID` varchar(36) NOT NULL default '', | 17 | `inventoryID` varchar(36) NOT NULL default '', |
@@ -36,7 +36,7 @@ CREATE TABLE `inventoryitems` ( | |||
36 | PRIMARY KEY (`inventoryID`), | 36 | PRIMARY KEY (`inventoryID`), |
37 | KEY `owner` (`avatarID`), | 37 | KEY `owner` (`avatarID`), |
38 | KEY `folder` (`parentFolderID`) | 38 | KEY `folder` (`parentFolderID`) |
39 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 39 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
40 | 40 | ||
41 | COMMIT; | 41 | COMMIT; |
42 | 42 | ||
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/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index 5dc96d2..c4e40fa 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations | |||
@@ -1,4 +1,4 @@ | |||
1 | :VERSION 1 # -------------------------- | 1 | :VERSION 1 # -------------------------- |
2 | 2 | ||
3 | BEGIN; | 3 | BEGIN; |
4 | 4 | ||
@@ -7,7 +7,7 @@ CREATE TABLE `Presence` ( | |||
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 | ) ENGINE=InnoDB; |
11 | 11 | ||
12 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); | 12 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); |
13 | CREATE INDEX UserID ON Presence(UserID); | 13 | CREATE INDEX UserID ON Presence(UserID); |
@@ -21,3 +21,11 @@ BEGIN; | |||
21 | ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; | 21 | ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; |
22 | 22 | ||
23 | COMMIT; | 23 | COMMIT; |
24 | |||
25 | :VERSION 3 # -------------------------- | ||
26 | |||
27 | BEGIN; | ||
28 | |||
29 | CREATE INDEX RegionID ON Presence(RegionID); | ||
30 | |||
31 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 071f64e..ac31380 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations | |||
@@ -146,7 +146,7 @@ CREATE TABLE `land` ( | |||
146 | `UserLookAtZ` float default NULL, | 146 | `UserLookAtZ` float default NULL, |
147 | `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', | 147 | `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', |
148 | PRIMARY KEY (`UUID`) | 148 | PRIMARY KEY (`UUID`) |
149 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 149 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
150 | 150 | ||
151 | CREATE TABLE `landaccesslist` ( | 151 | CREATE TABLE `landaccesslist` ( |
152 | `LandUUID` varchar(255) default NULL, | 152 | `LandUUID` varchar(255) default NULL, |
@@ -168,7 +168,7 @@ COMMIT; | |||
168 | :VERSION 3 #--------------------- | 168 | :VERSION 3 #--------------------- |
169 | 169 | ||
170 | BEGIN; | 170 | BEGIN; |
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'; | 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=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; |
172 | COMMIT; | 172 | COMMIT; |
173 | 173 | ||
174 | :VERSION 4 #--------------------- | 174 | :VERSION 4 #--------------------- |
@@ -226,13 +226,13 @@ COMMIT; | |||
226 | 226 | ||
227 | BEGIN; | 227 | BEGIN; |
228 | 228 | ||
229 | alter table landaccesslist ENGINE = MyISAM; | 229 | alter table landaccesslist ENGINE = InnoDB; |
230 | alter table migrations ENGINE = MyISAM; | 230 | alter table migrations ENGINE = InnoDB; |
231 | alter table primitems ENGINE = MyISAM; | 231 | alter table primitems ENGINE = InnoDB; |
232 | alter table prims ENGINE = MyISAM; | 232 | alter table prims ENGINE = InnoDB; |
233 | alter table primshapes ENGINE = MyISAM; | 233 | alter table primshapes ENGINE = InnoDB; |
234 | alter table regionsettings ENGINE = MyISAM; | 234 | alter table regionsettings ENGINE = InnoDB; |
235 | alter table terrain ENGINE = MyISAM; | 235 | alter table terrain ENGINE = InnoDB; |
236 | 236 | ||
237 | COMMIT; | 237 | COMMIT; |
238 | 238 | ||
@@ -384,7 +384,7 @@ CREATE TABLE `regionsettings` ( | |||
384 | `covenant` char(36) default NULL, | 384 | `covenant` char(36) default NULL, |
385 | `Sandbox` tinyint(4) NOT NULL, | 385 | `Sandbox` tinyint(4) NOT NULL, |
386 | PRIMARY KEY (`regionUUID`) | 386 | PRIMARY KEY (`regionUUID`) |
387 | ) ENGINE=MyISAM; | 387 | ) ENGINE=InnoDB; |
388 | 388 | ||
389 | commit; | 389 | commit; |
390 | 390 | ||
@@ -852,7 +852,7 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( | |||
852 | `Pitch` float NOT NULL, | 852 | `Pitch` float NOT NULL, |
853 | `Distance` float NOT NULL, | 853 | `Distance` float NOT NULL, |
854 | KEY `RegionID` (`RegionID`) | 854 | KEY `RegionID` (`RegionID`) |
855 | ) ENGINE=MyISAM; | 855 | ) ENGINE=Innodb; |
856 | 856 | ||
857 | ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; | 857 | ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; |
858 | COMMIT; | 858 | COMMIT; |
@@ -891,7 +891,7 @@ CREATE TABLE `regionenvironment` ( | |||
891 | `region_id` varchar(36) NOT NULL, | 891 | `region_id` varchar(36) NOT NULL, |
892 | `llsd_settings` TEXT NOT NULL, | 892 | `llsd_settings` TEXT NOT NULL, |
893 | PRIMARY KEY (`region_id`) | 893 | PRIMARY KEY (`region_id`) |
894 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 894 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
895 | 895 | ||
896 | COMMIT; | 896 | COMMIT; |
897 | 897 | ||
@@ -902,3 +902,49 @@ BEGIN; | |||
902 | CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); | 902 | CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); |
903 | 903 | ||
904 | COMMIT; | 904 | COMMIT; |
905 | |||
906 | :VERSION 46 #---------------- Dynamic attributes | ||
907 | |||
908 | BEGIN; | ||
909 | |||
910 | ALTER TABLE prims ADD COLUMN DynAttrs TEXT; | ||
911 | |||
912 | COMMIT; | ||
913 | |||
914 | :VERSION 47 #---------------- Extra physics params | ||
915 | |||
916 | BEGIN; | ||
917 | |||
918 | ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; | ||
919 | ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000'; | ||
920 | ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1'; | ||
921 | ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; | ||
922 | ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; | ||
923 | |||
924 | COMMIT; | ||
925 | |||
926 | :VERSION 48 #---------------- Keyframes | ||
927 | |||
928 | BEGIN; | ||
929 | |||
930 | ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; | ||
931 | |||
932 | COMMIT; | ||
933 | |||
934 | :VERSION 49 #--------------------- Save attachment info | ||
935 | |||
936 | BEGIN; | ||
937 | ALTER TABLE prims ADD COLUMN AttachedPosX double default 0; | ||
938 | ALTER TABLE prims ADD COLUMN AttachedPosY double default 0; | ||
939 | ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0; | ||
940 | ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; | ||
941 | COMMIT; | ||
942 | |||
943 | :VERSION 50 #---- Change LandFlags to unsigned | ||
944 | |||
945 | BEGIN; | ||
946 | |||
947 | ALTER TABLE land CHANGE COLUMN LandFlags LandFlags int unsigned default null; | ||
948 | |||
949 | COMMIT; | ||
950 | |||
diff --git a/OpenSim/Data/MySQL/Resources/UserAccount.migrations b/OpenSim/Data/MySQL/Resources/UserAccount.migrations index 97e5e4f..84011e6 100644 --- a/OpenSim/Data/MySQL/Resources/UserAccount.migrations +++ b/OpenSim/Data/MySQL/Resources/UserAccount.migrations | |||
@@ -10,7 +10,7 @@ CREATE TABLE `UserAccounts` ( | |||
10 | `Email` VARCHAR(64), | 10 | `Email` VARCHAR(64), |
11 | `ServiceURLs` TEXT, | 11 | `ServiceURLs` TEXT, |
12 | `Created` INT(11) | 12 | `Created` INT(11) |
13 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
14 | 14 | ||
15 | COMMIT; | 15 | COMMIT; |
16 | 16 | ||
diff --git a/sql/osprofile.sql b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations index bcd5be0..87e99fa 100644 --- a/sql/osprofile.sql +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations | |||
@@ -1,3 +1,7 @@ | |||
1 | :VERSION 1 # ------------------------------- | ||
2 | |||
3 | begin; | ||
4 | |||
1 | CREATE TABLE IF NOT EXISTS `classifieds` ( | 5 | CREATE TABLE IF NOT EXISTS `classifieds` ( |
2 | `classifieduuid` char(36) NOT NULL, | 6 | `classifieduuid` char(36) NOT NULL, |
3 | `creatoruuid` char(36) NOT NULL, | 7 | `creatoruuid` char(36) NOT NULL, |
@@ -15,7 +19,8 @@ CREATE TABLE IF NOT EXISTS `classifieds` ( | |||
15 | `classifiedflags` int(8) NOT NULL, | 19 | `classifiedflags` int(8) NOT NULL, |
16 | `priceforlisting` int(5) NOT NULL, | 20 | `priceforlisting` int(5) NOT NULL, |
17 | PRIMARY KEY (`classifieduuid`) | 21 | PRIMARY KEY (`classifieduuid`) |
18 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 22 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
23 | |||
19 | 24 | ||
20 | CREATE TABLE IF NOT EXISTS `usernotes` ( | 25 | CREATE TABLE IF NOT EXISTS `usernotes` ( |
21 | `useruuid` varchar(36) NOT NULL, | 26 | `useruuid` varchar(36) NOT NULL, |
@@ -24,6 +29,7 @@ CREATE TABLE IF NOT EXISTS `usernotes` ( | |||
24 | UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) | 29 | UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) |
25 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 30 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
26 | 31 | ||
32 | |||
27 | CREATE TABLE IF NOT EXISTS `userpicks` ( | 33 | CREATE TABLE IF NOT EXISTS `userpicks` ( |
28 | `pickuuid` varchar(36) NOT NULL, | 34 | `pickuuid` varchar(36) NOT NULL, |
29 | `creatoruuid` varchar(36) NOT NULL, | 35 | `creatoruuid` varchar(36) NOT NULL, |
@@ -41,6 +47,7 @@ CREATE TABLE IF NOT EXISTS `userpicks` ( | |||
41 | PRIMARY KEY (`pickuuid`) | 47 | PRIMARY KEY (`pickuuid`) |
42 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 48 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
43 | 49 | ||
50 | |||
44 | CREATE TABLE IF NOT EXISTS `userprofile` ( | 51 | CREATE TABLE IF NOT EXISTS `userprofile` ( |
45 | `useruuid` varchar(36) NOT NULL, | 52 | `useruuid` varchar(36) NOT NULL, |
46 | `profilePartner` varchar(36) NOT NULL, | 53 | `profilePartner` varchar(36) NOT NULL, |
@@ -59,6 +66,23 @@ CREATE TABLE IF NOT EXISTS `userprofile` ( | |||
59 | PRIMARY KEY (`useruuid`) | 66 | PRIMARY KEY (`useruuid`) |
60 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 67 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
61 | 68 | ||
69 | commit; | ||
70 | |||
71 | :VERSION 2 # ------------------------------- | ||
72 | |||
73 | begin; | ||
74 | CREATE TABLE IF NOT EXISTS `userdata` ( | ||
75 | `UserId` char(36) NOT NULL, | ||
76 | `TagId` varchar(64) NOT NULL, | ||
77 | `DataKey` varchar(255), | ||
78 | `DataVal` varchar(255), | ||
79 | PRIMARY KEY (`UserId`,`TagId`) | ||
80 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
81 | |||
82 | commit; | ||
83 | |||
84 | :VERSION 3 # ------------------------------- | ||
85 | begin; | ||
62 | CREATE TABLE IF NOT EXISTS `usersettings` ( | 86 | CREATE TABLE IF NOT EXISTS `usersettings` ( |
63 | `useruuid` varchar(36) NOT NULL, | 87 | `useruuid` varchar(36) NOT NULL, |
64 | `imviaemail` enum('true','false') NOT NULL, | 88 | `imviaemail` enum('true','false') NOT NULL, |
@@ -66,3 +90,9 @@ CREATE TABLE IF NOT EXISTS `usersettings` ( | |||
66 | `email` varchar(254) NOT NULL, | 90 | `email` varchar(254) NOT NULL, |
67 | PRIMARY KEY (`useruuid`) | 91 | PRIMARY KEY (`useruuid`) |
68 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 92 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
93 | commit; | ||
94 | |||
95 | :VERSION 4 # ------------------------------- | ||
96 | begin; | ||
97 | ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255); | ||
98 | commit; | ||
diff --git a/OpenSim/Data/MySQL/Resources/UserStore.migrations b/OpenSim/Data/MySQL/Resources/UserStore.migrations index 9129075..f054611 100644 --- a/OpenSim/Data/MySQL/Resources/UserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/UserStore.migrations | |||
@@ -21,7 +21,7 @@ CREATE TABLE `agents` ( | |||
21 | PRIMARY KEY (`UUID`), | 21 | PRIMARY KEY (`UUID`), |
22 | UNIQUE KEY `session` (`sessionID`), | 22 | UNIQUE KEY `session` (`sessionID`), |
23 | UNIQUE KEY `ssession` (`secureSessionID`) | 23 | UNIQUE KEY `ssession` (`secureSessionID`) |
24 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 24 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
25 | 25 | ||
26 | -- Create schema avatar_appearance | 26 | -- Create schema avatar_appearance |
27 | -- | 27 | -- |
@@ -59,7 +59,7 @@ CREATE TABLE `avatarappearance` ( | |||
59 | Skirt_Item char(36) NOT NULL, | 59 | Skirt_Item char(36) NOT NULL, |
60 | Skirt_Asset char(36) NOT NULL, | 60 | Skirt_Asset char(36) NOT NULL, |
61 | PRIMARY KEY (`Owner`) | 61 | PRIMARY KEY (`Owner`) |
62 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 62 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
63 | 63 | ||
64 | SET FOREIGN_KEY_CHECKS=0; | 64 | SET FOREIGN_KEY_CHECKS=0; |
65 | -- ---------------------------- | 65 | -- ---------------------------- |
@@ -71,7 +71,7 @@ CREATE TABLE `userfriends` ( | |||
71 | `friendPerms` INT NOT NULL, | 71 | `friendPerms` INT NOT NULL, |
72 | `datetimestamp` INT NOT NULL, | 72 | `datetimestamp` INT NOT NULL, |
73 | UNIQUE KEY (`ownerID`, `friendID`) | 73 | UNIQUE KEY (`ownerID`, `friendID`) |
74 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 74 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
75 | -- ---------------------------- | 75 | -- ---------------------------- |
76 | -- Table structure for users | 76 | -- Table structure for users |
77 | -- ---------------------------- | 77 | -- ---------------------------- |
@@ -101,7 +101,7 @@ CREATE TABLE `users` ( | |||
101 | `webLoginKey` varchar(36) default NULL, | 101 | `webLoginKey` varchar(36) default NULL, |
102 | PRIMARY KEY (`UUID`), | 102 | PRIMARY KEY (`UUID`), |
103 | UNIQUE KEY `usernames` (`username`,`lastname`) | 103 | UNIQUE KEY `usernames` (`username`,`lastname`) |
104 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 104 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
105 | 105 | ||
106 | -- ---------------------------- | 106 | -- ---------------------------- |
107 | -- Records | 107 | -- Records |
@@ -138,7 +138,7 @@ COMMIT; | |||
138 | 138 | ||
139 | BEGIN; | 139 | BEGIN; |
140 | 140 | ||
141 | CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=MyISAM; | 141 | CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=InnoDB; |
142 | 142 | ||
143 | COMMIT; | 143 | COMMIT; |
144 | 144 | ||
diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index bb58c39..9459e3e 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations | |||
@@ -3,25 +3,30 @@ | |||
3 | 3 | ||
4 | BEGIN; | 4 | BEGIN; |
5 | 5 | ||
6 | CREATE TABLE `xassetsmeta` ( | 6 | CREATE TABLE `XAssetsMeta` ( |
7 | `id` char(36) NOT NULL, | 7 | `ID` char(36) NOT NULL, |
8 | `hash` binary(32) NOT NULL, | 8 | `Hash` binary(32) NOT NULL, |
9 | `name` varchar(64) NOT NULL, | 9 | `Name` varchar(64) NOT NULL, |
10 | `description` varchar(64) NOT NULL, | 10 | `Description` varchar(64) NOT NULL, |
11 | `asset_type` tinyint(4) NOT NULL, | 11 | `AssetType` tinyint(4) NOT NULL, |
12 | `local` tinyint(1) NOT NULL, | 12 | `Local` tinyint(1) NOT NULL, |
13 | `temporary` tinyint(1) NOT NULL, | 13 | `Temporary` tinyint(1) NOT NULL, |
14 | `create_time` int(11) NOT NULL, | 14 | `CreateTime` int(11) NOT NULL, |
15 | `access_time` int(11) NOT NULL, | 15 | `AccessTime` int(11) NOT NULL, |
16 | `asset_flags` int(11) NOT NULL, | 16 | `AssetFlags` int(11) NOT NULL, |
17 | `creator_id` 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 | ||
21 | CREATE TABLE `xassetsdata` ( | 21 | CREATE 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 | ||
27 | COMMIT; \ No newline at end of file | 27 | COMMIT; |
28 | |||
29 | :VERSION 2 | ||
30 | |||
31 | BEGIN; | ||
32 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations new file mode 100644 index 0000000..9e6f1c1 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations | |||
@@ -0,0 +1,115 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `os_groups_groups` ( | ||
6 | `GroupID` char(36) NOT NULL default '', | ||
7 | `Location` varchar(255) NOT NULL default '', | ||
8 | `Name` varchar(255) NOT NULL default '', | ||
9 | `Charter` text NOT NULL, | ||
10 | `InsigniaID` char(36) NOT NULL default '', | ||
11 | `FounderID` char(36) NOT NULL default '', | ||
12 | `MembershipFee` int(11) NOT NULL default '0', | ||
13 | `OpenEnrollment` varchar(255) NOT NULL default '', | ||
14 | `ShowInList` int(4) NOT NULL default '0', | ||
15 | `AllowPublish` int(4) NOT NULL default '0', | ||
16 | `MaturePublish` int(4) NOT NULL default '0', | ||
17 | `OwnerRoleID` char(36) NOT NULL default '', | ||
18 | PRIMARY KEY (`GroupID`), | ||
19 | UNIQUE KEY `Name` (`Name`), | ||
20 | FULLTEXT KEY `Name_2` (`Name`) | ||
21 | ) ENGINE=MyISAM; | ||
22 | |||
23 | |||
24 | CREATE TABLE `os_groups_membership` ( | ||
25 | `GroupID`char(36) NOT NULL default '', | ||
26 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
27 | `SelectedRoleID` char(36) NOT NULL default '', | ||
28 | `Contribution` int(11) NOT NULL default '0', | ||
29 | `ListInProfile` int(4) NOT NULL default '1', | ||
30 | `AcceptNotices` int(4) NOT NULL default '1', | ||
31 | `AccessToken` char(36) NOT NULL default '', | ||
32 | PRIMARY KEY (`GroupID`,`PrincipalID`), | ||
33 | KEY `PrincipalID` (`PrincipalID`) | ||
34 | ) ENGINE=MyISAM; | ||
35 | |||
36 | |||
37 | CREATE TABLE `os_groups_roles` ( | ||
38 | `GroupID` char(36) NOT NULL default '', | ||
39 | `RoleID` char(36) NOT NULL default '', | ||
40 | `Name` varchar(255) NOT NULL default '', | ||
41 | `Description` varchar(255) NOT NULL default '', | ||
42 | `Title` varchar(255) NOT NULL default '', | ||
43 | `Powers` bigint(20) unsigned NOT NULL default '0', | ||
44 | PRIMARY KEY (`GroupID`,`RoleID`), | ||
45 | KEY `GroupID` (`GroupID`) | ||
46 | ) ENGINE=MyISAM; | ||
47 | |||
48 | |||
49 | CREATE TABLE `os_groups_rolemembership` ( | ||
50 | `GroupID` char(36) NOT NULL default '', | ||
51 | `RoleID` char(36) NOT NULL default '', | ||
52 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
53 | PRIMARY KEY (`GroupID`,`RoleID`,`PrincipalID`), | ||
54 | KEY `PrincipalID` (`PrincipalID`) | ||
55 | ) ENGINE=MyISAM; | ||
56 | |||
57 | |||
58 | CREATE TABLE `os_groups_invites` ( | ||
59 | `InviteID` char(36) NOT NULL default '', | ||
60 | `GroupID` char(36) NOT NULL default '', | ||
61 | `RoleID` char(36) NOT NULL default '', | ||
62 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
63 | `TMStamp` timestamp NOT NULL, | ||
64 | PRIMARY KEY (`InviteID`), | ||
65 | UNIQUE KEY `PrincipalGroup` (`GroupID`,`PrincipalID`) | ||
66 | ) ENGINE=MyISAM; | ||
67 | |||
68 | |||
69 | CREATE TABLE `os_groups_notices` ( | ||
70 | `GroupID` char(36) NOT NULL default '', | ||
71 | `NoticeID` char(36) NOT NULL default '', | ||
72 | `TMStamp` int(10) unsigned NOT NULL default '0', | ||
73 | `FromName` varchar(255) NOT NULL default '', | ||
74 | `Subject` varchar(255) NOT NULL default '', | ||
75 | `Message` text NOT NULL, | ||
76 | `HasAttachment` int(4) NOT NULL default '0', | ||
77 | `AttachmentType` int(4) NOT NULL default '0', | ||
78 | `AttachmentName` varchar(128) NOT NULL default '', | ||
79 | `AttachmentItemID` char(36) NOT NULL default '', | ||
80 | `AttachmentOwnerID` varchar(255) NOT NULL default '', | ||
81 | PRIMARY KEY (`NoticeID`), | ||
82 | KEY `GroupID` (`GroupID`), | ||
83 | KEY `TMStamp` (`TMStamp`) | ||
84 | ) ENGINE=MyISAM; | ||
85 | |||
86 | CREATE TABLE `os_groups_principals` ( | ||
87 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
88 | `ActiveGroupID` char(36) NOT NULL default '', | ||
89 | PRIMARY KEY (`PrincipalID`) | ||
90 | ) ENGINE=MyISAM; | ||
91 | |||
92 | COMMIT; | ||
93 | |||
94 | :VERSION 2 # -------------------------- | ||
95 | |||
96 | BEGIN; | ||
97 | |||
98 | INSERT INTO `os_groups_groups` SELECT * from `diva_groups_groups`; | ||
99 | DROP TABLE `diva_groups_groups`; | ||
100 | INSERT INTO `os_groups_membership` SELECT * from `diva_groups_membership`; | ||
101 | DROP TABLE `diva_groups_membership`; | ||
102 | INSERT INTO `os_groups_roles` SELECT * from `diva_groups_roles`; | ||
103 | DROP TABLE `diva_groups_roles`; | ||
104 | INSERT INTO `os_groups_rolemembership` SELECT * from `diva_groups_rolemembership`; | ||
105 | DROP TABLE `diva_groups_rolemembership`; | ||
106 | INSERT INTO `os_groups_invites` SELECT * from `diva_groups_invites`; | ||
107 | DROP TABLE `diva_groups_invites`; | ||
108 | INSERT INTO `os_groups_notices` SELECT * from `diva_groups_notices`; | ||
109 | DROP TABLE `diva_groups_notices`; | ||
110 | INSERT INTO `os_groups_principals` SELECT * from `diva_groups_principals`; | ||
111 | DROP TABLE `diva_groups_principals`; | ||
112 | |||
113 | DELETE FROM `migrations` WHERE name='diva_im_Store'; | ||
114 | |||
115 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs index d64136d..57592f1 100755 --- a/OpenSim/Data/Null/NullEstateData.cs +++ b/OpenSim/Data/Null/NullEstateData.cs | |||
@@ -42,6 +42,22 @@ namespace OpenSim.Data.Null | |||
42 | 42 | ||
43 | // private string m_connectionString; | 43 | // private string m_connectionString; |
44 | 44 | ||
45 | // private Dictionary<uint, EstateSettings> m_knownEstates = new Dictionary<uint, EstateSettings>(); | ||
46 | private EstateSettings m_estate = null; | ||
47 | |||
48 | private EstateSettings GetEstate() | ||
49 | { | ||
50 | if (m_estate == null) | ||
51 | { | ||
52 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | ||
53 | // The estate info is pretty empty so don't try banning anyone. | ||
54 | m_estate = new EstateSettings(); | ||
55 | m_estate.EstateID = 1; | ||
56 | m_estate.OnSave += StoreEstateSettings; | ||
57 | } | ||
58 | return m_estate; | ||
59 | } | ||
60 | |||
45 | protected virtual Assembly Assembly | 61 | protected virtual Assembly Assembly |
46 | { | 62 | { |
47 | get { return GetType().Assembly; } | 63 | get { return GetType().Assembly; } |
@@ -68,21 +84,18 @@ namespace OpenSim.Data.Null | |||
68 | 84 | ||
69 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 85 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
70 | { | 86 | { |
71 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | 87 | return GetEstate(); |
72 | // The estate info is pretty empty so don't try banning anyone. | ||
73 | EstateSettings oneEstate = new EstateSettings(); | ||
74 | oneEstate.EstateID = 1; | ||
75 | return oneEstate; | ||
76 | } | 88 | } |
77 | 89 | ||
78 | public void StoreEstateSettings(EstateSettings es) | 90 | public void StoreEstateSettings(EstateSettings es) |
79 | { | 91 | { |
92 | m_estate = es; | ||
80 | return; | 93 | return; |
81 | } | 94 | } |
82 | 95 | ||
83 | public EstateSettings LoadEstateSettings(int estateID) | 96 | public EstateSettings LoadEstateSettings(int estateID) |
84 | { | 97 | { |
85 | return new EstateSettings(); | 98 | return GetEstate(); |
86 | } | 99 | } |
87 | 100 | ||
88 | public EstateSettings CreateNewEstate() | 101 | public EstateSettings CreateNewEstate() |
@@ -93,13 +106,14 @@ namespace OpenSim.Data.Null | |||
93 | public List<EstateSettings> LoadEstateSettingsAll() | 106 | public List<EstateSettings> LoadEstateSettingsAll() |
94 | { | 107 | { |
95 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); | 108 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); |
96 | allEstateSettings.Add(new EstateSettings()); | 109 | allEstateSettings.Add(GetEstate()); |
97 | return allEstateSettings; | 110 | return allEstateSettings; |
98 | } | 111 | } |
99 | 112 | ||
100 | public List<int> GetEstatesAll() | 113 | public List<int> GetEstatesAll() |
101 | { | 114 | { |
102 | List<int> result = new List<int>(); | 115 | List<int> result = new List<int>(); |
116 | result.Add((int)GetEstate().EstateID); | ||
103 | return result; | 117 | return result; |
104 | } | 118 | } |
105 | 119 | ||
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs index b85b95e..aff0b0b 100644 --- a/OpenSim/Data/Null/NullPresenceData.cs +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -40,7 +40,7 @@ namespace OpenSim.Data.Null | |||
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 | private 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>(); |
46 | 46 | ||
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index f707d98..d28cd99 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -239,6 +239,11 @@ namespace OpenSim.Data.Null | |||
239 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 239 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
240 | } | 240 | } |
241 | 241 | ||
242 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
243 | { | ||
244 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
245 | } | ||
246 | |||
242 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 247 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
243 | { | 248 | { |
244 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 249 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs index 4979cf6..deeaced 100644 --- a/OpenSim/Data/Null/NullSimulationData.cs +++ b/OpenSim/Data/Null/NullSimulationData.cs | |||
@@ -77,20 +77,34 @@ namespace OpenSim.Data.Null | |||
77 | } | 77 | } |
78 | 78 | ||
79 | #region Environment Settings | 79 | #region Environment Settings |
80 | |||
81 | private Dictionary<UUID, string> EnvironmentSettings = new Dictionary<UUID, string>(); | ||
82 | |||
80 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 83 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
81 | { | 84 | { |
82 | //This connector doesn't support the Environment module yet | 85 | lock (EnvironmentSettings) |
86 | { | ||
87 | if (EnvironmentSettings.ContainsKey(regionUUID)) | ||
88 | return EnvironmentSettings[regionUUID]; | ||
89 | } | ||
83 | return string.Empty; | 90 | return string.Empty; |
84 | } | 91 | } |
85 | 92 | ||
86 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 93 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
87 | { | 94 | { |
88 | //This connector doesn't support the Environment module yet | 95 | lock (EnvironmentSettings) |
96 | { | ||
97 | EnvironmentSettings[regionUUID] = settings; | ||
98 | } | ||
89 | } | 99 | } |
90 | 100 | ||
91 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 101 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
92 | { | 102 | { |
93 | //This connector doesn't support the Environment module yet | 103 | lock (EnvironmentSettings) |
104 | { | ||
105 | if (EnvironmentSettings.ContainsKey(regionUUID)) | ||
106 | EnvironmentSettings.Remove(regionUUID); | ||
107 | } | ||
94 | } | 108 | } |
95 | #endregion | 109 | #endregion |
96 | 110 | ||
@@ -118,18 +132,36 @@ namespace OpenSim.Data.Null | |||
118 | return new List<SceneObjectGroup>(); | 132 | return new List<SceneObjectGroup>(); |
119 | } | 133 | } |
120 | 134 | ||
121 | Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>(); | 135 | Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); |
122 | public void StoreTerrain(double[,] ter, UUID regionID) | 136 | public void StoreTerrain(TerrainData ter, UUID regionID) |
123 | { | 137 | { |
124 | if (m_terrains.ContainsKey(regionID)) | 138 | if (m_terrains.ContainsKey(regionID)) |
125 | m_terrains.Remove(regionID); | 139 | m_terrains.Remove(regionID); |
126 | m_terrains.Add(regionID, ter); | 140 | m_terrains.Add(regionID, ter); |
127 | } | 141 | } |
128 | 142 | ||
143 | // Legacy. Just don't do this. | ||
144 | public void StoreTerrain(double[,] ter, UUID regionID) | ||
145 | { | ||
146 | TerrainData terrData = new HeightmapTerrainData(ter); | ||
147 | StoreTerrain(terrData, regionID); | ||
148 | } | ||
149 | |||
150 | // Legacy. Just don't do this. | ||
151 | // Returns 'null' if region not found | ||
129 | public double[,] LoadTerrain(UUID regionID) | 152 | public double[,] LoadTerrain(UUID regionID) |
130 | { | 153 | { |
131 | if (m_terrains.ContainsKey(regionID)) | 154 | if (m_terrains.ContainsKey(regionID)) |
132 | { | 155 | { |
156 | return m_terrains[regionID].GetDoubles(); | ||
157 | } | ||
158 | return null; | ||
159 | } | ||
160 | |||
161 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
162 | { | ||
163 | if (m_terrains.ContainsKey(regionID)) | ||
164 | { | ||
133 | return m_terrains[regionID]; | 165 | return m_terrains[regionID]; |
134 | } | 166 | } |
135 | return null; | 167 | return null; |
diff --git a/OpenSim/Data/Null/NullXGroupData.cs b/OpenSim/Data/Null/NullXGroupData.cs index 7a86b9f..3fa9451 100644 --- a/OpenSim/Data/Null/NullXGroupData.cs +++ b/OpenSim/Data/Null/NullXGroupData.cs | |||
@@ -38,7 +38,7 @@ using OpenSim.Data; | |||
38 | 38 | ||
39 | namespace OpenSim.Data.Null | 39 | namespace OpenSim.Data.Null |
40 | { | 40 | { |
41 | public class NullXGroupData : NullGenericDataHandler, IXGroupData | 41 | public class NullXGroupData : IXGroupData |
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 | ||
@@ -56,35 +56,31 @@ namespace OpenSim.Data.Null | |||
56 | return true; | 56 | return true; |
57 | } | 57 | } |
58 | 58 | ||
59 | public XGroup[] GetGroups(string field, string val) | 59 | public XGroup GetGroup(UUID groupID) |
60 | { | 60 | { |
61 | return GetGroups(new string[] { field }, new string[] { val }); | 61 | XGroup group = null; |
62 | } | ||
63 | 62 | ||
64 | public XGroup[] GetGroups(string[] fields, string[] vals) | ||
65 | { | ||
66 | lock (m_groups) | 63 | lock (m_groups) |
67 | { | 64 | m_groups.TryGetValue(groupID, out group); |
68 | List<XGroup> origGroups = Get<XGroup>(fields, vals, m_groups.Values.ToList()); | ||
69 | 65 | ||
70 | return origGroups.Select(g => g.Clone()).ToArray(); | 66 | return group; |
71 | } | ||
72 | } | 67 | } |
73 | 68 | ||
74 | public bool DeleteGroups(string field, string val) | 69 | public Dictionary<UUID, XGroup> GetGroups() |
75 | { | 70 | { |
76 | return DeleteGroups(new string[] { field }, new string[] { val }); | 71 | Dictionary<UUID, XGroup> groupsClone = new Dictionary<UUID, XGroup>(); |
72 | |||
73 | lock (m_groups) | ||
74 | foreach (XGroup group in m_groups.Values) | ||
75 | groupsClone[group.groupID] = group.Clone(); | ||
76 | |||
77 | return groupsClone; | ||
77 | } | 78 | } |
78 | 79 | ||
79 | public bool DeleteGroups(string[] fields, string[] vals) | 80 | public bool DeleteGroup(UUID groupID) |
80 | { | 81 | { |
81 | lock (m_groups) | 82 | lock (m_groups) |
82 | { | 83 | return m_groups.Remove(groupID); |
83 | XGroup[] groupsToDelete = GetGroups(fields, vals); | ||
84 | Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID)); | ||
85 | } | ||
86 | |||
87 | return true; | ||
88 | } | 84 | } |
89 | } | 85 | } |
90 | } \ No newline at end of file | 86 | } \ No newline at end of file |
diff --git a/OpenSim/Data/Null/Properties/AssemblyInfo.cs b/OpenSim/Data/Null/Properties/AssemblyInfo.cs index 43b0bb3..a827bd0 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.7.5.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | |
diff --git a/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs b/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs new file mode 100644 index 0000000..20612fe --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs | |||
@@ -0,0 +1,64 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using Npgsql; | ||
35 | |||
36 | namespace OpenSim.Data.PGSQL | ||
37 | { | ||
38 | public class PGSQLAgentPreferencesData : PGSQLGenericTableHandler<AgentPreferencesData>, IAgentPreferencesData | ||
39 | { | ||
40 | public PGSQLAgentPreferencesData(string connectionString, string realm) | ||
41 | : base(connectionString, realm, "AgentPrefs") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public AgentPreferencesData GetPrefs(UUID agentID) | ||
46 | { | ||
47 | // Until someone sends in a table that works | ||
48 | return null; | ||
49 | //AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString()); | ||
50 | |||
51 | //if (ret.Length == 0) | ||
52 | // return null; | ||
53 | |||
54 | //return ret[0]; | ||
55 | } | ||
56 | |||
57 | public override bool Store(AgentPreferencesData row) | ||
58 | { | ||
59 | // Until someone sends in a table that works | ||
60 | return false; | ||
61 | } | ||
62 | |||
63 | } | ||
64 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs index c7488d8..5d8b0a2 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs | |||
@@ -27,19 +27,20 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Data.SqlClient; | ||
31 | using System.Reflection; | 30 | using System.Reflection; |
32 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
34 | using log4net; | 33 | using log4net; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using Npgsql; | ||
36 | using NpgsqlTypes; | ||
36 | 37 | ||
37 | namespace OpenSim.Data.MSSQL | 38 | namespace OpenSim.Data.PGSQL |
38 | { | 39 | { |
39 | /// <summary> | 40 | /// <summary> |
40 | /// A MSSQL Interface for the Asset server | 41 | /// A PGSQL Interface for the Asset server |
41 | /// </summary> | 42 | /// </summary> |
42 | public class MSSQLAssetData : AssetDataBase | 43 | public class PGSQLAssetData : AssetDataBase |
43 | { | 44 | { |
44 | private const string _migrationStore = "AssetStore"; | 45 | private const string _migrationStore = "AssetStore"; |
45 | 46 | ||
@@ -48,9 +49,14 @@ namespace OpenSim.Data.MSSQL | |||
48 | /// <summary> | 49 | /// <summary> |
49 | /// Database manager | 50 | /// Database manager |
50 | /// </summary> | 51 | /// </summary> |
51 | private MSSQLManager m_database; | 52 | private PGSQLManager m_database; |
52 | private string m_connectionString; | 53 | private string m_connectionString; |
53 | 54 | ||
55 | protected virtual Assembly Assembly | ||
56 | { | ||
57 | get { return GetType().Assembly; } | ||
58 | } | ||
59 | |||
54 | #region IPlugin Members | 60 | #region IPlugin Members |
55 | 61 | ||
56 | override public void Dispose() { } | 62 | override public void Dispose() { } |
@@ -61,7 +67,7 @@ namespace OpenSim.Data.MSSQL | |||
61 | // [Obsolete("Cannot be default-initialized!")] | 67 | // [Obsolete("Cannot be default-initialized!")] |
62 | override public void Initialise() | 68 | override public void Initialise() |
63 | { | 69 | { |
64 | m_log.Info("[MSSQLAssetData]: " + Name + " cannot be default-initialized!"); | 70 | m_log.Info("[PGSQLAssetData]: " + Name + " cannot be default-initialized!"); |
65 | throw new PluginNotInitialisedException(Name); | 71 | throw new PluginNotInitialisedException(Name); |
66 | } | 72 | } |
67 | 73 | ||
@@ -76,7 +82,7 @@ namespace OpenSim.Data.MSSQL | |||
76 | { | 82 | { |
77 | m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks; | 83 | m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks; |
78 | 84 | ||
79 | m_database = new MSSQLManager(connectionString); | 85 | m_database = new PGSQLManager(connectionString); |
80 | m_connectionString = connectionString; | 86 | m_connectionString = connectionString; |
81 | 87 | ||
82 | //New migration to check for DB changes | 88 | //New migration to check for DB changes |
@@ -96,7 +102,7 @@ namespace OpenSim.Data.MSSQL | |||
96 | /// </summary> | 102 | /// </summary> |
97 | override public string Name | 103 | override public string Name |
98 | { | 104 | { |
99 | get { return "MSSQL Asset storage engine"; } | 105 | get { return "PGSQL Asset storage engine"; } |
100 | } | 106 | } |
101 | 107 | ||
102 | #endregion | 108 | #endregion |
@@ -110,13 +116,13 @@ namespace OpenSim.Data.MSSQL | |||
110 | /// <returns></returns> | 116 | /// <returns></returns> |
111 | override public AssetBase GetAsset(UUID assetID) | 117 | override public AssetBase GetAsset(UUID assetID) |
112 | { | 118 | { |
113 | string sql = "SELECT * FROM assets WHERE id = @id"; | 119 | string sql = "SELECT * FROM assets WHERE id = :id"; |
114 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 120 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
115 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 121 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
116 | { | 122 | { |
117 | cmd.Parameters.Add(m_database.CreateParameter("id", assetID)); | 123 | cmd.Parameters.Add(m_database.CreateParameter("id", assetID)); |
118 | conn.Open(); | 124 | conn.Open(); |
119 | using (SqlDataReader reader = cmd.ExecuteReader()) | 125 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
120 | { | 126 | { |
121 | if (reader.Read()) | 127 | if (reader.Read()) |
122 | { | 128 | { |
@@ -147,34 +153,38 @@ namespace OpenSim.Data.MSSQL | |||
147 | { | 153 | { |
148 | 154 | ||
149 | string sql = | 155 | string sql = |
150 | @"IF EXISTS(SELECT * FROM assets WHERE id=@id) | 156 | @"UPDATE assets set name = :name, description = :description, " + "\"assetType\" " + @" = :assetType, |
151 | UPDATE assets set name = @name, description = @description, assetType = @assetType, | 157 | local = :local, temporary = :temporary, creatorid = :creatorid, data = :data |
152 | local = @local, temporary = @temporary, creatorid = @creatorid, data = @data | 158 | WHERE id=:id; |
153 | WHERE id=@id | 159 | |
154 | ELSE | 160 | INSERT INTO assets |
155 | INSERT INTO assets | 161 | (id, name, description, " + "\"assetType\" " + @", local, |
156 | ([id], [name], [description], [assetType], [local], | 162 | temporary, create_time, access_time, creatorid, asset_flags, data) |
157 | [temporary], [create_time], [access_time], [creatorid], [asset_flags], [data]) | 163 | Select :id, :name, :description, :assetType, :local, |
158 | VALUES | 164 | :temporary, :create_time, :access_time, :creatorid, :asset_flags, :data |
159 | (@id, @name, @description, @assetType, @local, | 165 | Where not EXISTS(SELECT * FROM assets WHERE id=:id) |
160 | @temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)"; | 166 | "; |
161 | 167 | ||
162 | string assetName = asset.Name; | 168 | string assetName = asset.Name; |
163 | if (asset.Name.Length > 64) | 169 | if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) |
164 | { | 170 | { |
165 | assetName = asset.Name.Substring(0, 64); | 171 | assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); |
166 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | 172 | m_log.WarnFormat( |
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); | ||
167 | } | 175 | } |
168 | 176 | ||
169 | string assetDescription = asset.Description; | 177 | string assetDescription = asset.Description; |
170 | if (asset.Description.Length > 64) | 178 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) |
171 | { | 179 | { |
172 | assetDescription = asset.Description.Substring(0, 64); | 180 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
173 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | 181 | m_log.WarnFormat( |
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); | ||
174 | } | 184 | } |
175 | 185 | ||
176 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 186 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
177 | using (SqlCommand command = new SqlCommand(sql, conn)) | 187 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
178 | { | 188 | { |
179 | int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); | 189 | int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); |
180 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | 190 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); |
@@ -195,7 +205,7 @@ namespace OpenSim.Data.MSSQL | |||
195 | } | 205 | } |
196 | catch(Exception e) | 206 | catch(Exception e) |
197 | { | 207 | { |
198 | m_log.Error("[ASSET DB]: Error storing item :" + e.Message); | 208 | m_log.Error("[ASSET DB]: Error storing item :" + e.Message + " sql "+sql); |
199 | } | 209 | } |
200 | } | 210 | } |
201 | } | 211 | } |
@@ -204,11 +214,11 @@ namespace OpenSim.Data.MSSQL | |||
204 | // Commented out since currently unused - this probably should be called in GetAsset() | 214 | // Commented out since currently unused - this probably should be called in GetAsset() |
205 | // private void UpdateAccessTime(AssetBase asset) | 215 | // private void UpdateAccessTime(AssetBase asset) |
206 | // { | 216 | // { |
207 | // using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id")) | 217 | // using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = :access_time WHERE id=:id")) |
208 | // { | 218 | // { |
209 | // int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); | 219 | // int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); |
210 | // cmd.Parameters.AddWithValue("@id", asset.FullID.ToString()); | 220 | // cmd.Parameters.AddWithValue(":id", asset.FullID.ToString()); |
211 | // cmd.Parameters.AddWithValue("@access_time", now); | 221 | // cmd.Parameters.AddWithValue(":access_time", now); |
212 | // try | 222 | // try |
213 | // { | 223 | // { |
214 | // cmd.ExecuteNonQuery(); | 224 | // cmd.ExecuteNonQuery(); |
@@ -221,17 +231,38 @@ namespace OpenSim.Data.MSSQL | |||
221 | // } | 231 | // } |
222 | 232 | ||
223 | /// <summary> | 233 | /// <summary> |
224 | /// Check if asset exist in m_database | 234 | /// Check if the assets exist in the database. |
225 | /// </summary> | 235 | /// </summary> |
226 | /// <param name="uuid"></param> | 236 | /// <param name="uuids">The assets' IDs</param> |
227 | /// <returns>true if exist.</returns> | 237 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
228 | override public bool ExistsAsset(UUID uuid) | 238 | public override bool[] AssetsExist(UUID[] uuids) |
229 | { | 239 | { |
230 | if (GetAsset(uuid) != null) | 240 | if (uuids.Length == 0) |
241 | return new bool[0]; | ||
242 | |||
243 | HashSet<UUID> exist = new HashSet<UUID>(); | ||
244 | |||
245 | string ids = "'" + string.Join("','", uuids) + "'"; | ||
246 | string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); | ||
247 | |||
248 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
249 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
231 | { | 250 | { |
232 | return true; | 251 | conn.Open(); |
252 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
253 | { | ||
254 | while (reader.Read()) | ||
255 | { | ||
256 | UUID id = DBGuid.FromDB(reader["id"]); | ||
257 | exist.Add(id); | ||
258 | } | ||
259 | } | ||
233 | } | 260 | } |
234 | return false; | 261 | |
262 | bool[] results = new bool[uuids.Length]; | ||
263 | for (int i = 0; i < uuids.Length; i++) | ||
264 | results[i] = exist.Contains(uuids[i]); | ||
265 | return results; | ||
235 | } | 266 | } |
236 | 267 | ||
237 | /// <summary> | 268 | /// <summary> |
@@ -245,23 +276,19 @@ namespace OpenSim.Data.MSSQL | |||
245 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | 276 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) |
246 | { | 277 | { |
247 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 278 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
248 | string sql = @"WITH OrderedAssets AS | 279 | string sql = @" SELECT id, name, description, " + "\"assetType\"" + @", temporary, creatorid |
249 | ( | 280 | FROM assets |
250 | SELECT id, name, description, assetType, temporary, creatorid, | 281 | order by id |
251 | RowNumber = ROW_NUMBER() OVER (ORDER BY id) | 282 | limit :stop |
252 | FROM assets | 283 | offset :start;"; |
253 | ) | ||
254 | SELECT * | ||
255 | FROM OrderedAssets | ||
256 | WHERE RowNumber BETWEEN @start AND @stop;"; | ||
257 | 284 | ||
258 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 285 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
259 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 286 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
260 | { | 287 | { |
261 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | 288 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); |
262 | cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1)); | 289 | cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1)); |
263 | conn.Open(); | 290 | conn.Open(); |
264 | using (SqlDataReader reader = cmd.ExecuteReader()) | 291 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
265 | { | 292 | { |
266 | while (reader.Read()) | 293 | while (reader.Read()) |
267 | { | 294 | { |
diff --git a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs b/OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs index 1ae78c4..d174112 100644 --- a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLAuthenticationData.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 | * |
@@ -28,32 +28,38 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Data; | ||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
34 | using System.Data.SqlClient; | ||
35 | using System.Reflection; | 33 | using System.Reflection; |
36 | using System.Text; | 34 | using System.Text; |
35 | using System.Data; | ||
36 | using Npgsql; | ||
37 | using NpgsqlTypes; | ||
37 | 38 | ||
38 | namespace OpenSim.Data.MSSQL | 39 | namespace OpenSim.Data.PGSQL |
39 | { | 40 | { |
40 | public class MSSQLAuthenticationData : IAuthenticationData | 41 | public class PGSQLAuthenticationData : IAuthenticationData |
41 | { | 42 | { |
42 | private string m_Realm; | 43 | private string m_Realm; |
43 | private List<string> m_ColumnNames = null; | 44 | private List<string> m_ColumnNames = null; |
44 | private int m_LastExpire = 0; | 45 | private int m_LastExpire = 0; |
45 | private string m_ConnectionString; | 46 | private string m_ConnectionString; |
46 | private MSSQLManager m_database; | 47 | private PGSQLManager m_database; |
48 | |||
49 | protected virtual Assembly Assembly | ||
50 | { | ||
51 | get { return GetType().Assembly; } | ||
52 | } | ||
47 | 53 | ||
48 | public MSSQLAuthenticationData(string connectionString, string realm) | 54 | public PGSQLAuthenticationData(string connectionString, string realm) |
49 | { | 55 | { |
50 | m_Realm = realm; | 56 | m_Realm = realm; |
51 | m_ConnectionString = connectionString; | 57 | m_ConnectionString = connectionString; |
52 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 58 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
53 | { | 59 | { |
54 | conn.Open(); | 60 | conn.Open(); |
55 | Migration m = new Migration(conn, GetType().Assembly, "AuthStore"); | 61 | Migration m = new Migration(conn, GetType().Assembly, "AuthStore"); |
56 | m_database = new MSSQLManager(m_ConnectionString); | 62 | m_database = new PGSQLManager(m_ConnectionString); |
57 | m.Update(); | 63 | m.Update(); |
58 | } | 64 | } |
59 | } | 65 | } |
@@ -63,14 +69,14 @@ namespace OpenSim.Data.MSSQL | |||
63 | AuthenticationData ret = new AuthenticationData(); | 69 | AuthenticationData ret = new AuthenticationData(); |
64 | ret.Data = new Dictionary<string, object>(); | 70 | ret.Data = new Dictionary<string, object>(); |
65 | 71 | ||
66 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); | 72 | string sql = string.Format("select * from {0} where uuid = :principalID", m_Realm); |
67 | 73 | ||
68 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 74 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
69 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 75 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
70 | { | 76 | { |
71 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); | 77 | cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID)); |
72 | conn.Open(); | 78 | conn.Open(); |
73 | using (SqlDataReader result = cmd.ExecuteReader()) | 79 | using (NpgsqlDataReader result = cmd.ExecuteReader()) |
74 | { | 80 | { |
75 | if (result.Read()) | 81 | if (result.Read()) |
76 | { | 82 | { |
@@ -87,7 +93,7 @@ namespace OpenSim.Data.MSSQL | |||
87 | 93 | ||
88 | foreach (string s in m_ColumnNames) | 94 | foreach (string s in m_ColumnNames) |
89 | { | 95 | { |
90 | if (s == "UUID") | 96 | if (s == "UUID"||s == "uuid") |
91 | continue; | 97 | continue; |
92 | 98 | ||
93 | ret.Data[s] = result[s].ToString(); | 99 | ret.Data[s] = result[s].ToString(); |
@@ -103,12 +109,31 @@ namespace OpenSim.Data.MSSQL | |||
103 | { | 109 | { |
104 | if (data.Data.ContainsKey("UUID")) | 110 | if (data.Data.ContainsKey("UUID")) |
105 | data.Data.Remove("UUID"); | 111 | data.Data.Remove("UUID"); |
112 | if (data.Data.ContainsKey("uuid")) | ||
113 | data.Data.Remove("uuid"); | ||
114 | |||
115 | /* | ||
116 | Dictionary<string, object> oAuth = new Dictionary<string, object>(); | ||
106 | 117 | ||
118 | foreach (KeyValuePair<string, object> oDado in data.Data) | ||
119 | { | ||
120 | if (oDado.Key != oDado.Key.ToLower()) | ||
121 | { | ||
122 | oAuth.Add(oDado.Key.ToLower(), oDado.Value); | ||
123 | } | ||
124 | } | ||
125 | foreach (KeyValuePair<string, object> oDado in data.Data) | ||
126 | { | ||
127 | if (!oAuth.ContainsKey(oDado.Key.ToLower())) { | ||
128 | oAuth.Add(oDado.Key.ToLower(), oDado.Value); | ||
129 | } | ||
130 | } | ||
131 | */ | ||
107 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 132 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
108 | StringBuilder updateBuilder = new StringBuilder(); | 133 | StringBuilder updateBuilder = new StringBuilder(); |
109 | 134 | ||
110 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 135 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
111 | using (SqlCommand cmd = new SqlCommand()) | 136 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
112 | { | 137 | { |
113 | updateBuilder.AppendFormat("update {0} set ", m_Realm); | 138 | updateBuilder.AppendFormat("update {0} set ", m_Realm); |
114 | 139 | ||
@@ -117,27 +142,28 @@ namespace OpenSim.Data.MSSQL | |||
117 | { | 142 | { |
118 | if (!first) | 143 | if (!first) |
119 | updateBuilder.Append(", "); | 144 | updateBuilder.Append(", "); |
120 | updateBuilder.AppendFormat("{0} = @{0}",field); | 145 | updateBuilder.AppendFormat("\"{0}\" = :{0}",field); |
121 | 146 | ||
122 | first = false; | 147 | first = false; |
123 | cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); | 148 | |
149 | cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field])); | ||
124 | } | 150 | } |
125 | 151 | ||
126 | updateBuilder.Append(" where UUID = @principalID"); | 152 | updateBuilder.Append(" where uuid = :principalID"); |
127 | 153 | ||
128 | cmd.CommandText = updateBuilder.ToString(); | 154 | cmd.CommandText = updateBuilder.ToString(); |
129 | cmd.Connection = conn; | 155 | cmd.Connection = conn; |
130 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID)); | 156 | cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID)); |
131 | 157 | ||
132 | conn.Open(); | 158 | conn.Open(); |
133 | if (cmd.ExecuteNonQuery() < 1) | 159 | if (cmd.ExecuteNonQuery() < 1) |
134 | { | 160 | { |
135 | StringBuilder insertBuilder = new StringBuilder(); | 161 | StringBuilder insertBuilder = new StringBuilder(); |
136 | 162 | ||
137 | insertBuilder.AppendFormat("insert into {0} (UUID, ", m_Realm); | 163 | insertBuilder.AppendFormat("insert into {0} (uuid, \"", m_Realm); |
138 | insertBuilder.Append(String.Join(", ", fields)); | 164 | insertBuilder.Append(String.Join("\", \"", fields)); |
139 | insertBuilder.Append(") values (@principalID, @"); | 165 | insertBuilder.Append("\") values (:principalID, :"); |
140 | insertBuilder.Append(String.Join(", @", fields)); | 166 | insertBuilder.Append(String.Join(", :", fields)); |
141 | insertBuilder.Append(")"); | 167 | insertBuilder.Append(")"); |
142 | 168 | ||
143 | cmd.CommandText = insertBuilder.ToString(); | 169 | cmd.CommandText = insertBuilder.ToString(); |
@@ -153,11 +179,11 @@ namespace OpenSim.Data.MSSQL | |||
153 | 179 | ||
154 | public bool SetDataItem(UUID principalID, string item, string value) | 180 | public bool SetDataItem(UUID principalID, string item, string value) |
155 | { | 181 | { |
156 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); | 182 | string sql = string.Format("update {0} set {1} = :{1} where uuid = :UUID", m_Realm, item); |
157 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 183 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
158 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 184 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
159 | { | 185 | { |
160 | cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); | 186 | cmd.Parameters.Add(m_database.CreateParameter("" + item, value)); |
161 | conn.Open(); | 187 | conn.Open(); |
162 | if (cmd.ExecuteNonQuery() > 0) | 188 | if (cmd.ExecuteNonQuery() > 0) |
163 | return true; | 189 | return true; |
@@ -170,13 +196,13 @@ namespace OpenSim.Data.MSSQL | |||
170 | if (System.Environment.TickCount - m_LastExpire > 30000) | 196 | if (System.Environment.TickCount - m_LastExpire > 30000) |
171 | DoExpire(); | 197 | DoExpire(); |
172 | 198 | ||
173 | 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)"; |
174 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 200 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
175 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 201 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
176 | { | 202 | { |
177 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); | 203 | cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID)); |
178 | cmd.Parameters.Add(m_database.CreateParameter("@token", token)); | 204 | cmd.Parameters.Add(m_database.CreateParameter("token", token)); |
179 | cmd.Parameters.Add(m_database.CreateParameter("@lifetime", DateTime.Now.AddMinutes(lifetime))); | 205 | cmd.Parameters.Add(m_database.CreateParameter("lifetime", DateTime.Now.AddMinutes(lifetime))); |
180 | conn.Open(); | 206 | conn.Open(); |
181 | 207 | ||
182 | if (cmd.ExecuteNonQuery() > 0) | 208 | if (cmd.ExecuteNonQuery() > 0) |
@@ -193,13 +219,14 @@ namespace OpenSim.Data.MSSQL | |||
193 | DoExpire(); | 219 | DoExpire(); |
194 | 220 | ||
195 | DateTime validDate = DateTime.Now.AddMinutes(lifetime); | 221 | DateTime validDate = DateTime.Now.AddMinutes(lifetime); |
196 | string sql = "update tokens set validity = @validDate where UUID = @principalID and token = @token and validity > GetDate()"; | 222 | string sql = "update tokens set validity = :validDate where uuid = :principalID and token = :token and validity > (CURRENT_DATE + CURRENT_TIME)"; |
197 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 223 | |
198 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 224 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
225 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
199 | { | 226 | { |
200 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); | 227 | cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID)); |
201 | cmd.Parameters.Add(m_database.CreateParameter("@token", token)); | 228 | cmd.Parameters.Add(m_database.CreateParameter("token", token)); |
202 | cmd.Parameters.Add(m_database.CreateParameter("@validDate", validDate)); | 229 | cmd.Parameters.Add(m_database.CreateParameter("validDate", validDate)); |
203 | conn.Open(); | 230 | conn.Open(); |
204 | 231 | ||
205 | if (cmd.ExecuteNonQuery() > 0) | 232 | if (cmd.ExecuteNonQuery() > 0) |
@@ -213,12 +240,12 @@ namespace OpenSim.Data.MSSQL | |||
213 | private void DoExpire() | 240 | private void DoExpire() |
214 | { | 241 | { |
215 | DateTime currentDateTime = DateTime.Now; | 242 | DateTime currentDateTime = DateTime.Now; |
216 | string sql = "delete from tokens where validity < @currentDateTime"; | 243 | string sql = "delete from tokens where validity < :currentDateTime"; |
217 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 244 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
218 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 245 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
219 | { | 246 | { |
220 | conn.Open(); | 247 | conn.Open(); |
221 | cmd.Parameters.Add(m_database.CreateParameter("@currentDateTime", currentDateTime)); | 248 | cmd.Parameters.Add(m_database.CreateParameter("currentDateTime", currentDateTime)); |
222 | cmd.ExecuteNonQuery(); | 249 | cmd.ExecuteNonQuery(); |
223 | } | 250 | } |
224 | m_LastExpire = System.Environment.TickCount; | 251 | m_LastExpire = System.Environment.TickCount; |
diff --git a/OpenSim/Data/MSSQL/MSSQLAvatarData.cs b/OpenSim/Data/PGSQL/PGSQLAvatarData.cs index 301b424..d9c4905 100644 --- a/OpenSim/Data/MSSQL/MSSQLAvatarData.cs +++ b/OpenSim/Data/PGSQL/PGSQLAvatarData.cs | |||
@@ -27,38 +27,39 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | ||
31 | using System.Reflection; | 30 | using System.Reflection; |
32 | using System.Threading; | 31 | using System.Threading; |
33 | using log4net; | 32 | using log4net; |
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using System.Data.SqlClient; | 35 | using Npgsql; |
36 | using NpgsqlTypes; | ||
37 | 37 | ||
38 | namespace OpenSim.Data.MSSQL | 38 | |
39 | namespace OpenSim.Data.PGSQL | ||
39 | { | 40 | { |
40 | /// <summary> | 41 | /// <summary> |
41 | /// A MSSQL Interface for Avatar Storage | 42 | /// A PGSQL Interface for Avatar Storage |
42 | /// </summary> | 43 | /// </summary> |
43 | public class MSSQLAvatarData : MSSQLGenericTableHandler<AvatarBaseData>, | 44 | public class PGSQLAvatarData : PGSQLGenericTableHandler<AvatarBaseData>, |
44 | IAvatarData | 45 | IAvatarData |
45 | { | 46 | { |
46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 48 | ||
48 | public MSSQLAvatarData(string connectionString, string realm) : | 49 | public PGSQLAvatarData(string connectionString, string realm) : |
49 | base(connectionString, realm, "Avatar") | 50 | base(connectionString, realm, "Avatar") |
50 | { | 51 | { |
51 | } | 52 | } |
52 | 53 | ||
53 | public bool Delete(UUID principalID, string name) | 54 | public bool Delete(UUID principalID, string name) |
54 | { | 55 | { |
55 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 56 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
56 | using (SqlCommand cmd = new SqlCommand()) | 57 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
57 | { | 58 | { |
58 | 59 | ||
59 | cmd.CommandText = String.Format("DELETE FROM {0} where [PrincipalID] = @PrincipalID and [Name] = @Name", m_Realm); | 60 | cmd.CommandText = String.Format("DELETE FROM {0} where \"PrincipalID\" = :PrincipalID and \"Name\" = :Name", m_Realm); |
60 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | 61 | cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID)); |
61 | cmd.Parameters.Add(m_database.CreateParameter("@Name", name)); | 62 | cmd.Parameters.Add(m_database.CreateParameter("Name", name)); |
62 | cmd.Connection = conn; | 63 | cmd.Connection = conn; |
63 | conn.Open(); | 64 | conn.Open(); |
64 | if (cmd.ExecuteNonQuery() > 0) | 65 | if (cmd.ExecuteNonQuery() > 0) |
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/PGSQL/PGSQLEstateData.cs index 1faa249..b5ca235 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/PGSQL/PGSQLEstateData.cs | |||
@@ -27,38 +27,44 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | ||
31 | using System.Data.SqlClient; | ||
32 | using System.Reflection; | 30 | using System.Reflection; |
33 | using log4net; | 31 | using log4net; |
34 | using OpenMetaverse; | 32 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using System.Data; | ||
36 | using Npgsql; | ||
37 | using NpgsqlTypes; | ||
37 | 38 | ||
38 | namespace OpenSim.Data.MSSQL | 39 | namespace OpenSim.Data.PGSQL |
39 | { | 40 | { |
40 | public class MSSQLEstateStore : IEstateDataStore | 41 | public class PGSQLEstateStore : IEstateDataStore |
41 | { | 42 | { |
42 | private const string _migrationStore = "EstateStore"; | 43 | private const string _migrationStore = "EstateStore"; |
43 | 44 | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 46 | ||
46 | private MSSQLManager _Database; | 47 | private PGSQLManager _Database; |
47 | private string m_connectionString; | 48 | private string m_connectionString; |
48 | private FieldInfo[] _Fields; | 49 | private FieldInfo[] _Fields; |
49 | private Dictionary<string, FieldInfo> _FieldMap = new Dictionary<string, FieldInfo>(); | 50 | private Dictionary<string, FieldInfo> _FieldMap = new Dictionary<string, FieldInfo>(); |
50 | 51 | ||
51 | #region Public methods | 52 | #region Public methods |
52 | 53 | ||
53 | public MSSQLEstateStore() | 54 | public PGSQLEstateStore() |
54 | { | 55 | { |
55 | } | 56 | } |
56 | 57 | ||
57 | public MSSQLEstateStore(string connectionString) | 58 | public PGSQLEstateStore(string connectionString) |
58 | { | 59 | { |
59 | Initialise(connectionString); | 60 | Initialise(connectionString); |
60 | } | 61 | } |
61 | 62 | ||
63 | protected virtual Assembly Assembly | ||
64 | { | ||
65 | get { return GetType().Assembly; } | ||
66 | } | ||
67 | |||
62 | /// <summary> | 68 | /// <summary> |
63 | /// Initialises the estatedata class. | 69 | /// Initialises the estatedata class. |
64 | /// </summary> | 70 | /// </summary> |
@@ -68,11 +74,11 @@ namespace OpenSim.Data.MSSQL | |||
68 | if (!string.IsNullOrEmpty(connectionString)) | 74 | if (!string.IsNullOrEmpty(connectionString)) |
69 | { | 75 | { |
70 | m_connectionString = connectionString; | 76 | m_connectionString = connectionString; |
71 | _Database = new MSSQLManager(connectionString); | 77 | _Database = new PGSQLManager(connectionString); |
72 | } | 78 | } |
73 | 79 | ||
74 | //Migration settings | 80 | //Migration settings |
75 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 81 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
76 | { | 82 | { |
77 | conn.Open(); | 83 | conn.Open(); |
78 | Migration m = new Migration(conn, GetType().Assembly, "EstateStore"); | 84 | Migration m = new Migration(conn, GetType().Assembly, "EstateStore"); |
@@ -101,15 +107,17 @@ namespace OpenSim.Data.MSSQL | |||
101 | { | 107 | { |
102 | EstateSettings es = new EstateSettings(); | 108 | EstateSettings es = new EstateSettings(); |
103 | 109 | ||
104 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = @RegionID"; | 110 | string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) + |
111 | "\" from estate_map left join estate_settings on estate_map.\"EstateID\" = estate_settings.\"EstateID\" " + | ||
112 | " where estate_settings.\"EstateID\" is not null and \"RegionID\" = :RegionID"; | ||
105 | 113 | ||
106 | bool insertEstate = false; | 114 | bool insertEstate = false; |
107 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 115 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
108 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 116 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
109 | { | 117 | { |
110 | cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID)); | 118 | cmd.Parameters.Add(_Database.CreateParameter("RegionID", regionID)); |
111 | conn.Open(); | 119 | conn.Open(); |
112 | using (SqlDataReader reader = cmd.ExecuteReader()) | 120 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
113 | { | 121 | { |
114 | if (reader.Read()) | 122 | if (reader.Read()) |
115 | { | 123 | { |
@@ -119,11 +127,15 @@ namespace OpenSim.Data.MSSQL | |||
119 | object v = reader[name]; | 127 | object v = reader[name]; |
120 | if (f.FieldType == typeof(bool)) | 128 | if (f.FieldType == typeof(bool)) |
121 | { | 129 | { |
122 | f.SetValue(es, Convert.ToInt32(v) != 0); | 130 | f.SetValue(es, v); |
123 | } | 131 | } |
124 | else if (f.FieldType == typeof(UUID)) | 132 | else if (f.FieldType == typeof(UUID)) |
125 | { | 133 | { |
126 | f.SetValue(es, new UUID((Guid)v)); // uuid); | 134 | UUID estUUID = UUID.Zero; |
135 | |||
136 | UUID.TryParse(v.ToString(), out estUUID); | ||
137 | |||
138 | f.SetValue(es, estUUID); | ||
127 | } | 139 | } |
128 | else if (f.FieldType == typeof(string)) | 140 | else if (f.FieldType == typeof(string)) |
129 | { | 141 | { |
@@ -187,25 +199,37 @@ namespace OpenSim.Data.MSSQL | |||
187 | 199 | ||
188 | names.Remove("EstateID"); | 200 | names.Remove("EstateID"); |
189 | 201 | ||
190 | string sql = string.Format("insert into estate_settings ({0}) values ( @{1})", String.Join(",", names.ToArray()), String.Join(", @", names.ToArray())); | 202 | string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray())); |
191 | 203 | ||
192 | //_Log.Debug("[DB ESTATE]: SQL: " + sql); | 204 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
193 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 205 | using (NpgsqlCommand insertCommand = new NpgsqlCommand(sql, conn)) |
194 | using (SqlCommand insertCommand = new SqlCommand(sql, conn)) | ||
195 | { | 206 | { |
196 | insertCommand.CommandText = sql + " SET @ID = SCOPE_IDENTITY()"; | 207 | insertCommand.CommandText = sql; |
197 | 208 | ||
198 | foreach (string name in names) | 209 | foreach (string name in names) |
199 | { | 210 | { |
200 | insertCommand.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es))); | 211 | insertCommand.Parameters.Add(_Database.CreateParameter("" + name, _FieldMap[name].GetValue(es))); |
201 | } | 212 | } |
202 | SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int); | 213 | //NpgsqlParameter idParameter = new NpgsqlParameter("ID", SqlDbType.Int); |
203 | idParameter.Direction = ParameterDirection.Output; | 214 | //idParameter.Direction = ParameterDirection.Output; |
204 | insertCommand.Parameters.Add(idParameter); | 215 | //insertCommand.Parameters.Add(idParameter); |
205 | conn.Open(); | 216 | conn.Open(); |
206 | insertCommand.ExecuteNonQuery(); | ||
207 | 217 | ||
208 | es.EstateID = Convert.ToUInt32(idParameter.Value); | 218 | es.EstateID = 100; |
219 | |||
220 | if (insertCommand.ExecuteNonQuery() > 0) | ||
221 | { | ||
222 | insertCommand.CommandText = "Select cast(lastval() as int) as ID ;"; | ||
223 | |||
224 | using (NpgsqlDataReader result = insertCommand.ExecuteReader()) | ||
225 | { | ||
226 | if (result.Read()) | ||
227 | { | ||
228 | es.EstateID = (uint)result.GetInt32(0); | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | |||
209 | } | 233 | } |
210 | 234 | ||
211 | //TODO check if this is needed?? | 235 | //TODO check if this is needed?? |
@@ -225,20 +249,20 @@ namespace OpenSim.Data.MSSQL | |||
225 | string sql = string.Format("UPDATE estate_settings SET "); | 249 | string sql = string.Format("UPDATE estate_settings SET "); |
226 | foreach (string name in names) | 250 | foreach (string name in names) |
227 | { | 251 | { |
228 | sql += name + " = @" + name + ", "; | 252 | sql += "\"" + name + "\" = :" + name + ", "; |
229 | } | 253 | } |
230 | sql = sql.Remove(sql.LastIndexOf(",")); | 254 | sql = sql.Remove(sql.LastIndexOf(",")); |
231 | sql += " WHERE EstateID = @EstateID"; | 255 | sql += " WHERE \"EstateID\" = :EstateID"; |
232 | 256 | ||
233 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 257 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
234 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 258 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
235 | { | 259 | { |
236 | foreach (string name in names) | 260 | foreach (string name in names) |
237 | { | 261 | { |
238 | cmd.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es))); | 262 | cmd.Parameters.Add(_Database.CreateParameter("" + name, _FieldMap[name].GetValue(es))); |
239 | } | 263 | } |
240 | 264 | ||
241 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID)); | 265 | cmd.Parameters.Add(_Database.CreateParameter("EstateID", es.EstateID)); |
242 | conn.Open(); | 266 | conn.Open(); |
243 | cmd.ExecuteNonQuery(); | 267 | cmd.ExecuteNonQuery(); |
244 | } | 268 | } |
@@ -262,16 +286,16 @@ namespace OpenSim.Data.MSSQL | |||
262 | { | 286 | { |
263 | es.ClearBans(); | 287 | es.ClearBans(); |
264 | 288 | ||
265 | string sql = "select bannedUUID from estateban where EstateID = @EstateID"; | 289 | string sql = "select \"bannedUUID\" from estateban where \"EstateID\" = :EstateID"; |
266 | 290 | ||
267 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 291 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
268 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 292 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
269 | { | 293 | { |
270 | SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int); | 294 | NpgsqlParameter idParameter = new NpgsqlParameter("EstateID", DbType.Int32); |
271 | idParameter.Value = es.EstateID; | 295 | idParameter.Value = es.EstateID; |
272 | cmd.Parameters.Add(idParameter); | 296 | cmd.Parameters.Add(idParameter); |
273 | conn.Open(); | 297 | conn.Open(); |
274 | using (SqlDataReader reader = cmd.ExecuteReader()) | 298 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
275 | { | 299 | { |
276 | while (reader.Read()) | 300 | while (reader.Read()) |
277 | { | 301 | { |
@@ -290,14 +314,14 @@ namespace OpenSim.Data.MSSQL | |||
290 | { | 314 | { |
291 | List<UUID> uuids = new List<UUID>(); | 315 | List<UUID> uuids = new List<UUID>(); |
292 | 316 | ||
293 | string sql = string.Format("select uuid from {0} where EstateID = @EstateID", table); | 317 | string sql = string.Format("select uuid from {0} where \"EstateID\" = :EstateID", table); |
294 | 318 | ||
295 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 319 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
296 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 320 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
297 | { | 321 | { |
298 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID)); | 322 | cmd.Parameters.Add(_Database.CreateParameter("EstateID", estateID)); |
299 | conn.Open(); | 323 | conn.Open(); |
300 | using (SqlDataReader reader = cmd.ExecuteReader()) | 324 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
301 | { | 325 | { |
302 | while (reader.Read()) | 326 | while (reader.Read()) |
303 | { | 327 | { |
@@ -312,21 +336,21 @@ namespace OpenSim.Data.MSSQL | |||
312 | private void SaveBanList(EstateSettings es) | 336 | private void SaveBanList(EstateSettings es) |
313 | { | 337 | { |
314 | //Delete first | 338 | //Delete first |
315 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 339 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
316 | { | 340 | { |
317 | conn.Open(); | 341 | conn.Open(); |
318 | using (SqlCommand cmd = conn.CreateCommand()) | 342 | using (NpgsqlCommand cmd = conn.CreateCommand()) |
319 | { | 343 | { |
320 | cmd.CommandText = "delete from estateban where EstateID = @EstateID"; | 344 | cmd.CommandText = "delete from estateban where \"EstateID\" = :EstateID"; |
321 | cmd.Parameters.AddWithValue("@EstateID", (int)es.EstateID); | 345 | cmd.Parameters.AddWithValue("EstateID", (int)es.EstateID); |
322 | cmd.ExecuteNonQuery(); | 346 | cmd.ExecuteNonQuery(); |
323 | 347 | ||
324 | //Insert after | 348 | //Insert after |
325 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID,bannedIp, bannedIpHostMask, bannedNameMask) values ( @EstateID, @bannedUUID, '','','' )"; | 349 | cmd.CommandText = "insert into estateban (\"EstateID\", \"bannedUUID\",\"bannedIp\", \"bannedIpHostMask\", \"bannedNameMask\") values ( :EstateID, :bannedUUID, '','','' )"; |
326 | cmd.Parameters.AddWithValue("@bannedUUID", Guid.Empty); | 350 | cmd.Parameters.AddWithValue("bannedUUID", Guid.Empty); |
327 | foreach (EstateBan b in es.EstateBans) | 351 | foreach (EstateBan b in es.EstateBans) |
328 | { | 352 | { |
329 | cmd.Parameters["@bannedUUID"].Value = b.BannedUserID.Guid; | 353 | cmd.Parameters["bannedUUID"].Value = b.BannedUserID.Guid; |
330 | cmd.ExecuteNonQuery(); | 354 | cmd.ExecuteNonQuery(); |
331 | } | 355 | } |
332 | } | 356 | } |
@@ -335,20 +359,20 @@ namespace OpenSim.Data.MSSQL | |||
335 | 359 | ||
336 | private void SaveUUIDList(uint estateID, string table, UUID[] data) | 360 | private void SaveUUIDList(uint estateID, string table, UUID[] data) |
337 | { | 361 | { |
338 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 362 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
339 | { | 363 | { |
340 | conn.Open(); | 364 | conn.Open(); |
341 | using (SqlCommand cmd = conn.CreateCommand()) | 365 | using (NpgsqlCommand cmd = conn.CreateCommand()) |
342 | { | 366 | { |
343 | cmd.Parameters.AddWithValue("@EstateID", (int)estateID); | 367 | cmd.Parameters.AddWithValue("EstateID", (int)estateID); |
344 | cmd.CommandText = string.Format("delete from {0} where EstateID = @EstateID", table); | 368 | cmd.CommandText = string.Format("delete from {0} where \"EstateID\" = :EstateID", table); |
345 | cmd.ExecuteNonQuery(); | 369 | cmd.ExecuteNonQuery(); |
346 | 370 | ||
347 | cmd.CommandText = string.Format("insert into {0} (EstateID, uuid) values ( @EstateID, @uuid )", table); | 371 | cmd.CommandText = string.Format("insert into {0} (\"EstateID\", uuid) values ( :EstateID, :uuid )", table); |
348 | cmd.Parameters.AddWithValue("@uuid", Guid.Empty); | 372 | cmd.Parameters.AddWithValue("uuid", Guid.Empty); |
349 | foreach (UUID uuid in data) | 373 | foreach (UUID uuid in data) |
350 | { | 374 | { |
351 | cmd.Parameters["@uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works | 375 | cmd.Parameters["uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works |
352 | cmd.ExecuteNonQuery(); | 376 | cmd.ExecuteNonQuery(); |
353 | } | 377 | } |
354 | } | 378 | } |
@@ -358,14 +382,14 @@ namespace OpenSim.Data.MSSQL | |||
358 | public EstateSettings LoadEstateSettings(int estateID) | 382 | public EstateSettings LoadEstateSettings(int estateID) |
359 | { | 383 | { |
360 | EstateSettings es = new EstateSettings(); | 384 | EstateSettings es = new EstateSettings(); |
361 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = @EstateID"; | 385 | string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) + "\" from estate_settings where \"EstateID\" = :EstateID"; |
362 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 386 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
363 | { | 387 | { |
364 | conn.Open(); | 388 | conn.Open(); |
365 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 389 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
366 | { | 390 | { |
367 | cmd.Parameters.AddWithValue("@EstateID", (int)estateID); | 391 | cmd.Parameters.AddWithValue("EstateID", (int)estateID); |
368 | using (SqlDataReader reader = cmd.ExecuteReader()) | 392 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
369 | { | 393 | { |
370 | if (reader.Read()) | 394 | if (reader.Read()) |
371 | { | 395 | { |
@@ -428,13 +452,13 @@ namespace OpenSim.Data.MSSQL | |||
428 | public List<int> GetEstates(string search) | 452 | public List<int> GetEstates(string search) |
429 | { | 453 | { |
430 | List<int> result = new List<int>(); | 454 | List<int> result = new List<int>(); |
431 | string sql = "select estateID from estate_settings where EstateName = @EstateName"; | 455 | string sql = "select \"EstateID\" from estate_settings where lower(\"EstateName\") = lower(:EstateName)"; |
432 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 456 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
433 | { | 457 | { |
434 | conn.Open(); | 458 | conn.Open(); |
435 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 459 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
436 | { | 460 | { |
437 | cmd.Parameters.AddWithValue("@EstateName", search); | 461 | cmd.Parameters.AddWithValue("EstateName", search); |
438 | 462 | ||
439 | using (IDataReader reader = cmd.ExecuteReader()) | 463 | using (IDataReader reader = cmd.ExecuteReader()) |
440 | { | 464 | { |
@@ -453,11 +477,11 @@ namespace OpenSim.Data.MSSQL | |||
453 | public List<int> GetEstatesAll() | 477 | public List<int> GetEstatesAll() |
454 | { | 478 | { |
455 | List<int> result = new List<int>(); | 479 | List<int> result = new List<int>(); |
456 | string sql = "select estateID from estate_settings"; | 480 | string sql = "select \"EstateID\" from estate_settings"; |
457 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 481 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
458 | { | 482 | { |
459 | conn.Open(); | 483 | conn.Open(); |
460 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 484 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
461 | { | 485 | { |
462 | using (IDataReader reader = cmd.ExecuteReader()) | 486 | using (IDataReader reader = cmd.ExecuteReader()) |
463 | { | 487 | { |
@@ -476,13 +500,13 @@ namespace OpenSim.Data.MSSQL | |||
476 | public List<int> GetEstatesByOwner(UUID ownerID) | 500 | public List<int> GetEstatesByOwner(UUID ownerID) |
477 | { | 501 | { |
478 | List<int> result = new List<int>(); | 502 | List<int> result = new List<int>(); |
479 | string sql = "select estateID from estate_settings where EstateOwner = @EstateOwner"; | 503 | string sql = "select \"EstateID\" from estate_settings where \"EstateOwner\" = :EstateOwner"; |
480 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 504 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
481 | { | 505 | { |
482 | conn.Open(); | 506 | conn.Open(); |
483 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 507 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
484 | { | 508 | { |
485 | cmd.Parameters.AddWithValue("@EstateOwner", ownerID); | 509 | cmd.Parameters.AddWithValue("EstateOwner", ownerID); |
486 | 510 | ||
487 | using (IDataReader reader = cmd.ExecuteReader()) | 511 | using (IDataReader reader = cmd.ExecuteReader()) |
488 | { | 512 | { |
@@ -500,28 +524,29 @@ namespace OpenSim.Data.MSSQL | |||
500 | 524 | ||
501 | public bool LinkRegion(UUID regionID, int estateID) | 525 | public bool LinkRegion(UUID regionID, int estateID) |
502 | { | 526 | { |
503 | string deleteSQL = "delete from estate_map where RegionID = @RegionID"; | 527 | string deleteSQL = "delete from estate_map where \"RegionID\" = :RegionID"; |
504 | string insertSQL = "insert into estate_map values (@RegionID, @EstateID)"; | 528 | string insertSQL = "insert into estate_map values (:RegionID, :EstateID)"; |
505 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 529 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
506 | { | 530 | { |
507 | conn.Open(); | 531 | conn.Open(); |
508 | SqlTransaction transaction = conn.BeginTransaction(); | 532 | |
533 | NpgsqlTransaction transaction = conn.BeginTransaction(); | ||
509 | 534 | ||
510 | try | 535 | try |
511 | { | 536 | { |
512 | using (SqlCommand cmd = new SqlCommand(deleteSQL, conn)) | 537 | using (NpgsqlCommand cmd = new NpgsqlCommand(deleteSQL, conn)) |
513 | { | 538 | { |
514 | cmd.Transaction = transaction; | 539 | cmd.Transaction = transaction; |
515 | cmd.Parameters.AddWithValue("@RegionID", regionID.Guid); | 540 | cmd.Parameters.AddWithValue("RegionID", regionID.Guid); |
516 | 541 | ||
517 | cmd.ExecuteNonQuery(); | 542 | cmd.ExecuteNonQuery(); |
518 | } | 543 | } |
519 | 544 | ||
520 | using (SqlCommand cmd = new SqlCommand(insertSQL, conn)) | 545 | using (NpgsqlCommand cmd = new NpgsqlCommand(insertSQL, conn)) |
521 | { | 546 | { |
522 | cmd.Transaction = transaction; | 547 | cmd.Transaction = transaction; |
523 | cmd.Parameters.AddWithValue("@RegionID", regionID.Guid); | 548 | cmd.Parameters.AddWithValue("RegionID", regionID.Guid); |
524 | cmd.Parameters.AddWithValue("@EstateID", estateID); | 549 | cmd.Parameters.AddWithValue("EstateID", estateID); |
525 | 550 | ||
526 | int ret = cmd.ExecuteNonQuery(); | 551 | int ret = cmd.ExecuteNonQuery(); |
527 | 552 | ||
@@ -545,13 +570,13 @@ namespace OpenSim.Data.MSSQL | |||
545 | public List<UUID> GetRegions(int estateID) | 570 | public List<UUID> GetRegions(int estateID) |
546 | { | 571 | { |
547 | List<UUID> result = new List<UUID>(); | 572 | List<UUID> result = new List<UUID>(); |
548 | string sql = "select RegionID from estate_map where EstateID = @EstateID"; | 573 | string sql = "select \"RegionID\" from estate_map where \"EstateID\" = :EstateID"; |
549 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 574 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
550 | { | 575 | { |
551 | conn.Open(); | 576 | conn.Open(); |
552 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 577 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
553 | { | 578 | { |
554 | cmd.Parameters.AddWithValue("@EstateID", estateID); | 579 | cmd.Parameters.AddWithValue("EstateID", estateID); |
555 | 580 | ||
556 | using (IDataReader reader = cmd.ExecuteReader()) | 581 | using (IDataReader reader = cmd.ExecuteReader()) |
557 | { | 582 | { |
diff --git a/OpenSim/Data/PGSQL/PGSQLFramework.cs b/OpenSim/Data/PGSQL/PGSQLFramework.cs new file mode 100644 index 0000000..1028e4e --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLFramework.cs | |||
@@ -0,0 +1,111 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using System.Reflection; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using Npgsql; | ||
36 | |||
37 | namespace OpenSim.Data.PGSQL | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// A database interface class to a user profile storage system | ||
41 | /// </summary> | ||
42 | public class PGSqlFramework | ||
43 | { | ||
44 | private static readonly log4net.ILog m_log = | ||
45 | log4net.LogManager.GetLogger( | ||
46 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected string m_connectionString; | ||
49 | protected object m_dbLock = new object(); | ||
50 | |||
51 | protected PGSqlFramework(string connectionString) | ||
52 | { | ||
53 | m_connectionString = connectionString; | ||
54 | InitializeMonoSecurity(); | ||
55 | } | ||
56 | |||
57 | public void InitializeMonoSecurity() | ||
58 | { | ||
59 | if (!Util.IsPlatformMono) | ||
60 | { | ||
61 | |||
62 | if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null) | ||
63 | { | ||
64 | AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true"); | ||
65 | |||
66 | AppDomain currentDomain = AppDomain.CurrentDomain; | ||
67 | currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args) | ||
73 | { | ||
74 | Assembly MyAssembly = null; | ||
75 | |||
76 | if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security") | ||
77 | { | ||
78 | MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll"); | ||
79 | } | ||
80 | |||
81 | //Return the loaded assembly. | ||
82 | return MyAssembly; | ||
83 | } | ||
84 | ////////////////////////////////////////////////////////////// | ||
85 | // | ||
86 | // All non queries are funneled through one connection | ||
87 | // to increase performance a little | ||
88 | // | ||
89 | protected int ExecuteNonQuery(NpgsqlCommand cmd) | ||
90 | { | ||
91 | lock (m_dbLock) | ||
92 | { | ||
93 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
94 | { | ||
95 | dbcon.Open(); | ||
96 | cmd.Connection = dbcon; | ||
97 | |||
98 | try | ||
99 | { | ||
100 | return cmd.ExecuteNonQuery(); | ||
101 | } | ||
102 | catch (Exception e) | ||
103 | { | ||
104 | m_log.Error(e.Message, e); | ||
105 | return 0; | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs b/OpenSim/Data/PGSQL/PGSQLFriendsData.cs index fef6978..a841353 100644 --- a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLFriendsData.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 | * |
@@ -31,18 +31,18 @@ using System.Collections.Generic; | |||
31 | using System.Data; | 31 | using System.Data; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using System.Data.SqlClient; | ||
35 | using System.Reflection; | 34 | using System.Reflection; |
36 | using System.Text; | 35 | using System.Text; |
36 | using Npgsql; | ||
37 | 37 | ||
38 | namespace OpenSim.Data.MSSQL | 38 | namespace OpenSim.Data.PGSQL |
39 | { | 39 | { |
40 | public class MSSQLFriendsData : MSSQLGenericTableHandler<FriendsData>, IFriendsData | 40 | public class PGSQLFriendsData : PGSQLGenericTableHandler<FriendsData>, IFriendsData |
41 | { | 41 | { |
42 | public MSSQLFriendsData(string connectionString, string realm) | 42 | public PGSQLFriendsData(string connectionString, string realm) |
43 | : base(connectionString, realm, "FriendsStore") | 43 | : base(connectionString, realm, "FriendsStore") |
44 | { | 44 | { |
45 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 45 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
46 | { | 46 | { |
47 | conn.Open(); | 47 | conn.Open(); |
48 | Migration m = new Migration(conn, GetType().Assembly, "FriendsStore"); | 48 | Migration m = new Migration(conn, GetType().Assembly, "FriendsStore"); |
@@ -50,19 +50,27 @@ namespace OpenSim.Data.MSSQL | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | public bool Delete(UUID principalID, string friend) | 53 | |
54 | public override bool Delete(string principalID, string friend) | ||
54 | { | 55 | { |
55 | return Delete(principalID.ToString(), friend); | 56 | UUID princUUID = UUID.Zero; |
57 | |||
58 | bool ret = UUID.TryParse(principalID, out princUUID); | ||
59 | |||
60 | if (ret) | ||
61 | return Delete(princUUID, friend); | ||
62 | else | ||
63 | return false; | ||
56 | } | 64 | } |
57 | 65 | ||
58 | public bool Delete(string principalID, string friend) | 66 | public bool Delete(UUID principalID, string friend) |
59 | { | 67 | { |
60 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 68 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
61 | using (SqlCommand cmd = new SqlCommand()) | 69 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
62 | { | 70 | { |
63 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = @PrincipalID and Friend = @Friend", m_Realm); | 71 | cmd.CommandText = String.Format("delete from {0} where \"PrincipalID\" = :PrincipalID and \"Friend\" = :Friend", m_Realm); |
64 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | 72 | cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString())); |
65 | cmd.Parameters.Add(m_database.CreateParameter("@Friend", friend)); | 73 | cmd.Parameters.Add(m_database.CreateParameter("Friend", friend)); |
66 | cmd.Connection = conn; | 74 | cmd.Connection = conn; |
67 | conn.Open(); | 75 | conn.Open(); |
68 | cmd.ExecuteNonQuery(); | 76 | cmd.ExecuteNonQuery(); |
@@ -71,19 +79,28 @@ namespace OpenSim.Data.MSSQL | |||
71 | } | 79 | } |
72 | } | 80 | } |
73 | 81 | ||
74 | public FriendsData[] GetFriends(UUID principalID) | 82 | public FriendsData[] GetFriends(string principalID) |
75 | { | 83 | { |
76 | return GetFriends(principalID.ToString()); | 84 | UUID princUUID = UUID.Zero; |
85 | |||
86 | bool ret = UUID.TryParse(principalID, out princUUID); | ||
87 | |||
88 | if (ret) | ||
89 | return GetFriends(princUUID); | ||
90 | else | ||
91 | return new FriendsData[0]; | ||
77 | } | 92 | } |
78 | 93 | ||
79 | public FriendsData[] GetFriends(string principalID) | 94 | public FriendsData[] GetFriends(UUID principalID) |
80 | { | 95 | { |
81 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 96 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
82 | using (SqlCommand cmd = new SqlCommand()) | 97 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
83 | { | 98 | { |
84 | 99 | ||
85 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = @PrincipalID", m_Realm); | 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 " + |
86 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | 101 | " left join {0} as b on a.\"PrincipalID\" = b.\"Friend\" and a.\"Friend\" = b.\"PrincipalID\" " + |
102 | " where a.\"PrincipalID\" = :PrincipalID", m_Realm); | ||
103 | cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString())); | ||
87 | cmd.Connection = conn; | 104 | cmd.Connection = conn; |
88 | conn.Open(); | 105 | conn.Open(); |
89 | return DoQuery(cmd); | 106 | return DoQuery(cmd); |
@@ -92,7 +109,7 @@ namespace OpenSim.Data.MSSQL | |||
92 | 109 | ||
93 | public FriendsData[] GetFriends(Guid principalID) | 110 | public FriendsData[] GetFriends(Guid principalID) |
94 | { | 111 | { |
95 | return GetFriends(principalID.ToString()); | 112 | return GetFriends(principalID); |
96 | } | 113 | } |
97 | 114 | ||
98 | } | 115 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs index 4145d95..826c6fc 100644 --- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs +++ b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs | |||
@@ -30,30 +30,38 @@ using System.Collections.Generic; | |||
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using System.Data.SqlClient; | ||
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using System.Text; | 36 | using System.Text; |
37 | using Npgsql; | ||
38 | 38 | ||
39 | namespace OpenSim.Data.MSSQL | 39 | namespace OpenSim.Data.PGSQL |
40 | { | 40 | { |
41 | public class MSSQLGenericTableHandler<T> where T : class, new() | 41 | public class PGSQLGenericTableHandler<T> : PGSqlFramework where T : class, new() |
42 | { | 42 | { |
43 | // private static readonly ILog m_log = | 43 | private static readonly ILog m_log = |
44 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | protected string m_ConnectionString; | 46 | protected string m_ConnectionString; |
47 | protected MSSQLManager m_database; //used for parameter type translation | 47 | protected PGSQLManager m_database; //used for parameter type translation |
48 | protected Dictionary<string, FieldInfo> m_Fields = | 48 | protected Dictionary<string, FieldInfo> m_Fields = |
49 | new Dictionary<string, FieldInfo>(); | 49 | new Dictionary<string, FieldInfo>(); |
50 | 50 | ||
51 | protected Dictionary<string, string> m_FieldTypes = new Dictionary<string, string>(); | ||
52 | |||
51 | protected List<string> m_ColumnNames = null; | 53 | protected List<string> m_ColumnNames = null; |
52 | protected string m_Realm; | 54 | protected string m_Realm; |
53 | protected FieldInfo m_DataField = null; | 55 | protected FieldInfo m_DataField = null; |
54 | 56 | ||
55 | public MSSQLGenericTableHandler(string connectionString, | 57 | protected virtual Assembly Assembly |
58 | { | ||
59 | get { return GetType().Assembly; } | ||
60 | } | ||
61 | |||
62 | public PGSQLGenericTableHandler(string connectionString, | ||
56 | string realm, string storeName) | 63 | string realm, string storeName) |
64 | : base(connectionString) | ||
57 | { | 65 | { |
58 | m_Realm = realm; | 66 | m_Realm = realm; |
59 | 67 | ||
@@ -61,7 +69,7 @@ namespace OpenSim.Data.MSSQL | |||
61 | 69 | ||
62 | if (storeName != String.Empty) | 70 | if (storeName != String.Empty) |
63 | { | 71 | { |
64 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 72 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
65 | { | 73 | { |
66 | conn.Open(); | 74 | conn.Open(); |
67 | Migration m = new Migration(conn, GetType().Assembly, storeName); | 75 | Migration m = new Migration(conn, GetType().Assembly, storeName); |
@@ -69,13 +77,15 @@ namespace OpenSim.Data.MSSQL | |||
69 | } | 77 | } |
70 | 78 | ||
71 | } | 79 | } |
72 | m_database = new MSSQLManager(m_ConnectionString); | 80 | m_database = new PGSQLManager(m_ConnectionString); |
73 | 81 | ||
74 | Type t = typeof(T); | 82 | Type t = typeof(T); |
75 | FieldInfo[] fields = t.GetFields(BindingFlags.Public | | 83 | FieldInfo[] fields = t.GetFields(BindingFlags.Public | |
76 | BindingFlags.Instance | | 84 | BindingFlags.Instance | |
77 | BindingFlags.DeclaredOnly); | 85 | BindingFlags.DeclaredOnly); |
78 | 86 | ||
87 | LoadFieldTypes(); | ||
88 | |||
79 | if (fields.Length == 0) | 89 | if (fields.Length == 0) |
80 | return; | 90 | return; |
81 | 91 | ||
@@ -89,7 +99,31 @@ namespace OpenSim.Data.MSSQL | |||
89 | 99 | ||
90 | } | 100 | } |
91 | 101 | ||
92 | private void CheckColumnNames(SqlDataReader reader) | 102 | private void LoadFieldTypes() |
103 | { | ||
104 | m_FieldTypes = new Dictionary<string, string>(); | ||
105 | |||
106 | string query = string.Format(@"select column_name,data_type | ||
107 | from INFORMATION_SCHEMA.COLUMNS | ||
108 | where table_name = lower('{0}'); | ||
109 | |||
110 | ", m_Realm); | ||
111 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
112 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) | ||
113 | { | ||
114 | conn.Open(); | ||
115 | using (NpgsqlDataReader rdr = cmd.ExecuteReader()) | ||
116 | { | ||
117 | while (rdr.Read()) | ||
118 | { | ||
119 | // query produces 0 to many rows of single column, so always add the first item in each row | ||
120 | m_FieldTypes.Add((string)rdr[0], (string)rdr[1]); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | |||
126 | private void CheckColumnNames(NpgsqlDataReader reader) | ||
93 | { | 127 | { |
94 | if (m_ColumnNames != null) | 128 | if (m_ColumnNames != null) |
95 | return; | 129 | return; |
@@ -97,6 +131,7 @@ namespace OpenSim.Data.MSSQL | |||
97 | m_ColumnNames = new List<string>(); | 131 | m_ColumnNames = new List<string>(); |
98 | 132 | ||
99 | DataTable schemaTable = reader.GetSchemaTable(); | 133 | DataTable schemaTable = reader.GetSchemaTable(); |
134 | |||
100 | foreach (DataRow row in schemaTable.Rows) | 135 | foreach (DataRow row in schemaTable.Rows) |
101 | { | 136 | { |
102 | if (row["ColumnName"] != null && | 137 | if (row["ColumnName"] != null && |
@@ -106,21 +141,37 @@ namespace OpenSim.Data.MSSQL | |||
106 | } | 141 | } |
107 | } | 142 | } |
108 | 143 | ||
144 | // TODO GET CONSTRAINTS FROM POSTGRESQL | ||
109 | private List<string> GetConstraints() | 145 | private List<string> GetConstraints() |
110 | { | 146 | { |
111 | List<string> constraints = new List<string>(); | 147 | List<string> constraints = new List<string>(); |
112 | string query = string.Format(@"SELECT | 148 | string query = string.Format(@"SELECT kcu.column_name |
113 | COL_NAME(ic.object_id,ic.column_id) AS column_name | 149 | FROM information_schema.table_constraints tc |
114 | FROM sys.indexes AS i | 150 | LEFT JOIN information_schema.key_column_usage kcu |
115 | INNER JOIN sys.index_columns AS ic | 151 | ON tc.constraint_catalog = kcu.constraint_catalog |
116 | ON i.object_id = ic.object_id AND i.index_id = ic.index_id | 152 | AND tc.constraint_schema = kcu.constraint_schema |
117 | WHERE i.is_primary_key = 1 | 153 | AND tc.constraint_name = kcu.constraint_name |
118 | AND i.object_id = OBJECT_ID('{0}');", m_Realm); | 154 | |
119 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 155 | LEFT JOIN information_schema.referential_constraints rc |
120 | using (SqlCommand cmd = new SqlCommand(query, conn)) | 156 | ON tc.constraint_catalog = rc.constraint_catalog |
157 | AND tc.constraint_schema = rc.constraint_schema | ||
158 | AND tc.constraint_name = rc.constraint_name | ||
159 | |||
160 | LEFT JOIN information_schema.constraint_column_usage ccu | ||
161 | ON rc.unique_constraint_catalog = ccu.constraint_catalog | ||
162 | AND rc.unique_constraint_schema = ccu.constraint_schema | ||
163 | AND rc.unique_constraint_name = ccu.constraint_name | ||
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 | |||
170 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
171 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) | ||
121 | { | 172 | { |
122 | conn.Open(); | 173 | conn.Open(); |
123 | using (SqlDataReader rdr = cmd.ExecuteReader()) | 174 | using (NpgsqlDataReader rdr = cmd.ExecuteReader()) |
124 | { | 175 | { |
125 | while (rdr.Read()) | 176 | while (rdr.Read()) |
126 | { | 177 | { |
@@ -144,14 +195,18 @@ namespace OpenSim.Data.MSSQL | |||
144 | 195 | ||
145 | List<string> terms = new List<string>(); | 196 | List<string> terms = new List<string>(); |
146 | 197 | ||
147 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 198 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
148 | using (SqlCommand cmd = new SqlCommand()) | 199 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
149 | { | 200 | { |
150 | 201 | ||
151 | for (int i = 0; i < fields.Length; i++) | 202 | for (int i = 0; i < fields.Length; i++) |
152 | { | 203 | { |
153 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); | 204 | if ( m_FieldTypes.ContainsKey(fields[i]) ) |
154 | terms.Add("[" + fields[i] + "] = @" + fields[i]); | 205 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]])); |
206 | else | ||
207 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); | ||
208 | |||
209 | terms.Add(" \"" + fields[i] + "\" = :" + fields[i]); | ||
155 | } | 210 | } |
156 | 211 | ||
157 | string where = String.Join(" AND ", terms.ToArray()); | 212 | string where = String.Join(" AND ", terms.ToArray()); |
@@ -166,10 +221,18 @@ namespace OpenSim.Data.MSSQL | |||
166 | } | 221 | } |
167 | } | 222 | } |
168 | 223 | ||
169 | protected T[] DoQuery(SqlCommand cmd) | 224 | protected T[] DoQuery(NpgsqlCommand cmd) |
170 | { | 225 | { |
171 | List<T> result = new List<T>(); | 226 | List<T> result = new List<T>(); |
172 | using (SqlDataReader reader = cmd.ExecuteReader()) | 227 | if (cmd.Connection == null) |
228 | { | ||
229 | cmd.Connection = new NpgsqlConnection(m_connectionString); | ||
230 | } | ||
231 | if (cmd.Connection.State == ConnectionState.Closed) | ||
232 | { | ||
233 | cmd.Connection.Open(); | ||
234 | } | ||
235 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
173 | { | 236 | { |
174 | if (reader == null) | 237 | if (reader == null) |
175 | return new T[0]; | 238 | return new T[0]; |
@@ -213,6 +276,7 @@ namespace OpenSim.Data.MSSQL | |||
213 | foreach (string col in m_ColumnNames) | 276 | foreach (string col in m_ColumnNames) |
214 | { | 277 | { |
215 | data[col] = reader[col].ToString(); | 278 | data[col] = reader[col].ToString(); |
279 | |||
216 | if (data[col] == null) | 280 | if (data[col] == null) |
217 | data[col] = String.Empty; | 281 | data[col] = String.Empty; |
218 | } | 282 | } |
@@ -228,16 +292,34 @@ namespace OpenSim.Data.MSSQL | |||
228 | 292 | ||
229 | public virtual T[] Get(string where) | 293 | public virtual T[] Get(string where) |
230 | { | 294 | { |
231 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 295 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
232 | using (SqlCommand cmd = new SqlCommand()) | 296 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
233 | { | 297 | { |
234 | 298 | ||
235 | string query = String.Format("SELECT * FROM {0} WHERE {1}", | 299 | string query = String.Format("SELECT * FROM {0} WHERE {1}", |
236 | m_Realm, where); | 300 | m_Realm, where); |
237 | cmd.Connection = conn; | 301 | cmd.Connection = conn; |
238 | cmd.CommandText = query; | 302 | cmd.CommandText = query; |
303 | //m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); | ||
239 | 304 | ||
240 | //m_log.WarnFormat("[MSSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); | 305 | conn.Open(); |
306 | return DoQuery(cmd); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | public virtual T[] Get(string where, NpgsqlParameter parameter) | ||
311 | { | ||
312 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
313 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
314 | { | ||
315 | |||
316 | string query = String.Format("SELECT * FROM {0} WHERE {1}", | ||
317 | m_Realm, where); | ||
318 | cmd.Connection = conn; | ||
319 | cmd.CommandText = query; | ||
320 | //m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); | ||
321 | |||
322 | cmd.Parameters.Add(parameter); | ||
241 | 323 | ||
242 | conn.Open(); | 324 | conn.Open(); |
243 | return DoQuery(cmd); | 325 | return DoQuery(cmd); |
@@ -249,8 +331,8 @@ namespace OpenSim.Data.MSSQL | |||
249 | List<string> constraintFields = GetConstraints(); | 331 | List<string> constraintFields = GetConstraints(); |
250 | List<KeyValuePair<string, string>> constraints = new List<KeyValuePair<string, string>>(); | 332 | List<KeyValuePair<string, string>> constraints = new List<KeyValuePair<string, string>>(); |
251 | 333 | ||
252 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 334 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
253 | using (SqlCommand cmd = new SqlCommand()) | 335 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
254 | { | 336 | { |
255 | 337 | ||
256 | StringBuilder query = new StringBuilder(); | 338 | StringBuilder query = new StringBuilder(); |
@@ -260,21 +342,24 @@ namespace OpenSim.Data.MSSQL | |||
260 | foreach (FieldInfo fi in m_Fields.Values) | 342 | foreach (FieldInfo fi in m_Fields.Values) |
261 | { | 343 | { |
262 | names.Add(fi.Name); | 344 | names.Add(fi.Name); |
263 | values.Add("@" + fi.Name); | 345 | values.Add(":" + fi.Name); |
264 | // Temporarily return more information about what field is unexpectedly null for | 346 | // Temporarily return more information about what field is unexpectedly null for |
265 | // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the | 347 | // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the |
266 | // InventoryTransferModule or we may be required to substitute a DBNull here. | 348 | // InventoryTransferModule or we may be required to substitute a DBNull here. |
267 | if (fi.GetValue(row) == null) | 349 | if (fi.GetValue(row) == null) |
268 | throw new NullReferenceException( | 350 | throw new NullReferenceException( |
269 | string.Format( | 351 | string.Format( |
270 | "[MSSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null", | 352 | "[PGSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null", |
271 | fi.Name, row)); | 353 | fi.Name, row)); |
272 | 354 | ||
273 | if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name)) | 355 | if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name)) |
274 | { | 356 | { |
275 | constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString())); | 357 | constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString() )); |
276 | } | 358 | } |
277 | cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row).ToString())); | 359 | if (m_FieldTypes.ContainsKey(fi.Name)) |
360 | cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row), m_FieldTypes[fi.Name])); | ||
361 | else | ||
362 | cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row))); | ||
278 | } | 363 | } |
279 | 364 | ||
280 | if (m_DataField != null) | 365 | if (m_DataField != null) |
@@ -289,8 +374,12 @@ namespace OpenSim.Data.MSSQL | |||
289 | constraints.Add(new KeyValuePair<string, string>(kvp.Key, kvp.Key)); | 374 | constraints.Add(new KeyValuePair<string, string>(kvp.Key, kvp.Key)); |
290 | } | 375 | } |
291 | names.Add(kvp.Key); | 376 | names.Add(kvp.Key); |
292 | values.Add("@" + kvp.Key); | 377 | values.Add(":" + kvp.Key); |
293 | cmd.Parameters.Add(m_database.CreateParameter("@" + kvp.Key, kvp.Value)); | 378 | |
379 | if (m_FieldTypes.ContainsKey(kvp.Key)) | ||
380 | cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value, m_FieldTypes[kvp.Key])); | ||
381 | else | ||
382 | cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value)); | ||
294 | } | 383 | } |
295 | 384 | ||
296 | } | 385 | } |
@@ -299,15 +388,15 @@ namespace OpenSim.Data.MSSQL | |||
299 | int i = 0; | 388 | int i = 0; |
300 | for (i = 0; i < names.Count - 1; i++) | 389 | for (i = 0; i < names.Count - 1; i++) |
301 | { | 390 | { |
302 | query.AppendFormat("[{0}] = {1}, ", names[i], values[i]); | 391 | query.AppendFormat("\"{0}\" = {1}, ", names[i], values[i]); |
303 | } | 392 | } |
304 | query.AppendFormat("[{0}] = {1} ", names[i], values[i]); | 393 | query.AppendFormat("\"{0}\" = {1} ", names[i], values[i]); |
305 | if (constraints.Count > 0) | 394 | if (constraints.Count > 0) |
306 | { | 395 | { |
307 | List<string> terms = new List<string>(); | 396 | List<string> terms = new List<string>(); |
308 | for (int j = 0; j < constraints.Count; j++) | 397 | for (int j = 0; j < constraints.Count; j++) |
309 | { | 398 | { |
310 | terms.Add(" [" + constraints[j].Key + "] = @" + constraints[j].Key); | 399 | terms.Add(String.Format(" \"{0}\" = :{0}", constraints[j].Key)); |
311 | } | 400 | } |
312 | string where = String.Join(" AND ", terms.ToArray()); | 401 | string where = String.Join(" AND ", terms.ToArray()); |
313 | query.AppendFormat(" WHERE {0} ", where); | 402 | query.AppendFormat(" WHERE {0} ", where); |
@@ -319,7 +408,7 @@ namespace OpenSim.Data.MSSQL | |||
319 | conn.Open(); | 408 | conn.Open(); |
320 | if (cmd.ExecuteNonQuery() > 0) | 409 | if (cmd.ExecuteNonQuery() > 0) |
321 | { | 410 | { |
322 | //m_log.WarnFormat("[MSSQLGenericTable]: Updating {0}", m_Realm); | 411 | //m_log.WarnFormat("[PGSQLGenericTable]: Updating {0}", m_Realm); |
323 | return true; | 412 | return true; |
324 | } | 413 | } |
325 | else | 414 | else |
@@ -327,12 +416,14 @@ namespace OpenSim.Data.MSSQL | |||
327 | // assume record has not yet been inserted | 416 | // assume record has not yet been inserted |
328 | 417 | ||
329 | query = new StringBuilder(); | 418 | query = new StringBuilder(); |
330 | query.AppendFormat("INSERT INTO {0} ([", m_Realm); | 419 | query.AppendFormat("INSERT INTO {0} (\"", m_Realm); |
331 | query.Append(String.Join("],[", names.ToArray())); | 420 | query.Append(String.Join("\",\"", names.ToArray())); |
332 | query.Append("]) values (" + String.Join(",", values.ToArray()) + ")"); | 421 | query.Append("\") values (" + String.Join(",", values.ToArray()) + ")"); |
333 | cmd.Connection = conn; | 422 | cmd.Connection = conn; |
334 | cmd.CommandText = query.ToString(); | 423 | cmd.CommandText = query.ToString(); |
335 | //m_log.WarnFormat("[MSSQLGenericTable]: Inserting into {0}", m_Realm); | 424 | |
425 | // m_log.WarnFormat("[PGSQLGenericTable]: Inserting into {0} sql {1}", m_Realm, cmd.CommandText); | ||
426 | |||
336 | if (conn.State != ConnectionState.Open) | 427 | if (conn.State != ConnectionState.Open) |
337 | conn.Open(); | 428 | conn.Open(); |
338 | if (cmd.ExecuteNonQuery() > 0) | 429 | if (cmd.ExecuteNonQuery() > 0) |
@@ -355,13 +446,17 @@ namespace OpenSim.Data.MSSQL | |||
355 | 446 | ||
356 | List<string> terms = new List<string>(); | 447 | List<string> terms = new List<string>(); |
357 | 448 | ||
358 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 449 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
359 | using (SqlCommand cmd = new SqlCommand()) | 450 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
360 | { | 451 | { |
361 | for (int i = 0; i < fields.Length; i++) | 452 | for (int i = 0; i < fields.Length; i++) |
362 | { | 453 | { |
363 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); | 454 | if (m_FieldTypes.ContainsKey(fields[i])) |
364 | terms.Add("[" + fields[i] + "] = @" + fields[i]); | 455 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]])); |
456 | else | ||
457 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); | ||
458 | |||
459 | terms.Add(" \"" + fields[i] + "\" = :" + fields[i]); | ||
365 | } | 460 | } |
366 | 461 | ||
367 | string where = String.Join(" AND ", terms.ToArray()); | 462 | string where = String.Join(" AND ", terms.ToArray()); |
@@ -374,11 +469,69 @@ namespace OpenSim.Data.MSSQL | |||
374 | 469 | ||
375 | if (cmd.ExecuteNonQuery() > 0) | 470 | if (cmd.ExecuteNonQuery() > 0) |
376 | { | 471 | { |
377 | //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand); | 472 | //m_log.Warn("[PGSQLGenericTable]: " + deleteCommand); |
378 | return true; | 473 | return true; |
379 | } | 474 | } |
380 | return false; | 475 | return false; |
381 | } | 476 | } |
382 | } | 477 | } |
478 | public long GetCount(string field, string key) | ||
479 | { | ||
480 | return GetCount(new string[] { field }, new string[] { key }); | ||
481 | } | ||
482 | |||
483 | public long GetCount(string[] fields, string[] keys) | ||
484 | { | ||
485 | if (fields.Length != keys.Length) | ||
486 | return 0; | ||
487 | |||
488 | List<string> terms = new List<string>(); | ||
489 | |||
490 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
491 | { | ||
492 | for (int i = 0; i < fields.Length; i++) | ||
493 | { | ||
494 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | ||
495 | terms.Add("\"" + fields[i] + "\" = :" + fields[i]); | ||
496 | } | ||
497 | |||
498 | string where = String.Join(" and ", terms.ToArray()); | ||
499 | |||
500 | string query = String.Format("select count(*) from {0} where {1}", | ||
501 | m_Realm, where); | ||
502 | |||
503 | cmd.CommandText = query; | ||
504 | |||
505 | Object result = DoQueryScalar(cmd); | ||
506 | |||
507 | return Convert.ToInt64(result); | ||
508 | } | ||
509 | } | ||
510 | |||
511 | public long GetCount(string where) | ||
512 | { | ||
513 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
514 | { | ||
515 | string query = String.Format("select count(*) from {0} where {1}", | ||
516 | m_Realm, where); | ||
517 | |||
518 | cmd.CommandText = query; | ||
519 | |||
520 | object result = DoQueryScalar(cmd); | ||
521 | |||
522 | return Convert.ToInt64(result); | ||
523 | } | ||
524 | } | ||
525 | |||
526 | public object DoQueryScalar(NpgsqlCommand cmd) | ||
527 | { | ||
528 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_ConnectionString)) | ||
529 | { | ||
530 | dbcon.Open(); | ||
531 | cmd.Connection = dbcon; | ||
532 | |||
533 | return cmd.ExecuteScalar(); | ||
534 | } | ||
535 | } | ||
383 | } | 536 | } |
384 | } | 537 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs b/OpenSim/Data/PGSQL/PGSQLGridUserData.cs index 9e215f9..89319f3 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGridUserData.cs | |||
@@ -33,24 +33,23 @@ using System.Threading; | |||
33 | using log4net; | 33 | using log4net; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using System.Data.SqlClient; | ||
37 | 36 | ||
38 | namespace OpenSim.Data.MSSQL | 37 | namespace OpenSim.Data.PGSQL |
39 | { | 38 | { |
40 | /// <summary> | 39 | /// <summary> |
41 | /// A MSSQL Interface for Avatar Storage | 40 | /// A PGSQL Interface for Avatar Storage |
42 | /// </summary> | 41 | /// </summary> |
43 | public class MSSQLGridUserData : MSSQLGenericTableHandler<GridUserData>, | 42 | public class PGSQLGridUserData : PGSQLGenericTableHandler<GridUserData>, |
44 | IGridUserData | 43 | IGridUserData |
45 | { | 44 | { |
46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 46 | ||
48 | public MSSQLGridUserData(string connectionString, string realm) : | 47 | public PGSQLGridUserData(string connectionString, string realm) : |
49 | base(connectionString, realm, "GridUserStore") | 48 | base(connectionString, realm, "GridUserStore") |
50 | { | 49 | { |
51 | } | 50 | } |
52 | 51 | ||
53 | public GridUserData Get(string userID) | 52 | public new GridUserData Get(string userID) |
54 | { | 53 | { |
55 | GridUserData[] ret = Get("UserID", userID); | 54 | GridUserData[] ret = Get("UserID", userID); |
56 | 55 | ||
@@ -60,5 +59,10 @@ namespace OpenSim.Data.MSSQL | |||
60 | return ret[0]; | 59 | return ret[0]; |
61 | } | 60 | } |
62 | 61 | ||
62 | public GridUserData[] GetAll(string userID) | ||
63 | { | ||
64 | return base.Get(String.Format("\"UserID\" LIKE '{0}%'", userID)); | ||
65 | } | ||
66 | |||
63 | } | 67 | } |
64 | } | 68 | } |
diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs new file mode 100755 index 0000000..e257e7c --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs | |||
@@ -0,0 +1,485 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using Npgsql; | ||
36 | |||
37 | namespace OpenSim.Data.PGSQL | ||
38 | { | ||
39 | public class PGSQLGroupsData : IGroupsData | ||
40 | { | ||
41 | private PGSqlGroupsGroupsHandler m_Groups; | ||
42 | private PGSqlGroupsMembershipHandler m_Membership; | ||
43 | private PGSqlGroupsRolesHandler m_Roles; | ||
44 | private PGSqlGroupsRoleMembershipHandler m_RoleMembership; | ||
45 | private PGSqlGroupsInvitesHandler m_Invites; | ||
46 | private PGSqlGroupsNoticesHandler m_Notices; | ||
47 | private PGSqlGroupsPrincipalsHandler m_Principals; | ||
48 | |||
49 | public PGSQLGroupsData(string connectionString, string realm) | ||
50 | { | ||
51 | m_Groups = new PGSqlGroupsGroupsHandler(connectionString, realm + "_groups", realm + "_Store"); | ||
52 | m_Membership = new PGSqlGroupsMembershipHandler(connectionString, realm + "_membership"); | ||
53 | m_Roles = new PGSqlGroupsRolesHandler(connectionString, realm + "_roles"); | ||
54 | m_RoleMembership = new PGSqlGroupsRoleMembershipHandler(connectionString, realm + "_rolemembership"); | ||
55 | m_Invites = new PGSqlGroupsInvitesHandler(connectionString, realm + "_invites"); | ||
56 | m_Notices = new PGSqlGroupsNoticesHandler(connectionString, realm + "_notices"); | ||
57 | m_Principals = new PGSqlGroupsPrincipalsHandler(connectionString, realm + "_principals"); | ||
58 | } | ||
59 | |||
60 | #region groups table | ||
61 | public bool StoreGroup(GroupData data) | ||
62 | { | ||
63 | return m_Groups.Store(data); | ||
64 | } | ||
65 | |||
66 | public GroupData RetrieveGroup(UUID groupID) | ||
67 | { | ||
68 | GroupData[] groups = m_Groups.Get("GroupID", groupID.ToString()); | ||
69 | if (groups.Length > 0) | ||
70 | return groups[0]; | ||
71 | |||
72 | return null; | ||
73 | } | ||
74 | |||
75 | public GroupData RetrieveGroup(string name) | ||
76 | { | ||
77 | GroupData[] groups = m_Groups.Get("Name", name); | ||
78 | if (groups.Length > 0) | ||
79 | return groups[0]; | ||
80 | |||
81 | return null; | ||
82 | } | ||
83 | |||
84 | public GroupData[] RetrieveGroups(string pattern) | ||
85 | { | ||
86 | |||
87 | if (string.IsNullOrEmpty(pattern)) // True for where clause | ||
88 | { | ||
89 | pattern = " 1 ORDER BY lower(\"Name\") LIMIT 100"; | ||
90 | |||
91 | return m_Groups.Get(pattern); | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | pattern = " \"ShowInList\" = 1 AND lower(\"Name\") LIKE lower('%" + pattern + "%') ORDER BY lower(\"Name\") LIMIT 100"; | ||
96 | |||
97 | return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | public bool DeleteGroup(UUID groupID) | ||
102 | { | ||
103 | return m_Groups.Delete("GroupID", groupID.ToString()); | ||
104 | } | ||
105 | |||
106 | public int GroupsCount() | ||
107 | { | ||
108 | return (int)m_Groups.GetCount(" \"Location\" = \"\""); | ||
109 | } | ||
110 | |||
111 | #endregion | ||
112 | |||
113 | #region membership table | ||
114 | public MembershipData[] RetrieveMembers(UUID groupID) | ||
115 | { | ||
116 | return m_Membership.Get("GroupID", groupID.ToString()); | ||
117 | } | ||
118 | |||
119 | public MembershipData RetrieveMember(UUID groupID, string pricipalID) | ||
120 | { | ||
121 | MembershipData[] m = m_Membership.Get(new string[] { "GroupID", "PrincipalID" }, | ||
122 | new string[] { groupID.ToString(), pricipalID }); | ||
123 | if (m != null && m.Length > 0) | ||
124 | return m[0]; | ||
125 | |||
126 | return null; | ||
127 | } | ||
128 | |||
129 | public MembershipData[] RetrieveMemberships(string pricipalID) | ||
130 | { | ||
131 | return m_Membership.Get("PrincipalID", pricipalID.ToString()); | ||
132 | } | ||
133 | |||
134 | public bool StoreMember(MembershipData data) | ||
135 | { | ||
136 | return m_Membership.Store(data); | ||
137 | } | ||
138 | |||
139 | public bool DeleteMember(UUID groupID, string pricipalID) | ||
140 | { | ||
141 | return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" }, | ||
142 | new string[] { groupID.ToString(), pricipalID }); | ||
143 | } | ||
144 | |||
145 | public int MemberCount(UUID groupID) | ||
146 | { | ||
147 | return (int)m_Membership.GetCount("GroupID", groupID.ToString()); | ||
148 | } | ||
149 | #endregion | ||
150 | |||
151 | #region roles table | ||
152 | public bool StoreRole(RoleData data) | ||
153 | { | ||
154 | return m_Roles.Store(data); | ||
155 | } | ||
156 | |||
157 | public RoleData RetrieveRole(UUID groupID, UUID roleID) | ||
158 | { | ||
159 | RoleData[] data = m_Roles.Get(new string[] { "GroupID", "RoleID" }, | ||
160 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
161 | |||
162 | if (data != null && data.Length > 0) | ||
163 | return data[0]; | ||
164 | |||
165 | return null; | ||
166 | } | ||
167 | |||
168 | public RoleData[] RetrieveRoles(UUID groupID) | ||
169 | { | ||
170 | //return m_Roles.RetrieveRoles(groupID); | ||
171 | return m_Roles.Get("GroupID", groupID.ToString()); | ||
172 | } | ||
173 | |||
174 | public bool DeleteRole(UUID groupID, UUID roleID) | ||
175 | { | ||
176 | return m_Roles.Delete(new string[] { "GroupID", "RoleID" }, | ||
177 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
178 | } | ||
179 | |||
180 | public int RoleCount(UUID groupID) | ||
181 | { | ||
182 | return (int)m_Roles.GetCount("GroupID", groupID.ToString()); | ||
183 | } | ||
184 | |||
185 | |||
186 | #endregion | ||
187 | |||
188 | #region rolememberhip table | ||
189 | public RoleMembershipData[] RetrieveRolesMembers(UUID groupID) | ||
190 | { | ||
191 | RoleMembershipData[] data = m_RoleMembership.Get("GroupID", groupID.ToString()); | ||
192 | |||
193 | return data; | ||
194 | } | ||
195 | |||
196 | public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID) | ||
197 | { | ||
198 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID" }, | ||
199 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
200 | |||
201 | return data; | ||
202 | } | ||
203 | |||
204 | public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID) | ||
205 | { | ||
206 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "PrincipalID" }, | ||
207 | new string[] { groupID.ToString(), principalID.ToString() }); | ||
208 | |||
209 | return data; | ||
210 | } | ||
211 | |||
212 | public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID) | ||
213 | { | ||
214 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID", "PrincipalID" }, | ||
215 | new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() }); | ||
216 | |||
217 | if (data != null && data.Length > 0) | ||
218 | return data[0]; | ||
219 | |||
220 | return null; | ||
221 | } | ||
222 | |||
223 | public int RoleMemberCount(UUID groupID, UUID roleID) | ||
224 | { | ||
225 | return (int)m_RoleMembership.GetCount(new string[] { "GroupID", "RoleID" }, | ||
226 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
227 | } | ||
228 | |||
229 | public bool StoreRoleMember(RoleMembershipData data) | ||
230 | { | ||
231 | return m_RoleMembership.Store(data); | ||
232 | } | ||
233 | |||
234 | public bool DeleteRoleMember(RoleMembershipData data) | ||
235 | { | ||
236 | return m_RoleMembership.Delete(new string[] { "GroupID", "RoleID", "PrincipalID"}, | ||
237 | new string[] { data.GroupID.ToString(), data.RoleID.ToString(), data.PrincipalID }); | ||
238 | } | ||
239 | |||
240 | public bool DeleteMemberAllRoles(UUID groupID, string principalID) | ||
241 | { | ||
242 | return m_RoleMembership.Delete(new string[] { "GroupID", "PrincipalID" }, | ||
243 | new string[] { groupID.ToString(), principalID }); | ||
244 | } | ||
245 | |||
246 | #endregion | ||
247 | |||
248 | #region principals table | ||
249 | public bool StorePrincipal(PrincipalData data) | ||
250 | { | ||
251 | return m_Principals.Store(data); | ||
252 | } | ||
253 | |||
254 | public PrincipalData RetrievePrincipal(string principalID) | ||
255 | { | ||
256 | PrincipalData[] p = m_Principals.Get("PrincipalID", principalID); | ||
257 | if (p != null && p.Length > 0) | ||
258 | return p[0]; | ||
259 | |||
260 | return null; | ||
261 | } | ||
262 | |||
263 | public bool DeletePrincipal(string principalID) | ||
264 | { | ||
265 | return m_Principals.Delete("PrincipalID", principalID); | ||
266 | } | ||
267 | #endregion | ||
268 | |||
269 | #region invites table | ||
270 | |||
271 | public bool StoreInvitation(InvitationData data) | ||
272 | { | ||
273 | return m_Invites.Store(data); | ||
274 | } | ||
275 | |||
276 | public InvitationData RetrieveInvitation(UUID inviteID) | ||
277 | { | ||
278 | InvitationData[] invites = m_Invites.Get("InviteID", inviteID.ToString()); | ||
279 | |||
280 | if (invites != null && invites.Length > 0) | ||
281 | return invites[0]; | ||
282 | |||
283 | return null; | ||
284 | } | ||
285 | |||
286 | public InvitationData RetrieveInvitation(UUID groupID, string principalID) | ||
287 | { | ||
288 | InvitationData[] invites = m_Invites.Get(new string[] { "GroupID", "PrincipalID" }, | ||
289 | new string[] { groupID.ToString(), principalID }); | ||
290 | |||
291 | if (invites != null && invites.Length > 0) | ||
292 | return invites[0]; | ||
293 | |||
294 | return null; | ||
295 | } | ||
296 | |||
297 | public bool DeleteInvite(UUID inviteID) | ||
298 | { | ||
299 | return m_Invites.Delete("InviteID", inviteID.ToString()); | ||
300 | } | ||
301 | |||
302 | public void DeleteOldInvites() | ||
303 | { | ||
304 | m_Invites.DeleteOld(); | ||
305 | } | ||
306 | |||
307 | #endregion | ||
308 | |||
309 | #region notices table | ||
310 | |||
311 | public bool StoreNotice(NoticeData data) | ||
312 | { | ||
313 | return m_Notices.Store(data); | ||
314 | } | ||
315 | |||
316 | public NoticeData RetrieveNotice(UUID noticeID) | ||
317 | { | ||
318 | NoticeData[] notices = m_Notices.Get("NoticeID", noticeID.ToString()); | ||
319 | |||
320 | if (notices != null && notices.Length > 0) | ||
321 | return notices[0]; | ||
322 | |||
323 | return null; | ||
324 | } | ||
325 | |||
326 | public NoticeData[] RetrieveNotices(UUID groupID) | ||
327 | { | ||
328 | NoticeData[] notices = m_Notices.Get("GroupID", groupID.ToString()); | ||
329 | |||
330 | return notices; | ||
331 | } | ||
332 | |||
333 | public bool DeleteNotice(UUID noticeID) | ||
334 | { | ||
335 | return m_Notices.Delete("NoticeID", noticeID.ToString()); | ||
336 | } | ||
337 | |||
338 | public void DeleteOldNotices() | ||
339 | { | ||
340 | m_Notices.DeleteOld(); | ||
341 | } | ||
342 | |||
343 | #endregion | ||
344 | |||
345 | #region combinations | ||
346 | public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID) | ||
347 | { | ||
348 | // TODO | ||
349 | return null; | ||
350 | } | ||
351 | public MembershipData[] RetrievePrincipalGroupMemberships(string principalID) | ||
352 | { | ||
353 | // TODO | ||
354 | return null; | ||
355 | } | ||
356 | |||
357 | #endregion | ||
358 | } | ||
359 | |||
360 | public class PGSqlGroupsGroupsHandler : PGSQLGenericTableHandler<GroupData> | ||
361 | { | ||
362 | protected override Assembly Assembly | ||
363 | { | ||
364 | // WARNING! Moving migrations to this assembly!!! | ||
365 | get { return GetType().Assembly; } | ||
366 | } | ||
367 | |||
368 | public PGSqlGroupsGroupsHandler(string connectionString, string realm, string store) | ||
369 | : base(connectionString, realm, store) | ||
370 | { | ||
371 | } | ||
372 | |||
373 | } | ||
374 | |||
375 | public class PGSqlGroupsMembershipHandler : PGSQLGenericTableHandler<MembershipData> | ||
376 | { | ||
377 | protected override Assembly Assembly | ||
378 | { | ||
379 | // WARNING! Moving migrations to this assembly!!! | ||
380 | get { return GetType().Assembly; } | ||
381 | } | ||
382 | |||
383 | public PGSqlGroupsMembershipHandler(string connectionString, string realm) | ||
384 | : base(connectionString, realm, string.Empty) | ||
385 | { | ||
386 | } | ||
387 | |||
388 | } | ||
389 | |||
390 | public class PGSqlGroupsRolesHandler : PGSQLGenericTableHandler<RoleData> | ||
391 | { | ||
392 | protected override Assembly Assembly | ||
393 | { | ||
394 | // WARNING! Moving migrations to this assembly!!! | ||
395 | get { return GetType().Assembly; } | ||
396 | } | ||
397 | |||
398 | public PGSqlGroupsRolesHandler(string connectionString, string realm) | ||
399 | : base(connectionString, realm, string.Empty) | ||
400 | { | ||
401 | } | ||
402 | |||
403 | } | ||
404 | |||
405 | public class PGSqlGroupsRoleMembershipHandler : PGSQLGenericTableHandler<RoleMembershipData> | ||
406 | { | ||
407 | protected override Assembly Assembly | ||
408 | { | ||
409 | // WARNING! Moving migrations to this assembly!!! | ||
410 | get { return GetType().Assembly; } | ||
411 | } | ||
412 | |||
413 | public PGSqlGroupsRoleMembershipHandler(string connectionString, string realm) | ||
414 | : base(connectionString, realm, string.Empty) | ||
415 | { | ||
416 | } | ||
417 | |||
418 | } | ||
419 | |||
420 | public class PGSqlGroupsInvitesHandler : PGSQLGenericTableHandler<InvitationData> | ||
421 | { | ||
422 | protected override Assembly Assembly | ||
423 | { | ||
424 | // WARNING! Moving migrations to this assembly!!! | ||
425 | get { return GetType().Assembly; } | ||
426 | } | ||
427 | |||
428 | public PGSqlGroupsInvitesHandler(string connectionString, string realm) | ||
429 | : base(connectionString, realm, string.Empty) | ||
430 | { | ||
431 | } | ||
432 | |||
433 | public void DeleteOld() | ||
434 | { | ||
435 | |||
436 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
437 | { | ||
438 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); | ||
439 | |||
440 | ExecuteNonQuery(cmd); | ||
441 | } | ||
442 | |||
443 | } | ||
444 | } | ||
445 | |||
446 | public class PGSqlGroupsNoticesHandler : PGSQLGenericTableHandler<NoticeData> | ||
447 | { | ||
448 | protected override Assembly Assembly | ||
449 | { | ||
450 | // WARNING! Moving migrations to this assembly!!! | ||
451 | get { return GetType().Assembly; } | ||
452 | } | ||
453 | |||
454 | public PGSqlGroupsNoticesHandler(string connectionString, string realm) | ||
455 | : base(connectionString, realm, string.Empty) | ||
456 | { | ||
457 | } | ||
458 | |||
459 | public void DeleteOld() | ||
460 | { | ||
461 | |||
462 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
463 | { | ||
464 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); | ||
465 | |||
466 | ExecuteNonQuery(cmd); | ||
467 | } | ||
468 | |||
469 | } | ||
470 | } | ||
471 | |||
472 | public class PGSqlGroupsPrincipalsHandler : PGSQLGenericTableHandler<PrincipalData> | ||
473 | { | ||
474 | protected override Assembly Assembly | ||
475 | { | ||
476 | // WARNING! Moving migrations to this assembly!!! | ||
477 | get { return GetType().Assembly; } | ||
478 | } | ||
479 | |||
480 | public PGSqlGroupsPrincipalsHandler(string connectionString, string realm) | ||
481 | : base(connectionString, realm, string.Empty) | ||
482 | { | ||
483 | } | ||
484 | } | ||
485 | } | ||
diff --git a/OpenSim/Data/PGSQL/PGSQLHGTravelData.cs b/OpenSim/Data/PGSQL/PGSQLHGTravelData.cs new file mode 100644 index 0000000..c71b15f --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLHGTravelData.cs | |||
@@ -0,0 +1,80 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using Npgsql; | ||
37 | |||
38 | namespace OpenSim.Data.PGSQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A PGSQL Interface for user grid data | ||
42 | /// </summary> | ||
43 | public class PGSQLHGTravelData : PGSQLGenericTableHandler<HGTravelingData>, IHGTravelingData | ||
44 | { | ||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | public PGSQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { } | ||
48 | |||
49 | public HGTravelingData Get(UUID sessionID) | ||
50 | { | ||
51 | HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); | ||
52 | |||
53 | if (ret.Length == 0) | ||
54 | return null; | ||
55 | |||
56 | return ret[0]; | ||
57 | } | ||
58 | |||
59 | public HGTravelingData[] GetSessions(UUID userID) | ||
60 | { | ||
61 | return base.Get("UserID", userID.ToString()); | ||
62 | } | ||
63 | |||
64 | public bool Delete(UUID sessionID) | ||
65 | { | ||
66 | return Delete("SessionID", sessionID.ToString()); | ||
67 | } | ||
68 | |||
69 | public void DeleteOld() | ||
70 | { | ||
71 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
72 | { | ||
73 | cmd.CommandText = String.Format(@"delete from {0} where ""TMStamp"" < CURRENT_DATE - INTERVAL '2 day'", m_Realm); | ||
74 | |||
75 | ExecuteNonQuery(cmd); | ||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
80 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/PGSQL/PGSQLInventoryData.cs index 961593f..c999433 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/PGSQL/PGSQLInventoryData.cs | |||
@@ -28,18 +28,18 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Data.SqlClient; | ||
32 | using System.Reflection; | 31 | using System.Reflection; |
33 | using log4net; | 32 | using log4net; |
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using Npgsql; | ||
36 | 36 | ||
37 | namespace OpenSim.Data.MSSQL | 37 | namespace OpenSim.Data.PGSQL |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// A MSSQL interface for the inventory server | 40 | /// A PGSQL interface for the inventory server |
41 | /// </summary> | 41 | /// </summary> |
42 | public class MSSQLInventoryData : IInventoryDataPlugin | 42 | public class PGSQLInventoryData : IInventoryDataPlugin |
43 | { | 43 | { |
44 | private const string _migrationStore = "InventoryStore"; | 44 | private const string _migrationStore = "InventoryStore"; |
45 | 45 | ||
@@ -48,7 +48,7 @@ namespace OpenSim.Data.MSSQL | |||
48 | /// <summary> | 48 | /// <summary> |
49 | /// The database manager | 49 | /// The database manager |
50 | /// </summary> | 50 | /// </summary> |
51 | private MSSQLManager database; | 51 | private PGSQLManager database; |
52 | private string m_connectionString; | 52 | private string m_connectionString; |
53 | 53 | ||
54 | #region IPlugin members | 54 | #region IPlugin members |
@@ -56,19 +56,19 @@ namespace OpenSim.Data.MSSQL | |||
56 | [Obsolete("Cannot be default-initialized!")] | 56 | [Obsolete("Cannot be default-initialized!")] |
57 | public void Initialise() | 57 | public void Initialise() |
58 | { | 58 | { |
59 | m_log.Info("[MSSQLInventoryData]: " + Name + " cannot be default-initialized!"); | 59 | m_log.Info("[PGSQLInventoryData]: " + Name + " cannot be default-initialized!"); |
60 | throw new PluginNotInitialisedException(Name); | 60 | throw new PluginNotInitialisedException(Name); |
61 | } | 61 | } |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Loads and initialises the MSSQL inventory storage interface | 64 | /// Loads and initialises the PGSQL inventory storage interface |
65 | /// </summary> | 65 | /// </summary> |
66 | /// <param name="connectionString">connect string</param> | 66 | /// <param name="connectionString">connect string</param> |
67 | /// <remarks>use mssql_connection.ini</remarks> | 67 | /// <remarks>use PGSQL_connection.ini</remarks> |
68 | public void Initialise(string connectionString) | 68 | public void Initialise(string connectionString) |
69 | { | 69 | { |
70 | m_connectionString = connectionString; | 70 | m_connectionString = connectionString; |
71 | database = new MSSQLManager(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); |
@@ -80,7 +80,7 @@ namespace OpenSim.Data.MSSQL | |||
80 | /// <returns>A string containing the name of the DB provider</returns> | 80 | /// <returns>A string containing the name of the DB provider</returns> |
81 | public string Name | 81 | public string Name |
82 | { | 82 | { |
83 | get { return "MSSQL Inventory Data Interface"; } | 83 | get { return "PGSQL Inventory Data Interface"; } |
84 | } | 84 | } |
85 | 85 | ||
86 | /// <summary> | 86 | /// <summary> |
@@ -158,13 +158,13 @@ namespace OpenSim.Data.MSSQL | |||
158 | /// <returns>A folder class</returns> | 158 | /// <returns>A folder class</returns> |
159 | public InventoryFolderBase getInventoryFolder(UUID folderID) | 159 | public InventoryFolderBase getInventoryFolder(UUID folderID) |
160 | { | 160 | { |
161 | string sql = "SELECT * FROM inventoryfolders WHERE folderID = @folderID"; | 161 | string sql = "SELECT * FROM inventoryfolders WHERE \"folderID\" = :folderID"; |
162 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 162 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
163 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 163 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
164 | { | 164 | { |
165 | cmd.Parameters.Add(database.CreateParameter("folderID", folderID)); | 165 | cmd.Parameters.Add(database.CreateParameter("folderID", folderID)); |
166 | conn.Open(); | 166 | conn.Open(); |
167 | using (SqlDataReader reader = cmd.ExecuteReader()) | 167 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
168 | { | 168 | { |
169 | if (reader.Read()) | 169 | if (reader.Read()) |
170 | { | 170 | { |
@@ -200,11 +200,11 @@ namespace OpenSim.Data.MSSQL | |||
200 | if (parentID == UUID.Zero) | 200 | if (parentID == UUID.Zero) |
201 | return folders; | 201 | return folders; |
202 | 202 | ||
203 | string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID"; | 203 | string sql = "SELECT * FROM inventoryfolders WHERE \"parentFolderID\" = :parentID"; |
204 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 204 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
205 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 205 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
206 | { | 206 | { |
207 | cmd.Parameters.Add(database.CreateParameter("@parentID", parentID)); | 207 | cmd.Parameters.Add(database.CreateParameter("parentID", parentID)); |
208 | conn.Open(); | 208 | conn.Open(); |
209 | folders.AddRange(getInventoryFolders(cmd)); | 209 | folders.AddRange(getInventoryFolders(cmd)); |
210 | 210 | ||
@@ -228,8 +228,8 @@ namespace OpenSim.Data.MSSQL | |||
228 | /// <param name="folder">Folder to create</param> | 228 | /// <param name="folder">Folder to create</param> |
229 | public void addInventoryFolder(InventoryFolderBase folder) | 229 | public void addInventoryFolder(InventoryFolderBase folder) |
230 | { | 230 | { |
231 | string sql = @"INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version]) | 231 | string sql = "INSERT INTO inventoryfolders (\"folderID\", \"agentID\", \"parentFolderID\", \"folderName\", type, version) " + |
232 | VALUES (@folderID, @agentID, @parentFolderID, @folderName, @type, @version);"; | 232 | " VALUES (:folderID, :agentID, :parentFolderID, :folderName, :type, :version);"; |
233 | 233 | ||
234 | string folderName = folder.Name; | 234 | string folderName = folder.Name; |
235 | if (folderName.Length > 64) | 235 | if (folderName.Length > 64) |
@@ -237,8 +237,8 @@ namespace OpenSim.Data.MSSQL | |||
237 | folderName = folderName.Substring(0, 64); | 237 | folderName = folderName.Substring(0, 64); |
238 | m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add"); | 238 | m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add"); |
239 | } | 239 | } |
240 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 240 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
241 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 241 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
242 | { | 242 | { |
243 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); | 243 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); |
244 | cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); | 244 | cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); |
@@ -264,12 +264,12 @@ namespace OpenSim.Data.MSSQL | |||
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; |
275 | if (folderName.Length > 64) | 275 | if (folderName.Length > 64) |
@@ -277,8 +277,8 @@ namespace OpenSim.Data.MSSQL | |||
277 | folderName = folderName.Substring(0, 64); | 277 | folderName = folderName.Substring(0, 64); |
278 | m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update"); | 278 | m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update"); |
279 | } | 279 | } |
280 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 280 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
281 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 281 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
282 | { | 282 | { |
283 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); | 283 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); |
284 | cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); | 284 | cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); |
@@ -304,9 +304,9 @@ namespace OpenSim.Data.MSSQL | |||
304 | /// <param name="folder">Folder to update</param> | 304 | /// <param name="folder">Folder to update</param> |
305 | public void moveInventoryFolder(InventoryFolderBase folder) | 305 | public void moveInventoryFolder(InventoryFolderBase folder) |
306 | { | 306 | { |
307 | string sql = @"UPDATE inventoryfolders SET parentFolderID = @parentFolderID WHERE folderID = @folderID"; | 307 | string sql = @"UPDATE inventoryfolders SET ""parentFolderID"" = :parentFolderID WHERE ""folderID"" = :folderID"; |
308 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 308 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
309 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 309 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
310 | { | 310 | { |
311 | cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); | 311 | cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); |
312 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); | 312 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); |
@@ -328,13 +328,13 @@ namespace OpenSim.Data.MSSQL | |||
328 | /// <param name="folderID">Id of folder to delete</param> | 328 | /// <param name="folderID">Id of folder to delete</param> |
329 | public void deleteInventoryFolder(UUID folderID) | 329 | public void deleteInventoryFolder(UUID folderID) |
330 | { | 330 | { |
331 | string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID"; | 331 | string sql = @"SELECT * FROM inventoryfolders WHERE ""parentFolderID"" = :parentID"; |
332 | 332 | ||
333 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 333 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
334 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 334 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
335 | { | 335 | { |
336 | List<InventoryFolderBase> subFolders; | 336 | List<InventoryFolderBase> subFolders; |
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 | ||
@@ -363,15 +363,15 @@ namespace OpenSim.Data.MSSQL | |||
363 | /// <returns>A list containing inventory items</returns> | 363 | /// <returns>A list containing inventory items</returns> |
364 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | 364 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) |
365 | { | 365 | { |
366 | string sql = "SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID"; | 366 | string sql = @"SELECT * FROM inventoryitems WHERE ""parentFolderID"" = :parentFolderID"; |
367 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 367 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
368 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 368 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
369 | { | 369 | { |
370 | cmd.Parameters.Add(database.CreateParameter("parentFolderID", folderID)); | 370 | cmd.Parameters.Add(database.CreateParameter("parentFolderID", folderID)); |
371 | conn.Open(); | 371 | conn.Open(); |
372 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 372 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
373 | 373 | ||
374 | using (SqlDataReader reader = cmd.ExecuteReader()) | 374 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
375 | { | 375 | { |
376 | while (reader.Read()) | 376 | while (reader.Read()) |
377 | { | 377 | { |
@@ -389,13 +389,13 @@ namespace OpenSim.Data.MSSQL | |||
389 | /// <returns>An inventory item</returns> | 389 | /// <returns>An inventory item</returns> |
390 | public InventoryItemBase getInventoryItem(UUID itemID) | 390 | public InventoryItemBase getInventoryItem(UUID itemID) |
391 | { | 391 | { |
392 | string sql = "SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID"; | 392 | string sql = @"SELECT * FROM inventoryitems WHERE ""inventoryID"" = :inventoryID"; |
393 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 393 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
394 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 394 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
395 | { | 395 | { |
396 | cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID)); | 396 | cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID)); |
397 | conn.Open(); | 397 | conn.Open(); |
398 | using (SqlDataReader reader = cmd.ExecuteReader()) | 398 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
399 | { | 399 | { |
400 | if (reader.Read()) | 400 | if (reader.Read()) |
401 | { | 401 | { |
@@ -421,15 +421,15 @@ namespace OpenSim.Data.MSSQL | |||
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) |
@@ -445,8 +445,8 @@ namespace OpenSim.Data.MSSQL | |||
445 | m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters"); | 445 | m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters"); |
446 | } | 446 | } |
447 | 447 | ||
448 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 448 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
449 | using (SqlCommand command = new SqlCommand(sql, conn)) | 449 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
450 | { | 450 | { |
451 | command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); | 451 | command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); |
452 | command.Parameters.Add(database.CreateParameter("assetID", item.AssetID)); | 452 | command.Parameters.Add(database.CreateParameter("assetID", item.AssetID)); |
@@ -462,8 +462,8 @@ namespace OpenSim.Data.MSSQL | |||
462 | command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions)); | 462 | command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions)); |
463 | command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions)); | 463 | command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions)); |
464 | command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions)); | 464 | command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions)); |
465 | command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice)); | 465 | command.Parameters.Add(database.CreateParameter("SalePrice", item.SalePrice)); |
466 | command.Parameters.Add(database.CreateParameter("saleType", item.SaleType)); | 466 | command.Parameters.Add(database.CreateParameter("SaleType", item.SaleType)); |
467 | command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate)); | 467 | command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate)); |
468 | command.Parameters.Add(database.CreateParameter("groupID", item.GroupID)); | 468 | command.Parameters.Add(database.CreateParameter("groupID", item.GroupID)); |
469 | command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned)); | 469 | command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned)); |
@@ -479,9 +479,9 @@ namespace OpenSim.Data.MSSQL | |||
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | sql = "UPDATE inventoryfolders SET version = version + 1 WHERE folderID = @folderID"; | 482 | sql = @"UPDATE inventoryfolders SET version = version + 1 WHERE ""folderID"" = @folderID"; |
483 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 483 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
484 | using (SqlCommand command = new SqlCommand(sql, conn)) | 484 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
485 | { | 485 | { |
486 | command.Parameters.Add(database.CreateParameter("folderID", item.Folder.ToString())); | 486 | command.Parameters.Add(database.CreateParameter("folderID", item.Folder.ToString())); |
487 | conn.Open(); | 487 | conn.Open(); |
@@ -502,26 +502,26 @@ namespace OpenSim.Data.MSSQL | |||
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; |
527 | if (item.Name.Length > 64) | 527 | if (item.Name.Length > 64) |
@@ -537,8 +537,8 @@ namespace OpenSim.Data.MSSQL | |||
537 | m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update"); | 537 | m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update"); |
538 | } | 538 | } |
539 | 539 | ||
540 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 540 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
541 | using (SqlCommand command = new SqlCommand(sql, conn)) | 541 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
542 | { | 542 | { |
543 | command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); | 543 | command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); |
544 | command.Parameters.Add(database.CreateParameter("assetID", item.AssetID)); | 544 | command.Parameters.Add(database.CreateParameter("assetID", item.AssetID)); |
@@ -554,8 +554,8 @@ namespace OpenSim.Data.MSSQL | |||
554 | command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions)); | 554 | command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions)); |
555 | command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions)); | 555 | command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions)); |
556 | command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions)); | 556 | command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions)); |
557 | command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice)); | 557 | command.Parameters.Add(database.CreateParameter("SalePrice", item.SalePrice)); |
558 | command.Parameters.Add(database.CreateParameter("saleType", item.SaleType)); | 558 | command.Parameters.Add(database.CreateParameter("SaleType", item.SaleType)); |
559 | command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate)); | 559 | command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate)); |
560 | command.Parameters.Add(database.CreateParameter("groupID", item.GroupID)); | 560 | command.Parameters.Add(database.CreateParameter("groupID", item.GroupID)); |
561 | command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned)); | 561 | command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned)); |
@@ -580,9 +580,9 @@ namespace OpenSim.Data.MSSQL | |||
580 | /// <param name="itemID">the item UUID</param> | 580 | /// <param name="itemID">the item UUID</param> |
581 | public void deleteInventoryItem(UUID itemID) | 581 | public void deleteInventoryItem(UUID itemID) |
582 | { | 582 | { |
583 | string sql = "DELETE FROM inventoryitems WHERE inventoryID=@inventoryID"; | 583 | string sql = @"DELETE FROM inventoryitems WHERE ""inventoryID""=:inventoryID"; |
584 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 584 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
585 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 585 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
586 | { | 586 | { |
587 | cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID)); | 587 | cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID)); |
588 | try | 588 | try |
@@ -616,14 +616,14 @@ namespace OpenSim.Data.MSSQL | |||
616 | /// </returns> | 616 | /// </returns> |
617 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) | 617 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) |
618 | { | 618 | { |
619 | string sql = "SELECT * FROM inventoryitems WHERE avatarId = @uuid AND assetType = @assetType and flags = 1"; | 619 | string sql = @"SELECT * FROM inventoryitems WHERE ""avatarID"" = :uuid AND ""assetType"" = :assetType and flags = 1"; |
620 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 620 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
621 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 621 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
622 | { | 622 | { |
623 | cmd.Parameters.Add(database.CreateParameter("uuid", avatarID)); | 623 | cmd.Parameters.Add(database.CreateParameter("uuid", avatarID)); |
624 | cmd.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture)); | 624 | cmd.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture)); |
625 | conn.Open(); | 625 | conn.Open(); |
626 | using (SqlDataReader reader = cmd.ExecuteReader()) | 626 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
627 | { | 627 | { |
628 | List<InventoryItemBase> gestureList = new List<InventoryItemBase>(); | 628 | List<InventoryItemBase> gestureList = new List<InventoryItemBase>(); |
629 | while (reader.Read()) | 629 | while (reader.Read()) |
@@ -644,9 +644,9 @@ namespace OpenSim.Data.MSSQL | |||
644 | /// </summary> | 644 | /// </summary> |
645 | /// <param name="folderID">the item ID</param> | 645 | /// <param name="folderID">the item ID</param> |
646 | /// <param name="connection">connection to the database</param> | 646 | /// <param name="connection">connection to the database</param> |
647 | private void DeleteItemsInFolder(UUID folderID, SqlConnection connection) | 647 | private void DeleteItemsInFolder(UUID folderID, NpgsqlConnection connection) |
648 | { | 648 | { |
649 | using (SqlCommand command = new SqlCommand("DELETE FROM inventoryitems WHERE folderID=@folderID", connection)) | 649 | using (NpgsqlCommand command = new NpgsqlCommand(@"DELETE FROM inventoryitems WHERE ""folderID""=:folderID", connection)) |
650 | { | 650 | { |
651 | command.Parameters.Add(database.CreateParameter("folderID", folderID)); | 651 | command.Parameters.Add(database.CreateParameter("folderID", folderID)); |
652 | 652 | ||
@@ -667,9 +667,9 @@ namespace OpenSim.Data.MSSQL | |||
667 | /// <param name="parentID">parent ID.</param> | 667 | /// <param name="parentID">parent ID.</param> |
668 | /// <param name="command">SQL command/connection to database</param> | 668 | /// <param name="command">SQL command/connection to database</param> |
669 | /// <returns></returns> | 669 | /// <returns></returns> |
670 | private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, SqlCommand command) | 670 | private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, NpgsqlCommand command) |
671 | { | 671 | { |
672 | command.Parameters["@parentID"].Value = parentID.Guid; //.ToString(); | 672 | command.Parameters["parentID"].Value = parentID.Guid; //.ToString(); |
673 | 673 | ||
674 | List<InventoryFolderBase> folders = getInventoryFolders(command); | 674 | List<InventoryFolderBase> folders = getInventoryFolders(command); |
675 | 675 | ||
@@ -698,9 +698,9 @@ namespace OpenSim.Data.MSSQL | |||
698 | /// <returns></returns> | 698 | /// <returns></returns> |
699 | private List<InventoryFolderBase> getInventoryFolders(UUID parentID, UUID user) | 699 | private List<InventoryFolderBase> getInventoryFolders(UUID parentID, UUID user) |
700 | { | 700 | { |
701 | string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID AND agentID LIKE @uuid"; | 701 | string sql = @"SELECT * FROM inventoryfolders WHERE ""parentFolderID"" = :parentID AND ""agentID"" = :uuid"; |
702 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 702 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
703 | using (SqlCommand command = new SqlCommand(sql, conn)) | 703 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
704 | { | 704 | { |
705 | if (user == UUID.Zero) | 705 | if (user == UUID.Zero) |
706 | { | 706 | { |
@@ -721,9 +721,9 @@ namespace OpenSim.Data.MSSQL | |||
721 | /// </summary> | 721 | /// </summary> |
722 | /// <param name="command">SQLcommand.</param> | 722 | /// <param name="command">SQLcommand.</param> |
723 | /// <returns></returns> | 723 | /// <returns></returns> |
724 | private static List<InventoryFolderBase> getInventoryFolders(SqlCommand command) | 724 | private static List<InventoryFolderBase> getInventoryFolders(NpgsqlCommand command) |
725 | { | 725 | { |
726 | using (SqlDataReader reader = command.ExecuteReader()) | 726 | using (NpgsqlDataReader reader = command.ExecuteReader()) |
727 | { | 727 | { |
728 | 728 | ||
729 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 729 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
@@ -738,9 +738,9 @@ namespace OpenSim.Data.MSSQL | |||
738 | /// <summary> | 738 | /// <summary> |
739 | /// Reads a list of inventory folders returned by a query. | 739 | /// Reads a list of inventory folders returned by a query. |
740 | /// </summary> | 740 | /// </summary> |
741 | /// <param name="reader">A MSSQL Data Reader</param> | 741 | /// <param name="reader">A PGSQL Data Reader</param> |
742 | /// <returns>A List containing inventory folders</returns> | 742 | /// <returns>A List containing inventory folders</returns> |
743 | protected static InventoryFolderBase readInventoryFolder(SqlDataReader reader) | 743 | protected static InventoryFolderBase readInventoryFolder(NpgsqlDataReader reader) |
744 | { | 744 | { |
745 | try | 745 | try |
746 | { | 746 | { |
@@ -796,7 +796,7 @@ namespace OpenSim.Data.MSSQL | |||
796 | 796 | ||
797 | return item; | 797 | return item; |
798 | } | 798 | } |
799 | catch (SqlException e) | 799 | catch (NpgsqlException e) |
800 | { | 800 | { |
801 | m_log.Error("[INVENTORY DB]: Error reading inventory item :" + e.Message); | 801 | m_log.Error("[INVENTORY DB]: Error reading inventory item :" + e.Message); |
802 | } | 802 | } |
@@ -809,18 +809,18 @@ namespace OpenSim.Data.MSSQL | |||
809 | /// </summary> | 809 | /// </summary> |
810 | /// <param name="folderID">the folder UUID</param> | 810 | /// <param name="folderID">the folder UUID</param> |
811 | /// <param name="connection">connection to database</param> | 811 | /// <param name="connection">connection to database</param> |
812 | private void DeleteOneFolder(UUID folderID, SqlConnection connection) | 812 | private void DeleteOneFolder(UUID folderID, NpgsqlConnection connection) |
813 | { | 813 | { |
814 | try | 814 | try |
815 | { | 815 | { |
816 | using (SqlCommand command = new SqlCommand("DELETE FROM inventoryfolders WHERE folderID=@folderID and type=-1", connection)) | 816 | using (NpgsqlCommand command = new NpgsqlCommand(@"DELETE FROM inventoryfolders WHERE ""folderID""=:folderID and type=-1", connection)) |
817 | { | 817 | { |
818 | command.Parameters.Add(database.CreateParameter("folderID", folderID)); | 818 | command.Parameters.Add(database.CreateParameter("folderID", folderID)); |
819 | 819 | ||
820 | command.ExecuteNonQuery(); | 820 | command.ExecuteNonQuery(); |
821 | } | 821 | } |
822 | } | 822 | } |
823 | catch (SqlException e) | 823 | catch (NpgsqlException e) |
824 | { | 824 | { |
825 | m_log.Error("[INVENTORY DB]: Error deleting folder :" + e.Message); | 825 | m_log.Error("[INVENTORY DB]: Error deleting folder :" + e.Message); |
826 | } | 826 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/PGSQL/PGSQLManager.cs index 9a0015c..46f835a 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/PGSQL/PGSQLManager.cs | |||
@@ -28,18 +28,20 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Data.SqlClient; | ||
32 | using System.IO; | 31 | using System.IO; |
33 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Framework; | ||
34 | using log4net; | 34 | using log4net; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using Npgsql; | ||
37 | using NpgsqlTypes; | ||
36 | 38 | ||
37 | namespace OpenSim.Data.MSSQL | 39 | namespace OpenSim.Data.PGSQL |
38 | { | 40 | { |
39 | /// <summary> | 41 | /// <summary> |
40 | /// A management class for the MS SQL Storage Engine | 42 | /// A management class for the MS SQL Storage Engine |
41 | /// </summary> | 43 | /// </summary> |
42 | public class MSSQLManager | 44 | public class PGSQLManager |
43 | { | 45 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
@@ -52,9 +54,37 @@ namespace OpenSim.Data.MSSQL | |||
52 | /// Initialize the manager and set the connectionstring | 54 | /// Initialize the manager and set the connectionstring |
53 | /// </summary> | 55 | /// </summary> |
54 | /// <param name="connection"></param> | 56 | /// <param name="connection"></param> |
55 | public MSSQLManager(string connection) | 57 | public PGSQLManager(string connection) |
56 | { | 58 | { |
57 | connectionString = connection; | 59 | connectionString = connection; |
60 | InitializeMonoSecurity(); | ||
61 | } | ||
62 | |||
63 | public void InitializeMonoSecurity() | ||
64 | { | ||
65 | if (!Util.IsPlatformMono) | ||
66 | { | ||
67 | if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null) | ||
68 | { | ||
69 | AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true"); | ||
70 | |||
71 | AppDomain currentDomain = AppDomain.CurrentDomain; | ||
72 | currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args) | ||
78 | { | ||
79 | Assembly MyAssembly = null; | ||
80 | |||
81 | if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security") | ||
82 | { | ||
83 | MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll"); | ||
84 | } | ||
85 | |||
86 | //Return the loaded assembly. | ||
87 | return MyAssembly; | ||
58 | } | 88 | } |
59 | 89 | ||
60 | /// <summary> | 90 | /// <summary> |
@@ -62,54 +92,97 @@ namespace OpenSim.Data.MSSQL | |||
62 | /// </summary> | 92 | /// </summary> |
63 | /// <param name="type"></param> | 93 | /// <param name="type"></param> |
64 | /// <returns></returns> | 94 | /// <returns></returns> |
65 | internal SqlDbType DbtypeFromType(Type type) | 95 | internal NpgsqlDbType DbtypeFromType(Type type) |
66 | { | 96 | { |
67 | if (type == typeof(string)) | 97 | if (type == typeof(string)) |
68 | { | 98 | { |
69 | return SqlDbType.VarChar; | 99 | return NpgsqlDbType.Varchar; |
70 | } | 100 | } |
71 | if (type == typeof(double)) | 101 | if (type == typeof(double)) |
72 | { | 102 | { |
73 | return SqlDbType.Float; | 103 | return NpgsqlDbType.Double; |
74 | } | 104 | } |
75 | if (type == typeof(Single)) | 105 | if (type == typeof(Single)) |
76 | { | 106 | { |
77 | return SqlDbType.Float; | 107 | return NpgsqlDbType.Double; |
78 | } | 108 | } |
79 | if (type == typeof(int)) | 109 | if (type == typeof(int)) |
80 | { | 110 | { |
81 | return SqlDbType.Int; | 111 | return NpgsqlDbType.Integer; |
82 | } | 112 | } |
83 | if (type == typeof(bool)) | 113 | if (type == typeof(bool)) |
84 | { | 114 | { |
85 | return SqlDbType.Bit; | 115 | return NpgsqlDbType.Boolean; |
86 | } | 116 | } |
87 | if (type == typeof(UUID)) | 117 | if (type == typeof(UUID)) |
88 | { | 118 | { |
89 | return SqlDbType.UniqueIdentifier; | 119 | return NpgsqlDbType.Uuid; |
120 | } | ||
121 | if (type == typeof(byte)) | ||
122 | { | ||
123 | return NpgsqlDbType.Smallint; | ||
90 | } | 124 | } |
91 | if (type == typeof(sbyte)) | 125 | if (type == typeof(sbyte)) |
92 | { | 126 | { |
93 | return SqlDbType.Int; | 127 | return NpgsqlDbType.Integer; |
94 | } | 128 | } |
95 | if (type == typeof(Byte[])) | 129 | if (type == typeof(Byte[])) |
96 | { | 130 | { |
97 | return SqlDbType.Image; | 131 | return NpgsqlDbType.Bytea; |
98 | } | 132 | } |
99 | if (type == typeof(uint) || type == typeof(ushort)) | 133 | if (type == typeof(uint) || type == typeof(ushort)) |
100 | { | 134 | { |
101 | return SqlDbType.Int; | 135 | return NpgsqlDbType.Integer; |
102 | } | 136 | } |
103 | if (type == typeof(ulong)) | 137 | if (type == typeof(ulong)) |
104 | { | 138 | { |
105 | return SqlDbType.BigInt; | 139 | return NpgsqlDbType.Bigint; |
106 | } | 140 | } |
107 | if (type == typeof(DateTime)) | 141 | if (type == typeof(DateTime)) |
108 | { | 142 | { |
109 | return SqlDbType.DateTime; | 143 | return NpgsqlDbType.Timestamp; |
110 | } | 144 | } |
111 | 145 | ||
112 | return SqlDbType.VarChar; | 146 | return NpgsqlDbType.Varchar; |
147 | } | ||
148 | |||
149 | internal NpgsqlDbType DbtypeFromString(Type type, string PGFieldType) | ||
150 | { | ||
151 | if (PGFieldType == "") | ||
152 | { | ||
153 | return DbtypeFromType(type); | ||
154 | } | ||
155 | |||
156 | if (PGFieldType == "character varying") | ||
157 | { | ||
158 | return NpgsqlDbType.Varchar; | ||
159 | } | ||
160 | if (PGFieldType == "double precision") | ||
161 | { | ||
162 | return NpgsqlDbType.Double; | ||
163 | } | ||
164 | if (PGFieldType == "integer") | ||
165 | { | ||
166 | return NpgsqlDbType.Integer; | ||
167 | } | ||
168 | if (PGFieldType == "smallint") | ||
169 | { | ||
170 | return NpgsqlDbType.Smallint; | ||
171 | } | ||
172 | if (PGFieldType == "boolean") | ||
173 | { | ||
174 | return NpgsqlDbType.Boolean; | ||
175 | } | ||
176 | if (PGFieldType == "uuid") | ||
177 | { | ||
178 | return NpgsqlDbType.Uuid; | ||
179 | } | ||
180 | if (PGFieldType == "bytea") | ||
181 | { | ||
182 | return NpgsqlDbType.Bytea; | ||
183 | } | ||
184 | |||
185 | return DbtypeFromType(type); | ||
113 | } | 186 | } |
114 | 187 | ||
115 | /// <summary> | 188 | /// <summary> |
@@ -131,7 +204,7 @@ namespace OpenSim.Data.MSSQL | |||
131 | } | 204 | } |
132 | if (valueType == typeof(bool)) | 205 | if (valueType == typeof(bool)) |
133 | { | 206 | { |
134 | return (bool)value ? 1 : 0; | 207 | return (bool)value; |
135 | } | 208 | } |
136 | if (valueType == typeof(Byte[])) | 209 | if (valueType == typeof(Byte[])) |
137 | { | 210 | { |
@@ -145,12 +218,51 @@ namespace OpenSim.Data.MSSQL | |||
145 | } | 218 | } |
146 | 219 | ||
147 | /// <summary> | 220 | /// <summary> |
221 | /// Create value for parameter based on PGSQL Schema | ||
222 | /// </summary> | ||
223 | /// <param name="value"></param> | ||
224 | /// <param name="PGFieldType"></param> | ||
225 | /// <returns></returns> | ||
226 | internal static object CreateParameterValue(object value, string PGFieldType) | ||
227 | { | ||
228 | if (PGFieldType == "uuid") | ||
229 | { | ||
230 | UUID uidout; | ||
231 | UUID.TryParse(value.ToString(), out uidout); | ||
232 | return uidout; | ||
233 | } | ||
234 | if (PGFieldType == "integer") | ||
235 | { | ||
236 | int intout; | ||
237 | int.TryParse(value.ToString(), out intout); | ||
238 | return intout; | ||
239 | } | ||
240 | if (PGFieldType == "boolean") | ||
241 | { | ||
242 | return (value.ToString() == "true"); | ||
243 | } | ||
244 | if (PGFieldType == "timestamp with time zone") | ||
245 | { | ||
246 | return (DateTime)value; | ||
247 | } | ||
248 | if (PGFieldType == "timestamp without time zone") | ||
249 | { | ||
250 | return (DateTime)value; | ||
251 | } | ||
252 | if (PGFieldType == "double precision") | ||
253 | { | ||
254 | return (Double)value; | ||
255 | } | ||
256 | return CreateParameterValue(value); | ||
257 | } | ||
258 | |||
259 | /// <summary> | ||
148 | /// Create a parameter for a command | 260 | /// Create a parameter for a command |
149 | /// </summary> | 261 | /// </summary> |
150 | /// <param name="parameterName">Name of the parameter.</param> | 262 | /// <param name="parameterName">Name of the parameter.</param> |
151 | /// <param name="parameterObject">parameter object.</param> | 263 | /// <param name="parameterObject">parameter object.</param> |
152 | /// <returns></returns> | 264 | /// <returns></returns> |
153 | internal SqlParameter CreateParameter(string parameterName, object parameterObject) | 265 | internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject) |
154 | { | 266 | { |
155 | return CreateParameter(parameterName, parameterObject, false); | 267 | return CreateParameter(parameterName, parameterObject, false); |
156 | } | 268 | } |
@@ -162,15 +274,15 @@ namespace OpenSim.Data.MSSQL | |||
162 | /// <param name="parameterObject">parameter object.</param> | 274 | /// <param name="parameterObject">parameter object.</param> |
163 | /// <param name="parameterOut">if set to <c>true</c> parameter is a output parameter</param> | 275 | /// <param name="parameterOut">if set to <c>true</c> parameter is a output parameter</param> |
164 | /// <returns></returns> | 276 | /// <returns></returns> |
165 | internal SqlParameter CreateParameter(string parameterName, object parameterObject, bool parameterOut) | 277 | internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, bool parameterOut) |
166 | { | 278 | { |
167 | //Tweak so we dont always have to add @ sign | 279 | //Tweak so we dont always have to add : sign |
168 | if (!parameterName.StartsWith("@")) parameterName = "@" + parameterName; | 280 | if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":",""); |
169 | 281 | ||
170 | //HACK if object is null, it is turned into a string, there are no nullable type till now | 282 | //HACK if object is null, it is turned into a string, there are no nullable type till now |
171 | if (parameterObject == null) parameterObject = ""; | 283 | if (parameterObject == null) parameterObject = ""; |
172 | 284 | ||
173 | SqlParameter parameter = new SqlParameter(parameterName, DbtypeFromType(parameterObject.GetType())); | 285 | NpgsqlParameter parameter = new NpgsqlParameter(parameterName, DbtypeFromType(parameterObject.GetType())); |
174 | 286 | ||
175 | if (parameterOut) | 287 | if (parameterOut) |
176 | { | 288 | { |
@@ -186,16 +298,39 @@ namespace OpenSim.Data.MSSQL | |||
186 | } | 298 | } |
187 | 299 | ||
188 | /// <summary> | 300 | /// <summary> |
301 | /// Create a parameter with PGSQL schema type | ||
302 | /// </summary> | ||
303 | /// <param name="parameterName"></param> | ||
304 | /// <param name="parameterObject"></param> | ||
305 | /// <param name="PGFieldType"></param> | ||
306 | /// <returns></returns> | ||
307 | internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, string PGFieldType) | ||
308 | { | ||
309 | //Tweak so we dont always have to add : sign | ||
310 | if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":", ""); | ||
311 | |||
312 | //HACK if object is null, it is turned into a string, there are no nullable type till now | ||
313 | if (parameterObject == null) parameterObject = ""; | ||
314 | |||
315 | NpgsqlParameter parameter = new NpgsqlParameter(parameterName, DbtypeFromString(parameterObject.GetType(), PGFieldType)); | ||
316 | |||
317 | parameter.Direction = ParameterDirection.Input; | ||
318 | parameter.Value = CreateParameterValue(parameterObject, PGFieldType); | ||
319 | |||
320 | return parameter; | ||
321 | } | ||
322 | |||
323 | /// <summary> | ||
189 | /// Checks if we need to do some migrations to the database | 324 | /// Checks if we need to do some migrations to the database |
190 | /// </summary> | 325 | /// </summary> |
191 | /// <param name="migrationStore">migrationStore.</param> | 326 | /// <param name="migrationStore">migrationStore.</param> |
192 | public void CheckMigration(string migrationStore) | 327 | public void CheckMigration(string migrationStore) |
193 | { | 328 | { |
194 | using (SqlConnection connection = new SqlConnection(connectionString)) | 329 | using (NpgsqlConnection connection = new NpgsqlConnection(connectionString)) |
195 | { | 330 | { |
196 | connection.Open(); | 331 | connection.Open(); |
197 | Assembly assem = GetType().Assembly; | 332 | Assembly assem = GetType().Assembly; |
198 | MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); | 333 | PGSQLMigration migration = new PGSQLMigration(connection, assem, migrationStore); |
199 | 334 | ||
200 | migration.Update(); | 335 | migration.Update(); |
201 | } | 336 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLMigration.cs b/OpenSim/Data/PGSQL/PGSQLMigration.cs index c2fecef..709fde0 100644 --- a/OpenSim/Data/MSSQL/MSSQLMigration.cs +++ b/OpenSim/Data/PGSQL/PGSQLMigration.cs | |||
@@ -25,22 +25,22 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using Npgsql; | ||
28 | using System; | 29 | using System; |
29 | using System.Data; | 30 | using System.Data; |
30 | using System.Data.Common; | 31 | using System.Data.Common; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Data.SqlClient; | ||
33 | 33 | ||
34 | namespace OpenSim.Data.MSSQL | 34 | namespace OpenSim.Data.PGSQL |
35 | { | 35 | { |
36 | public class MSSQLMigration : Migration | 36 | public class PGSQLMigration : Migration |
37 | { | 37 | { |
38 | public MSSQLMigration(DbConnection conn, Assembly assem, string type) | 38 | public PGSQLMigration(NpgsqlConnection conn, Assembly assem, string type) |
39 | : base(conn, assem, type) | 39 | : base(conn, assem, type) |
40 | { | 40 | { |
41 | } | 41 | } |
42 | 42 | ||
43 | public MSSQLMigration(DbConnection conn, Assembly assem, string subtype, string type) | 43 | public PGSQLMigration(NpgsqlConnection conn, Assembly assem, string subtype, string type) |
44 | : base(conn, assem, subtype, type) | 44 | : base(conn, assem, subtype, type) |
45 | { | 45 | { |
46 | } | 46 | } |
@@ -48,12 +48,15 @@ namespace OpenSim.Data.MSSQL | |||
48 | protected override int FindVersion(DbConnection conn, string type) | 48 | protected override int FindVersion(DbConnection conn, string type) |
49 | { | 49 | { |
50 | int version = 0; | 50 | int version = 0; |
51 | using (DbCommand cmd = conn.CreateCommand()) | 51 | NpgsqlConnection lcConn = (NpgsqlConnection)conn; |
52 | |||
53 | using (NpgsqlCommand cmd = lcConn.CreateCommand()) | ||
52 | { | 54 | { |
53 | try | 55 | try |
54 | { | 56 | { |
55 | cmd.CommandText = "select top 1 version from migrations where name = '" + type + "' order by version desc"; //Must be | 57 | cmd.CommandText = "select version from migrations where name = '" + type + "' " + |
56 | using (IDataReader reader = cmd.ExecuteReader()) | 58 | " order by version desc limit 1"; //Must be |
59 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
57 | { | 60 | { |
58 | if (reader.Read()) | 61 | if (reader.Read()) |
59 | { | 62 | { |
@@ -73,7 +76,7 @@ namespace OpenSim.Data.MSSQL | |||
73 | 76 | ||
74 | protected override void ExecuteScript(DbConnection conn, string[] script) | 77 | protected override void ExecuteScript(DbConnection conn, string[] script) |
75 | { | 78 | { |
76 | if (!(conn is SqlConnection)) | 79 | if (!(conn is NpgsqlConnection)) |
77 | { | 80 | { |
78 | base.ExecuteScript(conn, script); | 81 | base.ExecuteScript(conn, script); |
79 | return; | 82 | return; |
@@ -83,7 +86,7 @@ namespace OpenSim.Data.MSSQL | |||
83 | { | 86 | { |
84 | try | 87 | try |
85 | { | 88 | { |
86 | using (SqlCommand cmd = new SqlCommand(sql, (SqlConnection)conn)) | 89 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, (NpgsqlConnection)conn)) |
87 | { | 90 | { |
88 | cmd.ExecuteNonQuery(); | 91 | cmd.ExecuteNonQuery(); |
89 | } | 92 | } |
diff --git a/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs b/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs new file mode 100644 index 0000000..82e5ed8 --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs | |||
@@ -0,0 +1,56 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using Npgsql; | ||
35 | |||
36 | namespace OpenSim.Data.PGSQL | ||
37 | { | ||
38 | public class PGSQLOfflineIMData : PGSQLGenericTableHandler<OfflineIMData>, IOfflineIMData | ||
39 | { | ||
40 | public PGSQLOfflineIMData(string connectionString, string realm) | ||
41 | : base(connectionString, realm, "IM_Store") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public void DeleteOld() | ||
46 | { | ||
47 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
48 | { | ||
49 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); | ||
50 | |||
51 | ExecuteNonQuery(cmd); | ||
52 | } | ||
53 | |||
54 | } | ||
55 | } | ||
56 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs index 0c71e79..0376585 100644..100755 --- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs +++ b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs | |||
@@ -33,27 +33,26 @@ using System.Threading; | |||
33 | using log4net; | 33 | using log4net; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using System.Data.SqlClient; | 36 | using Npgsql; |
37 | 37 | ||
38 | namespace OpenSim.Data.MSSQL | 38 | namespace OpenSim.Data.PGSQL |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// A MySQL Interface for the Presence Server | 41 | /// A PGSQL Interface for the Presence Server |
42 | /// </summary> | 42 | /// </summary> |
43 | public class MSSQLPresenceData : MSSQLGenericTableHandler<PresenceData>, | 43 | public class PGSQLPresenceData : PGSQLGenericTableHandler<PresenceData>, |
44 | IPresenceData | 44 | IPresenceData |
45 | { | 45 | { |
46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | public MSSQLPresenceData(string connectionString, string realm) : | 48 | public PGSQLPresenceData(string connectionString, string realm) : |
49 | base(connectionString, realm, "Presence") | 49 | base(connectionString, realm, "Presence") |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | public PresenceData Get(UUID sessionID) | 53 | public PresenceData Get(UUID sessionID) |
54 | { | 54 | { |
55 | PresenceData[] ret = Get("SessionID", | 55 | PresenceData[] ret = Get("SessionID", sessionID.ToString()); |
56 | sessionID.ToString()); | ||
57 | 56 | ||
58 | if (ret.Length == 0) | 57 | if (ret.Length == 0) |
59 | return null; | 58 | return null; |
@@ -63,13 +62,13 @@ namespace OpenSim.Data.MSSQL | |||
63 | 62 | ||
64 | public void LogoutRegionAgents(UUID regionID) | 63 | public void LogoutRegionAgents(UUID regionID) |
65 | { | 64 | { |
66 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 65 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
67 | using (SqlCommand cmd = new SqlCommand()) | 66 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
68 | { | 67 | { |
69 | 68 | ||
70 | cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm); | 69 | cmd.CommandText = String.Format("DELETE FROM {0} WHERE \"RegionID\" = :regionID", m_Realm); |
71 | 70 | ||
72 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); | 71 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); |
73 | cmd.Connection = conn; | 72 | cmd.Connection = conn; |
74 | conn.Open(); | 73 | conn.Open(); |
75 | cmd.ExecuteNonQuery(); | 74 | cmd.ExecuteNonQuery(); |
@@ -81,17 +80,18 @@ namespace OpenSim.Data.MSSQL | |||
81 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); | 80 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); |
82 | if (pd.Length == 0) | 81 | if (pd.Length == 0) |
83 | return false; | 82 | return false; |
83 | |||
84 | if (regionID == UUID.Zero) | ||
85 | return false; | ||
84 | 86 | ||
85 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 87 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
86 | using (SqlCommand cmd = new SqlCommand()) | 88 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
87 | { | 89 | { |
88 | 90 | ||
89 | cmd.CommandText = String.Format(@"UPDATE {0} SET | 91 | cmd.CommandText = String.Format("UPDATE {0} SET \"RegionID\" = :regionID, \"LastSeen\" = now() WHERE \"SessionID\" = :sessionID", m_Realm); |
90 | [RegionID] = @RegionID | ||
91 | WHERE [SessionID] = @SessionID", m_Realm); | ||
92 | 92 | ||
93 | cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); | 93 | cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID)); |
94 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); | 94 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); |
95 | cmd.Connection = conn; | 95 | cmd.Connection = conn; |
96 | conn.Open(); | 96 | conn.Open(); |
97 | if (cmd.ExecuteNonQuery() == 0) | 97 | if (cmd.ExecuteNonQuery() == 0) |
@@ -102,8 +102,7 @@ namespace OpenSim.Data.MSSQL | |||
102 | 102 | ||
103 | public bool VerifyAgent(UUID agentId, UUID secureSessionID) | 103 | public bool VerifyAgent(UUID agentId, UUID secureSessionID) |
104 | { | 104 | { |
105 | PresenceData[] ret = Get("SecureSessionID", | 105 | PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString()); |
106 | secureSessionID.ToString()); | ||
107 | 106 | ||
108 | if (ret.Length == 0) | 107 | if (ret.Length == 0) |
109 | return false; | 108 | return false; |
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/PGSQL/PGSQLRegionData.cs index 0d89706..b3076f0 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/PGSQL/PGSQLRegionData.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Data.SqlClient; | ||
32 | using System.Drawing; | 31 | using System.Drawing; |
33 | using System.IO; | 32 | using System.IO; |
34 | using System.Reflection; | 33 | using System.Reflection; |
@@ -38,45 +37,80 @@ using OpenSim.Framework; | |||
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
40 | using RegionFlags = OpenSim.Framework.RegionFlags; | 39 | using RegionFlags = OpenSim.Framework.RegionFlags; |
40 | using Npgsql; | ||
41 | 41 | ||
42 | namespace OpenSim.Data.MSSQL | 42 | namespace OpenSim.Data.PGSQL |
43 | { | 43 | { |
44 | /// <summary> | 44 | /// <summary> |
45 | /// A MSSQL Interface for the Region Server. | 45 | /// A PGSQL Interface for the Region Server. |
46 | /// </summary> | 46 | /// </summary> |
47 | public class MSSQLRegionData : IRegionData | 47 | public class PGSQLRegionData : IRegionData |
48 | { | 48 | { |
49 | private string m_Realm; | 49 | private string m_Realm; |
50 | private List<string> m_ColumnNames = null; | 50 | private List<string> m_ColumnNames = null; |
51 | private string m_ConnectionString; | 51 | private string m_ConnectionString; |
52 | private MSSQLManager m_database; | 52 | private PGSQLManager m_database; |
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 54 | ||
55 | public MSSQLRegionData(string connectionString, string realm) | 55 | protected Dictionary<string, string> m_FieldTypes = new Dictionary<string, string>(); |
56 | |||
57 | protected virtual Assembly Assembly | ||
58 | { | ||
59 | get { return GetType().Assembly; } | ||
60 | } | ||
61 | |||
62 | public PGSQLRegionData(string connectionString, string realm) | ||
56 | { | 63 | { |
57 | m_Realm = realm; | 64 | m_Realm = realm; |
58 | m_ConnectionString = connectionString; | 65 | m_ConnectionString = connectionString; |
59 | m_database = new MSSQLManager(connectionString); | 66 | m_database = new PGSQLManager(connectionString); |
60 | 67 | ||
61 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 68 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
62 | { | 69 | { |
63 | conn.Open(); | 70 | conn.Open(); |
64 | Migration m = new Migration(conn, GetType().Assembly, "GridStore"); | 71 | Migration m = new Migration(conn, GetType().Assembly, "GridStore"); |
65 | m.Update(); | 72 | m.Update(); |
66 | } | 73 | } |
74 | LoadFieldTypes(); | ||
67 | } | 75 | } |
68 | 76 | ||
77 | private void LoadFieldTypes() | ||
78 | { | ||
79 | m_FieldTypes = new Dictionary<string, string>(); | ||
80 | |||
81 | string query = string.Format(@"select column_name,data_type | ||
82 | from INFORMATION_SCHEMA.COLUMNS | ||
83 | where table_name = lower('{0}'); | ||
84 | |||
85 | ", m_Realm); | ||
86 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
87 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) | ||
88 | { | ||
89 | conn.Open(); | ||
90 | using (NpgsqlDataReader rdr = cmd.ExecuteReader()) | ||
91 | { | ||
92 | while (rdr.Read()) | ||
93 | { | ||
94 | // query produces 0 to many rows of single column, so always add the first item in each row | ||
95 | m_FieldTypes.Add((string)rdr[0], (string)rdr[1]); | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
69 | public List<RegionData> Get(string regionName, UUID scopeID) | 101 | public List<RegionData> Get(string regionName, UUID scopeID) |
70 | { | 102 | { |
71 | string sql = "select * from ["+m_Realm+"] where regionName like @regionName"; | 103 | string sql = "select * from "+m_Realm+" where lower(\"regionName\") like lower(:regionName) "; |
72 | if (scopeID != UUID.Zero) | 104 | if (scopeID != UUID.Zero) |
73 | sql += " and ScopeID = @scopeID"; | 105 | sql += " and \"ScopeID\" = :scopeID"; |
74 | sql += " order by regionName"; | 106 | sql += " order by lower(\"regionName\")"; |
75 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 107 | |
76 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 108 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
109 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
77 | { | 110 | { |
78 | cmd.Parameters.Add(m_database.CreateParameter("@regionName", regionName)); | 111 | cmd.Parameters.Add(m_database.CreateParameter("regionName", regionName)); |
79 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | 112 | if (scopeID != UUID.Zero) |
113 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); | ||
80 | conn.Open(); | 114 | conn.Open(); |
81 | return RunCommand(cmd); | 115 | return RunCommand(cmd); |
82 | } | 116 | } |
@@ -84,16 +118,17 @@ namespace OpenSim.Data.MSSQL | |||
84 | 118 | ||
85 | public RegionData Get(int posX, int posY, UUID scopeID) | 119 | public RegionData Get(int posX, int posY, UUID scopeID) |
86 | { | 120 | { |
87 | string sql = "select * from ["+m_Realm+"] where locX = @posX and locY = @posY"; | 121 | string sql = "select * from "+m_Realm+" where \"locX\" = :posX and \"locY\" = :posY"; |
88 | if (scopeID != UUID.Zero) | 122 | if (scopeID != UUID.Zero) |
89 | sql += " and ScopeID = @scopeID"; | 123 | sql += " and \"ScopeID\" = :scopeID"; |
90 | 124 | ||
91 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 125 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
92 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 126 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
93 | { | 127 | { |
94 | cmd.Parameters.Add(m_database.CreateParameter("@posX", posX.ToString())); | 128 | cmd.Parameters.Add(m_database.CreateParameter("posX", posX)); |
95 | cmd.Parameters.Add(m_database.CreateParameter("@posY", posY.ToString())); | 129 | cmd.Parameters.Add(m_database.CreateParameter("posY", posY)); |
96 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | 130 | if (scopeID != UUID.Zero) |
131 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); | ||
97 | conn.Open(); | 132 | conn.Open(); |
98 | List<RegionData> ret = RunCommand(cmd); | 133 | List<RegionData> ret = RunCommand(cmd); |
99 | if (ret.Count == 0) | 134 | if (ret.Count == 0) |
@@ -105,14 +140,15 @@ namespace OpenSim.Data.MSSQL | |||
105 | 140 | ||
106 | public RegionData Get(UUID regionID, UUID scopeID) | 141 | public RegionData Get(UUID regionID, UUID scopeID) |
107 | { | 142 | { |
108 | string sql = "select * from ["+m_Realm+"] where uuid = @regionID"; | 143 | string sql = "select * from "+m_Realm+" where uuid = :regionID"; |
109 | if (scopeID != UUID.Zero) | 144 | if (scopeID != UUID.Zero) |
110 | sql += " and ScopeID = @scopeID"; | 145 | sql += " and \"ScopeID\" = :scopeID"; |
111 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 146 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
112 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 147 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
113 | { | 148 | { |
114 | cmd.Parameters.Add(m_database.CreateParameter("@regionID", regionID)); | 149 | cmd.Parameters.Add(m_database.CreateParameter("regionID", regionID)); |
115 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | 150 | if (scopeID != UUID.Zero) |
151 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); | ||
116 | conn.Open(); | 152 | conn.Open(); |
117 | List<RegionData> ret = RunCommand(cmd); | 153 | List<RegionData> ret = RunCommand(cmd); |
118 | if (ret.Count == 0) | 154 | if (ret.Count == 0) |
@@ -124,28 +160,28 @@ namespace OpenSim.Data.MSSQL | |||
124 | 160 | ||
125 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 161 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
126 | { | 162 | { |
127 | string sql = "select * from ["+m_Realm+"] where locX between @startX and @endX and locY between @startY and @endY"; | 163 | string sql = "select * from "+m_Realm+" where \"locX\" between :startX and :endX and \"locY\" between :startY and :endY"; |
128 | if (scopeID != UUID.Zero) | 164 | if (scopeID != UUID.Zero) |
129 | sql += " and ScopeID = @scopeID"; | 165 | sql += " and \"ScopeID\" = :scopeID"; |
130 | 166 | ||
131 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 167 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
132 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 168 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
133 | { | 169 | { |
134 | cmd.Parameters.Add(m_database.CreateParameter("@startX", startX)); | 170 | cmd.Parameters.Add(m_database.CreateParameter("startX", startX)); |
135 | cmd.Parameters.Add(m_database.CreateParameter("@startY", startY)); | 171 | cmd.Parameters.Add(m_database.CreateParameter("startY", startY)); |
136 | cmd.Parameters.Add(m_database.CreateParameter("@endX", endX)); | 172 | cmd.Parameters.Add(m_database.CreateParameter("endX", endX)); |
137 | cmd.Parameters.Add(m_database.CreateParameter("@endY", endY)); | 173 | cmd.Parameters.Add(m_database.CreateParameter("endY", endY)); |
138 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | 174 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); |
139 | conn.Open(); | 175 | conn.Open(); |
140 | return RunCommand(cmd); | 176 | return RunCommand(cmd); |
141 | } | 177 | } |
142 | } | 178 | } |
143 | 179 | ||
144 | public List<RegionData> RunCommand(SqlCommand cmd) | 180 | public List<RegionData> RunCommand(NpgsqlCommand cmd) |
145 | { | 181 | { |
146 | List<RegionData> retList = new List<RegionData>(); | 182 | List<RegionData> retList = new List<RegionData>(); |
147 | 183 | ||
148 | SqlDataReader result = cmd.ExecuteReader(); | 184 | NpgsqlDataReader result = cmd.ExecuteReader(); |
149 | 185 | ||
150 | while (result.Read()) | 186 | while (result.Read()) |
151 | { | 187 | { |
@@ -217,43 +253,46 @@ namespace OpenSim.Data.MSSQL | |||
217 | 253 | ||
218 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 254 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
219 | 255 | ||
220 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 256 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
221 | using (SqlCommand cmd = new SqlCommand()) | 257 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
222 | { | 258 | { |
223 | 259 | ||
224 | string update = "update [" + m_Realm + "] set locX=@posX, locY=@posY, sizeX=@sizeX, sizeY=@sizeY "; | 260 | string update = "update " + m_Realm + " set \"locX\"=:posX, \"locY\"=:posY, \"sizeX\"=:sizeX, \"sizeY\"=:sizeY "; |
225 | 261 | ||
226 | foreach (string field in fields) | 262 | foreach (string field in fields) |
227 | { | 263 | { |
228 | 264 | ||
229 | update += ", "; | 265 | update += ", "; |
230 | update += "[" + field + "] = @" + field; | 266 | update += " \"" + field + "\" = :" + field; |
231 | 267 | ||
232 | cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); | 268 | if (m_FieldTypes.ContainsKey(field)) |
269 | cmd.Parameters.Add(m_database.CreateParameter(field, data.Data[field], m_FieldTypes[field])); | ||
270 | else | ||
271 | cmd.Parameters.Add(m_database.CreateParameter(field, data.Data[field])); | ||
233 | } | 272 | } |
234 | 273 | ||
235 | update += " where uuid = @regionID"; | 274 | update += " where uuid = :regionID"; |
236 | 275 | ||
237 | if (data.ScopeID != UUID.Zero) | 276 | if (data.ScopeID != UUID.Zero) |
238 | update += " and ScopeID = @scopeID"; | 277 | update += " and \"ScopeID\" = :scopeID"; |
239 | 278 | ||
240 | cmd.CommandText = update; | 279 | cmd.CommandText = update; |
241 | cmd.Connection = conn; | 280 | cmd.Connection = conn; |
242 | cmd.Parameters.Add(m_database.CreateParameter("@regionID", data.RegionID)); | 281 | cmd.Parameters.Add(m_database.CreateParameter("regionID", data.RegionID)); |
243 | cmd.Parameters.Add(m_database.CreateParameter("@regionName", data.RegionName)); | 282 | cmd.Parameters.Add(m_database.CreateParameter("regionName", data.RegionName)); |
244 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID)); | 283 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", data.ScopeID)); |
245 | cmd.Parameters.Add(m_database.CreateParameter("@posX", data.posX)); | 284 | cmd.Parameters.Add(m_database.CreateParameter("posX", data.posX)); |
246 | cmd.Parameters.Add(m_database.CreateParameter("@posY", data.posY)); | 285 | cmd.Parameters.Add(m_database.CreateParameter("posY", data.posY)); |
247 | cmd.Parameters.Add(m_database.CreateParameter("@sizeX", data.sizeX)); | 286 | cmd.Parameters.Add(m_database.CreateParameter("sizeX", data.sizeX)); |
248 | cmd.Parameters.Add(m_database.CreateParameter("@sizeY", data.sizeY)); | 287 | cmd.Parameters.Add(m_database.CreateParameter("sizeY", data.sizeY)); |
249 | conn.Open(); | 288 | conn.Open(); |
250 | try | 289 | try |
251 | { | 290 | { |
252 | if (cmd.ExecuteNonQuery() < 1) | 291 | if (cmd.ExecuteNonQuery() < 1) |
253 | { | 292 | { |
254 | string insert = "insert into [" + m_Realm + "] ([uuid], [ScopeID], [locX], [locY], [sizeX], [sizeY], [regionName], [" + | 293 | string insert = "insert into " + m_Realm + " (uuid, \"ScopeID\", \"locX\", \"locY\", \"sizeX\", \"sizeY\", \"regionName\", \"" + |
255 | String.Join("], [", fields) + | 294 | String.Join("\", \"", fields) + |
256 | "]) values (@regionID, @scopeID, @posX, @posY, @sizeX, @sizeY, @regionName, @" + String.Join(", @", fields) + ")"; | 295 | "\") values (:regionID, :scopeID, :posX, :posY, :sizeX, :sizeY, :regionName, :" + String.Join(", :", fields) + ")"; |
257 | 296 | ||
258 | cmd.CommandText = insert; | 297 | cmd.CommandText = insert; |
259 | 298 | ||
@@ -266,13 +305,13 @@ namespace OpenSim.Data.MSSQL | |||
266 | } | 305 | } |
267 | catch (Exception ex) | 306 | catch (Exception ex) |
268 | { | 307 | { |
269 | m_log.Warn("[MSSQL Grid]: Error inserting into Regions table: " + ex.Message + ", INSERT sql: " + insert); | 308 | m_log.Warn("[PGSQL Grid]: Error inserting into Regions table: " + ex.Message + ", INSERT sql: " + insert); |
270 | } | 309 | } |
271 | } | 310 | } |
272 | } | 311 | } |
273 | catch (Exception ex) | 312 | catch (Exception ex) |
274 | { | 313 | { |
275 | m_log.Warn("[MSSQL Grid]: Error updating Regions table: " + ex.Message + ", UPDATE sql: " + update); | 314 | m_log.Warn("[PGSQL Grid]: Error updating Regions table: " + ex.Message + ", UPDATE sql: " + update); |
276 | } | 315 | } |
277 | } | 316 | } |
278 | 317 | ||
@@ -281,13 +320,14 @@ namespace OpenSim.Data.MSSQL | |||
281 | 320 | ||
282 | public bool SetDataItem(UUID regionID, string item, string value) | 321 | public bool SetDataItem(UUID regionID, string item, string value) |
283 | { | 322 | { |
284 | string sql = "update [" + m_Realm + | 323 | string sql = "update " + m_Realm + |
285 | "] set [" + item + "] = @" + item + " where uuid = @UUID"; | 324 | " set \"" + item + "\" = :" + item + " where uuid = :UUID"; |
286 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 325 | |
287 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 326 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
327 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
288 | { | 328 | { |
289 | cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); | 329 | cmd.Parameters.Add(m_database.CreateParameter("" + item, value)); |
290 | cmd.Parameters.Add(m_database.CreateParameter("@UUID", regionID)); | 330 | cmd.Parameters.Add(m_database.CreateParameter("UUID", regionID)); |
291 | conn.Open(); | 331 | conn.Open(); |
292 | if (cmd.ExecuteNonQuery() > 0) | 332 | if (cmd.ExecuteNonQuery() > 0) |
293 | return true; | 333 | return true; |
@@ -297,12 +337,12 @@ namespace OpenSim.Data.MSSQL | |||
297 | 337 | ||
298 | public bool Delete(UUID regionID) | 338 | public bool Delete(UUID regionID) |
299 | { | 339 | { |
300 | string sql = "delete from [" + m_Realm + | 340 | string sql = "delete from " + m_Realm + |
301 | "] where uuid = @UUID"; | 341 | " where uuid = :UUID"; |
302 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 342 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
303 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 343 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
304 | { | 344 | { |
305 | cmd.Parameters.Add(m_database.CreateParameter("@UUID", regionID)); | 345 | cmd.Parameters.Add(m_database.CreateParameter("UUID", regionID)); |
306 | conn.Open(); | 346 | conn.Open(); |
307 | if (cmd.ExecuteNonQuery() > 0) | 347 | if (cmd.ExecuteNonQuery() > 0) |
308 | return true; | 348 | return true; |
@@ -315,6 +355,11 @@ namespace OpenSim.Data.MSSQL | |||
315 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 355 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
316 | } | 356 | } |
317 | 357 | ||
358 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
359 | { | ||
360 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
361 | } | ||
362 | |||
318 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 363 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
319 | { | 364 | { |
320 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 365 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
@@ -331,14 +376,14 @@ namespace OpenSim.Data.MSSQL | |||
331 | 376 | ||
332 | private List<RegionData> Get(int regionFlags, UUID scopeID) | 377 | private List<RegionData> Get(int regionFlags, UUID scopeID) |
333 | { | 378 | { |
334 | string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & " + regionFlags.ToString() + ") <> 0"; | 379 | string sql = "SELECT * FROM " + m_Realm + " WHERE (\"flags\" & " + regionFlags.ToString() + ") <> 0"; |
335 | if (scopeID != UUID.Zero) | 380 | if (scopeID != UUID.Zero) |
336 | sql += " AND ScopeID = @scopeID"; | 381 | sql += " AND \"ScopeID\" = :scopeID"; |
337 | 382 | ||
338 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 383 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
339 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 384 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
340 | { | 385 | { |
341 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | 386 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); |
342 | conn.Open(); | 387 | conn.Open(); |
343 | return RunCommand(cmd); | 388 | return RunCommand(cmd); |
344 | } | 389 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index 17f42e1..77d87d4 100644 --- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Data.SqlClient; | ||
32 | using System.Drawing; | 31 | using System.Drawing; |
33 | using System.IO; | 32 | using System.IO; |
34 | using System.Reflection; | 33 | using System.Reflection; |
@@ -37,15 +36,17 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using Npgsql; | ||
40 | 40 | ||
41 | namespace OpenSim.Data.MSSQL | 41 | namespace OpenSim.Data.PGSQL |
42 | { | 42 | { |
43 | /// <summary> | 43 | /// <summary> |
44 | /// A MSSQL Interface for the Region Server. | 44 | /// A PGSQL Interface for the Region Server. |
45 | /// </summary> | 45 | /// </summary> |
46 | public class MSSQLSimulationData : ISimulationDataStore | 46 | public class PGSQLSimulationData : ISimulationDataStore |
47 | { | 47 | { |
48 | private const string _migrationStore = "RegionStore"; | 48 | private const string _migrationStore = "RegionStore"; |
49 | private const string LogHeader = "[REGION DB PGSQL]"; | ||
49 | 50 | ||
50 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); | 51 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); |
51 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -53,18 +54,18 @@ namespace OpenSim.Data.MSSQL | |||
53 | /// <summary> | 54 | /// <summary> |
54 | /// The database manager | 55 | /// The database manager |
55 | /// </summary> | 56 | /// </summary> |
56 | private MSSQLManager _Database; | 57 | private PGSQLManager _Database; |
57 | private string m_connectionString; | 58 | private string m_connectionString; |
58 | protected virtual Assembly Assembly | 59 | protected virtual Assembly Assembly |
59 | { | 60 | { |
60 | get { return GetType().Assembly; } | 61 | get { return GetType().Assembly; } |
61 | } | 62 | } |
62 | 63 | ||
63 | public MSSQLSimulationData() | 64 | public PGSQLSimulationData() |
64 | { | 65 | { |
65 | } | 66 | } |
66 | 67 | ||
67 | public MSSQLSimulationData(string connectionString) | 68 | public PGSQLSimulationData(string connectionString) |
68 | { | 69 | { |
69 | Initialise(connectionString); | 70 | Initialise(connectionString); |
70 | } | 71 | } |
@@ -76,9 +77,9 @@ namespace OpenSim.Data.MSSQL | |||
76 | public void Initialise(string connectionString) | 77 | public void Initialise(string connectionString) |
77 | { | 78 | { |
78 | m_connectionString = connectionString; | 79 | m_connectionString = connectionString; |
79 | _Database = new MSSQLManager(connectionString); | 80 | _Database = new PGSQLManager(connectionString); |
80 | 81 | ||
81 | using (SqlConnection conn = new SqlConnection(connectionString)) | 82 | using (NpgsqlConnection conn = new NpgsqlConnection(connectionString)) |
82 | { | 83 | { |
83 | conn.Open(); | 84 | conn.Open(); |
84 | //New Migration settings | 85 | //New Migration settings |
@@ -107,19 +108,19 @@ namespace OpenSim.Data.MSSQL | |||
107 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); | 108 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); |
108 | SceneObjectGroup grp = null; | 109 | SceneObjectGroup grp = null; |
109 | 110 | ||
110 | string sql = "SELECT *, " + | 111 | string sql = @"SELECT *, |
111 | "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " + | 112 | CASE WHEN prims.""UUID"" = prims.""SceneGroupID"" THEN 0 ELSE 1 END as sort |
112 | "FROM prims " + | 113 | FROM prims |
113 | "LEFT JOIN primshapes ON prims.UUID = primshapes.UUID " + | 114 | LEFT JOIN primshapes ON prims.""UUID"" = primshapes.""UUID"" |
114 | "WHERE RegionUUID = @RegionUUID " + | 115 | WHERE ""RegionUUID"" = :RegionUUID |
115 | "ORDER BY SceneGroupID asc, sort asc, LinkNumber asc"; | 116 | ORDER BY ""SceneGroupID"" asc, sort asc, ""LinkNumber"" asc"; |
116 | 117 | ||
117 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 118 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
118 | using (SqlCommand command = new SqlCommand(sql, conn)) | 119 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
119 | { | 120 | { |
120 | command.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | 121 | command.Parameters.Add(_Database.CreateParameter("regionUUID", regionUUID)); |
121 | conn.Open(); | 122 | conn.Open(); |
122 | using (SqlDataReader reader = command.ExecuteReader()) | 123 | using (NpgsqlDataReader reader = command.ExecuteReader()) |
123 | { | 124 | { |
124 | while (reader.Read()) | 125 | while (reader.Read()) |
125 | { | 126 | { |
@@ -179,12 +180,12 @@ namespace OpenSim.Data.MSSQL | |||
179 | // list from DB of all prims which have items and | 180 | // list from DB of all prims which have items and |
180 | // LoadItems only on those | 181 | // LoadItems only on those |
181 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | 182 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); |
182 | string qry = "select distinct primID from primitems"; | 183 | string qry = "select distinct \"primID\" from primitems"; |
183 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 184 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
184 | using (SqlCommand command = new SqlCommand(qry, conn)) | 185 | using (NpgsqlCommand command = new NpgsqlCommand(qry, conn)) |
185 | { | 186 | { |
186 | conn.Open(); | 187 | conn.Open(); |
187 | using (SqlDataReader itemReader = command.ExecuteReader()) | 188 | using (NpgsqlDataReader itemReader = command.ExecuteReader()) |
188 | { | 189 | { |
189 | while (itemReader.Read()) | 190 | while (itemReader.Read()) |
190 | { | 191 | { |
@@ -213,19 +214,19 @@ namespace OpenSim.Data.MSSQL | |||
213 | /// <param name="allPrims">all prims with inventory on a region</param> | 214 | /// <param name="allPrims">all prims with inventory on a region</param> |
214 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) | 215 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) |
215 | { | 216 | { |
216 | string sql = "SELECT * FROM primitems WHERE PrimID = @PrimID"; | 217 | string sql = @"SELECT * FROM primitems WHERE ""primID"" = :PrimID"; |
217 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 218 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
218 | using (SqlCommand command = new SqlCommand(sql, conn)) | 219 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
219 | { | 220 | { |
220 | conn.Open(); | 221 | conn.Open(); |
221 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) | 222 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) |
222 | { | 223 | { |
223 | command.Parameters.Clear(); | 224 | command.Parameters.Clear(); |
224 | command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID)); | 225 | command.Parameters.Add(_Database.CreateParameter("PrimID", objectPart.UUID)); |
225 | 226 | ||
226 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | 227 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
227 | 228 | ||
228 | using (SqlDataReader reader = command.ExecuteReader()) | 229 | using (NpgsqlDataReader reader = command.ExecuteReader()) |
229 | { | 230 | { |
230 | while (reader.Read()) | 231 | while (reader.Read()) |
231 | { | 232 | { |
@@ -257,43 +258,43 @@ namespace OpenSim.Data.MSSQL | |||
257 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | 258 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) |
258 | return; | 259 | return; |
259 | 260 | ||
260 | _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length); | 261 | //_Log.DebugFormat("[PGSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length); |
261 | 262 | ||
262 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 263 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
263 | { | 264 | { |
264 | conn.Open(); | 265 | conn.Open(); |
265 | SqlTransaction transaction = conn.BeginTransaction(); | 266 | NpgsqlTransaction transaction = conn.BeginTransaction(); |
266 | 267 | ||
267 | try | 268 | try |
268 | { | 269 | { |
269 | foreach (SceneObjectPart sceneObjectPart in obj.Parts) | 270 | foreach (SceneObjectPart sceneObjectPart in obj.Parts) |
270 | { | 271 | { |
271 | //Update prim | 272 | //Update prim |
272 | using (SqlCommand sqlCommand = conn.CreateCommand()) | 273 | using (NpgsqlCommand sqlCommand = conn.CreateCommand()) |
273 | { | 274 | { |
274 | sqlCommand.Transaction = transaction; | 275 | sqlCommand.Transaction = transaction; |
275 | try | 276 | try |
276 | { | 277 | { |
277 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | 278 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); |
278 | } | 279 | } |
279 | catch (SqlException sqlEx) | 280 | catch (NpgsqlException sqlEx) |
280 | { | 281 | { |
281 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | 282 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.Line); |
282 | throw; | 283 | throw; |
283 | } | 284 | } |
284 | } | 285 | } |
285 | 286 | ||
286 | //Update primshapes | 287 | //Update primshapes |
287 | using (SqlCommand sqlCommand = conn.CreateCommand()) | 288 | using (NpgsqlCommand sqlCommand = conn.CreateCommand()) |
288 | { | 289 | { |
289 | sqlCommand.Transaction = transaction; | 290 | sqlCommand.Transaction = transaction; |
290 | try | 291 | try |
291 | { | 292 | { |
292 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | 293 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); |
293 | } | 294 | } |
294 | catch (SqlException sqlEx) | 295 | catch (NpgsqlException sqlEx) |
295 | { | 296 | { |
296 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | 297 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.Line); |
297 | throw; | 298 | throw; |
298 | } | 299 | } |
299 | } | 300 | } |
@@ -325,60 +326,59 @@ namespace OpenSim.Data.MSSQL | |||
325 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | 326 | /// <param name="sqlCommand">The SQL command with the transaction.</param> |
326 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | 327 | /// <param name="sceneGroupID">The scenegroup UUID.</param> |
327 | /// <param name="regionUUID">The region UUID.</param> | 328 | /// <param name="regionUUID">The region UUID.</param> |
328 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | 329 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) |
329 | { | 330 | { |
330 | //Big query to update or insert a new prim. | 331 | //Big query to update or insert a new prim. |
331 | //Note for SQL Server 2008 this could be simplified | 332 | |
332 | string queryPrims = @" | 333 | string queryPrims = @" |
333 | IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) | ||
334 | BEGIN | ||
335 | UPDATE prims SET | 334 | UPDATE prims SET |
336 | CreationDate = @CreationDate, Name = @Name, Text = @Text, Description = @Description, SitName = @SitName, | 335 | ""CreationDate"" = :CreationDate, ""Name"" = :Name, ""Text"" = :Text, ""Description"" = :Description, ""SitName"" = :SitName, |
337 | TouchName = @TouchName, ObjectFlags = @ObjectFlags, OwnerMask = @OwnerMask, NextOwnerMask = @NextOwnerMask, GroupMask = @GroupMask, | 336 | ""TouchName"" = :TouchName, ""ObjectFlags"" = :ObjectFlags, ""OwnerMask"" = :OwnerMask, ""NextOwnerMask"" = :NextOwnerMask, ""GroupMask"" = :GroupMask, |
338 | EveryoneMask = @EveryoneMask, BaseMask = @BaseMask, PositionX = @PositionX, PositionY = @PositionY, PositionZ = @PositionZ, | 337 | ""EveryoneMask"" = :EveryoneMask, ""BaseMask"" = :BaseMask, ""PositionX"" = :PositionX, ""PositionY"" = :PositionY, ""PositionZ"" = :PositionZ, |
339 | GroupPositionX = @GroupPositionX, GroupPositionY = @GroupPositionY, GroupPositionZ = @GroupPositionZ, VelocityX = @VelocityX, | 338 | ""GroupPositionX"" = :GroupPositionX, ""GroupPositionY"" = :GroupPositionY, ""GroupPositionZ"" = :GroupPositionZ, ""VelocityX"" = :VelocityX, |
340 | VelocityY = @VelocityY, VelocityZ = @VelocityZ, AngularVelocityX = @AngularVelocityX, AngularVelocityY = @AngularVelocityY, | 339 | ""VelocityY"" = :VelocityY, ""VelocityZ"" = :VelocityZ, ""AngularVelocityX"" = :AngularVelocityX, ""AngularVelocityY"" = :AngularVelocityY, |
341 | AngularVelocityZ = @AngularVelocityZ, AccelerationX = @AccelerationX, AccelerationY = @AccelerationY, | 340 | ""AngularVelocityZ"" = :AngularVelocityZ, ""AccelerationX"" = :AccelerationX, ""AccelerationY"" = :AccelerationY, |
342 | AccelerationZ = @AccelerationZ, RotationX = @RotationX, RotationY = @RotationY, RotationZ = @RotationZ, RotationW = @RotationW, | 341 | ""AccelerationZ"" = :AccelerationZ, ""RotationX"" = :RotationX, ""RotationY"" = :RotationY, ""RotationZ"" = :RotationZ, ""RotationW"" = :RotationW, |
343 | SitTargetOffsetX = @SitTargetOffsetX, SitTargetOffsetY = @SitTargetOffsetY, SitTargetOffsetZ = @SitTargetOffsetZ, | 342 | ""SitTargetOffsetX"" = :SitTargetOffsetX, ""SitTargetOffsetY"" = :SitTargetOffsetY, ""SitTargetOffsetZ"" = :SitTargetOffsetZ, |
344 | SitTargetOrientW = @SitTargetOrientW, SitTargetOrientX = @SitTargetOrientX, SitTargetOrientY = @SitTargetOrientY, | 343 | ""SitTargetOrientW"" = :SitTargetOrientW, ""SitTargetOrientX"" = :SitTargetOrientX, ""SitTargetOrientY"" = :SitTargetOrientY, |
345 | SitTargetOrientZ = @SitTargetOrientZ, RegionUUID = @RegionUUID, CreatorID = @CreatorID, OwnerID = @OwnerID, GroupID = @GroupID, | 344 | ""SitTargetOrientZ"" = :SitTargetOrientZ, ""RegionUUID"" = :RegionUUID, ""CreatorID"" = :CreatorID, ""OwnerID"" = :OwnerID, ""GroupID"" = :GroupID, |
346 | LastOwnerID = @LastOwnerID, SceneGroupID = @SceneGroupID, PayPrice = @PayPrice, PayButton1 = @PayButton1, PayButton2 = @PayButton2, | 345 | ""LastOwnerID"" = :LastOwnerID, ""SceneGroupID"" = :SceneGroupID, ""PayPrice"" = :PayPrice, ""PayButton1"" = :PayButton1, ""PayButton2"" = :PayButton2, |
347 | PayButton3 = @PayButton3, PayButton4 = @PayButton4, LoopedSound = @LoopedSound, LoopedSoundGain = @LoopedSoundGain, | 346 | ""PayButton3"" = :PayButton3, ""PayButton4"" = :PayButton4, ""LoopedSound"" = :LoopedSound, ""LoopedSoundGain"" = :LoopedSoundGain, |
348 | TextureAnimation = @TextureAnimation, OmegaX = @OmegaX, OmegaY = @OmegaY, OmegaZ = @OmegaZ, CameraEyeOffsetX = @CameraEyeOffsetX, | 347 | ""TextureAnimation"" = :TextureAnimation, ""OmegaX"" = :OmegaX, ""OmegaY"" = :OmegaY, ""OmegaZ"" = :OmegaZ, ""CameraEyeOffsetX"" = :CameraEyeOffsetX, |
349 | CameraEyeOffsetY = @CameraEyeOffsetY, CameraEyeOffsetZ = @CameraEyeOffsetZ, CameraAtOffsetX = @CameraAtOffsetX, | 348 | ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX, |
350 | CameraAtOffsetY = @CameraAtOffsetY, CameraAtOffsetZ = @CameraAtOffsetZ, ForceMouselook = @ForceMouselook, | 349 | ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook, |
351 | ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, | 350 | ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice, |
352 | SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, | 351 | ""SaleType"" = :SaleType, ""ColorR"" = :ColorR, ""ColorG"" = :ColorG, ""ColorB"" = :ColorB, ""ColorA"" = :ColorA, ""ParticleSystem"" = :ParticleSystem, |
353 | ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, | 352 | ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches, |
354 | LinkNumber = @LinkNumber, MediaURL = @MediaURL | 353 | ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs, |
355 | WHERE UUID = @UUID | 354 | ""PhysicsShapeType"" = :PhysicsShapeType, ""Density"" = :Density, ""GravityModifier"" = :GravityModifier, ""Friction"" = :Friction, ""Restitution"" = :Restitution |
356 | END | 355 | WHERE ""UUID"" = :UUID ; |
357 | ELSE | 356 | |
358 | BEGIN | ||
359 | INSERT INTO | 357 | INSERT INTO |
360 | prims ( | 358 | prims ( |
361 | UUID, CreationDate, Name, Text, Description, SitName, TouchName, ObjectFlags, OwnerMask, NextOwnerMask, GroupMask, | 359 | ""UUID"", ""CreationDate"", ""Name"", ""Text"", ""Description"", ""SitName"", ""TouchName"", ""ObjectFlags"", ""OwnerMask"", ""NextOwnerMask"", ""GroupMask"", |
362 | EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, | 360 | ""EveryoneMask"", ""BaseMask"", ""PositionX"", ""PositionY"", ""PositionZ"", ""GroupPositionX"", ""GroupPositionY"", ""GroupPositionZ"", ""VelocityX"", |
363 | VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, | 361 | ""VelocityY"", ""VelocityZ"", ""AngularVelocityX"", ""AngularVelocityY"", ""AngularVelocityZ"", ""AccelerationX"", ""AccelerationY"", ""AccelerationZ"", |
364 | RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, | 362 | ""RotationX"", ""RotationY"", ""RotationZ"", ""RotationW"", ""SitTargetOffsetX"", ""SitTargetOffsetY"", ""SitTargetOffsetZ"", ""SitTargetOrientW"", |
365 | SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, RegionUUID, CreatorID, OwnerID, GroupID, LastOwnerID, SceneGroupID, | 363 | ""SitTargetOrientX"", ""SitTargetOrientY"", ""SitTargetOrientZ"", ""RegionUUID"", ""CreatorID"", ""OwnerID"", ""GroupID"", ""LastOwnerID"", ""SceneGroupID"", |
366 | PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, | 364 | ""PayPrice"", ""PayButton1"", ""PayButton2"", ""PayButton3"", ""PayButton4"", ""LoopedSound"", ""LoopedSoundGain"", ""TextureAnimation"", ""OmegaX"", |
367 | OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, | 365 | ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"", |
368 | ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, | 366 | ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"", |
369 | ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL | 367 | ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"", |
370 | ) VALUES ( | 368 | ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"" |
371 | @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, | 369 | ) Select |
372 | @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, | 370 | :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask, |
373 | @VelocityY, @VelocityZ, @AngularVelocityX, @AngularVelocityY, @AngularVelocityZ, @AccelerationX, @AccelerationY, @AccelerationZ, | 371 | :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX, |
374 | @RotationX, @RotationY, @RotationZ, @RotationW, @SitTargetOffsetX, @SitTargetOffsetY, @SitTargetOffsetZ, @SitTargetOrientW, | 372 | :VelocityY, :VelocityZ, :AngularVelocityX, :AngularVelocityY, :AngularVelocityZ, :AccelerationX, :AccelerationY, :AccelerationZ, |
375 | @SitTargetOrientX, @SitTargetOrientY, @SitTargetOrientZ, @RegionUUID, @CreatorID, @OwnerID, @GroupID, @LastOwnerID, @SceneGroupID, | 373 | :RotationX, :RotationY, :RotationZ, :RotationW, :SitTargetOffsetX, :SitTargetOffsetY, :SitTargetOffsetZ, :SitTargetOrientW, |
376 | @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, | 374 | :SitTargetOrientX, :SitTargetOrientY, :SitTargetOrientZ, :RegionUUID, :CreatorID, :OwnerID, :GroupID, :LastOwnerID, :SceneGroupID, |
377 | @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, | 375 | :PayPrice, :PayButton1, :PayButton2, :PayButton3, :PayButton4, :LoopedSound, :LoopedSoundGain, :TextureAnimation, :OmegaX, |
378 | @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, | 376 | :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ, |
379 | @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL | 377 | :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA, |
380 | ) | 378 | :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs, |
381 | END"; | 379 | :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution |
380 | where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID); | ||
381 | "; | ||
382 | 382 | ||
383 | //Set commandtext. | 383 | //Set commandtext. |
384 | sqlCommand.CommandText = queryPrims; | 384 | sqlCommand.CommandText = queryPrims; |
@@ -396,35 +396,32 @@ ELSE | |||
396 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | 396 | /// <param name="sqlCommand">The SQL command with the transaction.</param> |
397 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | 397 | /// <param name="sceneGroupID">The scenegroup UUID.</param> |
398 | /// <param name="regionUUID">The region UUID.</param> | 398 | /// <param name="regionUUID">The region UUID.</param> |
399 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | 399 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) |
400 | { | 400 | { |
401 | //Big query to or insert or update primshapes | 401 | //Big query to or insert or update primshapes |
402 | //Note for SQL Server 2008 this can be simplified | 402 | |
403 | string queryPrimShapes = @" | 403 | string queryPrimShapes = @" |
404 | IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) | ||
405 | BEGIN | ||
406 | UPDATE primshapes SET | 404 | UPDATE primshapes SET |
407 | Shape = @Shape, ScaleX = @ScaleX, ScaleY = @ScaleY, ScaleZ = @ScaleZ, PCode = @PCode, PathBegin = @PathBegin, | 405 | ""Shape"" = :Shape, ""ScaleX"" = :ScaleX, ""ScaleY"" = :ScaleY, ""ScaleZ"" = :ScaleZ, ""PCode"" = :PCode, ""PathBegin"" = :PathBegin, |
408 | PathEnd = @PathEnd, PathScaleX = @PathScaleX, PathScaleY = @PathScaleY, PathShearX = @PathShearX, PathShearY = @PathShearY, | 406 | ""PathEnd"" = :PathEnd, ""PathScaleX"" = :PathScaleX, ""PathScaleY"" = :PathScaleY, ""PathShearX"" = :PathShearX, ""PathShearY"" = :PathShearY, |
409 | PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, | 407 | ""PathSkew"" = :PathSkew, ""PathCurve"" = :PathCurve, ""PathRadiusOffset"" = :PathRadiusOffset, ""PathRevolutions"" = :PathRevolutions, |
410 | PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, | 408 | ""PathTaperX"" = :PathTaperX, ""PathTaperY"" = :PathTaperY, ""PathTwist"" = :PathTwist, ""PathTwistBegin"" = :PathTwistBegin, |
411 | ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, | 409 | ""ProfileBegin"" = :ProfileBegin, ""ProfileEnd"" = :ProfileEnd, ""ProfileCurve"" = :ProfileCurve, ""ProfileHollow"" = :ProfileHollow, |
412 | Texture = @Texture, ExtraParams = @ExtraParams, State = @State, Media = @Media | 410 | ""Texture"" = :Texture, ""ExtraParams"" = :ExtraParams, ""State"" = :State, ""Media"" = :Media |
413 | WHERE UUID = @UUID | 411 | WHERE ""UUID"" = :UUID ; |
414 | END | 412 | |
415 | ELSE | ||
416 | BEGIN | ||
417 | INSERT INTO | 413 | INSERT INTO |
418 | primshapes ( | 414 | primshapes ( |
419 | UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, | 415 | ""UUID"", ""Shape"", ""ScaleX"", ""ScaleY"", ""ScaleZ"", ""PCode"", ""PathBegin"", ""PathEnd"", ""PathScaleX"", ""PathScaleY"", ""PathShearX"", ""PathShearY"", |
420 | PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, | 416 | ""PathSkew"", ""PathCurve"", ""PathRadiusOffset"", ""PathRevolutions"", ""PathTaperX"", ""PathTaperY"", ""PathTwist"", ""PathTwistBegin"", ""ProfileBegin"", |
421 | ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State, Media | 417 | ""ProfileEnd"", ""ProfileCurve"", ""ProfileHollow"", ""Texture"", ""ExtraParams"", ""State"", ""Media"" |
422 | ) VALUES ( | 418 | ) |
423 | @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, | 419 | Select |
424 | @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, | 420 | :UUID, :Shape, :ScaleX, :ScaleY, :ScaleZ, :PCode, :PathBegin, :PathEnd, :PathScaleX, :PathScaleY, :PathShearX, :PathShearY, |
425 | @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State, @Media | 421 | :PathSkew, :PathCurve, :PathRadiusOffset, :PathRevolutions, :PathTaperX, :PathTaperY, :PathTwist, :PathTwistBegin, :ProfileBegin, |
426 | ) | 422 | :ProfileEnd, :ProfileCurve, :ProfileHollow, :Texture, :ExtraParams, :State, :Media |
427 | END"; | 423 | where not EXISTS (SELECT ""UUID"" FROM primshapes WHERE ""UUID"" = :UUID); |
424 | "; | ||
428 | 425 | ||
429 | //Set commandtext. | 426 | //Set commandtext. |
430 | sqlCommand.CommandText = queryPrimShapes; | 427 | sqlCommand.CommandText = queryPrimShapes; |
@@ -445,18 +442,18 @@ ELSE | |||
445 | /// <param name="regionUUID">regionUUID (is this used anyway</param> | 442 | /// <param name="regionUUID">regionUUID (is this used anyway</param> |
446 | public void RemoveObject(UUID objectID, UUID regionUUID) | 443 | public void RemoveObject(UUID objectID, UUID regionUUID) |
447 | { | 444 | { |
448 | _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); | 445 | //_Log.InfoFormat("[PGSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); |
449 | 446 | ||
450 | //Remove from prims and primsitem table | 447 | //Remove from prims and primsitem table |
451 | string sqlPrims = "DELETE FROM PRIMS WHERE SceneGroupID = @objectID"; | 448 | string sqlPrims = @"DELETE FROM PRIMS WHERE ""SceneGroupID"" = :objectID"; |
452 | string sqlPrimItems = "DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | 449 | string sqlPrimItems = @"DELETE FROM PRIMITEMS WHERE ""primID"" in (SELECT ""UUID"" FROM PRIMS WHERE ""SceneGroupID"" = :objectID)"; |
453 | string sqlPrimShapes = "DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | 450 | string sqlPrimShapes = @"DELETE FROM PRIMSHAPES WHERE ""UUID"" in (SELECT ""UUID"" FROM PRIMS WHERE ""SceneGroupID"" = :objectID)"; |
454 | 451 | ||
455 | lock (_Database) | 452 | lock (_Database) |
456 | { | 453 | { |
457 | //Using the non transaction mode. | 454 | //Using the non transaction mode. |
458 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 455 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
459 | using (SqlCommand cmd = new SqlCommand()) | 456 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
460 | { | 457 | { |
461 | cmd.Connection = conn; | 458 | cmd.Connection = conn; |
462 | cmd.CommandText = sqlPrimShapes; | 459 | cmd.CommandText = sqlPrimShapes; |
@@ -482,31 +479,31 @@ ELSE | |||
482 | { | 479 | { |
483 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); | 480 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); |
484 | 481 | ||
485 | //Statement from MySQL section! | 482 | //Statement from PGSQL section! |
486 | // For now, we're just going to crudely remove all the previous inventory items | 483 | // For now, we're just going to crudely remove all the previous inventory items |
487 | // no matter whether they have changed or not, and replace them with the current set. | 484 | // no matter whether they have changed or not, and replace them with the current set. |
488 | 485 | ||
489 | //Delete everything from PrimID | 486 | //Delete everything from PrimID |
490 | //TODO add index on PrimID in DB, if not already exist | 487 | //TODO add index on PrimID in DB, if not already exist |
491 | 488 | ||
492 | string sql = "DELETE PRIMITEMS WHERE primID = @primID"; | 489 | string sql = @"delete from primitems where ""primID"" = :primID"; |
493 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 490 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
494 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 491 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
495 | { | 492 | { |
496 | cmd.Parameters.Add(_Database.CreateParameter("@primID", primID)); | 493 | cmd.Parameters.Add(_Database.CreateParameter("primID", primID)); |
497 | conn.Open(); | 494 | conn.Open(); |
498 | cmd.ExecuteNonQuery(); | 495 | cmd.ExecuteNonQuery(); |
499 | } | 496 | } |
500 | 497 | ||
501 | sql = | 498 | sql = |
502 | @"INSERT INTO primitems ( | 499 | @"INSERT INTO primitems ( |
503 | itemID,primID,assetID,parentFolderID,invType,assetType,name,description,creationDate,creatorID,ownerID,lastOwnerID,groupID, | 500 | ""itemID"",""primID"",""assetID"",""parentFolderID"",""invType"",""assetType"",""name"",""description"",""creationDate"",""creatorID"",""ownerID"",""lastOwnerID"",""groupID"", |
504 | nextPermissions,currentPermissions,basePermissions,everyonePermissions,groupPermissions,flags) | 501 | ""nextPermissions"",""currentPermissions"",""basePermissions"",""everyonePermissions"",""groupPermissions"",""flags"") |
505 | VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID, | 502 | VALUES (:itemID,:primID,:assetID,:parentFolderID,:invType,:assetType,:name,:description,:creationDate,:creatorID,:ownerID, |
506 | @lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)"; | 503 | :lastOwnerID,:groupID,:nextPermissions,:currentPermissions,:basePermissions,:everyonePermissions,:groupPermissions,:flags)"; |
507 | 504 | ||
508 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 505 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
509 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 506 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
510 | { | 507 | { |
511 | conn.Open(); | 508 | conn.Open(); |
512 | foreach (TaskInventoryItem taskItem in items) | 509 | foreach (TaskInventoryItem taskItem in items) |
@@ -527,43 +524,54 @@ ELSE | |||
527 | /// <returns></returns> | 524 | /// <returns></returns> |
528 | public double[,] LoadTerrain(UUID regionID) | 525 | public double[,] LoadTerrain(UUID regionID) |
529 | { | 526 | { |
530 | double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 527 | double[,] ret = null; |
531 | terrain.Initialize(); | 528 | TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); |
529 | if (terrData != null) | ||
530 | ret = terrData.GetDoubles(); | ||
531 | return ret; | ||
532 | } | ||
533 | |||
534 | // Returns 'null' if region not found | ||
535 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
536 | { | ||
537 | TerrainData terrData = null; | ||
532 | 538 | ||
533 | string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc"; | 539 | string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain |
540 | where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; "; | ||
534 | 541 | ||
535 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 542 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
536 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
537 | { | 543 | { |
538 | // MySqlParameter param = new MySqlParameter(); | 544 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
539 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
540 | conn.Open(); | ||
541 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
542 | { | 545 | { |
543 | int rev; | 546 | // PGSqlParameter param = new PGSqlParameter(); |
544 | if (reader.Read()) | 547 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
548 | conn.Open(); | ||
549 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
545 | { | 550 | { |
546 | MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); | 551 | int rev; |
547 | BinaryReader br = new BinaryReader(str); | 552 | if (reader.Read()) |
548 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
549 | { | 553 | { |
550 | for (int y = 0; y < (int)Constants.RegionSize; y++) | 554 | rev = Convert.ToInt32(reader["Revision"]); |
551 | { | 555 | byte[] blob = (byte[])reader["Heightfield"]; |
552 | terrain[x, y] = br.ReadDouble(); | 556 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); |
553 | } | ||
554 | } | 557 | } |
555 | rev = (int)reader["Revision"]; | 558 | else |
556 | } | 559 | { |
557 | else | 560 | _Log.Info("[REGION DB]: No terrain found for region"); |
558 | { | 561 | return null; |
559 | _Log.Info("[REGION DB]: No terrain found for region"); | 562 | } |
560 | return null; | 563 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); |
561 | } | 564 | } |
562 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
563 | } | 565 | } |
564 | } | 566 | } |
565 | 567 | ||
566 | return terrain; | 568 | return terrData; |
569 | } | ||
570 | |||
571 | // Legacy entry point for when terrain was always a 256x256 heightmap | ||
572 | public void StoreTerrain(double[,] terrain, UUID regionID) | ||
573 | { | ||
574 | StoreTerrain(new HeightmapTerrainData(terrain), regionID); | ||
567 | } | 575 | } |
568 | 576 | ||
569 | /// <summary> | 577 | /// <summary> |
@@ -571,33 +579,43 @@ ELSE | |||
571 | /// </summary> | 579 | /// </summary> |
572 | /// <param name="terrain">terrain map data.</param> | 580 | /// <param name="terrain">terrain map data.</param> |
573 | /// <param name="regionID">regionID.</param> | 581 | /// <param name="regionID">regionID.</param> |
574 | public void StoreTerrain(double[,] terrain, UUID regionID) | 582 | public void StoreTerrain(TerrainData terrData, UUID regionID) |
575 | { | 583 | { |
576 | int revision = Util.UnixTimeSinceEpoch(); | ||
577 | |||
578 | //Delete old terrain map | 584 | //Delete old terrain map |
579 | string sql = "delete from terrain where RegionUUID=@RegionUUID"; | 585 | string sql = @"delete from terrain where ""RegionUUID""=:RegionUUID"; |
580 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 586 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
581 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
582 | { | 587 | { |
583 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | 588 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
584 | conn.Open(); | 589 | { |
585 | cmd.ExecuteNonQuery(); | 590 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
591 | conn.Open(); | ||
592 | cmd.ExecuteNonQuery(); | ||
593 | |||
594 | _Log.InfoFormat("{0} Deleted terrain revision id = {1}", LogHeader, regionID); | ||
595 | } | ||
586 | } | 596 | } |
587 | 597 | ||
588 | sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)"; | 598 | int terrainDBRevision; |
599 | Array terrainDBblob; | ||
600 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
601 | |||
602 | sql = @"insert into terrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)"; | ||
589 | 603 | ||
590 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 604 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
591 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
592 | { | 605 | { |
593 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | 606 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
594 | cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision)); | 607 | { |
595 | cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain))); | 608 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
596 | conn.Open(); | 609 | cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision)); |
597 | cmd.ExecuteNonQuery(); | 610 | cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob)); |
611 | conn.Open(); | ||
612 | cmd.ExecuteNonQuery(); | ||
613 | |||
614 | _Log.InfoFormat("{0} Stored terrain id = {1}, terrainSize = <{2},{3}>", | ||
615 | LogHeader, regionID, terrData.SizeX, terrData.SizeY); | ||
616 | } | ||
598 | } | 617 | } |
599 | 618 | ||
600 | _Log.Info("[REGION DB]: Stored terrain revision r " + revision); | ||
601 | } | 619 | } |
602 | 620 | ||
603 | /// <summary> | 621 | /// <summary> |
@@ -609,15 +627,15 @@ ELSE | |||
609 | { | 627 | { |
610 | List<LandData> LandDataForRegion = new List<LandData>(); | 628 | List<LandData> LandDataForRegion = new List<LandData>(); |
611 | 629 | ||
612 | string sql = "select * from land where RegionUUID = @RegionUUID"; | 630 | string sql = @"select * from land where ""RegionUUID"" = :RegionUUID"; |
613 | 631 | ||
614 | //Retrieve all land data from region | 632 | //Retrieve all land data from region |
615 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 633 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
616 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 634 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
617 | { | 635 | { |
618 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionUUID)); | 636 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); |
619 | conn.Open(); | 637 | conn.Open(); |
620 | using (SqlDataReader readerLandData = cmd.ExecuteReader()) | 638 | using (NpgsqlDataReader readerLandData = cmd.ExecuteReader()) |
621 | { | 639 | { |
622 | while (readerLandData.Read()) | 640 | while (readerLandData.Read()) |
623 | { | 641 | { |
@@ -629,13 +647,13 @@ ELSE | |||
629 | //Retrieve all accesslist data for all landdata | 647 | //Retrieve all accesslist data for all landdata |
630 | foreach (LandData LandData in LandDataForRegion) | 648 | foreach (LandData LandData in LandDataForRegion) |
631 | { | 649 | { |
632 | sql = "select * from landaccesslist where LandUUID = @LandUUID"; | 650 | sql = @"select * from landaccesslist where ""LandUUID"" = :LandUUID"; |
633 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 651 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
634 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 652 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
635 | { | 653 | { |
636 | cmd.Parameters.Add(_Database.CreateParameter("@LandUUID", LandData.GlobalID)); | 654 | cmd.Parameters.Add(_Database.CreateParameter("LandUUID", LandData.GlobalID)); |
637 | conn.Open(); | 655 | conn.Open(); |
638 | using (SqlDataReader readerAccessList = cmd.ExecuteReader()) | 656 | using (NpgsqlDataReader readerAccessList = cmd.ExecuteReader()) |
639 | { | 657 | { |
640 | while (readerAccessList.Read()) | 658 | while (readerAccessList.Read()) |
641 | { | 659 | { |
@@ -656,29 +674,33 @@ ELSE | |||
656 | public void StoreLandObject(ILandObject parcel) | 674 | public void StoreLandObject(ILandObject parcel) |
657 | { | 675 | { |
658 | //As this is only one record in land table I just delete all and then add a new record. | 676 | //As this is only one record in land table I just delete all and then add a new record. |
659 | //As the delete landaccess is already in the mysql code | 677 | //As the delete landaccess is already in the pgsql code |
660 | 678 | ||
661 | //Delete old values | 679 | //Delete old values |
662 | RemoveLandObject(parcel.LandData.GlobalID); | 680 | RemoveLandObject(parcel.LandData.GlobalID); |
663 | 681 | ||
664 | //Insert new values | 682 | //Insert new values |
665 | string sql = @"INSERT INTO [land] | 683 | string sql = @"INSERT INTO land |
666 | ([UUID],[RegionUUID],[LocalLandID],[Bitmap],[Name],[Description],[OwnerUUID],[IsGroupOwned],[Area],[AuctionID],[Category],[ClaimDate],[ClaimPrice],[GroupUUID],[SalePrice],[LandStatus],[LandFlags],[LandingType],[MediaAutoScale],[MediaTextureUUID],[MediaURL],[MusicURL],[PassHours],[PassPrice],[SnapshotUUID],[UserLocationX],[UserLocationY],[UserLocationZ],[UserLookAtX],[UserLookAtY],[UserLookAtZ],[AuthbuyerID],[OtherCleanTime]) | 684 | (""UUID"",""RegionUUID"",""LocalLandID"",""Bitmap"",""Name"",""Description"",""OwnerUUID"",""IsGroupOwned"",""Area"",""AuctionID"",""Category"",""ClaimDate"",""ClaimPrice"", |
667 | VALUES | 685 | ""GroupUUID"",""SalePrice"",""LandStatus"",""LandFlags"",""LandingType"",""MediaAutoScale"",""MediaTextureUUID"",""MediaURL"",""MusicURL"",""PassHours"",""PassPrice"", |
668 | (@UUID,@RegionUUID,@LocalLandID,@Bitmap,@Name,@Description,@OwnerUUID,@IsGroupOwned,@Area,@AuctionID,@Category,@ClaimDate,@ClaimPrice,@GroupUUID,@SalePrice,@LandStatus,@LandFlags,@LandingType,@MediaAutoScale,@MediaTextureUUID,@MediaURL,@MusicURL,@PassHours,@PassPrice,@SnapshotUUID,@UserLocationX,@UserLocationY,@UserLocationZ,@UserLookAtX,@UserLookAtY,@UserLookAtZ,@AuthbuyerID,@OtherCleanTime)"; | 686 | ""SnapshotUUID"",""UserLocationX"",""UserLocationY"",""UserLocationZ"",""UserLookAtX"",""UserLookAtY"",""UserLookAtZ"",""AuthbuyerID"",""OtherCleanTime"") |
669 | 687 | VALUES | |
670 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 688 | (:UUID,:RegionUUID,:LocalLandID,:Bitmap,:Name,:Description,:OwnerUUID,:IsGroupOwned,:Area,:AuctionID,:Category,:ClaimDate,:ClaimPrice, |
671 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 689 | :GroupUUID,:SalePrice,:LandStatus,:LandFlags,:LandingType,:MediaAutoScale,:MediaTextureUUID,:MediaURL,:MusicURL,:PassHours,:PassPrice, |
690 | :SnapshotUUID,:UserLocationX,:UserLocationY,:UserLocationZ,:UserLookAtX,:UserLookAtY,:UserLookAtZ,:AuthbuyerID,:OtherCleanTime)"; | ||
691 | |||
692 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
693 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
672 | { | 694 | { |
673 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); | 695 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); |
674 | conn.Open(); | 696 | conn.Open(); |
675 | cmd.ExecuteNonQuery(); | 697 | cmd.ExecuteNonQuery(); |
676 | } | 698 | } |
677 | 699 | ||
678 | sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags],[Expires]) VALUES (@LandUUID,@AccessUUID,@Flags,@Expires)"; | 700 | sql = @"INSERT INTO landaccesslist (""LandUUID"",""AccessUUID"",""LandFlags"",""Expires"") VALUES (:LandUUID,:AccessUUID,:Flags,:Expires)"; |
679 | 701 | ||
680 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 702 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
681 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 703 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
682 | { | 704 | { |
683 | conn.Open(); | 705 | conn.Open(); |
684 | foreach (LandAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) | 706 | foreach (LandAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) |
@@ -697,19 +719,19 @@ VALUES | |||
697 | /// <param name="globalID">UUID of landobject</param> | 719 | /// <param name="globalID">UUID of landobject</param> |
698 | public void RemoveLandObject(UUID globalID) | 720 | public void RemoveLandObject(UUID globalID) |
699 | { | 721 | { |
700 | string sql = "delete from land where UUID=@UUID"; | 722 | string sql = @"delete from land where ""UUID""=:UUID"; |
701 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 723 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
702 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 724 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
703 | { | 725 | { |
704 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | 726 | cmd.Parameters.Add(_Database.CreateParameter("UUID", globalID)); |
705 | conn.Open(); | 727 | conn.Open(); |
706 | cmd.ExecuteNonQuery(); | 728 | cmd.ExecuteNonQuery(); |
707 | } | 729 | } |
708 | sql = "delete from landaccesslist where LandUUID=@UUID"; | 730 | sql = @"delete from landaccesslist where ""LandUUID""=:UUID"; |
709 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 731 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
710 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 732 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
711 | { | 733 | { |
712 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | 734 | cmd.Parameters.Add(_Database.CreateParameter("UUID", globalID)); |
713 | conn.Open(); | 735 | conn.Open(); |
714 | cmd.ExecuteNonQuery(); | 736 | cmd.ExecuteNonQuery(); |
715 | } | 737 | } |
@@ -718,13 +740,15 @@ VALUES | |||
718 | { | 740 | { |
719 | RegionLightShareData nWP = new RegionLightShareData(); | 741 | RegionLightShareData nWP = new RegionLightShareData(); |
720 | nWP.OnSave += StoreRegionWindlightSettings; | 742 | nWP.OnSave += StoreRegionWindlightSettings; |
721 | string sql = "select * from [regionwindlight] where region_id = @regionID"; | 743 | |
722 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 744 | string sql = @"select * from regionwindlight where ""region_id"" = :regionID"; |
723 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 745 | |
746 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
747 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
724 | { | 748 | { |
725 | cmd.Parameters.Add(_Database.CreateParameter("@regionID", regionUUID)); | 749 | cmd.Parameters.Add(_Database.CreateParameter("regionID", regionUUID.ToString() )); |
726 | conn.Open(); | 750 | conn.Open(); |
727 | using (SqlDataReader result = cmd.ExecuteReader()) | 751 | using (NpgsqlDataReader result = cmd.ExecuteReader()) |
728 | { | 752 | { |
729 | if (!result.Read()) | 753 | if (!result.Read()) |
730 | { | 754 | { |
@@ -807,27 +831,28 @@ VALUES | |||
807 | 831 | ||
808 | public void RemoveRegionWindlightSettings(UUID regionID) | 832 | public void RemoveRegionWindlightSettings(UUID regionID) |
809 | { | 833 | { |
810 | string sql = "delete from [regionwindlight] where region_id = @region_id"; | 834 | string sql = @"delete from regionwindlight where ""region_id"" = :region_id"; |
811 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 835 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
812 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 836 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
813 | { | 837 | { |
814 | conn.Open(); | 838 | conn.Open(); |
815 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionID)); | 839 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionID.ToString())); |
816 | cmd.ExecuteNonQuery(); | 840 | cmd.ExecuteNonQuery(); |
817 | } | 841 | } |
818 | } | 842 | } |
819 | 843 | ||
820 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | 844 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
821 | { | 845 | { |
822 | string sql = "select count (region_id) from regionwindlight where region_id = @region_id"; | 846 | string sql = @"select region_id from regionwindlight where ""region_id"" = :region_id limit 1;"; |
823 | bool exists = false; | 847 | bool exists = false; |
824 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 848 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
825 | { | 849 | { |
826 | conn.Open(); | 850 | conn.Open(); |
827 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 851 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
828 | { | 852 | { |
829 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", wl.regionID)); | 853 | cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString() )); |
830 | exists = (int)cmd.ExecuteScalar() > 0; | 854 | NpgsqlDataReader dr = cmd.ExecuteReader(); |
855 | exists = dr.Read(); | ||
831 | } | 856 | } |
832 | } | 857 | } |
833 | if (exists) | 858 | if (exists) |
@@ -836,140 +861,141 @@ VALUES | |||
836 | } | 861 | } |
837 | 862 | ||
838 | // sql insert | 863 | // sql insert |
839 | sql = @"INSERT INTO [regionwindlight] | 864 | sql = @"INSERT INTO regionwindlight |
840 | ([region_id] | 865 | (region_id |
841 | ,[water_color_r] | 866 | ,water_color_r |
842 | ,[water_color_g] | 867 | ,water_color_g |
843 | ,[water_color_b] | 868 | ,water_color_b |
844 | ,[water_fog_density_exponent] | 869 | ,water_fog_density_exponent |
845 | ,[underwater_fog_modifier] | 870 | ,underwater_fog_modifier |
846 | ,[reflection_wavelet_scale_1] | 871 | ,reflection_wavelet_scale_1 |
847 | ,[reflection_wavelet_scale_2] | 872 | ,reflection_wavelet_scale_2 |
848 | ,[reflection_wavelet_scale_3] | 873 | ,reflection_wavelet_scale_3 |
849 | ,[fresnel_scale] | 874 | ,fresnel_scale |
850 | ,[fresnel_offset] | 875 | ,fresnel_offset |
851 | ,[refract_scale_above] | 876 | ,refract_scale_above |
852 | ,[refract_scale_below] | 877 | ,refract_scale_below |
853 | ,[blur_multiplier] | 878 | ,blur_multiplier |
854 | ,[big_wave_direction_x] | 879 | ,big_wave_direction_x |
855 | ,[big_wave_direction_y] | 880 | ,big_wave_direction_y |
856 | ,[little_wave_direction_x] | 881 | ,little_wave_direction_x |
857 | ,[little_wave_direction_y] | 882 | ,little_wave_direction_y |
858 | ,[normal_map_texture] | 883 | ,normal_map_texture |
859 | ,[horizon_r] | 884 | ,horizon_r |
860 | ,[horizon_g] | 885 | ,horizon_g |
861 | ,[horizon_b] | 886 | ,horizon_b |
862 | ,[horizon_i] | 887 | ,horizon_i |
863 | ,[haze_horizon] | 888 | ,haze_horizon |
864 | ,[blue_density_r] | 889 | ,blue_density_r |
865 | ,[blue_density_g] | 890 | ,blue_density_g |
866 | ,[blue_density_b] | 891 | ,blue_density_b |
867 | ,[blue_density_i] | 892 | ,blue_density_i |
868 | ,[haze_density] | 893 | ,haze_density |
869 | ,[density_multiplier] | 894 | ,density_multiplier |
870 | ,[distance_multiplier] | 895 | ,distance_multiplier |
871 | ,[max_altitude] | 896 | ,max_altitude |
872 | ,[sun_moon_color_r] | 897 | ,sun_moon_color_r |
873 | ,[sun_moon_color_g] | 898 | ,sun_moon_color_g |
874 | ,[sun_moon_color_b] | 899 | ,sun_moon_color_b |
875 | ,[sun_moon_color_i] | 900 | ,sun_moon_color_i |
876 | ,[sun_moon_position] | 901 | ,sun_moon_position |
877 | ,[ambient_r] | 902 | ,ambient_r |
878 | ,[ambient_g] | 903 | ,ambient_g |
879 | ,[ambient_b] | 904 | ,ambient_b |
880 | ,[ambient_i] | 905 | ,ambient_i |
881 | ,[east_angle] | 906 | ,east_angle |
882 | ,[sun_glow_focus] | 907 | ,sun_glow_focus |
883 | ,[sun_glow_size] | 908 | ,sun_glow_size |
884 | ,[scene_gamma] | 909 | ,scene_gamma |
885 | ,[star_brightness] | 910 | ,star_brightness |
886 | ,[cloud_color_r] | 911 | ,cloud_color_r |
887 | ,[cloud_color_g] | 912 | ,cloud_color_g |
888 | ,[cloud_color_b] | 913 | ,cloud_color_b |
889 | ,[cloud_color_i] | 914 | ,cloud_color_i |
890 | ,[cloud_x] | 915 | ,cloud_x |
891 | ,[cloud_y] | 916 | ,cloud_y |
892 | ,[cloud_density] | 917 | ,cloud_density |
893 | ,[cloud_coverage] | 918 | ,cloud_coverage |
894 | ,[cloud_scale] | 919 | ,cloud_scale |
895 | ,[cloud_detail_x] | 920 | ,cloud_detail_x |
896 | ,[cloud_detail_y] | 921 | ,cloud_detail_y |
897 | ,[cloud_detail_density] | 922 | ,cloud_detail_density |
898 | ,[cloud_scroll_x] | 923 | ,cloud_scroll_x |
899 | ,[cloud_scroll_x_lock] | 924 | ,cloud_scroll_x_lock |
900 | ,[cloud_scroll_y] | 925 | ,cloud_scroll_y |
901 | ,[cloud_scroll_y_lock] | 926 | ,cloud_scroll_y_lock |
902 | ,[draw_classic_clouds]) | 927 | ,draw_classic_clouds) |
903 | VALUES | 928 | VALUES |
904 | (@region_id | 929 | (:region_id |
905 | ,@water_color_r | 930 | ,:water_color_r |
906 | ,@water_color_g | 931 | ,:water_color_g |
907 | ,@water_color_b | 932 | ,:water_color_b |
908 | ,@water_fog_density_exponent | 933 | ,:water_fog_density_exponent |
909 | ,@underwater_fog_modifier | 934 | ,:underwater_fog_modifier |
910 | ,@reflection_wavelet_scale_1 | 935 | ,:reflection_wavelet_scale_1 |
911 | ,@reflection_wavelet_scale_2 | 936 | ,:reflection_wavelet_scale_2 |
912 | ,@reflection_wavelet_scale_3 | 937 | ,:reflection_wavelet_scale_3 |
913 | ,@fresnel_scale | 938 | ,:fresnel_scale |
914 | ,@fresnel_offset | 939 | ,:fresnel_offset |
915 | ,@refract_scale_above | 940 | ,:refract_scale_above |
916 | ,@refract_scale_below | 941 | ,:refract_scale_below |
917 | ,@blur_multiplier | 942 | ,:blur_multiplier |
918 | ,@big_wave_direction_x | 943 | ,:big_wave_direction_x |
919 | ,@big_wave_direction_y | 944 | ,:big_wave_direction_y |
920 | ,@little_wave_direction_x | 945 | ,:little_wave_direction_x |
921 | ,@little_wave_direction_y | 946 | ,:little_wave_direction_y |
922 | ,@normal_map_texture | 947 | ,:normal_map_texture |
923 | ,@horizon_r | 948 | ,:horizon_r |
924 | ,@horizon_g | 949 | ,:horizon_g |
925 | ,@horizon_b | 950 | ,:horizon_b |
926 | ,@horizon_i | 951 | ,:horizon_i |
927 | ,@haze_horizon | 952 | ,:haze_horizon |
928 | ,@blue_density_r | 953 | ,:blue_density_r |
929 | ,@blue_density_g | 954 | ,:blue_density_g |
930 | ,@blue_density_b | 955 | ,:blue_density_b |
931 | ,@blue_density_i | 956 | ,:blue_density_i |
932 | ,@haze_density | 957 | ,:haze_density |
933 | ,@density_multiplier | 958 | ,:density_multiplier |
934 | ,@distance_multiplier | 959 | ,:distance_multiplier |
935 | ,@max_altitude | 960 | ,:max_altitude |
936 | ,@sun_moon_color_r | 961 | ,:sun_moon_color_r |
937 | ,@sun_moon_color_g | 962 | ,:sun_moon_color_g |
938 | ,@sun_moon_color_b | 963 | ,:sun_moon_color_b |
939 | ,@sun_moon_color_i | 964 | ,:sun_moon_color_i |
940 | ,@sun_moon_position | 965 | ,:sun_moon_position |
941 | ,@ambient_r | 966 | ,:ambient_r |
942 | ,@ambient_g | 967 | ,:ambient_g |
943 | ,@ambient_b | 968 | ,:ambient_b |
944 | ,@ambient_i | 969 | ,:ambient_i |
945 | ,@east_angle | 970 | ,:east_angle |
946 | ,@sun_glow_focus | 971 | ,:sun_glow_focus |
947 | ,@sun_glow_size | 972 | ,:sun_glow_size |
948 | ,@scene_gamma | 973 | ,:scene_gamma |
949 | ,@star_brightness | 974 | ,:star_brightness |
950 | ,@cloud_color_r | 975 | ,:cloud_color_r |
951 | ,@cloud_color_g | 976 | ,:cloud_color_g |
952 | ,@cloud_color_b | 977 | ,:cloud_color_b |
953 | ,@cloud_color_i | 978 | ,:cloud_color_i |
954 | ,@cloud_x | 979 | ,:cloud_x |
955 | ,@cloud_y | 980 | ,:cloud_y |
956 | ,@cloud_density | 981 | ,:cloud_density |
957 | ,@cloud_coverage | 982 | ,:cloud_coverage |
958 | ,@cloud_scale | 983 | ,:cloud_scale |
959 | ,@cloud_detail_x | 984 | ,:cloud_detail_x |
960 | ,@cloud_detail_y | 985 | ,:cloud_detail_y |
961 | ,@cloud_detail_density | 986 | ,:cloud_detail_density |
962 | ,@cloud_scroll_x | 987 | ,:cloud_scroll_x |
963 | ,@cloud_scroll_x_lock | 988 | ,:cloud_scroll_x_lock |
964 | ,@cloud_scroll_y | 989 | ,:cloud_scroll_y |
965 | ,@cloud_scroll_y_lock | 990 | ,:cloud_scroll_y_lock |
966 | ,@draw_classic_clouds)"; | 991 | ,:draw_classic_clouds);"; |
967 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 992 | |
993 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
968 | { | 994 | { |
969 | conn.Open(); | 995 | conn.Open(); |
970 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 996 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
971 | { | 997 | { |
972 | cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID)); | 998 | cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString())); |
973 | cmd.Parameters.Add(_Database.CreateParameter("water_color_r", wl.waterColor.X)); | 999 | cmd.Parameters.Add(_Database.CreateParameter("water_color_r", wl.waterColor.X)); |
974 | cmd.Parameters.Add(_Database.CreateParameter("water_color_g", wl.waterColor.Y)); | 1000 | cmd.Parameters.Add(_Database.CreateParameter("water_color_g", wl.waterColor.Y)); |
975 | cmd.Parameters.Add(_Database.CreateParameter("water_color_b", wl.waterColor.Z)); | 1001 | cmd.Parameters.Add(_Database.CreateParameter("water_color_b", wl.waterColor.Z)); |
@@ -987,7 +1013,7 @@ VALUES | |||
987 | cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_y", wl.bigWaveDirection.Y)); | 1013 | cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_y", wl.bigWaveDirection.Y)); |
988 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_x", wl.littleWaveDirection.X)); | 1014 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_x", wl.littleWaveDirection.X)); |
989 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_y", wl.littleWaveDirection.Y)); | 1015 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_y", wl.littleWaveDirection.Y)); |
990 | cmd.Parameters.Add(_Database.CreateParameter("normal_map_texture", wl.normalMapTexture)); | 1016 | cmd.Parameters.Add(_Database.CreateParameter("normal_map_texture", wl.normalMapTexture.ToString())); |
991 | cmd.Parameters.Add(_Database.CreateParameter("horizon_r", wl.horizon.X)); | 1017 | cmd.Parameters.Add(_Database.CreateParameter("horizon_r", wl.horizon.X)); |
992 | cmd.Parameters.Add(_Database.CreateParameter("horizon_g", wl.horizon.Y)); | 1018 | cmd.Parameters.Add(_Database.CreateParameter("horizon_g", wl.horizon.Y)); |
993 | cmd.Parameters.Add(_Database.CreateParameter("horizon_b", wl.horizon.Z)); | 1019 | cmd.Parameters.Add(_Database.CreateParameter("horizon_b", wl.horizon.Z)); |
@@ -1185,13 +1211,13 @@ VALUES | |||
1185 | #region Environment Settings | 1211 | #region Environment Settings |
1186 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1212 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
1187 | { | 1213 | { |
1188 | string sql = "select * from [regionenvironment] where region_id = @region_id"; | 1214 | string sql = "select * from regionenvironment where region_id = :region_id"; |
1189 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1215 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1190 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1216 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1191 | { | 1217 | { |
1192 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1218 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1193 | conn.Open(); | 1219 | conn.Open(); |
1194 | using (SqlDataReader result = cmd.ExecuteReader()) | 1220 | using (NpgsqlDataReader result = cmd.ExecuteReader()) |
1195 | { | 1221 | { |
1196 | if (!result.Read()) | 1222 | if (!result.Read()) |
1197 | { | 1223 | { |
@@ -1208,24 +1234,23 @@ VALUES | |||
1208 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1234 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1209 | { | 1235 | { |
1210 | { | 1236 | { |
1211 | string sql = "DELETE FROM [regionenvironment] WHERE region_id = @region_id"; | 1237 | string sql = "DELETE FROM regionenvironment WHERE region_id = :region_id ;"; |
1212 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1238 | |
1213 | 1239 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | |
1214 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1240 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1215 | { | 1241 | { |
1216 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1242 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1217 | conn.Open(); | 1243 | conn.Open(); |
1218 | cmd.ExecuteNonQuery(); | 1244 | cmd.ExecuteNonQuery(); |
1219 | } | 1245 | } |
1220 | 1246 | ||
1221 | sql = "INSERT INTO [regionenvironment] (region_id, llsd_settings) VALUES (@region_id, @llsd_settings)"; | 1247 | sql = "INSERT INTO regionenvironment (region_id, llsd_settings) VALUES (:region_id, :llsd_settings) ;"; |
1222 | |||
1223 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
1224 | 1248 | ||
1225 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1249 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1250 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
1226 | { | 1251 | { |
1227 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1252 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1228 | cmd.Parameters.Add(_Database.CreateParameter("@llsd_settings", settings)); | 1253 | cmd.Parameters.Add(_Database.CreateParameter("llsd_settings", settings)); |
1229 | 1254 | ||
1230 | conn.Open(); | 1255 | conn.Open(); |
1231 | cmd.ExecuteNonQuery(); | 1256 | cmd.ExecuteNonQuery(); |
@@ -1235,11 +1260,11 @@ VALUES | |||
1235 | 1260 | ||
1236 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1261 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1237 | { | 1262 | { |
1238 | string sql = "delete from [regionenvironment] where region_id = @region_id"; | 1263 | string sql = "delete from regionenvironment where region_id = :region_id ;"; |
1239 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1264 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1240 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1265 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1241 | { | 1266 | { |
1242 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1267 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1243 | 1268 | ||
1244 | conn.Open(); | 1269 | conn.Open(); |
1245 | cmd.ExecuteNonQuery(); | 1270 | cmd.ExecuteNonQuery(); |
@@ -1254,14 +1279,14 @@ VALUES | |||
1254 | /// <returns></returns> | 1279 | /// <returns></returns> |
1255 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 1280 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
1256 | { | 1281 | { |
1257 | string sql = "select * from regionsettings where regionUUID = @regionUUID"; | 1282 | string sql = @"select * from regionsettings where ""regionUUID"" = :regionUUID"; |
1258 | RegionSettings regionSettings; | 1283 | RegionSettings regionSettings; |
1259 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1284 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1260 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1285 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1261 | { | 1286 | { |
1262 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | 1287 | cmd.Parameters.Add(_Database.CreateParameter("regionUUID", regionUUID)); |
1263 | conn.Open(); | 1288 | conn.Open(); |
1264 | using (SqlDataReader reader = cmd.ExecuteReader()) | 1289 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
1265 | { | 1290 | { |
1266 | if (reader.Read()) | 1291 | if (reader.Read()) |
1267 | { | 1292 | { |
@@ -1294,11 +1319,11 @@ VALUES | |||
1294 | { | 1319 | { |
1295 | //Little check if regionUUID already exist in DB | 1320 | //Little check if regionUUID already exist in DB |
1296 | string regionUUID; | 1321 | string regionUUID; |
1297 | string sql = "SELECT regionUUID FROM regionsettings WHERE regionUUID = @regionUUID"; | 1322 | string sql = @"SELECT ""regionUUID"" FROM regionsettings WHERE ""regionUUID"" = :regionUUID"; |
1298 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1323 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1299 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1324 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1300 | { | 1325 | { |
1301 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionSettings.RegionUUID)); | 1326 | cmd.Parameters.Add(_Database.CreateParameter("regionUUID", regionSettings.RegionUUID)); |
1302 | conn.Open(); | 1327 | conn.Open(); |
1303 | regionUUID = cmd.ExecuteScalar().ToString(); | 1328 | regionUUID = cmd.ExecuteScalar().ToString(); |
1304 | } | 1329 | } |
@@ -1311,20 +1336,22 @@ VALUES | |||
1311 | { | 1336 | { |
1312 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB | 1337 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB |
1313 | sql = | 1338 | sql = |
1314 | @"UPDATE [regionsettings] SET [block_terraform] = @block_terraform ,[block_fly] = @block_fly ,[allow_damage] = @allow_damage | 1339 | @"UPDATE regionsettings SET block_terraform = :block_terraform ,block_fly = :block_fly ,allow_damage = :allow_damage |
1315 | ,[restrict_pushing] = @restrict_pushing ,[allow_land_resell] = @allow_land_resell ,[allow_land_join_divide] = @allow_land_join_divide | 1340 | ,restrict_pushing = :restrict_pushing ,allow_land_resell = :allow_land_resell ,allow_land_join_divide = :allow_land_join_divide |
1316 | ,[block_show_in_search] = @block_show_in_search ,[agent_limit] = @agent_limit ,[object_bonus] = @object_bonus ,[maturity] = @maturity | 1341 | ,block_show_in_search = :block_show_in_search ,agent_limit = :agent_limit ,object_bonus = :object_bonus ,maturity = :maturity |
1317 | ,[disable_scripts] = @disable_scripts ,[disable_collisions] = @disable_collisions ,[disable_physics] = @disable_physics | 1342 | ,disable_scripts = :disable_scripts ,disable_collisions = :disable_collisions ,disable_physics = :disable_physics |
1318 | ,[terrain_texture_1] = @terrain_texture_1 ,[terrain_texture_2] = @terrain_texture_2 ,[terrain_texture_3] = @terrain_texture_3 | 1343 | ,terrain_texture_1 = :terrain_texture_1 ,terrain_texture_2 = :terrain_texture_2 ,terrain_texture_3 = :terrain_texture_3 |
1319 | ,[terrain_texture_4] = @terrain_texture_4 ,[elevation_1_nw] = @elevation_1_nw ,[elevation_2_nw] = @elevation_2_nw | 1344 | ,terrain_texture_4 = :terrain_texture_4 ,elevation_1_nw = :elevation_1_nw ,elevation_2_nw = :elevation_2_nw |
1320 | ,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se | 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 |
1321 | ,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit | 1346 | ,elevation_1_sw = :elevation_1_sw ,elevation_2_sw = :elevation_2_sw ,water_height = :water_height ,terrain_raise_limit = :terrain_raise_limit |
1322 | ,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position | 1347 | ,terrain_lower_limit = :terrain_lower_limit ,use_estate_sun = :use_estate_sun ,fixed_sun = :fixed_sun ,sun_position = :sun_position |
1323 | ,[covenant] = @covenant ,[covenant_datetime] = @covenant_datetime, [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id, [map_tile_id] = @TerrainImageID, [telehubobject] = @telehubobject, [parcel_tile_id] = @ParcelImageID | 1348 | ,covenant = :covenant ,covenant_datetime = :covenant_datetime, sunvectorx = :sunvectorx, sunvectory = :sunvectory, sunvectorz = :sunvectorz, |
1324 | WHERE [regionUUID] = @regionUUID"; | 1349 | ""Sandbox"" = :Sandbox, loaded_creation_datetime = :loaded_creation_datetime, loaded_creation_id = :loaded_creation_id, ""map_tile_ID"" = :TerrainImageID, |
1325 | 1350 | ""TelehubObject"" = :telehubobject, ""parcel_tile_ID"" = :ParcelImageID | |
1326 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1351 | WHERE ""regionUUID"" = :regionUUID"; |
1327 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1352 | |
1353 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
1354 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
1328 | { | 1355 | { |
1329 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | 1356 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); |
1330 | conn.Open(); | 1357 | conn.Open(); |
@@ -1342,51 +1369,29 @@ VALUES | |||
1342 | #region Private Methods | 1369 | #region Private Methods |
1343 | 1370 | ||
1344 | /// <summary> | 1371 | /// <summary> |
1345 | /// Serializes the terrain data for storage in DB. | ||
1346 | /// </summary> | ||
1347 | /// <param name="val">terrain data</param> | ||
1348 | /// <returns></returns> | ||
1349 | private static Array serializeTerrain(double[,] val) | ||
1350 | { | ||
1351 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
1352 | BinaryWriter bw = new BinaryWriter(str); | ||
1353 | |||
1354 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1355 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1356 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1357 | { | ||
1358 | double height = val[x, y]; | ||
1359 | if (height == 0.0) | ||
1360 | height = double.Epsilon; | ||
1361 | |||
1362 | bw.Write(height); | ||
1363 | } | ||
1364 | |||
1365 | return str.ToArray(); | ||
1366 | } | ||
1367 | |||
1368 | /// <summary> | ||
1369 | /// Stores new regionsettings. | 1372 | /// Stores new regionsettings. |
1370 | /// </summary> | 1373 | /// </summary> |
1371 | /// <param name="regionSettings">The region settings.</param> | 1374 | /// <param name="regionSettings">The region settings.</param> |
1372 | private void StoreNewRegionSettings(RegionSettings regionSettings) | 1375 | private void StoreNewRegionSettings(RegionSettings regionSettings) |
1373 | { | 1376 | { |
1374 | string sql = @"INSERT INTO [regionsettings] | 1377 | string sql = @"INSERT INTO regionsettings |
1375 | ([regionUUID],[block_terraform],[block_fly],[allow_damage],[restrict_pushing],[allow_land_resell],[allow_land_join_divide], | 1378 | (""regionUUID"",block_terraform,block_fly,allow_damage,restrict_pushing,allow_land_resell,allow_land_join_divide, |
1376 | [block_show_in_search],[agent_limit],[object_bonus],[maturity],[disable_scripts],[disable_collisions],[disable_physics], | 1379 | block_show_in_search,agent_limit,object_bonus,maturity,disable_scripts,disable_collisions,disable_physics, |
1377 | [terrain_texture_1],[terrain_texture_2],[terrain_texture_3],[terrain_texture_4],[elevation_1_nw],[elevation_2_nw],[elevation_1_ne], | 1380 | terrain_texture_1,terrain_texture_2,terrain_texture_3,terrain_texture_4,elevation_1_nw,elevation_2_nw,elevation_1_ne, |
1378 | [elevation_2_ne],[elevation_1_se],[elevation_2_se],[elevation_1_sw],[elevation_2_sw],[water_height],[terrain_raise_limit], | 1381 | elevation_2_ne,elevation_1_se,elevation_2_se,elevation_1_sw,elevation_2_sw,water_height,terrain_raise_limit, |
1379 | [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[covenant_datetime],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_datetime], [loaded_creation_id] | 1382 | terrain_lower_limit,use_estate_sun,fixed_sun,sun_position,covenant,covenant_datetime,sunvectorx, sunvectory, sunvectorz, |
1380 | ) | 1383 | ""Sandbox"", loaded_creation_datetime, loaded_creation_id |
1384 | ) | ||
1381 | VALUES | 1385 | VALUES |
1382 | (@regionUUID,@block_terraform,@block_fly,@allow_damage,@restrict_pushing,@allow_land_resell,@allow_land_join_divide, | 1386 | (:regionUUID,:block_terraform,:block_fly,:allow_damage,:restrict_pushing,:allow_land_resell,:allow_land_join_divide, |
1383 | @block_show_in_search,@agent_limit,@object_bonus,@maturity,@disable_scripts,@disable_collisions,@disable_physics, | 1387 | :block_show_in_search,:agent_limit,:object_bonus,:maturity,:disable_scripts,:disable_collisions,:disable_physics, |
1384 | @terrain_texture_1,@terrain_texture_2,@terrain_texture_3,@terrain_texture_4,@elevation_1_nw,@elevation_2_nw,@elevation_1_ne, | 1388 | :terrain_texture_1,:terrain_texture_2,:terrain_texture_3,:terrain_texture_4,:elevation_1_nw,:elevation_2_nw,:elevation_1_ne, |
1385 | @elevation_2_ne,@elevation_1_se,@elevation_2_se,@elevation_1_sw,@elevation_2_sw,@water_height,@terrain_raise_limit, | 1389 | :elevation_2_ne,:elevation_1_se,:elevation_2_se,:elevation_1_sw,:elevation_2_sw,:water_height,:terrain_raise_limit, |
1386 | @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant, @covenant_datetime, @sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_datetime, @loaded_creation_id)"; | 1390 | :terrain_lower_limit,:use_estate_sun,:fixed_sun,:sun_position,:covenant, :covenant_datetime, :sunvectorx,:sunvectory, |
1387 | 1391 | :sunvectorz, :Sandbox, :loaded_creation_datetime, :loaded_creation_id )"; | |
1388 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1392 | |
1389 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1393 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1394 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
1390 | { | 1395 | { |
1391 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | 1396 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); |
1392 | conn.Open(); | 1397 | conn.Open(); |
@@ -1578,8 +1583,8 @@ VALUES | |||
1578 | prim.TouchName = (string)primRow["TouchName"]; | 1583 | prim.TouchName = (string)primRow["TouchName"]; |
1579 | // permissions | 1584 | // permissions |
1580 | prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]); | 1585 | prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]); |
1581 | //prim.CreatorID = new UUID((Guid)primRow["CreatorID"]); | 1586 | //prim.creatorID = new UUID((Guid)primRow["creatorID"]); |
1582 | prim.CreatorIdentification = (string)primRow["CreatorID"]; | 1587 | prim.CreatorIdentification = (string)primRow["CreatorID"].ToString(); |
1583 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); | 1588 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); |
1584 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); | 1589 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); |
1585 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); | 1590 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); |
@@ -1685,13 +1690,23 @@ VALUES | |||
1685 | 1690 | ||
1686 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); | 1691 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); |
1687 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); | 1692 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); |
1688 | if (Convert.ToInt16(primRow["PassTouches"]) != 0) | 1693 | |
1689 | prim.PassTouches = true; | 1694 | prim.PassTouches = (bool)primRow["PassTouches"]; |
1690 | prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); | ||
1691 | 1695 | ||
1692 | if (!(primRow["MediaURL"] is System.DBNull)) | 1696 | if (!(primRow["MediaURL"] is System.DBNull)) |
1693 | prim.MediaUrl = (string)primRow["MediaURL"]; | 1697 | prim.MediaUrl = (string)primRow["MediaURL"]; |
1694 | 1698 | ||
1699 | if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "") | ||
1700 | prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]); | ||
1701 | else | ||
1702 | prim.DynAttrs = new DAMap(); | ||
1703 | |||
1704 | prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]); | ||
1705 | prim.Density = Convert.ToSingle(primRow["Density"]); | ||
1706 | prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]); | ||
1707 | prim.Friction = Convert.ToSingle(primRow["Friction"]); | ||
1708 | prim.Restitution = Convert.ToSingle(primRow["Restitution"]); | ||
1709 | |||
1695 | return prim; | 1710 | return prim; |
1696 | } | 1711 | } |
1697 | 1712 | ||
@@ -1749,7 +1764,6 @@ VALUES | |||
1749 | baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); | 1764 | baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); |
1750 | } | 1765 | } |
1751 | 1766 | ||
1752 | |||
1753 | return baseShape; | 1767 | return baseShape; |
1754 | } | 1768 | } |
1755 | 1769 | ||
@@ -1773,8 +1787,8 @@ VALUES | |||
1773 | taskItem.Name = (string)inventoryRow["name"]; | 1787 | taskItem.Name = (string)inventoryRow["name"]; |
1774 | taskItem.Description = (string)inventoryRow["description"]; | 1788 | taskItem.Description = (string)inventoryRow["description"]; |
1775 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); | 1789 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); |
1776 | //taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]); | 1790 | //taskItem.creatorID = new UUID((Guid)inventoryRow["creatorID"]); |
1777 | taskItem.CreatorIdentification = (string)inventoryRow["creatorID"]; | 1791 | taskItem.CreatorIdentification = (string)inventoryRow["creatorID"].ToString(); |
1778 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); | 1792 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); |
1779 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); | 1793 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); |
1780 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); | 1794 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); |
@@ -1798,9 +1812,9 @@ VALUES | |||
1798 | /// </summary> | 1812 | /// </summary> |
1799 | /// <param name="taskItem">item in inventory.</param> | 1813 | /// <param name="taskItem">item in inventory.</param> |
1800 | /// <returns></returns> | 1814 | /// <returns></returns> |
1801 | private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) | 1815 | private NpgsqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) |
1802 | { | 1816 | { |
1803 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1817 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1804 | 1818 | ||
1805 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); | 1819 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); |
1806 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); | 1820 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); |
@@ -1831,9 +1845,9 @@ VALUES | |||
1831 | /// </summary> | 1845 | /// </summary> |
1832 | /// <param name="settings">regionsettings.</param> | 1846 | /// <param name="settings">regionsettings.</param> |
1833 | /// <returns></returns> | 1847 | /// <returns></returns> |
1834 | private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings) | 1848 | private NpgsqlParameter[] CreateRegionSettingParameters(RegionSettings settings) |
1835 | { | 1849 | { |
1836 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1850 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1837 | 1851 | ||
1838 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); | 1852 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); |
1839 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); | 1853 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); |
@@ -1888,9 +1902,9 @@ VALUES | |||
1888 | /// <param name="land">land parameters.</param> | 1902 | /// <param name="land">land parameters.</param> |
1889 | /// <param name="regionUUID">region UUID.</param> | 1903 | /// <param name="regionUUID">region UUID.</param> |
1890 | /// <returns></returns> | 1904 | /// <returns></returns> |
1891 | private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) | 1905 | private NpgsqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) |
1892 | { | 1906 | { |
1893 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1907 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1894 | 1908 | ||
1895 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); | 1909 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); |
1896 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | 1910 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); |
@@ -1912,8 +1926,8 @@ VALUES | |||
1912 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); | 1926 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); |
1913 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus | 1927 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus |
1914 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); | 1928 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); |
1915 | parameters.Add(_Database.CreateParameter("LandingType", land.LandingType)); | 1929 | parameters.Add(_Database.CreateParameter("LandingType", Convert.ToInt32( land.LandingType) )); |
1916 | parameters.Add(_Database.CreateParameter("MediaAutoScale", land.MediaAutoScale)); | 1930 | parameters.Add(_Database.CreateParameter("MediaAutoScale", Convert.ToInt32( land.MediaAutoScale ))); |
1917 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); | 1931 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); |
1918 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); | 1932 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); |
1919 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); | 1933 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); |
@@ -1938,9 +1952,9 @@ VALUES | |||
1938 | /// <param name="parcelAccessEntry">parcel access entry.</param> | 1952 | /// <param name="parcelAccessEntry">parcel access entry.</param> |
1939 | /// <param name="parcelID">parcel ID.</param> | 1953 | /// <param name="parcelID">parcel ID.</param> |
1940 | /// <returns></returns> | 1954 | /// <returns></returns> |
1941 | private SqlParameter[] CreateLandAccessParameters(LandAccessEntry parcelAccessEntry, UUID parcelID) | 1955 | private NpgsqlParameter[] CreateLandAccessParameters(LandAccessEntry parcelAccessEntry, UUID parcelID) |
1942 | { | 1956 | { |
1943 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1957 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1944 | 1958 | ||
1945 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); | 1959 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); |
1946 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); | 1960 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); |
@@ -1957,9 +1971,9 @@ VALUES | |||
1957 | /// <param name="sceneGroupID">The scenegroup ID.</param> | 1971 | /// <param name="sceneGroupID">The scenegroup ID.</param> |
1958 | /// <param name="regionUUID">The region ID.</param> | 1972 | /// <param name="regionUUID">The region ID.</param> |
1959 | /// <returns></returns> | 1973 | /// <returns></returns> |
1960 | private SqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | 1974 | private NpgsqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) |
1961 | { | 1975 | { |
1962 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1976 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1963 | 1977 | ||
1964 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | 1978 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); |
1965 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | 1979 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); |
@@ -2080,12 +2094,22 @@ VALUES | |||
2080 | 2094 | ||
2081 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); | 2095 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); |
2082 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); | 2096 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); |
2083 | if (prim.PassTouches) | 2097 | |
2084 | parameters.Add(_Database.CreateParameter("PassTouches", 1)); | 2098 | parameters.Add(_Database.CreateParameter("PassTouches", prim.PassTouches)); |
2085 | else | 2099 | |
2086 | parameters.Add(_Database.CreateParameter("PassTouches", 0)); | ||
2087 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); | 2100 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); |
2088 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); | 2101 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); |
2102 | |||
2103 | if (prim.DynAttrs.CountNamespaces > 0) | ||
2104 | parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); | ||
2105 | else | ||
2106 | parameters.Add(_Database.CreateParameter("DynAttrs", null)); | ||
2107 | |||
2108 | parameters.Add(_Database.CreateParameter("PhysicsShapeType", prim.PhysicsShapeType)); | ||
2109 | parameters.Add(_Database.CreateParameter("Density", (double)prim.Density)); | ||
2110 | parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier)); | ||
2111 | parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction)); | ||
2112 | parameters.Add(_Database.CreateParameter("Restitution", (double)prim.Restitution)); | ||
2089 | 2113 | ||
2090 | return parameters.ToArray(); | 2114 | return parameters.ToArray(); |
2091 | } | 2115 | } |
@@ -2097,9 +2121,9 @@ VALUES | |||
2097 | /// <param name="sceneGroupID">The scene group ID.</param> | 2121 | /// <param name="sceneGroupID">The scene group ID.</param> |
2098 | /// <param name="regionUUID">The region UUID.</param> | 2122 | /// <param name="regionUUID">The region UUID.</param> |
2099 | /// <returns></returns> | 2123 | /// <returns></returns> |
2100 | private SqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | 2124 | private NpgsqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) |
2101 | { | 2125 | { |
2102 | List<SqlParameter> parameters = new List<SqlParameter>(); | 2126 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
2103 | 2127 | ||
2104 | PrimitiveBaseShape s = prim.Shape; | 2128 | PrimitiveBaseShape s = prim.Shape; |
2105 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | 2129 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); |
@@ -2143,7 +2167,6 @@ VALUES | |||
2143 | parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); | 2167 | parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); |
2144 | } | 2168 | } |
2145 | 2169 | ||
2146 | |||
2147 | return parameters.ToArray(); | 2170 | return parameters.ToArray(); |
2148 | } | 2171 | } |
2149 | 2172 | ||
@@ -2155,13 +2178,14 @@ VALUES | |||
2155 | { | 2178 | { |
2156 | rs.ClearSpawnPoints(); | 2179 | rs.ClearSpawnPoints(); |
2157 | 2180 | ||
2158 | string sql = "SELECT Yaw, Pitch, Distance FROM spawn_points WHERE RegionUUID = @RegionUUID"; | 2181 | string sql = @"SELECT ""Yaw"", ""Pitch"", ""Distance"" FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID"; |
2159 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 2182 | |
2160 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 2183 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
2184 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
2161 | { | 2185 | { |
2162 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID.ToString())); | 2186 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); |
2163 | conn.Open(); | 2187 | conn.Open(); |
2164 | using (SqlDataReader reader = cmd.ExecuteReader()) | 2188 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
2165 | { | 2189 | { |
2166 | if (reader.Read()) | 2190 | if (reader.Read()) |
2167 | { | 2191 | { |
@@ -2179,24 +2203,24 @@ VALUES | |||
2179 | 2203 | ||
2180 | private void SaveSpawnPoints(RegionSettings rs) | 2204 | private void SaveSpawnPoints(RegionSettings rs) |
2181 | { | 2205 | { |
2182 | string sql = "DELETE FROM spawn_points WHERE RegionUUID = @RegionUUID"; | 2206 | string sql = @"DELETE FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID"; |
2183 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 2207 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
2184 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 2208 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
2185 | { | 2209 | { |
2186 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID)); | 2210 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); |
2187 | conn.Open(); | 2211 | conn.Open(); |
2188 | cmd.ExecuteNonQuery(); | 2212 | cmd.ExecuteNonQuery(); |
2189 | } | 2213 | } |
2190 | foreach (SpawnPoint p in rs.SpawnPoints()) | 2214 | foreach (SpawnPoint p in rs.SpawnPoints()) |
2191 | { | 2215 | { |
2192 | sql = "INSERT INTO spawn_points (RegionUUID, Yaw, Pitch, Distance) VALUES (@RegionUUID, @Yaw, @Pitch, @Distance)"; | 2216 | sql = @"INSERT INTO spawn_points (""RegionUUID"", ""Yaw"", ""Pitch"", ""Distance"") VALUES (:RegionUUID, :Yaw, :Pitch, :Distance)"; |
2193 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 2217 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
2194 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 2218 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
2195 | { | 2219 | { |
2196 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID)); | 2220 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); |
2197 | cmd.Parameters.Add(_Database.CreateParameter("@Yaw", p.Yaw)); | 2221 | cmd.Parameters.Add(_Database.CreateParameter("Yaw", p.Yaw)); |
2198 | cmd.Parameters.Add(_Database.CreateParameter("@Pitch", p.Pitch)); | 2222 | cmd.Parameters.Add(_Database.CreateParameter("Pitch", p.Pitch)); |
2199 | cmd.Parameters.Add(_Database.CreateParameter("@Distance", p.Distance)); | 2223 | cmd.Parameters.Add(_Database.CreateParameter("Distance", p.Distance)); |
2200 | conn.Open(); | 2224 | conn.Open(); |
2201 | cmd.ExecuteNonQuery(); | 2225 | cmd.ExecuteNonQuery(); |
2202 | } | 2226 | } |
diff --git a/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs b/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs new file mode 100644 index 0000000..0a68b23 --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs | |||
@@ -0,0 +1,329 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using System.Text; | ||
35 | using Npgsql; | ||
36 | using log4net; | ||
37 | using System.Reflection; | ||
38 | |||
39 | namespace OpenSim.Data.PGSQL | ||
40 | { | ||
41 | public class PGSQLUserAccountData : PGSQLGenericTableHandler<UserAccountData>,IUserAccountData | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | |||
46 | public PGSQLUserAccountData(string connectionString, string realm) : | ||
47 | base(connectionString, realm, "UserAccount") | ||
48 | { | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | private string m_Realm; | ||
53 | private List<string> m_ColumnNames = null; | ||
54 | private PGSQLManager m_database; | ||
55 | |||
56 | public PGSQLUserAccountData(string connectionString, string realm) : | ||
57 | base(connectionString, realm, "UserAccount") | ||
58 | { | ||
59 | m_Realm = realm; | ||
60 | m_ConnectionString = connectionString; | ||
61 | m_database = new PGSQLManager(connectionString); | ||
62 | |||
63 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
64 | { | ||
65 | conn.Open(); | ||
66 | Migration m = new Migration(conn, GetType().Assembly, "UserAccount"); | ||
67 | m.Update(); | ||
68 | } | ||
69 | } | ||
70 | */ | ||
71 | /* | ||
72 | public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query) | ||
73 | { | ||
74 | return null; | ||
75 | } | ||
76 | */ | ||
77 | /* | ||
78 | public override UserAccountData[] Get(string[] fields, string[] keys) | ||
79 | { | ||
80 | UserAccountData[] retUA = base.Get(fields,keys); | ||
81 | |||
82 | if (retUA.Length > 0) | ||
83 | { | ||
84 | Dictionary<string, string> data = retUA[0].Data; | ||
85 | Dictionary<string, string> data2 = new Dictionary<string, string>(); | ||
86 | |||
87 | foreach (KeyValuePair<string,string> chave in data) | ||
88 | { | ||
89 | string s2 = chave.Key; | ||
90 | |||
91 | data2[s2] = chave.Value; | ||
92 | |||
93 | if (!m_FieldTypes.ContainsKey(chave.Key)) | ||
94 | { | ||
95 | string tipo = ""; | ||
96 | m_FieldTypes.TryGetValue(chave.Key, out tipo); | ||
97 | m_FieldTypes.Add(s2, tipo); | ||
98 | } | ||
99 | } | ||
100 | foreach (KeyValuePair<string, string> chave in data2) | ||
101 | { | ||
102 | if (!retUA[0].Data.ContainsKey(chave.Key)) | ||
103 | retUA[0].Data.Add(chave.Key, chave.Value); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | return retUA; | ||
108 | } | ||
109 | */ | ||
110 | /* | ||
111 | public UserAccountData Get(UUID principalID, UUID scopeID) | ||
112 | { | ||
113 | UserAccountData ret = new UserAccountData(); | ||
114 | ret.Data = new Dictionary<string, string>(); | ||
115 | |||
116 | string sql = string.Format(@"select * from {0} where ""PrincipalID"" = :principalID", m_Realm); | ||
117 | if (scopeID != UUID.Zero) | ||
118 | sql += @" and ""ScopeID"" = :scopeID"; | ||
119 | |||
120 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
121 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
122 | { | ||
123 | cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID)); | ||
124 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); | ||
125 | |||
126 | conn.Open(); | ||
127 | using (NpgsqlDataReader result = cmd.ExecuteReader()) | ||
128 | { | ||
129 | if (result.Read()) | ||
130 | { | ||
131 | ret.PrincipalID = principalID; | ||
132 | UUID scope; | ||
133 | UUID.TryParse(result["scopeid"].ToString(), out scope); | ||
134 | ret.ScopeID = scope; | ||
135 | |||
136 | if (m_ColumnNames == null) | ||
137 | { | ||
138 | m_ColumnNames = new List<string>(); | ||
139 | |||
140 | DataTable schemaTable = result.GetSchemaTable(); | ||
141 | foreach (DataRow row in schemaTable.Rows) | ||
142 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
143 | } | ||
144 | |||
145 | foreach (string s in m_ColumnNames) | ||
146 | { | ||
147 | string s2 = s; | ||
148 | if (s2 == "uuid") | ||
149 | continue; | ||
150 | if (s2 == "scopeid") | ||
151 | continue; | ||
152 | |||
153 | ret.Data[s] = result[s].ToString(); | ||
154 | } | ||
155 | return ret; | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | return null; | ||
160 | } | ||
161 | |||
162 | |||
163 | public override bool Store(UserAccountData data) | ||
164 | { | ||
165 | if (data.Data.ContainsKey("PrincipalID")) | ||
166 | data.Data.Remove("PrincipalID"); | ||
167 | if (data.Data.ContainsKey("ScopeID")) | ||
168 | data.Data.Remove("ScopeID"); | ||
169 | |||
170 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | ||
171 | |||
172 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
173 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
174 | { | ||
175 | m_log.DebugFormat("[USER]: Try to update user {0} {1}", data.FirstName, data.LastName); | ||
176 | |||
177 | StringBuilder updateBuilder = new StringBuilder(); | ||
178 | updateBuilder.AppendFormat("update {0} set ", m_Realm); | ||
179 | bool first = true; | ||
180 | foreach (string field in fields) | ||
181 | { | ||
182 | if (!first) | ||
183 | updateBuilder.Append(", "); | ||
184 | updateBuilder.AppendFormat("\"{0}\" = :{0}", field); | ||
185 | |||
186 | first = false; | ||
187 | if (m_FieldTypes.ContainsKey(field)) | ||
188 | cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field], m_FieldTypes[field])); | ||
189 | else | ||
190 | cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field])); | ||
191 | } | ||
192 | |||
193 | updateBuilder.Append(" where \"PrincipalID\" = :principalID"); | ||
194 | |||
195 | if (data.ScopeID != UUID.Zero) | ||
196 | updateBuilder.Append(" and \"ScopeID\" = :scopeID"); | ||
197 | |||
198 | cmd.CommandText = updateBuilder.ToString(); | ||
199 | cmd.Connection = conn; | ||
200 | cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID)); | ||
201 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", data.ScopeID)); | ||
202 | |||
203 | m_log.DebugFormat("[USER]: SQL update user {0} ", cmd.CommandText); | ||
204 | |||
205 | conn.Open(); | ||
206 | |||
207 | m_log.DebugFormat("[USER]: CON opened update user {0} ", cmd.CommandText); | ||
208 | |||
209 | int conta = 0; | ||
210 | try | ||
211 | { | ||
212 | conta = cmd.ExecuteNonQuery(); | ||
213 | } | ||
214 | catch (Exception e){ | ||
215 | m_log.ErrorFormat("[USER]: ERROR opened update user {0} ", e.Message); | ||
216 | } | ||
217 | |||
218 | |||
219 | if (conta < 1) | ||
220 | { | ||
221 | m_log.DebugFormat("[USER]: Try to insert user {0} {1}", data.FirstName, data.LastName); | ||
222 | |||
223 | StringBuilder insertBuilder = new StringBuilder(); | ||
224 | insertBuilder.AppendFormat(@"insert into {0} (""PrincipalID"", ""ScopeID"", ""FirstName"", ""LastName"", """, m_Realm); | ||
225 | insertBuilder.Append(String.Join(@""", """, fields)); | ||
226 | insertBuilder.Append(@""") values (:principalID, :scopeID, :FirstName, :LastName, :"); | ||
227 | insertBuilder.Append(String.Join(", :", fields)); | ||
228 | insertBuilder.Append(");"); | ||
229 | |||
230 | cmd.Parameters.Add(m_database.CreateParameter("FirstName", data.FirstName)); | ||
231 | cmd.Parameters.Add(m_database.CreateParameter("LastName", data.LastName)); | ||
232 | |||
233 | cmd.CommandText = insertBuilder.ToString(); | ||
234 | |||
235 | if (cmd.ExecuteNonQuery() < 1) | ||
236 | { | ||
237 | return false; | ||
238 | } | ||
239 | } | ||
240 | else | ||
241 | m_log.DebugFormat("[USER]: User {0} {1} exists", data.FirstName, data.LastName); | ||
242 | } | ||
243 | return true; | ||
244 | } | ||
245 | |||
246 | |||
247 | public bool Store(UserAccountData data, UUID principalID, string token) | ||
248 | { | ||
249 | return false; | ||
250 | } | ||
251 | |||
252 | |||
253 | public bool SetDataItem(UUID principalID, string item, string value) | ||
254 | { | ||
255 | string sql = string.Format(@"update {0} set {1} = :{1} where ""UUID"" = :UUID", m_Realm, item); | ||
256 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
257 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
258 | { | ||
259 | if (m_FieldTypes.ContainsKey(item)) | ||
260 | cmd.Parameters.Add(m_database.CreateParameter("" + item, value, m_FieldTypes[item])); | ||
261 | else | ||
262 | cmd.Parameters.Add(m_database.CreateParameter("" + item, value)); | ||
263 | |||
264 | cmd.Parameters.Add(m_database.CreateParameter("UUID", principalID)); | ||
265 | conn.Open(); | ||
266 | |||
267 | if (cmd.ExecuteNonQuery() > 0) | ||
268 | return true; | ||
269 | } | ||
270 | return false; | ||
271 | } | ||
272 | */ | ||
273 | /* | ||
274 | public UserAccountData[] Get(string[] keys, string[] vals) | ||
275 | { | ||
276 | return null; | ||
277 | } | ||
278 | */ | ||
279 | |||
280 | public UserAccountData[] GetUsers(UUID scopeID, string query) | ||
281 | { | ||
282 | string[] words = query.Split(new char[] { ' ' }); | ||
283 | |||
284 | for (int i = 0; i < words.Length; i++) | ||
285 | { | ||
286 | if (words[i].Length < 3) | ||
287 | { | ||
288 | if (i != words.Length - 1) | ||
289 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
290 | Array.Resize(ref words, words.Length - 1); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | if (words.Length == 0) | ||
295 | return new UserAccountData[0]; | ||
296 | |||
297 | if (words.Length > 2) | ||
298 | return new UserAccountData[0]; | ||
299 | |||
300 | string sql = ""; | ||
301 | UUID scope_id; | ||
302 | UUID.TryParse(scopeID.ToString(), out scope_id); | ||
303 | |||
304 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | ||
305 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | ||
306 | { | ||
307 | if (words.Length == 1) | ||
308 | { | ||
309 | sql = String.Format(@"select * from {0} where (""ScopeID""=:ScopeID or ""ScopeID""=:UUIDZero) and (""FirstName"" ilike :search or ""LastName"" ilike :search)", m_Realm); | ||
310 | cmd.Parameters.Add(m_database.CreateParameter("scopeID", (UUID)scope_id)); | ||
311 | cmd.Parameters.Add (m_database.CreateParameter("UUIDZero", (UUID)UUID.Zero)); | ||
312 | cmd.Parameters.Add(m_database.CreateParameter("search", "%" + words[0] + "%")); | ||
313 | } | ||
314 | else | ||
315 | { | ||
316 | sql = String.Format(@"select * from {0} where (""ScopeID""=:ScopeID or ""ScopeID""=:UUIDZero) and (""FirstName"" ilike :searchFirst or ""LastName"" ilike :searchLast)", m_Realm); | ||
317 | cmd.Parameters.Add(m_database.CreateParameter("searchFirst", "%" + words[0] + "%")); | ||
318 | cmd.Parameters.Add(m_database.CreateParameter("searchLast", "%" + words[1] + "%")); | ||
319 | cmd.Parameters.Add (m_database.CreateParameter("UUIDZero", (UUID)UUID.Zero)); | ||
320 | cmd.Parameters.Add(m_database.CreateParameter("ScopeID", (UUID)scope_id)); | ||
321 | } | ||
322 | cmd.Connection = conn; | ||
323 | cmd.CommandText = sql; | ||
324 | conn.Open(); | ||
325 | return DoQuery(cmd); | ||
326 | } | ||
327 | } | ||
328 | } | ||
329 | } | ||
diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs new file mode 100644 index 0000000..f166976 --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | |||
@@ -0,0 +1,1064 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Data; | ||
30 | using System.Reflection; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenMetaverse.StructuredData; | ||
35 | using log4net; | ||
36 | using Npgsql; | ||
37 | |||
38 | namespace OpenSim.Data.PGSQL | ||
39 | { | ||
40 | public class UserProfilesData : IProfilesData | ||
41 | { | ||
42 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected PGSQLManager m_database; | ||
45 | |||
46 | #region Properites | ||
47 | string ConnectionString | ||
48 | { | ||
49 | get; | ||
50 | set; | ||
51 | } | ||
52 | |||
53 | protected virtual Assembly Assembly | ||
54 | { | ||
55 | get { return GetType().Assembly; } | ||
56 | } | ||
57 | |||
58 | #endregion Properties | ||
59 | |||
60 | #region class Member Functions | ||
61 | public UserProfilesData(string connectionString) | ||
62 | { | ||
63 | ConnectionString = connectionString; | ||
64 | Init(); | ||
65 | } | ||
66 | |||
67 | void Init() | ||
68 | { | ||
69 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
70 | { | ||
71 | dbcon.Open(); | ||
72 | |||
73 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); | ||
74 | m.Update(); | ||
75 | m_database = new PGSQLManager(ConnectionString); | ||
76 | } | ||
77 | } | ||
78 | #endregion Member Functions | ||
79 | |||
80 | #region Classifieds Queries | ||
81 | /// <summary> | ||
82 | /// Gets the classified records. | ||
83 | /// </summary> | ||
84 | /// <returns> | ||
85 | /// Array of classified records | ||
86 | /// </returns> | ||
87 | /// <param name='creatorId'> | ||
88 | /// Creator identifier. | ||
89 | /// </param> | ||
90 | public OSDArray GetClassifiedRecords(UUID creatorId) | ||
91 | { | ||
92 | OSDArray data = new OSDArray(); | ||
93 | |||
94 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
95 | { | ||
96 | string query = @"SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id"; | ||
97 | dbcon.Open(); | ||
98 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
99 | { | ||
100 | cmd.Parameters.Add(m_database.CreateParameter("Id", creatorId)); | ||
101 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) | ||
102 | { | ||
103 | if (reader.HasRows) | ||
104 | { | ||
105 | while (reader.Read()) | ||
106 | { | ||
107 | OSDMap n = new OSDMap(); | ||
108 | UUID Id = UUID.Zero; | ||
109 | |||
110 | string Name = null; | ||
111 | try | ||
112 | { | ||
113 | Id = DBGuid.FromDB(reader["classifieduuid"]); | ||
114 | Name = Convert.ToString(reader["name"]); | ||
115 | } | ||
116 | catch (Exception e) | ||
117 | { | ||
118 | m_log.Error("[PROFILES_DATA]: UserAccount exception ", e); | ||
119 | } | ||
120 | |||
121 | n.Add("classifieduuid", OSD.FromUUID(Id)); | ||
122 | n.Add("name", OSD.FromString(Name)); | ||
123 | data.Add(n); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | return data; | ||
130 | } | ||
131 | |||
132 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | ||
133 | { | ||
134 | string query = string.Empty; | ||
135 | |||
136 | query = @"WITH upsert AS ( | ||
137 | UPDATE classifieds SET | ||
138 | classifieduuid = :ClassifiedId, creatoruuid = :CreatorId, creationdate = :CreatedDate, | ||
139 | expirationdate = :ExpirationDate,category =:Category, name = :Name, description = :Description, | ||
140 | parceluuid = :ParcelId, parentestate = :ParentEstate, snapshotuuid = :SnapshotId, | ||
141 | simname = :SimName, posglobal = :GlobalPos, parcelname = :ParcelName, classifiedflags = :Flags, | ||
142 | priceforlisting = :ListingPrice | ||
143 | RETURNING * ) | ||
144 | INSERT INTO classifieds (classifieduuid,creatoruuid,creationdate,expirationdate,category,name, | ||
145 | description,parceluuid,parentestate,snapshotuuid,simname,posglobal,parcelname,classifiedflags, | ||
146 | priceforlisting) | ||
147 | SELECT | ||
148 | :ClassifiedId,:CreatorId,:CreatedDate,:ExpirationDate,:Category,:Name,:Description, | ||
149 | :ParcelId,:ParentEstate,:SnapshotId,:SimName,:GlobalPos,:ParcelName,:Flags,:ListingPrice | ||
150 | WHERE NOT EXISTS ( | ||
151 | SELECT * FROM upsert )"; | ||
152 | |||
153 | if (string.IsNullOrEmpty(ad.ParcelName)) | ||
154 | ad.ParcelName = "Unknown"; | ||
155 | if (ad.ParcelId == null) | ||
156 | ad.ParcelId = UUID.Zero; | ||
157 | if (string.IsNullOrEmpty(ad.Description)) | ||
158 | ad.Description = "No Description"; | ||
159 | |||
160 | DateTime epoch = new DateTime(1970, 1, 1); | ||
161 | DateTime now = DateTime.Now; | ||
162 | TimeSpan epochnow = now - epoch; | ||
163 | TimeSpan duration; | ||
164 | DateTime expiration; | ||
165 | TimeSpan epochexp; | ||
166 | |||
167 | if (ad.Flags == 2) | ||
168 | { | ||
169 | duration = new TimeSpan(7, 0, 0, 0); | ||
170 | expiration = now.Add(duration); | ||
171 | epochexp = expiration - epoch; | ||
172 | } | ||
173 | else | ||
174 | { | ||
175 | duration = new TimeSpan(365, 0, 0, 0); | ||
176 | expiration = now.Add(duration); | ||
177 | epochexp = expiration - epoch; | ||
178 | } | ||
179 | ad.CreationDate = (int)epochnow.TotalSeconds; | ||
180 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | ||
181 | |||
182 | try | ||
183 | { | ||
184 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
185 | { | ||
186 | dbcon.Open(); | ||
187 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
188 | { | ||
189 | cmd.Parameters.Add(m_database.CreateParameter("ClassifiedId", ad.ClassifiedId)); | ||
190 | cmd.Parameters.Add(m_database.CreateParameter("CreatorId", ad.CreatorId)); | ||
191 | cmd.Parameters.Add(m_database.CreateParameter("CreatedDate", (int)ad.CreationDate)); | ||
192 | cmd.Parameters.Add(m_database.CreateParameter("ExpirationDate", (int)ad.ExpirationDate)); | ||
193 | cmd.Parameters.Add(m_database.CreateParameter("Category", ad.Category.ToString())); | ||
194 | cmd.Parameters.Add(m_database.CreateParameter("Name", ad.Name.ToString())); | ||
195 | cmd.Parameters.Add(m_database.CreateParameter("Description", ad.Description.ToString())); | ||
196 | cmd.Parameters.Add(m_database.CreateParameter("ParcelId", ad.ParcelId)); | ||
197 | cmd.Parameters.Add(m_database.CreateParameter("ParentEstate", (int)ad.ParentEstate)); | ||
198 | cmd.Parameters.Add(m_database.CreateParameter("SnapshotId", ad.SnapshotId)); | ||
199 | cmd.Parameters.Add(m_database.CreateParameter("SimName", ad.SimName.ToString())); | ||
200 | cmd.Parameters.Add(m_database.CreateParameter("GlobalPos", ad.GlobalPos.ToString())); | ||
201 | cmd.Parameters.Add(m_database.CreateParameter("ParcelName", ad.ParcelName.ToString())); | ||
202 | cmd.Parameters.Add(m_database.CreateParameter("Flags", (int)Convert.ToInt32(ad.Flags))); | ||
203 | cmd.Parameters.Add(m_database.CreateParameter("ListingPrice", (int)Convert.ToInt32(ad.Price))); | ||
204 | |||
205 | cmd.ExecuteNonQuery(); | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | catch (Exception e) | ||
210 | { | ||
211 | m_log.Error("[PROFILES_DATA]: ClassifiedsUpdate exception ", e); | ||
212 | result = e.Message; | ||
213 | return false; | ||
214 | } | ||
215 | |||
216 | return true; | ||
217 | } | ||
218 | |||
219 | public bool DeleteClassifiedRecord(UUID recordId) | ||
220 | { | ||
221 | string query = string.Empty; | ||
222 | |||
223 | query = @"DELETE FROM classifieds WHERE classifieduuid = :ClassifiedId ;"; | ||
224 | |||
225 | try | ||
226 | { | ||
227 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
228 | { | ||
229 | dbcon.Open(); | ||
230 | |||
231 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
232 | { | ||
233 | cmd.Parameters.Add(m_database.CreateParameter("ClassifiedId", recordId)); | ||
234 | cmd.ExecuteNonQuery(); | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | catch (Exception e) | ||
239 | { | ||
240 | m_log.Error("[PROFILES_DATA]: DeleteClassifiedRecord exception ", e); | ||
241 | return false; | ||
242 | } | ||
243 | |||
244 | return true; | ||
245 | } | ||
246 | |||
247 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | ||
248 | { | ||
249 | string query = string.Empty; | ||
250 | |||
251 | query += "SELECT * FROM classifieds WHERE "; | ||
252 | query += "classifieduuid = :AdId"; | ||
253 | |||
254 | try | ||
255 | { | ||
256 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
257 | { | ||
258 | dbcon.Open(); | ||
259 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
260 | { | ||
261 | cmd.Parameters.Add(m_database.CreateParameter("AdId", ad.ClassifiedId)); | ||
262 | |||
263 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
264 | { | ||
265 | if (reader.Read()) | ||
266 | { | ||
267 | ad.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); | ||
268 | ad.ParcelId = DBGuid.FromDB(reader["parceluuid"]); | ||
269 | ad.SnapshotId = DBGuid.FromDB(reader["snapshotuuid"]); | ||
270 | ad.CreationDate = Convert.ToInt32(reader["creationdate"]); | ||
271 | ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); | ||
272 | ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); | ||
273 | ad.Flags = (byte)Convert.ToInt16(reader["classifiedflags"]); | ||
274 | ad.Category = Convert.ToInt32(reader["category"]); | ||
275 | ad.Price = Convert.ToInt16(reader["priceforlisting"]); | ||
276 | ad.Name = reader["name"].ToString(); | ||
277 | ad.Description = reader["description"].ToString(); | ||
278 | ad.SimName = reader["simname"].ToString(); | ||
279 | ad.GlobalPos = reader["posglobal"].ToString(); | ||
280 | ad.ParcelName = reader["parcelname"].ToString(); | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | dbcon.Close(); | ||
285 | } | ||
286 | } | ||
287 | catch (Exception e) | ||
288 | { | ||
289 | m_log.Error("[PROFILES_DATA]: GetClassifiedInfo exception ", e); | ||
290 | } | ||
291 | |||
292 | return true; | ||
293 | } | ||
294 | |||
295 | public static UUID GetUUID(object uuidValue) | ||
296 | { | ||
297 | |||
298 | UUID ret = UUID.Zero; | ||
299 | |||
300 | UUID.TryParse(uuidValue.ToString(), out ret); | ||
301 | |||
302 | return ret; | ||
303 | } | ||
304 | |||
305 | #endregion Classifieds Queries | ||
306 | |||
307 | #region Picks Queries | ||
308 | public OSDArray GetAvatarPicks(UUID avatarId) | ||
309 | { | ||
310 | string query = string.Empty; | ||
311 | |||
312 | query += "SELECT pickuuid, name FROM userpicks WHERE "; | ||
313 | query += "creatoruuid = :Id"; | ||
314 | OSDArray data = new OSDArray(); | ||
315 | |||
316 | try | ||
317 | { | ||
318 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
319 | { | ||
320 | dbcon.Open(); | ||
321 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
322 | { | ||
323 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | ||
324 | |||
325 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
326 | { | ||
327 | if (reader.HasRows) | ||
328 | { | ||
329 | while (reader.Read()) | ||
330 | { | ||
331 | OSDMap record = new OSDMap(); | ||
332 | |||
333 | record.Add("pickuuid", OSD.FromUUID(DBGuid.FromDB(reader["pickuuid"]))); | ||
334 | record.Add("name", OSD.FromString((string)reader["name"])); | ||
335 | data.Add(record); | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | catch (Exception e) | ||
343 | { | ||
344 | m_log.Error("[PROFILES_DATA]: GetAvatarPicks exception ", e); | ||
345 | } | ||
346 | |||
347 | return data; | ||
348 | } | ||
349 | |||
350 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | ||
351 | { | ||
352 | string query = string.Empty; | ||
353 | UserProfilePick pick = new UserProfilePick(); | ||
354 | |||
355 | query += "SELECT * FROM userpicks WHERE "; | ||
356 | query += "creatoruuid = :CreatorId AND "; | ||
357 | query += "pickuuid = :PickId"; | ||
358 | |||
359 | try | ||
360 | { | ||
361 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
362 | { | ||
363 | dbcon.Open(); | ||
364 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
365 | { | ||
366 | cmd.Parameters.Add(m_database.CreateParameter("CreatorId", avatarId)); | ||
367 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId)); | ||
368 | |||
369 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
370 | { | ||
371 | if (reader.HasRows) | ||
372 | { | ||
373 | reader.Read(); | ||
374 | |||
375 | string description = (string)reader["description"]; | ||
376 | |||
377 | if (string.IsNullOrEmpty(description)) | ||
378 | description = "No description given."; | ||
379 | |||
380 | pick.PickId = DBGuid.FromDB(reader["pickuuid"]); | ||
381 | pick.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); | ||
382 | pick.ParcelId = DBGuid.FromDB(reader["parceluuid"]); | ||
383 | pick.SnapshotId = DBGuid.FromDB(reader["snapshotuuid"]); | ||
384 | pick.GlobalPos = (string)reader["posglobal"].ToString(); | ||
385 | pick.TopPick = Convert.ToBoolean(reader["toppick"]); | ||
386 | pick.Enabled = Convert.ToBoolean(reader["enabled"]); | ||
387 | pick.Name = reader["name"].ToString(); | ||
388 | pick.Desc = reader["description"].ToString(); | ||
389 | pick.ParcelName = reader["user"].ToString(); | ||
390 | pick.OriginalName = reader["originalname"].ToString(); | ||
391 | pick.SimName = reader["simname"].ToString(); | ||
392 | pick.SortOrder = (int)reader["sortorder"]; | ||
393 | } | ||
394 | } | ||
395 | } | ||
396 | dbcon.Close(); | ||
397 | } | ||
398 | } | ||
399 | catch (Exception e) | ||
400 | { | ||
401 | m_log.Error("[PROFILES_DATA]: GetPickInfo exception ", e); | ||
402 | } | ||
403 | |||
404 | return pick; | ||
405 | } | ||
406 | |||
407 | public bool UpdatePicksRecord(UserProfilePick pick) | ||
408 | { | ||
409 | string query = string.Empty; | ||
410 | |||
411 | |||
412 | query = @"WITH upsert AS ( | ||
413 | UPDATE userpicks SET | ||
414 | pickuuid = :PickId, creatoruuid = :CreatorId, toppick = :TopPick, parceluuid = :ParcelId, | ||
415 | name = :Name, description = :Desc, snapshotuuid = :SnapshotId, ""user"" = :User, | ||
416 | originalname = :Original, simname = :SimName, posglobal = :GlobalPos, | ||
417 | sortorder = :SortOrder, enabled = :Enabled | ||
418 | RETURNING * ) | ||
419 | INSERT INTO userpicks (pickuuid,creatoruuid,toppick,parceluuid,name,description, | ||
420 | snapshotuuid,""user"",originalname,simname,posglobal,sortorder,enabled) | ||
421 | SELECT | ||
422 | :PickId,:CreatorId,:TopPick,:ParcelId,:Name,:Desc,:SnapshotId,:User, | ||
423 | :Original,:SimName,:GlobalPos,:SortOrder,:Enabled | ||
424 | WHERE NOT EXISTS ( | ||
425 | SELECT * FROM upsert )"; | ||
426 | |||
427 | try | ||
428 | { | ||
429 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
430 | { | ||
431 | dbcon.Open(); | ||
432 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
433 | { | ||
434 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pick.PickId)); | ||
435 | cmd.Parameters.Add(m_database.CreateParameter("CreatorId", pick.CreatorId)); | ||
436 | cmd.Parameters.Add(m_database.CreateParameter("TopPick", pick.TopPick)); | ||
437 | cmd.Parameters.Add(m_database.CreateParameter("ParcelId", pick.ParcelId)); | ||
438 | cmd.Parameters.Add(m_database.CreateParameter("Name", pick.Name)); | ||
439 | cmd.Parameters.Add(m_database.CreateParameter("Desc", pick.Desc)); | ||
440 | cmd.Parameters.Add(m_database.CreateParameter("SnapshotId", pick.SnapshotId)); | ||
441 | cmd.Parameters.Add(m_database.CreateParameter("User", pick.ParcelName)); | ||
442 | cmd.Parameters.Add(m_database.CreateParameter("Original", pick.OriginalName)); | ||
443 | cmd.Parameters.Add(m_database.CreateParameter("SimName", pick.SimName)); | ||
444 | cmd.Parameters.Add(m_database.CreateParameter("GlobalPos", pick.GlobalPos)); | ||
445 | cmd.Parameters.Add(m_database.CreateParameter("SortOrder", pick.SortOrder)); | ||
446 | cmd.Parameters.Add(m_database.CreateParameter("Enabled", pick.Enabled)); | ||
447 | |||
448 | cmd.ExecuteNonQuery(); | ||
449 | } | ||
450 | } | ||
451 | } | ||
452 | catch (Exception e) | ||
453 | { | ||
454 | m_log.Error("[PROFILES_DATA]: UpdateAvatarNotes exception ", e); | ||
455 | return false; | ||
456 | } | ||
457 | |||
458 | return true; | ||
459 | } | ||
460 | |||
461 | public bool DeletePicksRecord(UUID pickId) | ||
462 | { | ||
463 | string query = string.Empty; | ||
464 | |||
465 | query += "DELETE FROM userpicks WHERE "; | ||
466 | query += "pickuuid = :PickId"; | ||
467 | |||
468 | try | ||
469 | { | ||
470 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
471 | { | ||
472 | dbcon.Open(); | ||
473 | |||
474 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
475 | { | ||
476 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId)); | ||
477 | |||
478 | cmd.ExecuteNonQuery(); | ||
479 | } | ||
480 | } | ||
481 | } | ||
482 | catch (Exception e) | ||
483 | { | ||
484 | m_log.Error("[PROFILES_DATA]: DeleteUserPickRecord exception ", e); | ||
485 | return false; | ||
486 | } | ||
487 | |||
488 | return true; | ||
489 | } | ||
490 | |||
491 | #endregion Picks Queries | ||
492 | |||
493 | #region Avatar Notes Queries | ||
494 | |||
495 | public bool GetAvatarNotes(ref UserProfileNotes notes) | ||
496 | { // WIP | ||
497 | string query = string.Empty; | ||
498 | |||
499 | query += "SELECT notes FROM usernotes WHERE "; | ||
500 | query += "useruuid = :Id AND "; | ||
501 | query += "targetuuid = :TargetId"; | ||
502 | OSDArray data = new OSDArray(); | ||
503 | |||
504 | try | ||
505 | { | ||
506 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
507 | { | ||
508 | dbcon.Open(); | ||
509 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
510 | { | ||
511 | cmd.Parameters.Add(m_database.CreateParameter("Id", notes.UserId)); | ||
512 | cmd.Parameters.Add(m_database.CreateParameter("TargetId", notes.TargetId)); | ||
513 | |||
514 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
515 | { | ||
516 | if (reader.HasRows) | ||
517 | { | ||
518 | reader.Read(); | ||
519 | notes.Notes = OSD.FromString((string)reader["notes"]); | ||
520 | } | ||
521 | } | ||
522 | } | ||
523 | } | ||
524 | } | ||
525 | catch (Exception e) | ||
526 | { | ||
527 | m_log.Error("[PROFILES_DATA]: GetAvatarNotes exception ", e); | ||
528 | } | ||
529 | |||
530 | return true; | ||
531 | } | ||
532 | |||
533 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | ||
534 | { | ||
535 | string query = string.Empty; | ||
536 | bool remove; | ||
537 | |||
538 | if (string.IsNullOrEmpty(note.Notes)) | ||
539 | { | ||
540 | remove = true; | ||
541 | query += "DELETE FROM usernotes WHERE "; | ||
542 | query += "useruuid=:UserId AND "; | ||
543 | query += "targetuuid=:TargetId"; | ||
544 | } | ||
545 | else | ||
546 | { | ||
547 | remove = false; | ||
548 | |||
549 | query = @"WITH upsert AS ( | ||
550 | UPDATE usernotes SET notes = :Notes, useruuid = :UserId, targetuuid = :TargetId RETURNING * ) | ||
551 | INSERT INTO usernotes (notes,useruuid,targetuuid) | ||
552 | SELECT :Notes,:UserId,:TargetId | ||
553 | WHERE NOT EXISTS ( | ||
554 | SELECT * FROM upsert | ||
555 | )"; | ||
556 | } | ||
557 | |||
558 | try | ||
559 | { | ||
560 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
561 | { | ||
562 | dbcon.Open(); | ||
563 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
564 | { | ||
565 | if (!remove) | ||
566 | cmd.Parameters.Add(m_database.CreateParameter("Notes", note.Notes)); | ||
567 | |||
568 | cmd.Parameters.Add(m_database.CreateParameter("TargetId", note.TargetId)); | ||
569 | cmd.Parameters.Add(m_database.CreateParameter("UserId", note.UserId)); | ||
570 | |||
571 | cmd.ExecuteNonQuery(); | ||
572 | } | ||
573 | } | ||
574 | } | ||
575 | catch (Exception e) | ||
576 | { | ||
577 | m_log.Error("[PROFILES_DATA]: UpdateAvatarNotes exception ", e); | ||
578 | return false; | ||
579 | } | ||
580 | |||
581 | return true; | ||
582 | } | ||
583 | |||
584 | #endregion Avatar Notes Queries | ||
585 | |||
586 | #region Avatar Properties | ||
587 | |||
588 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | ||
589 | { | ||
590 | string query = string.Empty; | ||
591 | |||
592 | query += "SELECT * FROM userprofile WHERE "; | ||
593 | query += "useruuid = :Id"; | ||
594 | |||
595 | try | ||
596 | { | ||
597 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
598 | { | ||
599 | dbcon.Open(); | ||
600 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
601 | { | ||
602 | cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId)); | ||
603 | |||
604 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
605 | { | ||
606 | if (reader.HasRows) | ||
607 | { | ||
608 | // m_log.DebugFormat("[PROFILES_DATA]" + | ||
609 | // ": Getting data for {0}.", props.UserId); | ||
610 | reader.Read(); | ||
611 | props.WebUrl = (string)reader["profileURL"].ToString(); | ||
612 | props.ImageId = DBGuid.FromDB(reader["profileImage"]); | ||
613 | props.AboutText = (string)reader["profileAboutText"]; | ||
614 | props.FirstLifeImageId = DBGuid.FromDB(reader["profileFirstImage"]); | ||
615 | props.FirstLifeText = (string)reader["profileFirstText"]; | ||
616 | props.PartnerId = DBGuid.FromDB(reader["profilePartner"]); | ||
617 | props.WantToMask = (int)reader["profileWantToMask"]; | ||
618 | props.WantToText = (string)reader["profileWantToText"]; | ||
619 | props.SkillsMask = (int)reader["profileSkillsMask"]; | ||
620 | props.SkillsText = (string)reader["profileSkillsText"]; | ||
621 | props.Language = (string)reader["profileLanguages"]; | ||
622 | } | ||
623 | else | ||
624 | { | ||
625 | //m_log.DebugFormat("[PROFILES_DATA]" + | ||
626 | // ": No data for {0}", props.UserId); | ||
627 | |||
628 | props.WebUrl = string.Empty; | ||
629 | props.ImageId = UUID.Zero; | ||
630 | props.AboutText = string.Empty; | ||
631 | props.FirstLifeImageId = UUID.Zero; | ||
632 | props.FirstLifeText = string.Empty; | ||
633 | props.PartnerId = UUID.Zero; | ||
634 | props.WantToMask = 0; | ||
635 | props.WantToText = string.Empty; | ||
636 | props.SkillsMask = 0; | ||
637 | props.SkillsText = string.Empty; | ||
638 | props.Language = string.Empty; | ||
639 | props.PublishProfile = false; | ||
640 | props.PublishMature = false; | ||
641 | |||
642 | query = "INSERT INTO userprofile ("; | ||
643 | query += "useruuid, "; | ||
644 | query += "\"profilePartner\", "; | ||
645 | query += "\"profileAllowPublish\", "; | ||
646 | query += "\"profileMaturePublish\", "; | ||
647 | query += "\"profileURL\", "; | ||
648 | query += "\"profileWantToMask\", "; | ||
649 | query += "\"profileWantToText\", "; | ||
650 | query += "\"profileSkillsMask\", "; | ||
651 | query += "\"profileSkillsText\", "; | ||
652 | query += "\"profileLanguages\", "; | ||
653 | query += "\"profileImage\", "; | ||
654 | query += "\"profileAboutText\", "; | ||
655 | query += "\"profileFirstImage\", "; | ||
656 | query += "\"profileFirstText\") VALUES ("; | ||
657 | query += ":userId, "; | ||
658 | query += ":profilePartner, "; | ||
659 | query += ":profileAllowPublish, "; | ||
660 | query += ":profileMaturePublish, "; | ||
661 | query += ":profileURL, "; | ||
662 | query += ":profileWantToMask, "; | ||
663 | query += ":profileWantToText, "; | ||
664 | query += ":profileSkillsMask, "; | ||
665 | query += ":profileSkillsText, "; | ||
666 | query += ":profileLanguages, "; | ||
667 | query += ":profileImage, "; | ||
668 | query += ":profileAboutText, "; | ||
669 | query += ":profileFirstImage, "; | ||
670 | query += ":profileFirstText)"; | ||
671 | |||
672 | dbcon.Close(); | ||
673 | dbcon.Open(); | ||
674 | |||
675 | using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon)) | ||
676 | { | ||
677 | //m_log.DebugFormat("[PROFILES_DATA]" + | ||
678 | // ": Adding new data for {0}", props.UserId); | ||
679 | |||
680 | put.Parameters.Add(m_database.CreateParameter("userId", props.UserId)); | ||
681 | put.Parameters.Add(m_database.CreateParameter("profilePartner", props.PartnerId)); | ||
682 | put.Parameters.Add(m_database.CreateParameter("profileAllowPublish", props.PublishProfile)); | ||
683 | put.Parameters.Add(m_database.CreateParameter("profileMaturePublish", props.PublishMature)); | ||
684 | put.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl)); | ||
685 | put.Parameters.Add(m_database.CreateParameter("profileWantToMask", props.WantToMask)); | ||
686 | put.Parameters.Add(m_database.CreateParameter("profileWantToText", props.WantToText)); | ||
687 | put.Parameters.Add(m_database.CreateParameter("profileSkillsMask", props.SkillsMask)); | ||
688 | put.Parameters.Add(m_database.CreateParameter("profileSkillsText", props.SkillsText)); | ||
689 | put.Parameters.Add(m_database.CreateParameter("profileLanguages", props.Language)); | ||
690 | put.Parameters.Add(m_database.CreateParameter("profileImage", props.ImageId)); | ||
691 | put.Parameters.Add(m_database.CreateParameter("profileAboutText", props.AboutText)); | ||
692 | put.Parameters.Add(m_database.CreateParameter("profileFirstImage", props.FirstLifeImageId)); | ||
693 | put.Parameters.Add(m_database.CreateParameter("profileFirstText", props.FirstLifeText)); | ||
694 | |||
695 | put.ExecuteNonQuery(); | ||
696 | } | ||
697 | } | ||
698 | } | ||
699 | } | ||
700 | } | ||
701 | } | ||
702 | catch (Exception e) | ||
703 | { | ||
704 | m_log.Error("[PROFILES_DATA]: GetAvatarProperties exception ", e); | ||
705 | result = e.Message; | ||
706 | return false; | ||
707 | } | ||
708 | |||
709 | return true; | ||
710 | } | ||
711 | |||
712 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | ||
713 | { | ||
714 | string query = string.Empty; | ||
715 | |||
716 | query += "UPDATE userprofile SET "; | ||
717 | query += "\"profileURL\"=:profileURL, "; | ||
718 | query += "\"profileImage\"=:image, "; | ||
719 | query += "\"profileAboutText\"=:abouttext,"; | ||
720 | query += "\"profileFirstImage\"=:firstlifeimage,"; | ||
721 | query += "\"profileFirstText\"=:firstlifetext "; | ||
722 | query += "WHERE \"useruuid\"=:uuid"; | ||
723 | |||
724 | try | ||
725 | { | ||
726 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
727 | { | ||
728 | dbcon.Open(); | ||
729 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
730 | { | ||
731 | cmd.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl)); | ||
732 | cmd.Parameters.Add(m_database.CreateParameter("image", props.ImageId)); | ||
733 | cmd.Parameters.Add(m_database.CreateParameter("abouttext", props.AboutText)); | ||
734 | cmd.Parameters.Add(m_database.CreateParameter("firstlifeimage", props.FirstLifeImageId)); | ||
735 | cmd.Parameters.Add(m_database.CreateParameter("firstlifetext", props.FirstLifeText)); | ||
736 | cmd.Parameters.Add(m_database.CreateParameter("uuid", props.UserId)); | ||
737 | |||
738 | cmd.ExecuteNonQuery(); | ||
739 | } | ||
740 | } | ||
741 | } | ||
742 | catch (Exception e) | ||
743 | { | ||
744 | m_log.Error("[PROFILES_DATA]: AgentPropertiesUpdate exception ", e); | ||
745 | return false; | ||
746 | } | ||
747 | |||
748 | return true; | ||
749 | } | ||
750 | |||
751 | #endregion Avatar Properties | ||
752 | |||
753 | #region Avatar Interests | ||
754 | |||
755 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | ||
756 | { | ||
757 | string query = string.Empty; | ||
758 | |||
759 | query += "UPDATE userprofile SET "; | ||
760 | query += "\"profileWantToMask\"=:WantMask, "; | ||
761 | query += "\"profileWantToText\"=:WantText,"; | ||
762 | query += "\"profileSkillsMask\"=:SkillsMask,"; | ||
763 | query += "\"profileSkillsText\"=:SkillsText, "; | ||
764 | query += "\"profileLanguages\"=:Languages "; | ||
765 | query += "WHERE \"useruuid\"=:uuid"; | ||
766 | |||
767 | try | ||
768 | { | ||
769 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
770 | { | ||
771 | dbcon.Open(); | ||
772 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
773 | { | ||
774 | cmd.Parameters.Add(m_database.CreateParameter("WantMask", up.WantToMask)); | ||
775 | cmd.Parameters.Add(m_database.CreateParameter("WantText", up.WantToText)); | ||
776 | cmd.Parameters.Add(m_database.CreateParameter("SkillsMask", up.SkillsMask)); | ||
777 | cmd.Parameters.Add(m_database.CreateParameter("SkillsText", up.SkillsText)); | ||
778 | cmd.Parameters.Add(m_database.CreateParameter("Languages", up.Language)); | ||
779 | cmd.Parameters.Add(m_database.CreateParameter("uuid", up.UserId)); | ||
780 | |||
781 | cmd.ExecuteNonQuery(); | ||
782 | } | ||
783 | } | ||
784 | } | ||
785 | catch (Exception e) | ||
786 | { | ||
787 | m_log.Error("[PROFILES_DATA]: UpdateAvatarInterests exception ", e); | ||
788 | result = e.Message; | ||
789 | return false; | ||
790 | } | ||
791 | |||
792 | return true; | ||
793 | } | ||
794 | |||
795 | #endregion Avatar Interests | ||
796 | |||
797 | public OSDArray GetUserImageAssets(UUID avatarId) | ||
798 | { | ||
799 | OSDArray data = new OSDArray(); | ||
800 | string query = "SELECT \"snapshotuuid\" FROM {0} WHERE \"creatoruuid\" = :Id"; | ||
801 | |||
802 | try | ||
803 | { | ||
804 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
805 | { | ||
806 | dbcon.Open(); | ||
807 | |||
808 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"classifieds\""), dbcon)) | ||
809 | { | ||
810 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | ||
811 | |||
812 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
813 | { | ||
814 | if (reader.HasRows) | ||
815 | { | ||
816 | while (reader.Read()) | ||
817 | { | ||
818 | data.Add(new OSDString(reader["snapshotuuid"].ToString())); | ||
819 | } | ||
820 | } | ||
821 | } | ||
822 | } | ||
823 | |||
824 | dbcon.Close(); | ||
825 | dbcon.Open(); | ||
826 | |||
827 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"userpicks\""), dbcon)) | ||
828 | { | ||
829 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | ||
830 | |||
831 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
832 | { | ||
833 | if (reader.HasRows) | ||
834 | { | ||
835 | while (reader.Read()) | ||
836 | { | ||
837 | data.Add(new OSDString(reader["snapshotuuid"].ToString())); | ||
838 | } | ||
839 | } | ||
840 | } | ||
841 | } | ||
842 | |||
843 | dbcon.Close(); | ||
844 | dbcon.Open(); | ||
845 | |||
846 | query = "SELECT \"profileImage\", \"profileFirstImage\" FROM \"userprofile\" WHERE \"useruuid\" = :Id"; | ||
847 | |||
848 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"userpicks\""), dbcon)) | ||
849 | { | ||
850 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | ||
851 | |||
852 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
853 | { | ||
854 | if (reader.HasRows) | ||
855 | { | ||
856 | while (reader.Read()) | ||
857 | { | ||
858 | data.Add(new OSDString(reader["profileImage"].ToString())); | ||
859 | data.Add(new OSDString(reader["profileFirstImage"].ToString())); | ||
860 | } | ||
861 | } | ||
862 | } | ||
863 | } | ||
864 | } | ||
865 | } | ||
866 | catch (Exception e) | ||
867 | { | ||
868 | m_log.Error("[PROFILES_DATA]: GetUserImageAssets exception ", e); | ||
869 | } | ||
870 | |||
871 | return data; | ||
872 | } | ||
873 | |||
874 | #region User Preferences | ||
875 | |||
876 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | ||
877 | { | ||
878 | string query = string.Empty; | ||
879 | |||
880 | query += "SELECT imviaemail::VARCHAR,visible::VARCHAR,email FROM "; | ||
881 | query += "usersettings WHERE "; | ||
882 | query += "useruuid = :Id"; | ||
883 | |||
884 | OSDArray data = new OSDArray(); | ||
885 | |||
886 | try | ||
887 | { | ||
888 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
889 | { | ||
890 | dbcon.Open(); | ||
891 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
892 | { | ||
893 | cmd.Parameters.Add(m_database.CreateParameter("Id", pref.UserId)); | ||
894 | |||
895 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
896 | { | ||
897 | if (reader.HasRows) | ||
898 | { | ||
899 | reader.Read(); | ||
900 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | ||
901 | bool.TryParse((string)reader["visible"], out pref.Visible); | ||
902 | pref.EMail = (string)reader["email"]; | ||
903 | } | ||
904 | else | ||
905 | { | ||
906 | using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon)) | ||
907 | { | ||
908 | put.Parameters.Add(m_database.CreateParameter("Id", pref.UserId)); | ||
909 | query = "INSERT INTO usersettings VALUES "; | ||
910 | query += "(:Id,'false','false', '')"; | ||
911 | |||
912 | put.ExecuteNonQuery(); | ||
913 | } | ||
914 | } | ||
915 | } | ||
916 | } | ||
917 | } | ||
918 | } | ||
919 | catch (Exception e) | ||
920 | { | ||
921 | m_log.Error("[PROFILES_DATA]: GetUserPreferences exception ", e); | ||
922 | result = e.Message; | ||
923 | } | ||
924 | |||
925 | return true; | ||
926 | } | ||
927 | |||
928 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | ||
929 | { | ||
930 | string query = string.Empty; | ||
931 | |||
932 | query += "UPDATE usersettings SET "; | ||
933 | query += "imviaemail=:ImViaEmail, "; | ||
934 | query += "visible=:Visible, "; | ||
935 | query += "email=:Email "; | ||
936 | query += "WHERE useruuid=:uuid"; | ||
937 | |||
938 | try | ||
939 | { | ||
940 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
941 | { | ||
942 | dbcon.Open(); | ||
943 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
944 | { | ||
945 | cmd.Parameters.Add(m_database.CreateParameter("ImViaEmail", pref.IMViaEmail)); | ||
946 | cmd.Parameters.Add(m_database.CreateParameter("Visible", pref.Visible)); | ||
947 | cmd.Parameters.Add(m_database.CreateParameter("EMail", pref.EMail.ToString().ToLower())); | ||
948 | cmd.Parameters.Add(m_database.CreateParameter("uuid", pref.UserId)); | ||
949 | |||
950 | cmd.ExecuteNonQuery(); | ||
951 | } | ||
952 | } | ||
953 | } | ||
954 | catch (Exception e) | ||
955 | { | ||
956 | m_log.Error("[PROFILES_DATA]: UpdateUserPreferences exception ", e); | ||
957 | result = e.Message; | ||
958 | return false; | ||
959 | } | ||
960 | |||
961 | return true; | ||
962 | } | ||
963 | |||
964 | #endregion User Preferences | ||
965 | |||
966 | #region Integration | ||
967 | |||
968 | public bool GetUserAppData(ref UserAppData props, ref string result) | ||
969 | { | ||
970 | string query = string.Empty; | ||
971 | |||
972 | query += "SELECT * FROM userdata WHERE "; | ||
973 | query += "\"UserId\" = :Id AND "; | ||
974 | query += "\"TagId\" = :TagId"; | ||
975 | |||
976 | try | ||
977 | { | ||
978 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
979 | { | ||
980 | dbcon.Open(); | ||
981 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
982 | { | ||
983 | cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId)); | ||
984 | cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId)); | ||
985 | |||
986 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
987 | { | ||
988 | if (reader.HasRows) | ||
989 | { | ||
990 | reader.Read(); | ||
991 | props.DataKey = (string)reader["DataKey"]; | ||
992 | props.DataVal = (string)reader["DataVal"]; | ||
993 | } | ||
994 | else | ||
995 | { | ||
996 | query += "INSERT INTO userdata VALUES ( "; | ||
997 | query += ":UserId,"; | ||
998 | query += ":TagId,"; | ||
999 | query += ":DataKey,"; | ||
1000 | query += ":DataVal) "; | ||
1001 | |||
1002 | using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon)) | ||
1003 | { | ||
1004 | put.Parameters.Add(m_database.CreateParameter("UserId", props.UserId)); | ||
1005 | put.Parameters.Add(m_database.CreateParameter("TagId", props.TagId)); | ||
1006 | put.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString())); | ||
1007 | put.Parameters.Add(m_database.CreateParameter("DataVal", props.DataVal.ToString())); | ||
1008 | |||
1009 | put.ExecuteNonQuery(); | ||
1010 | } | ||
1011 | } | ||
1012 | } | ||
1013 | } | ||
1014 | } | ||
1015 | } | ||
1016 | catch (Exception e) | ||
1017 | { | ||
1018 | m_log.Error("[PROFILES_DATA]: GetUserAppData exception ", e); | ||
1019 | result = e.Message; | ||
1020 | return false; | ||
1021 | } | ||
1022 | |||
1023 | return true; | ||
1024 | } | ||
1025 | |||
1026 | public bool SetUserAppData(UserAppData props, ref string result) | ||
1027 | { | ||
1028 | string query = string.Empty; | ||
1029 | |||
1030 | query += "UPDATE userdata SET "; | ||
1031 | query += "\"TagId\" = :TagId, "; | ||
1032 | query += "\"DataKey\" = :DataKey, "; | ||
1033 | query += "\"DataVal\" = :DataVal WHERE "; | ||
1034 | query += "\"UserId\" = :UserId AND "; | ||
1035 | query += "\"TagId\" = :TagId"; | ||
1036 | |||
1037 | try | ||
1038 | { | ||
1039 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | ||
1040 | { | ||
1041 | dbcon.Open(); | ||
1042 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | ||
1043 | { | ||
1044 | cmd.Parameters.Add(m_database.CreateParameter("UserId", props.UserId.ToString())); | ||
1045 | cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId.ToString())); | ||
1046 | cmd.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString())); | ||
1047 | cmd.Parameters.Add(m_database.CreateParameter("DataVal", props.DataKey.ToString())); | ||
1048 | |||
1049 | cmd.ExecuteNonQuery(); | ||
1050 | } | ||
1051 | } | ||
1052 | } | ||
1053 | catch (Exception e) | ||
1054 | { | ||
1055 | m_log.Error("[PROFILES_DATA]: SetUserData exception ", e); | ||
1056 | return false; | ||
1057 | } | ||
1058 | |||
1059 | return true; | ||
1060 | } | ||
1061 | |||
1062 | #endregion Integration | ||
1063 | } | ||
1064 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs new file mode 100644 index 0000000..4f682f0 --- /dev/null +++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs | |||
@@ -0,0 +1,587 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.IO; | ||
32 | using System.IO.Compression; | ||
33 | using System.Reflection; | ||
34 | using System.Security.Cryptography; | ||
35 | using System.Text; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Data; | ||
40 | using Npgsql; | ||
41 | |||
42 | namespace OpenSim.Data.PGSQL | ||
43 | { | ||
44 | public class PGSQLXAssetData : IXAssetDataPlugin | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected virtual Assembly Assembly | ||
49 | { | ||
50 | get { return GetType().Assembly; } | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Number of days that must pass before we update the access time on an asset when it has been fetched. | ||
55 | /// </summary> | ||
56 | private const int DaysBetweenAccessTimeUpdates = 30; | ||
57 | |||
58 | private bool m_enableCompression = false; | ||
59 | private PGSQLManager m_database; | ||
60 | private string m_connectionString; | ||
61 | private object m_dbLock = new object(); | ||
62 | |||
63 | /// <summary> | ||
64 | /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock | ||
65 | /// </summary> | ||
66 | private HashAlgorithm hasher = new SHA256CryptoServiceProvider(); | ||
67 | |||
68 | #region IPlugin Members | ||
69 | |||
70 | public string Version { get { return "1.0.0.0"; } } | ||
71 | |||
72 | /// <summary> | ||
73 | /// <para>Initialises Asset interface</para> | ||
74 | /// <para> | ||
75 | /// <list type="bullet"> | ||
76 | /// <item>Loads and initialises the PGSQL storage plugin.</item> | ||
77 | /// <item>Warns and uses the obsolete pgsql_connection.ini if connect string is empty.</item> | ||
78 | /// <item>Check for migration</item> | ||
79 | /// </list> | ||
80 | /// </para> | ||
81 | /// </summary> | ||
82 | /// <param name="connect">connect string</param> | ||
83 | public void Initialise(string connect) | ||
84 | { | ||
85 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | ||
86 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | ||
87 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | ||
88 | m_log.ErrorFormat("[PGSQL XASSETDATA]: THIS PLUGIN IS STRICTLY EXPERIMENTAL."); | ||
89 | m_log.ErrorFormat("[PGSQL XASSETDATA]: DO NOT USE FOR ANY DATA THAT YOU DO NOT MIND LOSING."); | ||
90 | m_log.ErrorFormat("[PGSQL XASSETDATA]: DATABASE TABLES CAN CHANGE AT ANY TIME, CAUSING EXISTING DATA TO BE LOST."); | ||
91 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | ||
92 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | ||
93 | m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************"); | ||
94 | |||
95 | m_connectionString = connect; | ||
96 | m_database = new PGSQLManager(m_connectionString); | ||
97 | |||
98 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
99 | { | ||
100 | dbcon.Open(); | ||
101 | Migration m = new Migration(dbcon, Assembly, "XAssetStore"); | ||
102 | m.Update(); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | public void Initialise() | ||
107 | { | ||
108 | throw new NotImplementedException(); | ||
109 | } | ||
110 | |||
111 | public void Dispose() { } | ||
112 | |||
113 | /// <summary> | ||
114 | /// The name of this DB provider | ||
115 | /// </summary> | ||
116 | public string Name | ||
117 | { | ||
118 | get { return "PGSQL XAsset storage engine"; } | ||
119 | } | ||
120 | |||
121 | #endregion | ||
122 | |||
123 | #region IAssetDataPlugin Members | ||
124 | |||
125 | /// <summary> | ||
126 | /// Fetch Asset <paramref name="assetID"/> from database | ||
127 | /// </summary> | ||
128 | /// <param name="assetID">Asset UUID to fetch</param> | ||
129 | /// <returns>Return the asset</returns> | ||
130 | /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks> | ||
131 | public AssetBase GetAsset(UUID assetID) | ||
132 | { | ||
133 | // m_log.DebugFormat("[PGSQL XASSET DATA]: Looking for asset {0}", assetID); | ||
134 | |||
135 | AssetBase asset = null; | ||
136 | lock (m_dbLock) | ||
137 | { | ||
138 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
139 | { | ||
140 | dbcon.Open(); | ||
141 | |||
142 | using (NpgsqlCommand cmd = new NpgsqlCommand( | ||
143 | @"SELECT name, description, access_time, ""AssetType"", local, temporary, asset_flags, creatorid, data | ||
144 | FROM XAssetsMeta | ||
145 | JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID", | ||
146 | dbcon)) | ||
147 | { | ||
148 | cmd.Parameters.Add(m_database.CreateParameter("ID", assetID)); | ||
149 | |||
150 | try | ||
151 | { | ||
152 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
153 | { | ||
154 | if (dbReader.Read()) | ||
155 | { | ||
156 | asset = new AssetBase( | ||
157 | assetID, | ||
158 | (string)dbReader["name"], | ||
159 | Convert.ToSByte(dbReader["AssetType"]), | ||
160 | dbReader["creatorid"].ToString()); | ||
161 | |||
162 | asset.Data = (byte[])dbReader["data"]; | ||
163 | asset.Description = (string)dbReader["description"]; | ||
164 | |||
165 | string local = dbReader["local"].ToString(); | ||
166 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | ||
167 | asset.Local = true; | ||
168 | else | ||
169 | asset.Local = false; | ||
170 | |||
171 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
172 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | ||
173 | |||
174 | if (m_enableCompression) | ||
175 | { | ||
176 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | ||
177 | { | ||
178 | MemoryStream outputStream = new MemoryStream(); | ||
179 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); | ||
180 | // int compressedLength = asset.Data.Length; | ||
181 | asset.Data = outputStream.ToArray(); | ||
182 | |||
183 | // m_log.DebugFormat( | ||
184 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | ||
185 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | UpdateAccessTime(asset.Metadata, (int)dbReader["access_time"]); | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | catch (Exception e) | ||
194 | { | ||
195 | m_log.Error(string.Format("[PGSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | |||
201 | return asset; | ||
202 | } | ||
203 | |||
204 | /// <summary> | ||
205 | /// Create an asset in database, or update it if existing. | ||
206 | /// </summary> | ||
207 | /// <param name="asset">Asset UUID to create</param> | ||
208 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | ||
209 | public void StoreAsset(AssetBase asset) | ||
210 | { | ||
211 | // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); | ||
212 | |||
213 | lock (m_dbLock) | ||
214 | { | ||
215 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
216 | { | ||
217 | dbcon.Open(); | ||
218 | |||
219 | using (NpgsqlTransaction transaction = dbcon.BeginTransaction()) | ||
220 | { | ||
221 | string assetName = asset.Name; | ||
222 | if (asset.Name.Length > 64) | ||
223 | { | ||
224 | assetName = asset.Name.Substring(0, 64); | ||
225 | m_log.WarnFormat( | ||
226 | "[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); | ||
228 | } | ||
229 | |||
230 | string assetDescription = asset.Description; | ||
231 | if (asset.Description.Length > 64) | ||
232 | { | ||
233 | assetDescription = asset.Description.Substring(0, 64); | ||
234 | m_log.WarnFormat( | ||
235 | "[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); | ||
237 | } | ||
238 | |||
239 | if (m_enableCompression) | ||
240 | { | ||
241 | MemoryStream outputStream = new MemoryStream(); | ||
242 | |||
243 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) | ||
244 | { | ||
245 | // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); | ||
246 | // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. | ||
247 | compressionStream.Close(); | ||
248 | byte[] compressedData = outputStream.ToArray(); | ||
249 | asset.Data = compressedData; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | byte[] hash = hasher.ComputeHash(asset.Data); | ||
254 | |||
255 | UUID asset_id; | ||
256 | UUID.TryParse(asset.ID, out asset_id); | ||
257 | |||
258 | // m_log.DebugFormat( | ||
259 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", | ||
260 | // asset.ID, asset.Name, hash, compressedData.Length); | ||
261 | |||
262 | try | ||
263 | { | ||
264 | using (NpgsqlCommand cmd = | ||
265 | new NpgsqlCommand( | ||
266 | @"insert INTO XAssetsMeta(id, hash, name, description, ""AssetType"", local, temporary, create_time, access_time, asset_flags, creatorid) | ||
267 | Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID | ||
268 | where not exists( Select id from XAssetsMeta where id = :ID); | ||
269 | |||
270 | update XAssetsMeta | ||
271 | set id = :ID, hash = :Hash, name = :Name, description = :Description, | ||
272 | ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime, | ||
273 | access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID | ||
274 | where id = :ID; | ||
275 | ", | ||
276 | dbcon)) | ||
277 | { | ||
278 | |||
279 | // create unix epoch time | ||
280 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
281 | cmd.Parameters.Add(m_database.CreateParameter("ID", asset_id)); | ||
282 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); | ||
283 | cmd.Parameters.Add(m_database.CreateParameter("Name", assetName)); | ||
284 | cmd.Parameters.Add(m_database.CreateParameter("Description", assetDescription)); | ||
285 | cmd.Parameters.Add(m_database.CreateParameter("AssetType", asset.Type)); | ||
286 | cmd.Parameters.Add(m_database.CreateParameter("Local", asset.Local)); | ||
287 | cmd.Parameters.Add(m_database.CreateParameter("Temporary", asset.Temporary)); | ||
288 | cmd.Parameters.Add(m_database.CreateParameter("CreateTime", now)); | ||
289 | cmd.Parameters.Add(m_database.CreateParameter("AccessTime", now)); | ||
290 | cmd.Parameters.Add(m_database.CreateParameter("CreatorID", asset.Metadata.CreatorID)); | ||
291 | cmd.Parameters.Add(m_database.CreateParameter("AssetFlags", (int)asset.Flags)); | ||
292 | |||
293 | cmd.ExecuteNonQuery(); | ||
294 | } | ||
295 | } | ||
296 | catch (Exception e) | ||
297 | { | ||
298 | m_log.ErrorFormat("[ASSET DB]: PGSQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", | ||
299 | asset.FullID, asset.Name, e.Message); | ||
300 | |||
301 | transaction.Rollback(); | ||
302 | |||
303 | return; | ||
304 | } | ||
305 | |||
306 | if (!ExistsData(dbcon, transaction, hash)) | ||
307 | { | ||
308 | try | ||
309 | { | ||
310 | using (NpgsqlCommand cmd = | ||
311 | new NpgsqlCommand( | ||
312 | @"INSERT INTO XAssetsData(hash, data) VALUES(:Hash, :Data)", | ||
313 | dbcon)) | ||
314 | { | ||
315 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); | ||
316 | cmd.Parameters.Add(m_database.CreateParameter("Data", asset.Data)); | ||
317 | cmd.ExecuteNonQuery(); | ||
318 | } | ||
319 | } | ||
320 | catch (Exception e) | ||
321 | { | ||
322 | m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}", | ||
323 | asset.FullID, asset.Name, e.Message); | ||
324 | |||
325 | transaction.Rollback(); | ||
326 | |||
327 | return; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | transaction.Commit(); | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | } | ||
336 | |||
337 | /// <summary> | ||
338 | /// Updates the access time of the asset if it was accessed above a given threshhold amount of time. | ||
339 | /// </summary> | ||
340 | /// <remarks> | ||
341 | /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done | ||
342 | /// over the threshold time to avoid excessive database writes as assets are fetched. | ||
343 | /// </remarks> | ||
344 | /// <param name='asset'></param> | ||
345 | /// <param name='accessTime'></param> | ||
346 | private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime) | ||
347 | { | ||
348 | DateTime now = DateTime.UtcNow; | ||
349 | |||
350 | if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) | ||
351 | return; | ||
352 | |||
353 | lock (m_dbLock) | ||
354 | { | ||
355 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
356 | { | ||
357 | dbcon.Open(); | ||
358 | NpgsqlCommand cmd = | ||
359 | new NpgsqlCommand(@"update XAssetsMeta set access_time=:AccessTime where id=:ID", dbcon); | ||
360 | |||
361 | try | ||
362 | { | ||
363 | UUID asset_id; | ||
364 | UUID.TryParse(assetMetadata.ID, out asset_id); | ||
365 | |||
366 | using (cmd) | ||
367 | { | ||
368 | // create unix epoch time | ||
369 | cmd.Parameters.Add(m_database.CreateParameter("id", asset_id)); | ||
370 | cmd.Parameters.Add(m_database.CreateParameter("access_time", (int)Utils.DateTimeToUnixTime(now))); | ||
371 | cmd.ExecuteNonQuery(); | ||
372 | } | ||
373 | } | ||
374 | catch (Exception e) | ||
375 | { | ||
376 | m_log.ErrorFormat( | ||
377 | "[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}", | ||
378 | assetMetadata.ID, assetMetadata.Name, e.Message); | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | } | ||
383 | |||
384 | /// <summary> | ||
385 | /// We assume we already have the m_dbLock. | ||
386 | /// </summary> | ||
387 | /// TODO: need to actually use the transaction. | ||
388 | /// <param name="dbcon"></param> | ||
389 | /// <param name="transaction"></param> | ||
390 | /// <param name="hash"></param> | ||
391 | /// <returns></returns> | ||
392 | private bool ExistsData(NpgsqlConnection dbcon, NpgsqlTransaction transaction, byte[] hash) | ||
393 | { | ||
394 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | ||
395 | |||
396 | bool exists = false; | ||
397 | |||
398 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT hash FROM XAssetsData WHERE hash=:Hash", dbcon)) | ||
399 | { | ||
400 | cmd.Parameters.Add(m_database.CreateParameter("Hash", hash)); | ||
401 | |||
402 | try | ||
403 | { | ||
404 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
405 | { | ||
406 | if (dbReader.Read()) | ||
407 | { | ||
408 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
409 | exists = true; | ||
410 | } | ||
411 | } | ||
412 | } | ||
413 | catch (Exception e) | ||
414 | { | ||
415 | m_log.ErrorFormat( | ||
416 | "[XASSETS DB]: PGSql failure in ExistsData fetching hash {0}. Exception {1}{2}", | ||
417 | hash, e.Message, e.StackTrace); | ||
418 | } | ||
419 | } | ||
420 | |||
421 | return exists; | ||
422 | } | ||
423 | |||
424 | /// <summary> | ||
425 | /// Check if the assets exist in the database. | ||
426 | /// </summary> | ||
427 | /// <param name="uuids">The assets' IDs</param> | ||
428 | /// <returns>For each asset: true if it exists, false otherwise</returns> | ||
429 | public bool[] AssetsExist(UUID[] uuids) | ||
430 | { | ||
431 | if (uuids.Length == 0) | ||
432 | return new bool[0]; | ||
433 | |||
434 | HashSet<UUID> exist = new HashSet<UUID>(); | ||
435 | |||
436 | string ids = "'" + string.Join("','", uuids) + "'"; | ||
437 | string sql = string.Format(@"SELECT id FROM XAssetsMeta WHERE id IN ({0})", ids); | ||
438 | |||
439 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
440 | { | ||
441 | conn.Open(); | ||
442 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
443 | { | ||
444 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
445 | { | ||
446 | while (reader.Read()) | ||
447 | { | ||
448 | UUID id = DBGuid.FromDB(reader["id"]); | ||
449 | exist.Add(id); | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | } | ||
454 | |||
455 | bool[] results = new bool[uuids.Length]; | ||
456 | for (int i = 0; i < uuids.Length; i++) | ||
457 | results[i] = exist.Contains(uuids[i]); | ||
458 | return results; | ||
459 | } | ||
460 | |||
461 | /// <summary> | ||
462 | /// Check if the asset exists in the database | ||
463 | /// </summary> | ||
464 | /// <param name="uuid">The asset UUID</param> | ||
465 | /// <returns>true if it exists, false otherwise.</returns> | ||
466 | public bool ExistsAsset(UUID uuid) | ||
467 | { | ||
468 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | ||
469 | |||
470 | bool assetExists = false; | ||
471 | |||
472 | lock (m_dbLock) | ||
473 | { | ||
474 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
475 | { | ||
476 | dbcon.Open(); | ||
477 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT id FROM XAssetsMeta WHERE id=:ID", dbcon)) | ||
478 | { | ||
479 | cmd.Parameters.Add(m_database.CreateParameter("id", uuid)); | ||
480 | |||
481 | try | ||
482 | { | ||
483 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
484 | { | ||
485 | if (dbReader.Read()) | ||
486 | { | ||
487 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
488 | assetExists = true; | ||
489 | } | ||
490 | } | ||
491 | } | ||
492 | catch (Exception e) | ||
493 | { | ||
494 | m_log.Error(string.Format("[XASSETS DB]: PGSql failure fetching asset {0}", uuid), e); | ||
495 | } | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | |||
500 | return assetExists; | ||
501 | } | ||
502 | |||
503 | |||
504 | /// <summary> | ||
505 | /// Returns a list of AssetMetadata objects. The list is a subset of | ||
506 | /// the entire data set offset by <paramref name="start" /> containing | ||
507 | /// <paramref name="count" /> elements. | ||
508 | /// </summary> | ||
509 | /// <param name="start">The number of results to discard from the total data set.</param> | ||
510 | /// <param name="count">The number of rows the returned list should contain.</param> | ||
511 | /// <returns>A list of AssetMetadata objects.</returns> | ||
512 | public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | ||
513 | { | ||
514 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | ||
515 | |||
516 | lock (m_dbLock) | ||
517 | { | ||
518 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
519 | { | ||
520 | dbcon.Open(); | ||
521 | NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid | ||
522 | FROM XAssetsMeta | ||
523 | 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 | { | ||
529 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) | ||
530 | { | ||
531 | while (dbReader.Read()) | ||
532 | { | ||
533 | AssetMetadata metadata = new AssetMetadata(); | ||
534 | metadata.Name = (string)dbReader["name"]; | ||
535 | metadata.Description = (string)dbReader["description"]; | ||
536 | metadata.Type = Convert.ToSByte(dbReader["AssetType"]); | ||
537 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
538 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | ||
539 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | ||
540 | metadata.CreatorID = dbReader["creatorid"].ToString(); | ||
541 | |||
542 | // We'll ignore this for now - it appears unused! | ||
543 | // metadata.SHA1 = dbReader["hash"]); | ||
544 | |||
545 | UpdateAccessTime(metadata, (int)dbReader["access_time"]); | ||
546 | |||
547 | retList.Add(metadata); | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | catch (Exception e) | ||
552 | { | ||
553 | m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString()); | ||
554 | } | ||
555 | } | ||
556 | } | ||
557 | |||
558 | return retList; | ||
559 | } | ||
560 | |||
561 | public bool Delete(string id) | ||
562 | { | ||
563 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); | ||
564 | |||
565 | lock (m_dbLock) | ||
566 | { | ||
567 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | ||
568 | { | ||
569 | dbcon.Open(); | ||
570 | |||
571 | using (NpgsqlCommand cmd = new NpgsqlCommand(@"delete from XAssetsMeta where id=:ID", dbcon)) | ||
572 | { | ||
573 | cmd.Parameters.Add(m_database.CreateParameter(id, id)); | ||
574 | cmd.ExecuteNonQuery(); | ||
575 | } | ||
576 | |||
577 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | ||
578 | // keep a reference count (?) | ||
579 | } | ||
580 | } | ||
581 | |||
582 | return true; | ||
583 | } | ||
584 | |||
585 | #endregion | ||
586 | } | ||
587 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs index 9164ffe..a22b882 100644 --- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs +++ b/OpenSim/Data/PGSQL/PGSQLXInventoryData.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 | * |
@@ -31,29 +31,39 @@ using System.Collections.Generic; | |||
31 | using System.Data; | 31 | using System.Data; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using System.Data.SqlClient; | ||
35 | using System.Reflection; | 34 | using System.Reflection; |
36 | using System.Text; | 35 | using System.Text; |
37 | using log4net; | 36 | using log4net; |
37 | using Npgsql; | ||
38 | using NpgsqlTypes; | ||
38 | 39 | ||
39 | namespace OpenSim.Data.MSSQL | 40 | namespace OpenSim.Data.PGSQL |
40 | { | 41 | { |
41 | public class MSSQLXInventoryData : IXInventoryData | 42 | public class PGSQLXInventoryData : IXInventoryData |
42 | { | 43 | { |
43 | // private static readonly ILog m_log = LogManager.GetLogger( | 44 | // private static readonly ILog m_log = LogManager.GetLogger( |
44 | // MethodBase.GetCurrentMethod().DeclaringType); | 45 | // MethodBase.GetCurrentMethod().DeclaringType); |
45 | 46 | ||
46 | private MSSQLFolderHandler m_Folders; | 47 | private PGSQLFolderHandler m_Folders; |
47 | private MSSQLItemHandler m_Items; | 48 | private PGSQLItemHandler m_Items; |
48 | 49 | ||
49 | public MSSQLXInventoryData(string conn, string realm) | 50 | public PGSQLXInventoryData(string conn, string realm) |
50 | { | 51 | { |
51 | m_Folders = new MSSQLFolderHandler( | 52 | m_Folders = new PGSQLFolderHandler( |
52 | conn, "inventoryfolders", "InventoryStore"); | 53 | conn, "inventoryfolders", "InventoryStore"); |
53 | m_Items = new MSSQLItemHandler( | 54 | m_Items = new PGSQLItemHandler( |
54 | conn, "inventoryitems", String.Empty); | 55 | conn, "inventoryitems", String.Empty); |
55 | } | 56 | } |
56 | 57 | ||
58 | public static UUID str2UUID(string strUUID) | ||
59 | { | ||
60 | UUID newUUID = UUID.Zero; | ||
61 | |||
62 | UUID.TryParse(strUUID, out newUUID); | ||
63 | |||
64 | return newUUID; | ||
65 | } | ||
66 | |||
57 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) | 67 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) |
58 | { | 68 | { |
59 | return m_Folders.Get(fields, vals); | 69 | return m_Folders.Get(fields, vals); |
@@ -113,7 +123,7 @@ namespace OpenSim.Data.MSSQL | |||
113 | 123 | ||
114 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 124 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
115 | { | 125 | { |
116 | return m_Items.GetActiveGestures(principalID); | 126 | return m_Items.GetActiveGestures(principalID.ToString()); |
117 | } | 127 | } |
118 | 128 | ||
119 | public int GetAssetPermissions(UUID principalID, UUID assetID) | 129 | public int GetAssetPermissions(UUID principalID, UUID assetID) |
@@ -122,9 +132,9 @@ namespace OpenSim.Data.MSSQL | |||
122 | } | 132 | } |
123 | } | 133 | } |
124 | 134 | ||
125 | public class MSSQLItemHandler : MSSQLInventoryHandler<XInventoryItem> | 135 | public class PGSQLItemHandler : PGSQLInventoryHandler<XInventoryItem> |
126 | { | 136 | { |
127 | public MSSQLItemHandler(string c, string t, string m) : | 137 | public PGSQLItemHandler(string c, string t, string m) : |
128 | base(c, t, m) | 138 | base(c, t, m) |
129 | { | 139 | { |
130 | } | 140 | } |
@@ -137,14 +147,13 @@ namespace OpenSim.Data.MSSQL | |||
137 | 147 | ||
138 | UUID oldParent = retrievedItems[0].parentFolderID; | 148 | UUID oldParent = retrievedItems[0].parentFolderID; |
139 | 149 | ||
140 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 150 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
141 | { | 151 | { |
142 | using (SqlCommand cmd = new SqlCommand()) | 152 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
143 | { | 153 | { |
144 | 154 | cmd.CommandText = String.Format(@"update {0} set ""parentFolderID"" = :ParentFolderID where ""inventoryID"" = :InventoryID", m_Realm); | |
145 | cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); | 155 | cmd.Parameters.Add(m_database.CreateParameter("ParentFolderID", newParent)); |
146 | cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); | 156 | cmd.Parameters.Add(m_database.CreateParameter("InventoryID", id )); |
147 | cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); | ||
148 | cmd.Connection = conn; | 157 | cmd.Connection = conn; |
149 | conn.Open(); | 158 | conn.Open(); |
150 | 159 | ||
@@ -159,16 +168,19 @@ namespace OpenSim.Data.MSSQL | |||
159 | return true; | 168 | return true; |
160 | } | 169 | } |
161 | 170 | ||
162 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 171 | public XInventoryItem[] GetActiveGestures(string principalID) |
163 | { | 172 | { |
164 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 173 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
165 | { | 174 | { |
166 | using (SqlCommand cmd = new SqlCommand()) | 175 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
167 | { | 176 | { |
168 | 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 | UUID princID = UUID.Zero; | ||
180 | UUID.TryParse(principalID, out princID); | ||
169 | 181 | ||
170 | cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); | 182 | cmd.Parameters.Add(m_database.CreateParameter("uuid", principalID)); |
171 | cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); | 183 | cmd.Parameters.Add(m_database.CreateParameter("type", (int)AssetType.Gesture)); |
172 | cmd.Connection = conn; | 184 | cmd.Connection = conn; |
173 | conn.Open(); | 185 | conn.Open(); |
174 | return DoQuery(cmd); | 186 | return DoQuery(cmd); |
@@ -178,16 +190,21 @@ namespace OpenSim.Data.MSSQL | |||
178 | 190 | ||
179 | public int GetAssetPermissions(UUID principalID, UUID assetID) | 191 | public int GetAssetPermissions(UUID principalID, UUID assetID) |
180 | { | 192 | { |
181 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 193 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
182 | { | 194 | { |
183 | using (SqlCommand cmd = new SqlCommand()) | 195 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
184 | { | 196 | { |
185 | cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); | 197 | cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions"" |
186 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | 198 | from inventoryitems |
187 | cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString())); | 199 | where ""avatarID"" = :PrincipalID |
200 | and ""assetID"" = :AssetID | ||
201 | group by ""assetID"" ", m_Realm); | ||
202 | |||
203 | cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID)); | ||
204 | cmd.Parameters.Add(m_database.CreateParameter("AssetID", assetID)); | ||
188 | cmd.Connection = conn; | 205 | cmd.Connection = conn; |
189 | conn.Open(); | 206 | conn.Open(); |
190 | using (SqlDataReader reader = cmd.ExecuteReader()) | 207 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
191 | { | 208 | { |
192 | 209 | ||
193 | int perms = 0; | 210 | int perms = 0; |
@@ -215,9 +232,9 @@ namespace OpenSim.Data.MSSQL | |||
215 | } | 232 | } |
216 | } | 233 | } |
217 | 234 | ||
218 | public class MSSQLFolderHandler : MSSQLInventoryHandler<XInventoryFolder> | 235 | public class PGSQLFolderHandler : PGSQLInventoryHandler<XInventoryFolder> |
219 | { | 236 | { |
220 | public MSSQLFolderHandler(string c, string t, string m) : | 237 | public PGSQLFolderHandler(string c, string t, string m) : |
221 | base(c, t, m) | 238 | base(c, t, m) |
222 | { | 239 | { |
223 | } | 240 | } |
@@ -231,14 +248,19 @@ namespace OpenSim.Data.MSSQL | |||
231 | 248 | ||
232 | UUID oldParentFolderUUID = folders[0].parentFolderID; | 249 | UUID oldParentFolderUUID = folders[0].parentFolderID; |
233 | 250 | ||
234 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 251 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
235 | { | 252 | { |
236 | using (SqlCommand cmd = new SqlCommand()) | 253 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
237 | { | 254 | { |
255 | UUID foldID = UUID.Zero; | ||
256 | UUID.TryParse(id, out foldID); | ||
257 | |||
258 | UUID newPar = UUID.Zero; | ||
259 | UUID.TryParse(newParentFolderID, out newPar); | ||
238 | 260 | ||
239 | cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm); | 261 | cmd.CommandText = String.Format(@"update {0} set ""parentFolderID"" = :ParentFolderID where ""folderID"" = :folderID", m_Realm); |
240 | cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID)); | 262 | cmd.Parameters.Add(m_database.CreateParameter("ParentFolderID", newPar)); |
241 | cmd.Parameters.Add(m_database.CreateParameter("@folderID", id)); | 263 | cmd.Parameters.Add(m_database.CreateParameter("folderID", foldID)); |
242 | cmd.Connection = conn; | 264 | cmd.Connection = conn; |
243 | conn.Open(); | 265 | conn.Open(); |
244 | 266 | ||
@@ -264,9 +286,9 @@ namespace OpenSim.Data.MSSQL | |||
264 | } | 286 | } |
265 | } | 287 | } |
266 | 288 | ||
267 | public class MSSQLInventoryHandler<T> : MSSQLGenericTableHandler<T> where T: class, new() | 289 | public class PGSQLInventoryHandler<T> : PGSQLGenericTableHandler<T> where T: class, new() |
268 | { | 290 | { |
269 | public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {} | 291 | public PGSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {} |
270 | 292 | ||
271 | protected bool IncrementFolderVersion(UUID folderID) | 293 | protected bool IncrementFolderVersion(UUID folderID) |
272 | { | 294 | { |
@@ -275,18 +297,21 @@ namespace OpenSim.Data.MSSQL | |||
275 | 297 | ||
276 | protected bool IncrementFolderVersion(string folderID) | 298 | protected bool IncrementFolderVersion(string folderID) |
277 | { | 299 | { |
278 | // m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); | 300 | // m_log.DebugFormat("[PGSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); |
279 | // Util.PrintCallStack(); | 301 | // Util.PrintCallStack(); |
280 | 302 | ||
281 | string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID"; | 303 | string sql = @"update inventoryfolders set version=version+1 where ""folderID"" = :folderID"; |
282 | 304 | ||
283 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 305 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
284 | { | 306 | { |
285 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 307 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
286 | { | 308 | { |
309 | UUID foldID = UUID.Zero; | ||
310 | UUID.TryParse(folderID, out foldID); | ||
311 | |||
287 | conn.Open(); | 312 | conn.Open(); |
288 | 313 | ||
289 | cmd.Parameters.AddWithValue("@folderID", folderID); | 314 | cmd.Parameters.Add( m_database.CreateParameter("folderID", foldID) ); |
290 | 315 | ||
291 | try | 316 | try |
292 | { | 317 | { |
@@ -302,4 +327,4 @@ namespace OpenSim.Data.MSSQL | |||
302 | return true; | 327 | return true; |
303 | } | 328 | } |
304 | } | 329 | } |
305 | } \ No newline at end of file | 330 | } |
diff --git a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs index 1a67e70..1e88b2c 100644 --- a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs | |||
@@ -32,11 +32,11 @@ using System.Runtime.InteropServices; | |||
32 | // set of attributes. Change these attribute values to modify the information | 32 | // set of attributes. Change these attribute values to modify the information |
33 | // associated with an assembly. | 33 | // associated with an assembly. |
34 | 34 | ||
35 | [assembly : AssemblyTitle("OpenSim.Data.MSSQL")] | 35 | [assembly : AssemblyTitle("OpenSim.Data.PGSQL")] |
36 | [assembly : AssemblyDescription("")] | 36 | [assembly : AssemblyDescription("")] |
37 | [assembly : AssemblyConfiguration("")] | 37 | [assembly : AssemblyConfiguration("")] |
38 | [assembly : AssemblyCompany("http://opensimulator.org")] | 38 | [assembly : AssemblyCompany("http://opensimulator.org")] |
39 | [assembly : AssemblyProduct("OpenSim.Data.MSSQL")] | 39 | [assembly : AssemblyProduct("OpenSim.Data.PGSQL")] |
40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | 40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] |
41 | [assembly : AssemblyTrademark("")] | 41 | [assembly : AssemblyTrademark("")] |
42 | [assembly : AssemblyCulture("")] | 42 | [assembly : AssemblyCulture("")] |
@@ -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.7.5.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | |
diff --git a/OpenSim/Data/PGSQL/Resources/AssetStore.migrations b/OpenSim/Data/PGSQL/Resources/AssetStore.migrations new file mode 100644 index 0000000..7a858b4 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/AssetStore.migrations | |||
@@ -0,0 +1,99 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE assets ( | ||
4 | "id" varchar(36) NOT NULL PRIMARY KEY, | ||
5 | "name" varchar(64) NOT NULL, | ||
6 | "description" varchar(64) NOT NULL, | ||
7 | "assetType" smallint NOT NULL, | ||
8 | "local" smallint NOT NULL, | ||
9 | "temporary" smallint NOT NULL, | ||
10 | "data" bytea NOT NULL | ||
11 | ) ; | ||
12 | |||
13 | :VERSION 2 | ||
14 | |||
15 | BEGIN TRANSACTION; | ||
16 | |||
17 | CREATE TABLE Tmp_assets | ||
18 | ( | ||
19 | "id" varchar(36) NOT NULL, | ||
20 | "name" varchar(64) NOT NULL, | ||
21 | "description" varchar(64) NOT NULL, | ||
22 | "assetType" smallint NOT NULL, | ||
23 | "local" boolean NOT NULL, | ||
24 | "temporary" boolean NOT NULL, | ||
25 | "data" bytea NOT NULL | ||
26 | ) ; | ||
27 | |||
28 | INSERT INTO Tmp_assets ("id", "name", "description", "assetType", "local", "temporary", "data") | ||
29 | SELECT "id", "name", "description", "assetType", case when "local" = 1 then true else false end, case when "temporary" = 1 then true else false end, "data" | ||
30 | FROM assets ; | ||
31 | |||
32 | DROP TABLE assets; | ||
33 | |||
34 | Alter table Tmp_assets | ||
35 | rename to assets; | ||
36 | |||
37 | ALTER TABLE assets ADD PRIMARY KEY ("id"); | ||
38 | |||
39 | COMMIT; | ||
40 | |||
41 | |||
42 | :VERSION 3 | ||
43 | |||
44 | BEGIN TRANSACTION; | ||
45 | |||
46 | ALTER TABLE assets add "create_time" integer default 0; | ||
47 | ALTER TABLE assets add "access_time" integer default 0; | ||
48 | |||
49 | COMMIT; | ||
50 | |||
51 | |||
52 | :VERSION 4 | ||
53 | |||
54 | BEGIN TRANSACTION; | ||
55 | |||
56 | CREATE TABLE Tmp_assets | ||
57 | ( | ||
58 | "id" uuid NOT NULL, | ||
59 | "name" varchar(64) NOT NULL, | ||
60 | "description" varchar(64) NOT NULL, | ||
61 | "assetType" smallint NOT NULL, | ||
62 | "local" boolean NOT NULL, | ||
63 | "temporary" boolean NOT NULL, | ||
64 | "data" bytea NOT NULL, | ||
65 | "create_time" int NULL, | ||
66 | "access_time" int NULL | ||
67 | ) ; | ||
68 | |||
69 | |||
70 | INSERT INTO Tmp_assets ("id", "name", "description", "assetType", "local", "temporary", "data", "create_time", "access_time") | ||
71 | SELECT cast("id" as uuid), "name", "description", "assetType", "local", "temporary", "data", "create_time", "access_time" | ||
72 | FROM assets ; | ||
73 | |||
74 | DROP TABLE assets; | ||
75 | |||
76 | Alter table Tmp_assets | ||
77 | rename to assets; | ||
78 | |||
79 | ALTER TABLE assets ADD PRIMARY KEY ("id"); | ||
80 | |||
81 | COMMIT; | ||
82 | |||
83 | |||
84 | :VERSION 5 | ||
85 | |||
86 | DELETE FROM assets WHERE "id" = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621'; | ||
87 | |||
88 | :VERSION 6 | ||
89 | |||
90 | ALTER TABLE assets ADD "asset_flags" INTEGER NOT NULL DEFAULT 0; | ||
91 | |||
92 | :VERSION 7 | ||
93 | |||
94 | alter table assets add "creatorid" varchar(36) not null default ''; | ||
95 | |||
96 | :VERSION 8 | ||
97 | |||
98 | BEGIN TRANSACTION; | ||
99 | COMMIT; | ||
diff --git a/OpenSim/Data/PGSQL/Resources/AuthStore.migrations b/OpenSim/Data/PGSQL/Resources/AuthStore.migrations new file mode 100644 index 0000000..a1f5b61 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/AuthStore.migrations | |||
@@ -0,0 +1,32 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE auth ( | ||
6 | uuid uuid NOT NULL default '00000000-0000-0000-0000-000000000000', | ||
7 | "passwordHash" varchar(32) NOT NULL, | ||
8 | "passwordSalt" varchar(32) NOT NULL, | ||
9 | "webLoginKey" varchar(255) NOT NULL, | ||
10 | "accountType" VARCHAR(32) NOT NULL DEFAULT 'UserAccount' | ||
11 | ) ; | ||
12 | |||
13 | CREATE TABLE tokens ( | ||
14 | uuid uuid NOT NULL default '00000000-0000-0000-0000-000000000000', | ||
15 | token varchar(255) NOT NULL, | ||
16 | validity TIMESTAMP NOT NULL ) | ||
17 | ; | ||
18 | |||
19 | COMMIT; | ||
20 | |||
21 | :VERSION 2 | ||
22 | |||
23 | BEGIN TRANSACTION; | ||
24 | |||
25 | INSERT INTO auth (uuid, "passwordHash", "passwordSalt", "webLoginKey", "accountType") | ||
26 | SELECT uuid AS UUID, passwordHash AS passwordHash, passwordSalt AS passwordSalt, webLoginKey AS webLoginKey, 'UserAccount' as accountType | ||
27 | FROM users | ||
28 | where exists ( Select * from information_schema.tables where table_name = 'users' ) | ||
29 | ; | ||
30 | |||
31 | COMMIT; | ||
32 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/Avatar.migrations b/OpenSim/Data/PGSQL/Resources/Avatar.migrations new file mode 100644 index 0000000..160086d --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/Avatar.migrations | |||
@@ -0,0 +1,59 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE Avatars ( | ||
6 | "PrincipalID" uuid NOT NULL PRIMARY KEY, | ||
7 | "Name" varchar(32) NOT NULL, | ||
8 | "Value" varchar(255) NOT NULL DEFAULT '' | ||
9 | ); | ||
10 | |||
11 | |||
12 | COMMIT; | ||
13 | |||
14 | :VERSION 2 | ||
15 | |||
16 | BEGIN TRANSACTION; | ||
17 | |||
18 | CREATE TABLE Tmp_Avatars | ||
19 | ( | ||
20 | "PrincipalID" uuid NOT NULL, | ||
21 | "Name" varchar(32) NOT NULL, | ||
22 | "Value" text NOT NULL DEFAULT '' | ||
23 | ) ; | ||
24 | |||
25 | INSERT INTO Tmp_Avatars ("PrincipalID", "Name", "Value") | ||
26 | SELECT "PrincipalID", cast("Name" as text), "Value" | ||
27 | FROM Avatars ; | ||
28 | |||
29 | DROP TABLE Avatars; | ||
30 | |||
31 | Alter table Tmp_Avatars | ||
32 | rename to Avatars; | ||
33 | |||
34 | COMMIT; | ||
35 | |||
36 | :VERSION 3 | ||
37 | |||
38 | BEGIN TRANSACTION; | ||
39 | |||
40 | CREATE TABLE Tmp_Avatars | ||
41 | ( | ||
42 | "PrincipalID" uuid NOT NULL, | ||
43 | "Name" varchar(32) NOT NULL, | ||
44 | "Value" text NOT NULL DEFAULT '' | ||
45 | ); | ||
46 | |||
47 | ALTER TABLE Tmp_Avatars ADD PRIMARY KEY ("PrincipalID", "Name"); | ||
48 | |||
49 | |||
50 | INSERT INTO Tmp_Avatars ("PrincipalID", "Name", "Value") | ||
51 | SELECT "PrincipalID", "Name", cast("Value" as text) FROM Avatars ; | ||
52 | |||
53 | DROP TABLE Avatars; | ||
54 | |||
55 | Alter table Tmp_Avatars | ||
56 | rename to Avatars; | ||
57 | |||
58 | COMMIT; | ||
59 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/EstateStore.migrations b/OpenSim/Data/PGSQL/Resources/EstateStore.migrations new file mode 100644 index 0000000..59270f8 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/EstateStore.migrations | |||
@@ -0,0 +1,307 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE estate_managers( | ||
6 | "EstateID" int NOT NULL Primary Key, | ||
7 | uuid varchar(36) NOT NULL | ||
8 | ); | ||
9 | |||
10 | CREATE TABLE estate_groups( | ||
11 | "EstateID" int NOT NULL, | ||
12 | uuid varchar(36) NOT NULL | ||
13 | ); | ||
14 | |||
15 | |||
16 | CREATE TABLE estate_users( | ||
17 | "EstateID" int NOT NULL, | ||
18 | uuid varchar(36) NOT NULL | ||
19 | ); | ||
20 | |||
21 | |||
22 | CREATE TABLE estateban( | ||
23 | "EstateID" int NOT NULL, | ||
24 | "bannedUUID" varchar(36) NOT NULL, | ||
25 | "bannedIp" varchar(16) NOT NULL, | ||
26 | "bannedIpHostMask" varchar(16) NOT NULL, | ||
27 | "bannedNameMask" varchar(64) NULL DEFAULT NULL | ||
28 | ); | ||
29 | |||
30 | Create Sequence estate_settings_id increment by 100 start with 100; | ||
31 | |||
32 | CREATE TABLE estate_settings( | ||
33 | "EstateID" integer DEFAULT nextval('estate_settings_id') NOT NULL, | ||
34 | "EstateName" varchar(64) NULL DEFAULT (NULL), | ||
35 | "AbuseEmailToEstateOwner" boolean NOT NULL, | ||
36 | "DenyAnonymous" boolean NOT NULL, | ||
37 | "ResetHomeOnTeleport" boolean NOT NULL, | ||
38 | "FixedSun" boolean NOT NULL, | ||
39 | "DenyTransacted" boolean NOT NULL, | ||
40 | "BlockDwell" boolean NOT NULL, | ||
41 | "DenyIdentified" boolean NOT NULL, | ||
42 | "AllowVoice" boolean NOT NULL, | ||
43 | "UseGlobalTime" boolean NOT NULL, | ||
44 | "PricePerMeter" int NOT NULL, | ||
45 | "TaxFree" boolean NOT NULL, | ||
46 | "AllowDirectTeleport" boolean NOT NULL, | ||
47 | "RedirectGridX" int NOT NULL, | ||
48 | "RedirectGridY" int NOT NULL, | ||
49 | "ParentEstateID" int NOT NULL, | ||
50 | "SunPosition" double precision NOT NULL, | ||
51 | "EstateSkipScripts" boolean NOT NULL, | ||
52 | "BillableFactor" double precision NOT NULL, | ||
53 | "PublicAccess" boolean NOT NULL, | ||
54 | "AbuseEmail" varchar(255) NOT NULL, | ||
55 | "EstateOwner" varchar(36) NOT NULL, | ||
56 | "DenyMinors" boolean NOT NULL | ||
57 | ); | ||
58 | |||
59 | |||
60 | CREATE TABLE estate_map( | ||
61 | "RegionID" varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
62 | "EstateID" int NOT NULL | ||
63 | ); | ||
64 | |||
65 | COMMIT; | ||
66 | |||
67 | :VERSION 2 | ||
68 | |||
69 | BEGIN TRANSACTION; | ||
70 | |||
71 | CREATE INDEX IX_estate_managers ON estate_managers | ||
72 | ( | ||
73 | "EstateID" | ||
74 | ); | ||
75 | |||
76 | |||
77 | CREATE INDEX IX_estate_groups ON estate_groups | ||
78 | ( | ||
79 | "EstateID" | ||
80 | ); | ||
81 | |||
82 | |||
83 | CREATE INDEX IX_estate_users ON estate_users | ||
84 | ( | ||
85 | "EstateID" | ||
86 | ); | ||
87 | |||
88 | COMMIT; | ||
89 | |||
90 | :VERSION 3 | ||
91 | |||
92 | BEGIN TRANSACTION; | ||
93 | |||
94 | CREATE 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 | |||
106 | DROP TABLE estateban; | ||
107 | |||
108 | Alter table Tmp_estateban | ||
109 | rename to estateban; | ||
110 | |||
111 | CREATE INDEX IX_estateban ON estateban | ||
112 | ( | ||
113 | "EstateID" | ||
114 | ); | ||
115 | |||
116 | COMMIT; | ||
117 | |||
118 | |||
119 | :VERSION 4 | ||
120 | |||
121 | BEGIN TRANSACTION; | ||
122 | |||
123 | CREATE TABLE Tmp_estate_managers | ||
124 | ( | ||
125 | "EstateID" int NOT NULL, | ||
126 | uuid uuid NOT NULL | ||
127 | ); | ||
128 | |||
129 | INSERT INTO Tmp_estate_managers ("EstateID", uuid) | ||
130 | SELECT "EstateID", cast(uuid as uuid) FROM estate_managers; | ||
131 | |||
132 | DROP TABLE estate_managers; | ||
133 | |||
134 | Alter table Tmp_estate_managers | ||
135 | rename to estate_managers; | ||
136 | |||
137 | CREATE INDEX IX_estate_managers ON estate_managers | ||
138 | ( | ||
139 | "EstateID" | ||
140 | ); | ||
141 | |||
142 | COMMIT; | ||
143 | |||
144 | |||
145 | :VERSION 5 | ||
146 | |||
147 | BEGIN TRANSACTION; | ||
148 | |||
149 | CREATE 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 | |||
158 | DROP TABLE estate_groups; | ||
159 | |||
160 | Alter table Tmp_estate_groups | ||
161 | rename to estate_groups; | ||
162 | |||
163 | CREATE INDEX IX_estate_groups ON estate_groups | ||
164 | ( | ||
165 | "EstateID" | ||
166 | ); | ||
167 | |||
168 | COMMIT; | ||
169 | |||
170 | |||
171 | :VERSION 6 | ||
172 | |||
173 | BEGIN TRANSACTION; | ||
174 | |||
175 | CREATE TABLE Tmp_estate_users | ||
176 | ( | ||
177 | "EstateID" int NOT NULL, | ||
178 | uuid uuid NOT NULL | ||
179 | ); | ||
180 | |||
181 | INSERT INTO Tmp_estate_users ("EstateID", uuid) | ||
182 | SELECT "EstateID", cast(uuid as uuid) FROM estate_users ; | ||
183 | |||
184 | DROP TABLE estate_users; | ||
185 | |||
186 | Alter table Tmp_estate_users | ||
187 | rename to estate_users; | ||
188 | |||
189 | CREATE INDEX IX_estate_users ON estate_users | ||
190 | ( | ||
191 | "EstateID" | ||
192 | ); | ||
193 | |||
194 | COMMIT; | ||
195 | |||
196 | |||
197 | :VERSION 7 | ||
198 | |||
199 | BEGIN TRANSACTION; | ||
200 | |||
201 | CREATE 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 | |||
210 | INSERT INTO Tmp_estateban ("EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask") | ||
211 | SELECT "EstateID", cast("bannedUUID" as uuid), "bannedIp", "bannedIpHostMask", "bannedNameMask" FROM estateban ; | ||
212 | |||
213 | DROP TABLE estateban; | ||
214 | |||
215 | Alter table Tmp_estateban | ||
216 | rename to estateban; | ||
217 | |||
218 | CREATE INDEX IX_estateban ON estateban | ||
219 | ( | ||
220 | "EstateID" | ||
221 | ); | ||
222 | |||
223 | COMMIT; | ||
224 | |||
225 | |||
226 | :VERSION 8 | ||
227 | |||
228 | BEGIN TRANSACTION; | ||
229 | |||
230 | CREATE 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, | ||
255 | "DenyMinors" boolean NOT NULL | ||
256 | ); | ||
257 | |||
258 | INSERT 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") | ||
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 ; | ||
260 | |||
261 | DROP TABLE estate_settings; | ||
262 | |||
263 | |||
264 | Alter table Tmp_estate_settings | ||
265 | rename to estate_settings; | ||
266 | |||
267 | |||
268 | Create index on estate_settings (lower("EstateName")); | ||
269 | |||
270 | COMMIT; | ||
271 | |||
272 | |||
273 | :VERSION 9 | ||
274 | |||
275 | BEGIN TRANSACTION; | ||
276 | |||
277 | CREATE TABLE Tmp_estate_map | ||
278 | ( | ||
279 | "RegionID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
280 | "EstateID" int NOT NULL | ||
281 | ); | ||
282 | |||
283 | INSERT INTO Tmp_estate_map ("RegionID", "EstateID") | ||
284 | SELECT cast("RegionID" as uuid), "EstateID" FROM estate_map ; | ||
285 | |||
286 | DROP TABLE estate_map; | ||
287 | |||
288 | Alter table Tmp_estate_map | ||
289 | rename to estate_map; | ||
290 | |||
291 | COMMIT; | ||
292 | |||
293 | :VERSION 10 | ||
294 | |||
295 | BEGIN TRANSACTION; | ||
296 | ALTER TABLE estate_settings ADD COLUMN "AllowLandmark" boolean NOT NULL default true; | ||
297 | ALTER TABLE estate_settings ADD COLUMN "AllowParcelChanges" boolean NOT NULL default true; | ||
298 | ALTER TABLE estate_settings ADD COLUMN "AllowSetHome" boolean NOT NULL default true; | ||
299 | COMMIT; | ||
300 | |||
301 | :VERSION 11 | ||
302 | |||
303 | Begin transaction; | ||
304 | |||
305 | |||
306 | Commit; | ||
307 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/FriendsStore.migrations b/OpenSim/Data/PGSQL/Resources/FriendsStore.migrations new file mode 100644 index 0000000..a87199b --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/FriendsStore.migrations | |||
@@ -0,0 +1,44 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE Friends ( | ||
6 | "PrincipalID" uuid NOT NULL, | ||
7 | "Friend" varchar(255) NOT NULL, | ||
8 | "Flags" char(16) NOT NULL DEFAULT '0', | ||
9 | "Offered" varchar(32) NOT NULL DEFAULT 0); | ||
10 | |||
11 | |||
12 | COMMIT; | ||
13 | |||
14 | :VERSION 2 | ||
15 | |||
16 | BEGIN TRANSACTION; | ||
17 | |||
18 | INSERT INTO Friends ("PrincipalID", "Friend", "Flags", "Offered") | ||
19 | SELECT "ownerID", "friendID", "friendPerms", 0 FROM userfriends; | ||
20 | |||
21 | COMMIT; | ||
22 | |||
23 | :VERSION 3 | ||
24 | |||
25 | BEGIN TRANSACTION; | ||
26 | |||
27 | CREATE TABLE Tmp_Friends | ||
28 | ("PrincipalID" varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
29 | "Friend" varchar(255) NOT NULL, | ||
30 | "Flags" char(16) NOT NULL DEFAULT '0', | ||
31 | "Offered" varchar(32) NOT NULL DEFAULT 0) ; | ||
32 | |||
33 | INSERT INTO Tmp_Friends ("PrincipalID", "Friend", "Flags", "Offered") | ||
34 | SELECT cast("PrincipalID" as varchar(255)), "Friend", "Flags", "Offered" FROM Friends ; | ||
35 | |||
36 | DROP TABLE Friends; | ||
37 | |||
38 | Alter table Tmp_Friends | ||
39 | rename to Friends; | ||
40 | |||
41 | ALTER TABLE Friends ADD PRIMARY KEY("PrincipalID", "Friend"); | ||
42 | |||
43 | |||
44 | COMMIT; | ||
diff --git a/OpenSim/Data/PGSQL/Resources/GridStore.migrations b/OpenSim/Data/PGSQL/Resources/GridStore.migrations new file mode 100644 index 0000000..0ab8d2b --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/GridStore.migrations | |||
@@ -0,0 +1,242 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE regions( | ||
6 | "regionHandle" varchar(255) NULL, | ||
7 | "regionName" varchar(255) NULL, | ||
8 | uuid varchar(255) NOT NULL PRIMARY KEY, | ||
9 | "regionRecvKey" varchar(255) NULL, | ||
10 | "regionSecret" varchar(255) NULL, | ||
11 | "regionSendKey" varchar(255) NULL, | ||
12 | "regionDataURI" varchar(255) NULL, | ||
13 | "serverIP" varchar(255) NULL, | ||
14 | "serverPort" varchar(255) NULL, | ||
15 | "serverURI" varchar(255) NULL, | ||
16 | "locX" varchar(255) NULL, | ||
17 | "locY" varchar(255) NULL, | ||
18 | "locZ" varchar(255) NULL, | ||
19 | "eastOverrideHandle" varchar(255) NULL, | ||
20 | "westOverrideHandle" varchar(255) NULL, | ||
21 | "southOverrideHandle" varchar(255) NULL, | ||
22 | "northOverrideHandle" varchar(255) NULL, | ||
23 | "regionAssetURI" varchar(255) NULL, | ||
24 | "regionAssetRecvKey" varchar(255) NULL, | ||
25 | "regionAssetSendKey" varchar(255) NULL, | ||
26 | "regionUserURI" varchar(255) NULL, | ||
27 | "regionUserRecvKey" varchar(255) NULL, | ||
28 | "regionUserSendKey" varchar(255) NULL, | ||
29 | "regionMapTexture" varchar(255) NULL, | ||
30 | "serverHttpPort" varchar(255) NULL, | ||
31 | "serverRemotingPort" varchar(255) NULL, | ||
32 | "owner_uuid" varchar(36) NULL | ||
33 | ); | ||
34 | |||
35 | COMMIT; | ||
36 | |||
37 | |||
38 | :VERSION 2 | ||
39 | |||
40 | BEGIN TRANSACTION; | ||
41 | |||
42 | CREATE TABLE Tmp_regions | ||
43 | ( | ||
44 | uuid varchar(36) NOT NULL, | ||
45 | "regionHandle" bigint NULL, | ||
46 | "regionName" varchar(20) NULL, | ||
47 | "regionRecvKey" varchar(128) NULL, | ||
48 | "regionSendKey" varchar(128) NULL, | ||
49 | "regionSecret" varchar(128) NULL, | ||
50 | "regionDataURI" varchar(128) NULL, | ||
51 | "serverIP" varchar(64) NULL, | ||
52 | "serverPort" int NULL, | ||
53 | "serverURI" varchar(255) NULL, | ||
54 | "locX" int NULL, | ||
55 | "locY" int NULL, | ||
56 | "locZ" int NULL, | ||
57 | "eastOverrideHandle" bigint NULL, | ||
58 | "westOverrideHandle" bigint NULL, | ||
59 | "southOverrideHandle" bigint NULL, | ||
60 | "northOverrideHandle" bigint NULL, | ||
61 | "regionAssetURI" varchar(255) NULL, | ||
62 | "regionAssetRecvKey" varchar(128) NULL, | ||
63 | "regionAssetSendKey" varchar(128) NULL, | ||
64 | "regionUserURI" varchar(255) NULL, | ||
65 | "regionUserRecvKey" varchar(128) NULL, | ||
66 | "regionUserSendKey" varchar(128) NULL, | ||
67 | "regionMapTexture" varchar(36) NULL, | ||
68 | "serverHttpPort" int NULL, | ||
69 | "serverRemotingPort" int NULL, | ||
70 | "owner_uuid" varchar(36) NULL, | ||
71 | "originUUID" varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000') | ||
72 | ); | ||
73 | |||
74 | INSERT INTO Tmp_regions (uuid, "regionHandle", "regionName", "regionRecvKey", "regionSendKey", "regionSecret", "regionDataURI", "serverIP", "serverPort", "serverURI", "locX", "locY", "locZ", "eastOverrideHandle", "westOverrideHandle", "southOverrideHandle", "northOverrideHandle", "regionAssetURI", "regionAssetRecvKey", "regionAssetSendKey", "regionUserURI", "regionUserRecvKey", "regionUserSendKey", "regionMapTexture", "serverHttpPort", "serverRemotingPort", "owner_uuid") | ||
75 | SELECT cast(uuid as varchar(36)), cast("regionHandle" as bigint), cast("regionName" as varchar(20)), cast("regionRecvKey" as varchar(128)), cast("regionSendKey" as varchar(128)), cast("regionSecret" as varchar(128)), cast("regionDataURI" as varchar(128)), cast("serverIP" as varchar(64)), cast("serverPort" as int), "serverURI", cast("locX" as int), cast("locY" as int), cast("locZ" as int), cast("eastOverrideHandle" as bigint), cast("westOverrideHandle" as bigint), | ||
76 | cast("southOverrideHandle" as bigint), cast("northOverrideHandle" as bigint), "regionAssetURI", cast("regionAssetRecvKey" as varchar(128)), cast("regionAssetSendKey" as varchar(128)), "regionUserURI", cast("regionUserRecvKey" as varchar(128)), cast("regionUserSendKey" as varchar(128)), cast("regionMapTexture" as varchar(36)), | ||
77 | cast("serverHttpPort" as int), cast("serverRemotingPort" as int), "owner_uuid" | ||
78 | FROM regions; | ||
79 | |||
80 | DROP TABLE regions; | ||
81 | |||
82 | alter table Tmp_regions | ||
83 | rename to regions; | ||
84 | |||
85 | COMMIT; | ||
86 | |||
87 | :VERSION 3 | ||
88 | |||
89 | BEGIN TRANSACTION; | ||
90 | |||
91 | CREATE INDEX IX_regions_name ON regions | ||
92 | ( | ||
93 | "regionName" | ||
94 | ); | ||
95 | |||
96 | CREATE INDEX IX_regions_handle ON regions | ||
97 | ( | ||
98 | "regionHandle" | ||
99 | ); | ||
100 | |||
101 | |||
102 | CREATE INDEX IX_regions_override ON regions | ||
103 | ( | ||
104 | "eastOverrideHandle", | ||
105 | "westOverrideHandle", | ||
106 | "southOverrideHandle", | ||
107 | "northOverrideHandle" | ||
108 | ); | ||
109 | |||
110 | COMMIT; | ||
111 | |||
112 | |||
113 | :VERSION 4 | ||
114 | |||
115 | /* To prevent any potential data loss issues, you should review this script in detail before running it outside the cotext of the database designer.*/ | ||
116 | BEGIN TRANSACTION; | ||
117 | |||
118 | CREATE TABLE Tmp_regions | ||
119 | ( | ||
120 | uuid uuid NOT NULL, | ||
121 | "regionHandle" bigint NULL, | ||
122 | "regionName" varchar(20) NULL, | ||
123 | "regionRecvKey" varchar(128) NULL, | ||
124 | "regionSendKey" varchar(128) NULL, | ||
125 | "regionSecret" varchar(128) NULL, | ||
126 | "regionDataURI" varchar(128) NULL, | ||
127 | "serverIP" varchar(64) NULL, | ||
128 | "serverPort" int NULL, | ||
129 | "serverURI" varchar(255) NULL, | ||
130 | "locX" int NULL, | ||
131 | "locY" int NULL, | ||
132 | "locZ" int NULL, | ||
133 | "eastOverrideHandle" bigint NULL, | ||
134 | "westOverrideHandle" bigint NULL, | ||
135 | "southOverrideHandle" bigint NULL, | ||
136 | "northOverrideHandle" bigint NULL, | ||
137 | "regionAssetURI" varchar(255) NULL, | ||
138 | "regionAssetRecvKey" varchar(128) NULL, | ||
139 | "regionAssetSendKey" varchar(128) NULL, | ||
140 | "regionUserURI" varchar(255) NULL, | ||
141 | "regionUserRecvKey" varchar(128) NULL, | ||
142 | "regionUserSendKey" varchar(128) NULL, | ||
143 | "regionMapTexture" uuid NULL, | ||
144 | "serverHttpPort" int NULL, | ||
145 | "serverRemotingPort" int NULL, | ||
146 | "owner_uuid" uuid NOT NULL, | ||
147 | "originUUID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000') | ||
148 | ); | ||
149 | |||
150 | |||
151 | INSERT INTO Tmp_regions (uuid, "regionHandle", "regionName", "regionRecvKey", "regionSendKey", "regionSecret", "regionDataURI", "serverIP", "serverPort", "serverURI", "locX", "locY", "locZ", "eastOverrideHandle", "westOverrideHandle", "southOverrideHandle", "northOverrideHandle", "regionAssetURI", "regionAssetRecvKey", "regionAssetSendKey", "regionUserURI", "regionUserRecvKey", "regionUserSendKey", "regionMapTexture", "serverHttpPort", "serverRemotingPort", "owner_uuid", "originUUID") | ||
152 | SELECT cast(uuid as uuid), "regionHandle", "regionName", "regionRecvKey", "regionSendKey", "regionSecret", "regionDataURI", "serverIP", "serverPort", "serverURI", "locX", "locY", "locZ", "eastOverrideHandle", "westOverrideHandle", "southOverrideHandle", "northOverrideHandle", "regionAssetURI", "regionAssetRecvKey", "regionAssetSendKey", "regionUserURI", "regionUserRecvKey", "regionUserSendKey", cast("regionMapTexture" as uuid), "serverHttpPort", "serverRemotingPort", cast( "owner_uuid" as uuid), cast("originUUID" as uuid) FROM regions ; | ||
153 | |||
154 | |||
155 | DROP TABLE regions; | ||
156 | |||
157 | alter table Tmp_regions rename to regions; | ||
158 | |||
159 | ALTER TABLE regions ADD CONSTRAINT | ||
160 | PK__regions__uuid PRIMARY KEY | ||
161 | ( | ||
162 | uuid | ||
163 | ); | ||
164 | |||
165 | CREATE INDEX IX_regions_name ON regions | ||
166 | ( | ||
167 | "regionName" | ||
168 | ); | ||
169 | |||
170 | CREATE INDEX IX_regions_handle ON regions | ||
171 | ( | ||
172 | "regionHandle" | ||
173 | ); | ||
174 | |||
175 | CREATE INDEX IX_regions_override ON regions | ||
176 | ( | ||
177 | "eastOverrideHandle", | ||
178 | "westOverrideHandle", | ||
179 | "southOverrideHandle", | ||
180 | "northOverrideHandle" | ||
181 | ); | ||
182 | |||
183 | COMMIT; | ||
184 | |||
185 | |||
186 | :VERSION 5 | ||
187 | |||
188 | BEGIN TRANSACTION; | ||
189 | |||
190 | ALTER TABLE regions ADD access int default 0; | ||
191 | |||
192 | COMMIT; | ||
193 | |||
194 | |||
195 | :VERSION 6 | ||
196 | |||
197 | BEGIN TRANSACTION; | ||
198 | |||
199 | ALTER TABLE regions ADD "ScopeID" uuid default '00000000-0000-0000-0000-000000000000'; | ||
200 | ALTER TABLE regions alter column "owner_uuid" set DEFAULT ('00000000-0000-0000-0000-000000000000'); | ||
201 | ALTER TABLE regions ADD "sizeX" integer not null default 0; | ||
202 | ALTER TABLE regions ADD "sizeY" integer not null default 0; | ||
203 | |||
204 | COMMIT; | ||
205 | |||
206 | |||
207 | :VERSION 7 | ||
208 | |||
209 | BEGIN TRANSACTION; | ||
210 | |||
211 | ALTER TABLE regions ADD "flags" integer NOT NULL DEFAULT 0; | ||
212 | CREATE INDEX flags ON regions("flags"); | ||
213 | ALTER TABLE regions ADD "last_seen" integer NOT NULL DEFAULT 0; | ||
214 | ALTER TABLE regions ADD "PrincipalID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
215 | ALTER TABLE regions ADD "Token" varchar(255) NOT NULL DEFAULT 0; | ||
216 | |||
217 | COMMIT; | ||
218 | |||
219 | :VERSION 8 | ||
220 | |||
221 | BEGIN TRANSACTION; | ||
222 | ALTER TABLE regions ALTER COLUMN "regionName" type VarChar(128) ; | ||
223 | |||
224 | DROP INDEX IX_regions_name; | ||
225 | ALTER TABLE regions ALTER COLUMN "regionName" type VarChar(128), | ||
226 | ALTER COLUMN "regionName" SET NOT NULL; | ||
227 | |||
228 | CREATE INDEX IX_regions_name ON regions | ||
229 | ( | ||
230 | "regionName" | ||
231 | ); | ||
232 | |||
233 | COMMIT; | ||
234 | |||
235 | :VERSION 9 | ||
236 | |||
237 | BEGIN TRANSACTION; | ||
238 | |||
239 | ALTER TABLE regions ADD "parcelMapTexture" uuid NULL; | ||
240 | |||
241 | COMMIT; | ||
242 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/GridUserStore.migrations b/OpenSim/Data/PGSQL/Resources/GridUserStore.migrations new file mode 100644 index 0000000..d37c4f6d --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/GridUserStore.migrations | |||
@@ -0,0 +1,60 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE GridUser ( | ||
6 | "UserID" VARCHAR(255) NOT NULL Primary Key, | ||
7 | "HomeRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
8 | "HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
9 | "HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
10 | "LastRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
11 | "LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
12 | "LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
13 | "Online" CHAR(5) NOT NULL DEFAULT 'false', | ||
14 | "Login" CHAR(16) NOT NULL DEFAULT '0', | ||
15 | "Logout" CHAR(16) NOT NULL DEFAULT '0' | ||
16 | ) ; | ||
17 | |||
18 | COMMIT; | ||
19 | |||
20 | :VERSION 2 # -------------------------- | ||
21 | |||
22 | BEGIN TRANSACTION; | ||
23 | |||
24 | CREATE TABLE GridUser_tmp ( | ||
25 | "UserID" VARCHAR(255) NOT NULL PRIMARY KEY, | ||
26 | "HomeRegionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
27 | "HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
28 | "HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
29 | "LastRegionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
30 | "LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
31 | "LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
32 | "Online" CHAR(5) NOT NULL DEFAULT 'false', | ||
33 | "Login" CHAR(16) NOT NULL DEFAULT '0', | ||
34 | "Logout" CHAR(16) NOT NULL DEFAULT '0' | ||
35 | ); | ||
36 | |||
37 | COMMIT; | ||
38 | |||
39 | |||
40 | INSERT INTO GridUser_tmp ("UserID" | ||
41 | ,"HomeRegionID" | ||
42 | ,"HomePosition" | ||
43 | ,"HomeLookAt" | ||
44 | ,"LastRegionID" | ||
45 | ,"LastPosition" | ||
46 | ,"LastLookAt" | ||
47 | ,"Online" | ||
48 | ,"Login" | ||
49 | ,"Logout") | ||
50 | SELECT "UserID", cast("HomeRegionID" as uuid), "HomePosition" ,"HomeLookAt" , cast("LastRegionID" as uuid), | ||
51 | "LastPosition" | ||
52 | ,"LastLookAt" | ||
53 | ,"Online" | ||
54 | ,"Login" | ||
55 | ,"Logout" FROM GridUser; | ||
56 | |||
57 | DROP TABLE GridUser; | ||
58 | |||
59 | alter table GridUser_tmp rename to GridUser; | ||
60 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/HGTravelStore.migrations b/OpenSim/Data/PGSQL/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..adf126d --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/HGTravelStore.migrations | |||
@@ -0,0 +1,17 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE hg_traveling_data ( | ||
6 | "SessionID" VARCHAR(36) NOT NULL Primary Key, | ||
7 | "UserID" VARCHAR(36) NOT NULL, | ||
8 | "GridExternalName" VARCHAR(255) NOT NULL DEFAULT '', | ||
9 | "ServiceToken" VARCHAR(255) NOT NULL DEFAULT '', | ||
10 | "ClientIPAddress" VARCHAR(16) NOT NULL DEFAULT '', | ||
11 | "MyIPAddress" VARCHAR(16) NOT NULL DEFAULT '', | ||
12 | "TMStamp" timestamp NOT NULL default now() | ||
13 | ); | ||
14 | |||
15 | |||
16 | COMMIT; | ||
17 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/IM_Store.migrations b/OpenSim/Data/PGSQL/Resources/IM_Store.migrations new file mode 100644 index 0000000..eb97824 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/IM_Store.migrations | |||
@@ -0,0 +1,45 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN Transaction; | ||
4 | |||
5 | Create Sequence im_offiline_id increment by 1 start with 1; | ||
6 | |||
7 | CREATE TABLE im_offline ( | ||
8 | "ID" integer PRIMARY KEY NOT NULL DEFAULT nextval('im_offiline_id') , | ||
9 | "PrincipalID" char(36) NOT NULL default '', | ||
10 | "Message" text NOT NULL, | ||
11 | "TMStamp" timestamp NOT NULL default now() | ||
12 | ); | ||
13 | |||
14 | COMMIT; | ||
15 | |||
16 | :VERSION 2 # -------------------------- | ||
17 | |||
18 | BEGIN; | ||
19 | |||
20 | /* | ||
21 | INSERT INTO `im_offline` SELECT * from `diva_im_offline`; | ||
22 | DROP TABLE `diva_im_offline`; | ||
23 | DELETE FROM `migrations` WHERE name='diva_im_Store'; | ||
24 | */ | ||
25 | |||
26 | COMMIT; | ||
27 | |||
28 | :VERSION 3 # -------------------------- | ||
29 | |||
30 | BEGIN; | ||
31 | |||
32 | -- dropping the table here as there most likely is only one record in the table at the time of migration | ||
33 | |||
34 | DROP TABLE IF EXISTS "public"."im_offline"; | ||
35 | CREATE TABLE "public"."im_offline" ( | ||
36 | "ID" serial, | ||
37 | "PrincipalID" uuid NOT NULL, | ||
38 | "Message" text NOT NULL COLLATE "default", | ||
39 | "TMStamp" timestamp(6) NOT NULL DEFAULT clock_timestamp(), | ||
40 | "FromID" uuid NOT NULL | ||
41 | ) | ||
42 | WITH (OIDS=FALSE); | ||
43 | ALTER TABLE "public"."im_offline" ADD PRIMARY KEY ("ID","PrincipalID","FromID") NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
44 | |||
45 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations b/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations new file mode 100644 index 0000000..8f7982a --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations | |||
@@ -0,0 +1,220 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE inventoryfolders ( | ||
6 | "folderID" varchar(36) NOT NULL default '' PRIMARY KEY, | ||
7 | "agentID" varchar(36) default NULL, | ||
8 | "parentFolderID" varchar(36) default NULL, | ||
9 | "folderName" varchar(64) default NULL, | ||
10 | "type" smallint NOT NULL default 0, | ||
11 | "version" int NOT NULL default 0 | ||
12 | ); | ||
13 | |||
14 | |||
15 | CREATE INDEX owner ON inventoryfolders | ||
16 | ( | ||
17 | "agentID" ASC | ||
18 | ); | ||
19 | |||
20 | CREATE INDEX parent ON inventoryfolders | ||
21 | ( | ||
22 | "parentFolderID" ASC | ||
23 | ); | ||
24 | |||
25 | |||
26 | CREATE TABLE inventoryitems ( | ||
27 | "inventoryID" varchar(36) NOT NULL default '' Primary Key, | ||
28 | "assetID" varchar(36) default NULL, | ||
29 | "assetType" int default NULL, | ||
30 | "parentFolderID" varchar(36) default NULL, | ||
31 | "avatarID" varchar(36) default NULL, | ||
32 | "inventoryName" varchar(64) default NULL, | ||
33 | "inventoryDescription" varchar(128) default NULL, | ||
34 | "inventoryNextPermissions" int default NULL, | ||
35 | "inventoryCurrentPermissions" int default NULL, | ||
36 | "invType" int default NULL, | ||
37 | "creatorID" varchar(36) default NULL, | ||
38 | "inventoryBasePermissions" int NOT NULL default 0, | ||
39 | "inventoryEveryOnePermissions" int NOT NULL default 0, | ||
40 | "salePrice" int default NULL, | ||
41 | "saleType" smallint default NULL, | ||
42 | "creationDate" int default NULL, | ||
43 | "groupID" varchar(36) default NULL, | ||
44 | "groupOwned" boolean default NULL, | ||
45 | "flags" int default NULL | ||
46 | ); | ||
47 | |||
48 | |||
49 | CREATE INDEX ii_owner ON inventoryitems | ||
50 | ( | ||
51 | "avatarID" ASC | ||
52 | ); | ||
53 | |||
54 | CREATE INDEX ii_folder ON inventoryitems | ||
55 | ( | ||
56 | "parentFolderID" ASC | ||
57 | ); | ||
58 | |||
59 | COMMIT; | ||
60 | |||
61 | |||
62 | :VERSION 2 | ||
63 | |||
64 | BEGIN TRANSACTION; | ||
65 | |||
66 | ALTER TABLE inventoryitems ADD "inventoryGroupPermissions" INTEGER NOT NULL default 0; | ||
67 | |||
68 | COMMIT; | ||
69 | |||
70 | :VERSION 3 | ||
71 | |||
72 | /* To prevent any potential data loss issues, you should review this script in detail before running it outside the cotext of the database designer.*/ | ||
73 | BEGIN TRANSACTION; | ||
74 | |||
75 | CREATE TABLE Tmp_inventoryfolders | ||
76 | ( | ||
77 | "folderID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
78 | "agentID" uuid NULL DEFAULT (NULL), | ||
79 | "parentFolderID" uuid NULL DEFAULT (NULL), | ||
80 | "folderName" varchar(64) NULL DEFAULT (NULL), | ||
81 | "type" smallint NOT NULL DEFAULT ((0)), | ||
82 | "version" int NOT NULL DEFAULT ((0)) | ||
83 | ); | ||
84 | |||
85 | INSERT INTO Tmp_inventoryfolders ("folderID", "agentID", "parentFolderID", "folderName", type, version) | ||
86 | SELECT cast("folderID" as uuid), cast("agentID" as uuid), cast("parentFolderID" as uuid), "folderName", "type", "version" | ||
87 | FROM inventoryfolders; | ||
88 | |||
89 | DROP TABLE inventoryfolders; | ||
90 | |||
91 | alter table Tmp_inventoryfolders rename to inventoryfolders; | ||
92 | |||
93 | ALTER TABLE inventoryfolders ADD CONSTRAINT | ||
94 | PK__inventor__C2FABFB3173876EA PRIMARY KEY | ||
95 | ( | ||
96 | "folderID" | ||
97 | ); | ||
98 | |||
99 | CREATE INDEX owner ON inventoryfolders | ||
100 | ( | ||
101 | "agentID" | ||
102 | ); | ||
103 | |||
104 | CREATE INDEX parent ON inventoryfolders | ||
105 | ( | ||
106 | "parentFolderID" | ||
107 | ); | ||
108 | |||
109 | COMMIT; | ||
110 | |||
111 | |||
112 | :VERSION 4 | ||
113 | |||
114 | BEGIN TRANSACTION; | ||
115 | |||
116 | CREATE TABLE Tmp_inventoryitems | ||
117 | ( | ||
118 | "inventoryID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
119 | "assetID" uuid NULL DEFAULT (NULL), | ||
120 | "assetType" int NULL DEFAULT (NULL), | ||
121 | "parentFolderID" uuid NULL DEFAULT (NULL), | ||
122 | "avatarID" uuid NULL DEFAULT (NULL), | ||
123 | "inventoryName" varchar(64) NULL DEFAULT (NULL), | ||
124 | "inventoryDescription" varchar(128) NULL DEFAULT (NULL), | ||
125 | "inventoryNextPermissions" int NULL DEFAULT (NULL), | ||
126 | "inventoryCurrentPermissions" int NULL DEFAULT (NULL), | ||
127 | "invType" int NULL DEFAULT (NULL), | ||
128 | "creatorID" uuid NULL DEFAULT (NULL), | ||
129 | "inventoryBasePermissions" int NOT NULL DEFAULT ((0)), | ||
130 | "inventoryEveryOnePermissions" int NOT NULL DEFAULT ((0)), | ||
131 | "salePrice" int NULL DEFAULT (NULL), | ||
132 | "SaleType" smallint NULL DEFAULT (NULL), | ||
133 | "creationDate" int NULL DEFAULT (NULL), | ||
134 | "groupID" uuid NULL DEFAULT (NULL), | ||
135 | "groupOwned" boolean NULL DEFAULT (NULL), | ||
136 | "flags" int NULL DEFAULT (NULL), | ||
137 | "inventoryGroupPermissions" int NOT NULL DEFAULT ((0)) | ||
138 | ); | ||
139 | |||
140 | |||
141 | INSERT INTO Tmp_inventoryitems ("inventoryID", "assetID", "assetType", "parentFolderID", "avatarID", "inventoryName", "inventoryDescription", "inventoryNextPermissions", "inventoryCurrentPermissions", "invType", "creatorID", "inventoryBasePermissions", "inventoryEveryOnePermissions", "salePrice", "SaleType", "creationDate", "groupID", "groupOwned", "flags", "inventoryGroupPermissions") | ||
142 | SELECT cast("inventoryID" as uuid), cast("assetID" as uuid), "assetType", cast("parentFolderID" as uuid), cast("avatarID" as uuid), "inventoryName", "inventoryDescription", "inventoryNextPermissions", "inventoryCurrentPermissions", "invType", cast("creatorID" as uuid), "inventoryBasePermissions", "inventoryEveryOnePermissions", "salePrice", "SaleType", "creationDate", cast("groupID" as uuid), "groupOwned", "flags", "inventoryGroupPermissions" | ||
143 | FROM inventoryitems ; | ||
144 | |||
145 | DROP TABLE inventoryitems; | ||
146 | |||
147 | alter table Tmp_inventoryitems rename to inventoryitems; | ||
148 | |||
149 | ALTER TABLE inventoryitems ADD CONSTRAINT | ||
150 | PK__inventor__C4B7BC2220C1E124 PRIMARY KEY | ||
151 | ( | ||
152 | "inventoryID" | ||
153 | ); | ||
154 | |||
155 | |||
156 | CREATE INDEX ii2_owner ON inventoryitems | ||
157 | ( | ||
158 | "avatarID" | ||
159 | ); | ||
160 | |||
161 | CREATE INDEX ii2_folder ON inventoryitems | ||
162 | ( | ||
163 | "parentFolderID" | ||
164 | ); | ||
165 | |||
166 | COMMIT; | ||
167 | |||
168 | :VERSION 5 | ||
169 | |||
170 | |||
171 | BEGIN TRANSACTION; | ||
172 | |||
173 | -- # Restoring defaults: | ||
174 | -- # NOTE: "inventoryID" does NOT need one: it's NOT NULL PK and a unique Guid must be provided every time anyway! | ||
175 | |||
176 | alter table inventoryitems | ||
177 | alter column "inventoryBasePermissions" set default 0; | ||
178 | alter table inventoryitems | ||
179 | alter column "inventoryEveryOnePermissions" set default 0; | ||
180 | alter table inventoryitems | ||
181 | alter column "inventoryGroupPermissions" set default 0 ; | ||
182 | |||
183 | COMMIT ; | ||
184 | |||
185 | :VERSION 7 | ||
186 | |||
187 | BEGIN TRANSACTION; | ||
188 | |||
189 | -- # "creatorID" goes back to VARCHAR(36) (???) | ||
190 | |||
191 | alter table inventoryitems | ||
192 | alter column "creatorID" type varchar(36); | ||
193 | |||
194 | COMMIT ; | ||
195 | |||
196 | :VERSION 8 | ||
197 | |||
198 | ALTER TABLE inventoryitems | ||
199 | alter column "creatorID" set DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
200 | |||
201 | |||
202 | :VERSION 9 | ||
203 | |||
204 | BEGIN TRANSACTION; | ||
205 | |||
206 | --# "creatorID" goes up to VARCHAR(255) | ||
207 | |||
208 | alter table inventoryitems | ||
209 | alter column "creatorID" type varchar(255); | ||
210 | |||
211 | Commit; | ||
212 | |||
213 | :VERSION 10 | ||
214 | |||
215 | BEGIN TRANSACTION; | ||
216 | |||
217 | Alter table inventoryitems Rename Column "SaleType" to "saleType"; | ||
218 | |||
219 | Commit; | ||
220 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/LogStore.migrations b/OpenSim/Data/PGSQL/Resources/LogStore.migrations new file mode 100644 index 0000000..83727c6 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/LogStore.migrations | |||
@@ -0,0 +1,16 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE logs ( | ||
6 | "logID" int NOT NULL Primary Key, | ||
7 | "target" varchar(36) default NULL, | ||
8 | "server" varchar(64) default NULL, | ||
9 | "method" varchar(64) default NULL, | ||
10 | "arguments" varchar(255) default NULL, | ||
11 | "priority" int default NULL, | ||
12 | "message" text | ||
13 | ); | ||
14 | |||
15 | COMMIT; | ||
16 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/Presence.migrations b/OpenSim/Data/PGSQL/Resources/Presence.migrations new file mode 100755 index 0000000..5184034 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/Presence.migrations | |||
@@ -0,0 +1,42 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE Presence ( | ||
6 | "UserID" varchar(255) NOT NULL, | ||
7 | "RegionID" uuid NOT NULL, | ||
8 | "SessionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
9 | "SecureSessionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' | ||
10 | ); | ||
11 | |||
12 | |||
13 | COMMIT; | ||
14 | |||
15 | :VERSION 2 | ||
16 | |||
17 | BEGIN TRANSACTION; | ||
18 | |||
19 | CREATE UNIQUE INDEX SessionID ON Presence("SessionID"); | ||
20 | CREATE INDEX UserID ON Presence("UserID"); | ||
21 | |||
22 | ALTER TABLE Presence ADD "LastSeen" Timestamp; | ||
23 | |||
24 | COMMIT; | ||
25 | |||
26 | :VERSION 3 # -------------------------- | ||
27 | |||
28 | BEGIN; | ||
29 | |||
30 | CREATE INDEX RegionID ON Presence("RegionID"); | ||
31 | |||
32 | COMMIT; | ||
33 | |||
34 | :VERSION 4 # Making sure LastSeen is actually defined in the table as it most likely erred in the double version 2 migration above | ||
35 | |||
36 | BEGIN; | ||
37 | |||
38 | ALTER TABLE Presence | ||
39 | DROP COLUMN IF EXISTS "LastSeen", | ||
40 | ADD COLUMN "LastSeen" Timestamp; | ||
41 | |||
42 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations new file mode 100644 index 0000000..1284ce0 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations | |||
@@ -0,0 +1,1162 @@ | |||
1 | begin transaction ; | ||
2 | :VERSION 1 | ||
3 | |||
4 | CREATE TABLE prims( | ||
5 | "UUID" varchar(255) NOT NULL Primary key, | ||
6 | "RegionUUID" varchar(255) NULL, | ||
7 | "ParentID" int NULL, | ||
8 | "CreationDate" int NULL, | ||
9 | "Name" varchar(255) NULL, | ||
10 | "SceneGroupID" varchar(255) NULL, | ||
11 | "Text" varchar(255) NULL, | ||
12 | "Description" varchar(255) NULL, | ||
13 | "SitName" varchar(255) NULL, | ||
14 | "TouchName" varchar(255) NULL, | ||
15 | "ObjectFlags" int NULL, | ||
16 | "CreatorID" varchar(255) NULL, | ||
17 | "OwnerID" varchar(255) NULL, | ||
18 | "GroupID" varchar(255) NULL, | ||
19 | "LastOwnerID" varchar(255) NULL, | ||
20 | "OwnerMask" int NULL, | ||
21 | "NextOwnerMask" int NULL, | ||
22 | "GroupMask" int NULL, | ||
23 | "EveryoneMask" int NULL, | ||
24 | "BaseMask" int NULL, | ||
25 | "PositionX" double precision NULL, | ||
26 | "PositionY" double precision NULL, | ||
27 | "PositionZ" double precision NULL, | ||
28 | "GroupPositionX" double precision NULL, | ||
29 | "GroupPositionY" double precision NULL, | ||
30 | "GroupPositionZ" double precision NULL, | ||
31 | "VelocityX" double precision NULL, | ||
32 | "VelocityY" double precision NULL, | ||
33 | "VelocityZ" double precision NULL, | ||
34 | "AngularVelocityX" double precision NULL, | ||
35 | "AngularVelocityY" double precision NULL, | ||
36 | "AngularVelocityZ" double precision NULL, | ||
37 | "AccelerationX" double precision NULL, | ||
38 | "AccelerationY" double precision NULL, | ||
39 | "AccelerationZ" double precision NULL, | ||
40 | "RotationX" double precision NULL, | ||
41 | "RotationY" double precision NULL, | ||
42 | "RotationZ" double precision NULL, | ||
43 | "RotationW" double precision NULL, | ||
44 | "SitTargetOffsetX" double precision NULL, | ||
45 | "SitTargetOffsetY" double precision NULL, | ||
46 | "SitTargetOffsetZ" double precision NULL, | ||
47 | "SitTargetOrientW" double precision NULL, | ||
48 | "SitTargetOrientX" double precision NULL, | ||
49 | "SitTargetOrientY" double precision NULL, | ||
50 | "SitTargetOrientZ" double precision NULL | ||
51 | ); | ||
52 | |||
53 | CREATE TABLE primshapes( | ||
54 | "UUID" varchar(255) NOT NULL primary key, | ||
55 | "Shape" int NULL, | ||
56 | "ScaleX" double precision NULL, | ||
57 | "ScaleY" double precision NULL, | ||
58 | "ScaleZ" double precision NULL, | ||
59 | "PCode" int NULL, | ||
60 | "PathBegin" int NULL, | ||
61 | "PathEnd" int NULL, | ||
62 | "PathScaleX" int NULL, | ||
63 | "PathScaleY" int NULL, | ||
64 | "PathShearX" int NULL, | ||
65 | "PathShearY" int NULL, | ||
66 | "PathSkew" int NULL, | ||
67 | "PathCurve" int NULL, | ||
68 | "PathRadiusOffset" int NULL, | ||
69 | "PathRevolutions" int NULL, | ||
70 | "PathTaperX" int NULL, | ||
71 | "PathTaperY" int NULL, | ||
72 | "PathTwist" int NULL, | ||
73 | "PathTwistBegin" int NULL, | ||
74 | "ProfileBegin" int NULL, | ||
75 | "ProfileEnd" int NULL, | ||
76 | "ProfileCurve" int NULL, | ||
77 | "ProfileHollow" int NULL, | ||
78 | "State" int NULL, | ||
79 | "Texture" bytea NULL, | ||
80 | "ExtraParams" bytea NULL | ||
81 | ); | ||
82 | |||
83 | CREATE TABLE primitems( | ||
84 | "itemID" varchar(255) NOT NULL primary key, | ||
85 | "primID" varchar(255) NULL, | ||
86 | "assetID" varchar(255) NULL, | ||
87 | "parentFolderID" varchar(255) NULL, | ||
88 | "invType" int NULL, | ||
89 | "assetType" int NULL, | ||
90 | "name" varchar(255) NULL, | ||
91 | "description" varchar(255) NULL, | ||
92 | "creationDate" varchar(255) NULL, | ||
93 | "creatorID" varchar(255) NULL, | ||
94 | "ownerID" varchar(255) NULL, | ||
95 | "lastOwnerID" varchar(255) NULL, | ||
96 | "groupID" varchar(255) NULL, | ||
97 | "nextPermissions" int NULL, | ||
98 | "currentPermissions" int NULL, | ||
99 | "basePermissions" int NULL, | ||
100 | "everyonePermissions" int NULL, | ||
101 | "groupPermissions" int NULL | ||
102 | ); | ||
103 | |||
104 | CREATE TABLE terrain( | ||
105 | "RegionUUID" varchar(255) NULL, | ||
106 | "Revision" int NULL, | ||
107 | "Heightfield" bytea NULL | ||
108 | ); | ||
109 | |||
110 | |||
111 | CREATE TABLE land( | ||
112 | "UUID" varchar(255) NOT NULL primary key, | ||
113 | "RegionUUID" varchar(255) NULL, | ||
114 | "LocalLandID" int NULL, | ||
115 | "Bitmap" bytea NULL, | ||
116 | "Name" varchar(255) NULL, | ||
117 | "Description" varchar(255) NULL, | ||
118 | "OwnerUUID" varchar(255) NULL, | ||
119 | "IsGroupOwned" boolean NULL, | ||
120 | "Area" int NULL, | ||
121 | "AuctionID" int NULL, | ||
122 | "Category" int NULL, | ||
123 | "ClaimDate" int NULL, | ||
124 | "ClaimPrice" int NULL, | ||
125 | "GroupUUID" varchar(255) NULL, | ||
126 | "SalePrice" int NULL, | ||
127 | "LandStatus" int NULL, | ||
128 | "LandFlags" int NULL, | ||
129 | "LandingType" int NULL, | ||
130 | "MediaAutoScale" int NULL, | ||
131 | "MediaTextureUUID" varchar(255) NULL, | ||
132 | "MediaURL" varchar(255) NULL, | ||
133 | "MusicURL" varchar(255) NULL, | ||
134 | "PassHours" double precision NULL, | ||
135 | "PassPrice" int NULL, | ||
136 | "SnapshotUUID" varchar(255) NULL, | ||
137 | "UserLocationX" double precision NULL, | ||
138 | "UserLocationY" double precision NULL, | ||
139 | "UserLocationZ" double precision NULL, | ||
140 | "UserLookAtX" double precision NULL, | ||
141 | "UserLookAtY" double precision NULL, | ||
142 | "UserLookAtZ" double precision NULL | ||
143 | ); | ||
144 | |||
145 | Create index on land (lower("Name")); | ||
146 | |||
147 | CREATE TABLE landaccesslist( | ||
148 | "LandUUID" varchar(255) NULL, | ||
149 | "AccessUUID" varchar(255) NULL, | ||
150 | "Flags" int NULL | ||
151 | ); | ||
152 | |||
153 | COMMIT; | ||
154 | |||
155 | :VERSION 2 | ||
156 | |||
157 | BEGIN TRANSACTION; | ||
158 | |||
159 | CREATE TABLE regionban ( | ||
160 | "regionUUID" VARCHAR(36) NOT NULL, | ||
161 | "bannedUUID" VARCHAR(36) NOT NULL, | ||
162 | "bannedIp" VARCHAR(16) NOT NULL, | ||
163 | "bannedIpHostMask" VARCHAR(16) NOT NULL | ||
164 | ); | ||
165 | |||
166 | create table regionsettings ( | ||
167 | "regionUUID" varchar(36) not null primary key, | ||
168 | "block_terraform" boolean not null, | ||
169 | "block_fly" boolean not null, | ||
170 | "allow_damage" boolean not null, | ||
171 | "restrict_pushing" boolean not null, | ||
172 | "allow_land_resell" boolean not null, | ||
173 | "allow_land_join_divide" boolean not null, | ||
174 | "block_show_in_search" boolean not null, | ||
175 | "agent_limit" int not null, | ||
176 | "object_bonus" double precision not null, | ||
177 | "maturity" int not null, | ||
178 | "disable_scripts" boolean not null, | ||
179 | "disable_collisions" boolean not null, | ||
180 | "disable_physics" boolean not null, | ||
181 | "terrain_texture_1" varchar(36) not null, | ||
182 | "terrain_texture_2" varchar(36) not null, | ||
183 | "terrain_texture_3" varchar(36) not null, | ||
184 | "terrain_texture_4" varchar(36) not null, | ||
185 | "elevation_1_nw" double precision not null, | ||
186 | "elevation_2_nw" double precision not null, | ||
187 | "elevation_1_ne" double precision not null, | ||
188 | "elevation_2_ne" double precision not null, | ||
189 | "elevation_1_se" double precision not null, | ||
190 | "elevation_2_se" double precision not null, | ||
191 | "elevation_1_sw" double precision not null, | ||
192 | "elevation_2_sw" double precision not null, | ||
193 | "water_height" double precision not null, | ||
194 | "terrain_raise_limit" double precision not null, | ||
195 | "terrain_lower_limit" double precision not null, | ||
196 | "use_estate_sun" boolean not null, | ||
197 | "fixed_sun" boolean not null, | ||
198 | "sun_position" double precision not null, | ||
199 | "covenant" varchar(36) default NULL, | ||
200 | "Sandbox" boolean NOT NULL | ||
201 | ); | ||
202 | |||
203 | COMMIT; | ||
204 | |||
205 | :VERSION 3 | ||
206 | |||
207 | BEGIN TRANSACTION; | ||
208 | |||
209 | CREATE TABLE Tmp_prims | ||
210 | ( | ||
211 | "UUID" varchar(36) NOT NULL , | ||
212 | "RegionUUID" varchar(36) NULL, | ||
213 | "ParentID" int NULL, | ||
214 | "CreationDate" int NULL, | ||
215 | "Name" varchar(255) NULL, | ||
216 | "SceneGroupID" varchar(36) NULL, | ||
217 | "Text" varchar(255) NULL, | ||
218 | "Description" varchar(255) NULL, | ||
219 | "SitName" varchar(255) NULL, | ||
220 | "TouchName" varchar(255) NULL, | ||
221 | "ObjectFlags" int NULL, | ||
222 | "CreatorID" varchar(36) NULL, | ||
223 | "OwnerID" varchar(36) NULL, | ||
224 | "GroupID" varchar(36) NULL, | ||
225 | "LastOwnerID" varchar(36) NULL, | ||
226 | "OwnerMask" int NULL, | ||
227 | "NextOwnerMask" int NULL, | ||
228 | "GroupMask" int NULL, | ||
229 | "EveryoneMask" int NULL, | ||
230 | "BaseMask" int NULL, | ||
231 | "PositionX" double precision NULL, | ||
232 | "PositionY" double precision NULL, | ||
233 | "PositionZ" double precision NULL, | ||
234 | "GroupPositionX" double precision NULL, | ||
235 | "GroupPositionY" double precision NULL, | ||
236 | "GroupPositionZ" double precision NULL, | ||
237 | "VelocityX" double precision NULL, | ||
238 | "VelocityY" double precision NULL, | ||
239 | "VelocityZ" double precision NULL, | ||
240 | "AngularVelocityX" double precision NULL, | ||
241 | "AngularVelocityY" double precision NULL, | ||
242 | "AngularVelocityZ" double precision NULL, | ||
243 | "AccelerationX" double precision NULL, | ||
244 | "AccelerationY" double precision NULL, | ||
245 | "AccelerationZ" double precision NULL, | ||
246 | "RotationX" double precision NULL, | ||
247 | "RotationY" double precision NULL, | ||
248 | "RotationZ" double precision NULL, | ||
249 | "RotationW" double precision NULL, | ||
250 | "SitTargetOffsetX" double precision NULL, | ||
251 | "SitTargetOffsetY" double precision NULL, | ||
252 | "SitTargetOffsetZ" double precision NULL, | ||
253 | "SitTargetOrientW" double precision NULL, | ||
254 | "SitTargetOrientX" double precision NULL, | ||
255 | "SitTargetOrientY" double precision NULL, | ||
256 | "SitTargetOrientZ" double precision NULL | ||
257 | ); | ||
258 | |||
259 | INSERT INTO Tmp_prims ("UUID", "RegionUUID", "ParentID", "CreationDate", "Name", "SceneGroupID", "Text", "Description", "SitName", "TouchName", "ObjectFlags", "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", "SitTargetOffsetX", "SitTargetOffsetY", "SitTargetOffsetZ", "SitTargetOrientW", "SitTargetOrientX", "SitTargetOrientY", "SitTargetOrientZ") | ||
260 | SELECT cast("UUID" as varchar(36)), cast("RegionUUID" as varchar(36)), "ParentID", "CreationDate", "Name", cast("SceneGroupID" as varchar(36)), "Text", "Description", "SitName", "TouchName", "ObjectFlags", cast("CreatorID" as varchar(36)), cast("OwnerID" as varchar(36)), cast( "GroupID" as varchar(36)), cast("LastOwnerID" as varchar(36)), "OwnerMask", "NextOwnerMask", "GroupMask", "EveryoneMask", "BaseMask", "PositionX", "PositionY", "PositionZ", "GroupPositionX", "GroupPositionY", "GroupPositionZ", "VelocityX", "VelocityY", "VelocityZ", "AngularVelocityX", "AngularVelocityY", "AngularVelocityZ", "AccelerationX", "AccelerationY", "AccelerationZ", "RotationX", "RotationY", "RotationZ", "RotationW", "SitTargetOffsetX", "SitTargetOffsetY", "SitTargetOffsetZ", "SitTargetOrientW", "SitTargetOrientX", "SitTargetOrientY", "SitTargetOrientZ" | ||
261 | FROM prims ; | ||
262 | |||
263 | DROP TABLE prims; | ||
264 | |||
265 | alter table Tmp_prims rename to prims; | ||
266 | |||
267 | |||
268 | ALTER TABLE prims ADD CONSTRAINT | ||
269 | PK__prims__10566F31 PRIMARY KEY | ||
270 | ( | ||
271 | "UUID" | ||
272 | ); | ||
273 | |||
274 | COMMIT; | ||
275 | |||
276 | :VERSION 4 | ||
277 | |||
278 | BEGIN TRANSACTION; | ||
279 | |||
280 | CREATE TABLE Tmp_primitems | ||
281 | ( | ||
282 | "itemID" varchar(36) NOT NULL, | ||
283 | "primID" varchar(36) NULL, | ||
284 | "assetID" varchar(36) NULL, | ||
285 | "parentFolderID" varchar(36) NULL, | ||
286 | "invType" int NULL, | ||
287 | "assetType" int NULL, | ||
288 | "name" varchar(255) NULL, | ||
289 | "description" varchar(255) NULL, | ||
290 | "creationDate" varchar(255) NULL, | ||
291 | "creatorID" varchar(36) NULL, | ||
292 | "ownerID" varchar(36) NULL, | ||
293 | "lastOwnerID" varchar(36) NULL, | ||
294 | "groupID" varchar(36) NULL, | ||
295 | "nextPermissions" int NULL, | ||
296 | "currentPermissions" int NULL, | ||
297 | "basePermissions" int NULL, | ||
298 | "everyonePermissions" int NULL, | ||
299 | "groupPermissions" int NULL | ||
300 | ); | ||
301 | |||
302 | INSERT INTO Tmp_primitems ("itemID", "primID", "assetID", "parentFolderID", "invType", "assetType", "name", "description", "creationDate", "creatorID", "ownerID", "lastOwnerID", "groupID", "nextPermissions", "currentPermissions", "basePermissions", "everyonePermissions", "groupPermissions") | ||
303 | SELECT cast("itemID" as varchar(36)), cast("primID" as varchar(36)), cast("assetID" as varchar(36)), cast( "parentFolderID" as varchar(36)), "invType", "assetType", "name", "description", "creationDate", cast( "creatorID" as varchar(36)), cast("ownerID" as varchar(36)), cast("lastOwnerID" as varchar(36)), cast("groupID" as varchar(36)), "nextPermissions", "currentPermissions", "basePermissions", "everyonePermissions", "groupPermissions" | ||
304 | from primitems; | ||
305 | |||
306 | DROP TABLE primitems; | ||
307 | |||
308 | alter table Tmp_primitems rename to primitems; | ||
309 | |||
310 | ALTER TABLE primitems ADD CONSTRAINT | ||
311 | PK__primitems__0A688BB1 PRIMARY KEY | ||
312 | ( | ||
313 | "itemID" | ||
314 | ); | ||
315 | |||
316 | |||
317 | COMMIT; | ||
318 | |||
319 | |||
320 | :VERSION 5 | ||
321 | |||
322 | BEGIN TRANSACTION; | ||
323 | |||
324 | CREATE TABLE Tmp_primshapes | ||
325 | ( | ||
326 | "UUID" varchar(36) NOT NULL, | ||
327 | "Shape" int NULL, | ||
328 | "ScaleX" double precision NULL, | ||
329 | "ScaleY" double precision NULL, | ||
330 | "ScaleZ" double precision NULL, | ||
331 | "PCode" int NULL, | ||
332 | "PathBegin" int NULL, | ||
333 | "PathEnd" int NULL, | ||
334 | "PathScaleX" int NULL, | ||
335 | "PathScaleY" int NULL, | ||
336 | "PathShearX" int NULL, | ||
337 | "PathShearY" int NULL, | ||
338 | "PathSkew" int NULL, | ||
339 | "PathCurve" int NULL, | ||
340 | "PathRadiusOffset" int NULL, | ||
341 | "PathRevolutions" int NULL, | ||
342 | "PathTaperX" int NULL, | ||
343 | "PathTaperY" int NULL, | ||
344 | "PathTwist" int NULL, | ||
345 | "PathTwistBegin" int NULL, | ||
346 | "ProfileBegin" int NULL, | ||
347 | "ProfileEnd" int NULL, | ||
348 | "ProfileCurve" int NULL, | ||
349 | "ProfileHollow" int NULL, | ||
350 | "State" int NULL, | ||
351 | "Texture" bytea NULL, | ||
352 | "ExtraParams" bytea NULL | ||
353 | ) ; | ||
354 | |||
355 | INSERT INTO Tmp_primshapes ("UUID", "Shape", "ScaleX", "ScaleY", "ScaleZ", "PCode", "PathBegin", "PathEnd", "PathScaleX", "PathScaleY", "PathShearX", "PathShearY", "PathSkew", "PathCurve", "PathRadiusOffset", "PathRevolutions", "PathTaperX", "PathTaperY", "PathTwist", "PathTwistBegin", "ProfileBegin", "ProfileEnd", "ProfileCurve", "ProfileHollow", "State", "Texture", "ExtraParams") | ||
356 | SELECT cast("UUID" as varchar(36)), "Shape", "ScaleX", "ScaleY", "ScaleZ", "PCode", "PathBegin", "PathEnd", "PathScaleX", "PathScaleY", "PathShearX", "PathShearY", "PathSkew", "PathCurve", "PathRadiusOffset", "PathRevolutions", "PathTaperX", "PathTaperY", "PathTwist", "PathTwistBegin", "ProfileBegin", "ProfileEnd", "ProfileCurve", "ProfileHollow", "State", "Texture", "ExtraParams" | ||
357 | FROM primshapes; | ||
358 | |||
359 | DROP TABLE primshapes; | ||
360 | |||
361 | alter table Tmp_primshapes rename to primshapes; | ||
362 | |||
363 | ALTER TABLE primshapes ADD CONSTRAINT | ||
364 | PK__primshapes__0880433F PRIMARY KEY | ||
365 | ( | ||
366 | "UUID" | ||
367 | ) ; | ||
368 | |||
369 | COMMIT; | ||
370 | |||
371 | |||
372 | :VERSION 6 | ||
373 | |||
374 | BEGIN TRANSACTION; | ||
375 | |||
376 | ALTER TABLE prims ADD "PayPrice" int not null default 0; | ||
377 | ALTER TABLE prims ADD "PayButton1" int not null default 0; | ||
378 | ALTER TABLE prims ADD "PayButton2" int not null default 0; | ||
379 | ALTER TABLE prims ADD "PayButton3" int not null default 0; | ||
380 | ALTER TABLE prims ADD "PayButton4" int not null default 0; | ||
381 | ALTER TABLE prims ADD "LoopedSound" varchar(36) not null default '00000000-0000-0000-0000-000000000000'; | ||
382 | ALTER TABLE prims ADD "LoopedSoundGain" double precision not null default 0.0; | ||
383 | ALTER TABLE prims ADD "TextureAnimation" bytea; | ||
384 | ALTER TABLE prims ADD "OmegaX" double precision not null default 0.0; | ||
385 | ALTER TABLE prims ADD "OmegaY" double precision not null default 0.0; | ||
386 | ALTER TABLE prims ADD "OmegaZ" double precision not null default 0.0; | ||
387 | ALTER TABLE prims ADD "CameraEyeOffsetX" double precision not null default 0.0; | ||
388 | ALTER TABLE prims ADD "CameraEyeOffsetY" double precision not null default 0.0; | ||
389 | ALTER TABLE prims ADD "CameraEyeOffsetZ" double precision not null default 0.0; | ||
390 | ALTER TABLE prims ADD "CameraAtOffsetX" double precision not null default 0.0; | ||
391 | ALTER TABLE prims ADD "CameraAtOffsetY" double precision not null default 0.0; | ||
392 | ALTER TABLE prims ADD "CameraAtOffsetZ" double precision not null default 0.0; | ||
393 | ALTER TABLE prims ADD "ForceMouselook" smallint not null default 0; | ||
394 | ALTER TABLE prims ADD "ScriptAccessPin" int not null default 0; | ||
395 | ALTER TABLE prims ADD "AllowedDrop" smallint not null default 0; | ||
396 | ALTER TABLE prims ADD "DieAtEdge" smallint not null default 0; | ||
397 | ALTER TABLE prims ADD "SalePrice" int not null default 10; | ||
398 | ALTER TABLE prims ADD "SaleType" smallint not null default 0; | ||
399 | |||
400 | ALTER TABLE primitems add "flags" integer not null default 0; | ||
401 | |||
402 | ALTER TABLE land ADD "AuthbuyerID" varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; | ||
403 | |||
404 | CREATE index prims_regionuuid on prims("RegionUUID"); | ||
405 | CREATE index prims_parentid on prims("ParentID"); | ||
406 | |||
407 | CREATE index primitems_primid on primitems("primID"); | ||
408 | |||
409 | COMMIT; | ||
410 | |||
411 | |||
412 | :VERSION 7 | ||
413 | |||
414 | BEGIN TRANSACTION; | ||
415 | |||
416 | ALTER TABLE prims ADD "ColorR" int not null default 0; | ||
417 | ALTER TABLE prims ADD "ColorG" int not null default 0; | ||
418 | ALTER TABLE prims ADD "ColorB" int not null default 0; | ||
419 | ALTER TABLE prims ADD "ColorA" int not null default 0; | ||
420 | ALTER TABLE prims ADD "ParticleSystem" bytea; | ||
421 | ALTER TABLE prims ADD "ClickAction" smallint NOT NULL default 0; | ||
422 | |||
423 | COMMIT; | ||
424 | |||
425 | |||
426 | :VERSION 8 | ||
427 | |||
428 | BEGIN TRANSACTION; | ||
429 | |||
430 | ALTER TABLE land ADD "OtherCleanTime" integer NOT NULL default 0; | ||
431 | ALTER TABLE land ADD "Dwell" integer NOT NULL default 0; | ||
432 | |||
433 | COMMIT; | ||
434 | |||
435 | :VERSION 9 | ||
436 | |||
437 | BEGIN TRANSACTION; | ||
438 | |||
439 | ALTER TABLE prims ADD "Material" smallint NOT NULL default 3; | ||
440 | |||
441 | COMMIT; | ||
442 | |||
443 | |||
444 | :VERSION 10 | ||
445 | |||
446 | BEGIN TRANSACTION; | ||
447 | |||
448 | ALTER TABLE regionsettings ADD "sunvectorx" double precision NOT NULL default 0; | ||
449 | ALTER TABLE regionsettings ADD "sunvectory" double precision NOT NULL default 0; | ||
450 | ALTER TABLE regionsettings ADD "sunvectorz" double precision NOT NULL default 0; | ||
451 | |||
452 | COMMIT; | ||
453 | |||
454 | |||
455 | :VERSION 11 | ||
456 | |||
457 | BEGIN TRANSACTION; | ||
458 | |||
459 | ALTER TABLE prims ADD "CollisionSound" char(36) not null default '00000000-0000-0000-0000-000000000000'; | ||
460 | ALTER TABLE prims ADD "CollisionSoundVolume" double precision not null default 0.0; | ||
461 | |||
462 | COMMIT; | ||
463 | |||
464 | |||
465 | :VERSION 12 | ||
466 | |||
467 | BEGIN TRANSACTION; | ||
468 | |||
469 | ALTER TABLE prims ADD "LinkNumber" integer not null default 0; | ||
470 | |||
471 | COMMIT; | ||
472 | |||
473 | |||
474 | :VERSION 13 | ||
475 | |||
476 | BEGIN TRANSACTION; | ||
477 | |||
478 | CREATE TABLE Tmp_prims | ||
479 | ( | ||
480 | "UUID" uuid NOT NULL, | ||
481 | "RegionUUID" uuid NULL, | ||
482 | "ParentID" int NULL, | ||
483 | "CreationDate" int NULL, | ||
484 | "Name" varchar(255) NULL, | ||
485 | "SceneGroupID" uuid NULL, | ||
486 | "Text" varchar(255) NULL, | ||
487 | "Description" varchar(255) NULL, | ||
488 | "SitName" varchar(255) NULL, | ||
489 | "TouchName" varchar(255) NULL, | ||
490 | "ObjectFlags" int NULL, | ||
491 | "CreatorID" uuid NULL, | ||
492 | "OwnerID" uuid NULL, | ||
493 | "GroupID" uuid NULL, | ||
494 | "LastOwnerID" uuid NULL, | ||
495 | "OwnerMask" int NULL, | ||
496 | "NextOwnerMask" int NULL, | ||
497 | "GroupMask" int NULL, | ||
498 | "EveryoneMask" int NULL, | ||
499 | "BaseMask" int NULL, | ||
500 | "PositionX" double precision NULL, | ||
501 | "PositionY" double precision NULL, | ||
502 | "PositionZ" double precision NULL, | ||
503 | "GroupPositionX" double precision NULL, | ||
504 | "GroupPositionY" double precision NULL, | ||
505 | "GroupPositionZ" double precision NULL, | ||
506 | "VelocityX" double precision NULL, | ||
507 | "VelocityY" double precision NULL, | ||
508 | "VelocityZ" double precision NULL, | ||
509 | "AngularVelocityX" double precision NULL, | ||
510 | "AngularVelocityY" double precision NULL, | ||
511 | "AngularVelocityZ" double precision NULL, | ||
512 | "AccelerationX" double precision NULL, | ||
513 | "AccelerationY" double precision NULL, | ||
514 | "AccelerationZ" double precision NULL, | ||
515 | "RotationX" double precision NULL, | ||
516 | "RotationY" double precision NULL, | ||
517 | "RotationZ" double precision NULL, | ||
518 | "RotationW" double precision NULL, | ||
519 | "SitTargetOffsetX" double precision NULL, | ||
520 | "SitTargetOffsetY" double precision NULL, | ||
521 | "SitTargetOffsetZ" double precision NULL, | ||
522 | "SitTargetOrientW" double precision NULL, | ||
523 | "SitTargetOrientX" double precision NULL, | ||
524 | "SitTargetOrientY" double precision NULL, | ||
525 | "SitTargetOrientZ" double precision NULL, | ||
526 | "PayPrice" int NOT NULL DEFAULT ((0)), | ||
527 | "PayButton1" int NOT NULL DEFAULT ((0)), | ||
528 | "PayButton2" int NOT NULL DEFAULT ((0)), | ||
529 | "PayButton3" int NOT NULL DEFAULT ((0)), | ||
530 | "PayButton4" int NOT NULL DEFAULT ((0)), | ||
531 | "LoopedSound" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
532 | "LoopedSoundGain" double precision NOT NULL DEFAULT ((0.0)), | ||
533 | "TextureAnimation" bytea NULL, | ||
534 | "OmegaX" double precision NOT NULL DEFAULT ((0.0)), | ||
535 | "OmegaY" double precision NOT NULL DEFAULT ((0.0)), | ||
536 | "OmegaZ" double precision NOT NULL DEFAULT ((0.0)), | ||
537 | "CameraEyeOffsetX" double precision NOT NULL DEFAULT ((0.0)), | ||
538 | "CameraEyeOffsetY" double precision NOT NULL DEFAULT ((0.0)), | ||
539 | "CameraEyeOffsetZ" double precision NOT NULL DEFAULT ((0.0)), | ||
540 | "CameraAtOffsetX" double precision NOT NULL DEFAULT ((0.0)), | ||
541 | "CameraAtOffsetY" double precision NOT NULL DEFAULT ((0.0)), | ||
542 | "CameraAtOffsetZ" double precision NOT NULL DEFAULT ((0.0)), | ||
543 | "ForceMouselook" smallint NOT NULL DEFAULT ((0)), | ||
544 | "ScriptAccessPin" int NOT NULL DEFAULT ((0)), | ||
545 | "AllowedDrop" smallint NOT NULL DEFAULT ((0)), | ||
546 | "DieAtEdge" smallint NOT NULL DEFAULT ((0)), | ||
547 | "SalePrice" int NOT NULL DEFAULT ((10)), | ||
548 | "SaleType" smallint NOT NULL DEFAULT ((0)), | ||
549 | "ColorR" int NOT NULL DEFAULT ((0)), | ||
550 | "ColorG" int NOT NULL DEFAULT ((0)), | ||
551 | "ColorB" int NOT NULL DEFAULT ((0)), | ||
552 | "ColorA" int NOT NULL DEFAULT ((0)), | ||
553 | "ParticleSystem" bytea NULL, | ||
554 | "ClickAction" smallint NOT NULL DEFAULT ((0)), | ||
555 | "Material" smallint NOT NULL DEFAULT ((3)), | ||
556 | "CollisionSound" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
557 | "CollisionSoundVolume" double precision NOT NULL DEFAULT ((0.0)), | ||
558 | "LinkNumber" int NOT NULL DEFAULT ((0)) | ||
559 | ); | ||
560 | |||
561 | INSERT INTO Tmp_prims ("UUID", "RegionUUID", "ParentID", "CreationDate", "Name", "SceneGroupID", "Text", "Description", "SitName", "TouchName", "ObjectFlags", "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", "SitTargetOffsetX", "SitTargetOffsetY", "SitTargetOffsetZ", "SitTargetOrientW", "SitTargetOrientX", "SitTargetOrientY", "SitTargetOrientZ", "PayPrice", "PayButton1", "PayButton2", "PayButton3", "PayButton4", "LoopedSound", "LoopedSoundGain", "TextureAnimation", "OmegaX", "OmegaY", "OmegaZ", "CameraEyeOffsetX", "CameraEyeOffsetY", "CameraEyeOffsetZ", "CameraAtOffsetX", "CameraAtOffsetY", "CameraAtOffsetZ", "ForceMouselook", "ScriptAccessPin", "AllowedDrop", "DieAtEdge", "SalePrice", "SaleType", "ColorR", "ColorG", "ColorB", "ColorA", "ParticleSystem", "ClickAction", "Material", "CollisionSound", "CollisionSoundVolume", "LinkNumber") | ||
562 | SELECT cast("UUID" as uuid), cast("RegionUUID" as uuid), "ParentID", "CreationDate", "Name", cast("SceneGroupID" as uuid), "Text", "Description", "SitName", "TouchName", "ObjectFlags", cast("CreatorID" as uuid), cast("OwnerID" as uuid), cast("GroupID" as uuid), cast("LastOwnerID" as uuid), "OwnerMask", "NextOwnerMask", "GroupMask", "EveryoneMask", "BaseMask", "PositionX", "PositionY", "PositionZ", "GroupPositionX", "GroupPositionY", "GroupPositionZ", "VelocityX", "VelocityY", "VelocityZ", "AngularVelocityX", "AngularVelocityY", "AngularVelocityZ", "AccelerationX", "AccelerationY", "AccelerationZ", "RotationX", "RotationY", "RotationZ", "RotationW", "SitTargetOffsetX", "SitTargetOffsetY", "SitTargetOffsetZ", "SitTargetOrientW", "SitTargetOrientX", "SitTargetOrientY", "SitTargetOrientZ", "PayPrice", "PayButton1", "PayButton2", "PayButton3", "PayButton4", cast("LoopedSound" as uuid), "LoopedSoundGain", "TextureAnimation", "OmegaX", "OmegaY", "OmegaZ", "CameraEyeOffsetX", "CameraEyeOffsetY", "CameraEyeOffsetZ", "CameraAtOffsetX", "CameraAtOffsetY", "CameraAtOffsetZ", "ForceMouselook", "ScriptAccessPin", "AllowedDrop", "DieAtEdge", "SalePrice", "SaleType", "ColorR", "ColorG", "ColorB", "ColorA", "ParticleSystem", "ClickAction", "Material", cast("CollisionSound" as uuid), "CollisionSoundVolume", "LinkNumber" | ||
563 | FROM prims ; | ||
564 | |||
565 | DROP TABLE prims; | ||
566 | |||
567 | alter table Tmp_prims rename to prims; | ||
568 | |||
569 | ALTER TABLE prims ADD CONSTRAINT | ||
570 | PK__prims__10566F31 PRIMARY KEY | ||
571 | ( | ||
572 | "UUID" | ||
573 | ); | ||
574 | |||
575 | |||
576 | CREATE INDEX prims_regionuuid ON prims | ||
577 | ( | ||
578 | "RegionUUID" | ||
579 | ); | ||
580 | |||
581 | CREATE INDEX prims_parentid ON prims | ||
582 | ( | ||
583 | "ParentID" | ||
584 | ); | ||
585 | |||
586 | COMMIT; | ||
587 | |||
588 | |||
589 | :VERSION 14 | ||
590 | |||
591 | BEGIN TRANSACTION; | ||
592 | |||
593 | CREATE TABLE Tmp_primshapes | ||
594 | ( | ||
595 | "UUID" uuid NOT NULL, | ||
596 | "Shape" int NULL, | ||
597 | "ScaleX" double precision NULL, | ||
598 | "ScaleY" double precision NULL, | ||
599 | "ScaleZ" double precision NULL, | ||
600 | "PCode" int NULL, | ||
601 | "PathBegin" int NULL, | ||
602 | "PathEnd" int NULL, | ||
603 | "PathScaleX" int NULL, | ||
604 | "PathScaleY" int NULL, | ||
605 | "PathShearX" int NULL, | ||
606 | "PathShearY" int NULL, | ||
607 | "PathSkew" int NULL, | ||
608 | "PathCurve" int NULL, | ||
609 | "PathRadiusOffset" int NULL, | ||
610 | "PathRevolutions" int NULL, | ||
611 | "PathTaperX" int NULL, | ||
612 | "PathTaperY" int NULL, | ||
613 | "PathTwist" int NULL, | ||
614 | "PathTwistBegin" int NULL, | ||
615 | "ProfileBegin" int NULL, | ||
616 | "ProfileEnd" int NULL, | ||
617 | "ProfileCurve" int NULL, | ||
618 | "ProfileHollow" int NULL, | ||
619 | "State" int NULL, | ||
620 | "Texture" bytea NULL, | ||
621 | "ExtraParams" bytea NULL | ||
622 | ); | ||
623 | |||
624 | INSERT INTO Tmp_primshapes ("UUID", "Shape", "ScaleX", "ScaleY", "ScaleZ", "PCode", "PathBegin", "PathEnd", "PathScaleX", "PathScaleY", "PathShearX", "PathShearY", "PathSkew", "PathCurve", "PathRadiusOffset", "PathRevolutions", "PathTaperX", "PathTaperY", "PathTwist", "PathTwistBegin", "ProfileBegin", "ProfileEnd", "ProfileCurve", "ProfileHollow", "State", "Texture", "ExtraParams") | ||
625 | SELECT cast("UUID" as uuid), "Shape", "ScaleX", "ScaleY", "ScaleZ", "PCode", "PathBegin", "PathEnd", "PathScaleX", "PathScaleY", "PathShearX", "PathShearY", "PathSkew", "PathCurve", "PathRadiusOffset", "PathRevolutions", "PathTaperX", "PathTaperY", "PathTwist", "PathTwistBegin", "ProfileBegin", "ProfileEnd", "ProfileCurve", "ProfileHollow", "State", "Texture", "ExtraParams" | ||
626 | FROM primshapes; | ||
627 | |||
628 | DROP TABLE primshapes; | ||
629 | |||
630 | alter table Tmp_primshapes rename to primshapes; | ||
631 | |||
632 | ALTER TABLE primshapes ADD CONSTRAINT | ||
633 | PK__primshapes__0880433F PRIMARY KEY | ||
634 | ( | ||
635 | "UUID" | ||
636 | ); | ||
637 | |||
638 | COMMIT; | ||
639 | |||
640 | |||
641 | :VERSION 15 | ||
642 | |||
643 | BEGIN TRANSACTION; | ||
644 | |||
645 | CREATE TABLE Tmp_primitems | ||
646 | ( | ||
647 | "itemID" uuid NOT NULL, | ||
648 | "primID" uuid NULL, | ||
649 | "assetID" uuid NULL, | ||
650 | "parentFolderID" uuid NULL, | ||
651 | "invType" int NULL, | ||
652 | "assetType" int NULL, | ||
653 | "name" varchar(255) NULL, | ||
654 | "description" varchar(255) NULL, | ||
655 | "creationDate" varchar(255) NULL, | ||
656 | "creatorID" uuid NULL, | ||
657 | "ownerID" uuid NULL, | ||
658 | "lastOwnerID" uuid NULL, | ||
659 | "groupID" uuid NULL, | ||
660 | "nextPermissions" int NULL, | ||
661 | "currentPermissions" int NULL, | ||
662 | "basePermissions" int NULL, | ||
663 | "everyonePermissions" int NULL, | ||
664 | "groupPermissions" int NULL, | ||
665 | flags int NOT NULL DEFAULT ((0)) | ||
666 | ); | ||
667 | |||
668 | INSERT INTO Tmp_primitems ("itemID", "primID", "assetID", "parentFolderID", "invType", "assetType", "name", "description", "creationDate", "creatorID", "ownerID", "lastOwnerID", "groupID", "nextPermissions", "currentPermissions", "basePermissions", "everyonePermissions", "groupPermissions", flags) | ||
669 | SELECT cast("itemID" as uuid), cast("primID" as uuid), cast("assetID" as uuid), cast("parentFolderID" as uuid), "invType", "assetType", "name", "description", "creationDate", cast("creatorID" as uuid), cast("ownerID" as uuid), cast("lastOwnerID" as uuid), cast("groupID" as uuid), "nextPermissions", "currentPermissions", "basePermissions", "everyonePermissions", "groupPermissions", flags | ||
670 | FROM primitems ; | ||
671 | |||
672 | DROP TABLE primitems; | ||
673 | |||
674 | alter table Tmp_primitems rename to primitems; | ||
675 | |||
676 | ALTER TABLE primitems ADD CONSTRAINT | ||
677 | PK__primitems__0A688BB1 PRIMARY KEY | ||
678 | ( | ||
679 | "itemID" | ||
680 | ); | ||
681 | |||
682 | CREATE INDEX primitems_primid ON primitems | ||
683 | ( | ||
684 | "primID" | ||
685 | ) ; | ||
686 | |||
687 | COMMIT; | ||
688 | |||
689 | |||
690 | :VERSION 16 | ||
691 | |||
692 | |||
693 | BEGIN TRANSACTION; | ||
694 | |||
695 | CREATE TABLE Tmp_terrain | ||
696 | ( | ||
697 | "RegionUUID" uuid NULL, | ||
698 | "Revision" int NULL, | ||
699 | "Heightfield" bytea NULL | ||
700 | ); | ||
701 | |||
702 | INSERT INTO Tmp_terrain ("RegionUUID", "Revision", "Heightfield") | ||
703 | SELECT cast("RegionUUID" as uuid), "Revision", "Heightfield" | ||
704 | FROM terrain ; | ||
705 | |||
706 | DROP TABLE terrain; | ||
707 | |||
708 | alter table Tmp_terrain rename to terrain; | ||
709 | |||
710 | COMMIT; | ||
711 | |||
712 | |||
713 | :VERSION 17 | ||
714 | |||
715 | BEGIN TRANSACTION; | ||
716 | |||
717 | CREATE TABLE Tmp_land | ||
718 | ( | ||
719 | "UUID" uuid NOT NULL, | ||
720 | "RegionUUID" uuid NULL, | ||
721 | "LocalLandID" int NULL, | ||
722 | "Bitmap" bytea NULL, | ||
723 | "Name" varchar(255) NULL, | ||
724 | "Description" varchar(255) NULL, | ||
725 | "OwnerUUID" uuid NULL, | ||
726 | "IsGroupOwned" boolean NULL, | ||
727 | "Area" int NULL, | ||
728 | "AuctionID" int NULL, | ||
729 | "Category" int NULL, | ||
730 | "ClaimDate" int NULL, | ||
731 | "ClaimPrice" int NULL, | ||
732 | "GroupUUID" uuid NULL, | ||
733 | "SalePrice" int NULL, | ||
734 | "LandStatus" int NULL, | ||
735 | "LandFlags" int NULL, | ||
736 | "LandingType" int NULL, | ||
737 | "MediaAutoScale" int NULL, | ||
738 | "MediaTextureUUID" uuid NULL, | ||
739 | "MediaURL" varchar(255) NULL, | ||
740 | "MusicURL" varchar(255) NULL, | ||
741 | "PassHours" double precision NULL, | ||
742 | "PassPrice" int NULL, | ||
743 | "SnapshotUUID" uuid NULL, | ||
744 | "UserLocationX" double precision NULL, | ||
745 | "UserLocationY" double precision NULL, | ||
746 | "UserLocationZ" double precision NULL, | ||
747 | "UserLookAtX" double precision NULL, | ||
748 | "UserLookAtY" double precision NULL, | ||
749 | "UserLookAtZ" double precision NULL, | ||
750 | "AuthbuyerID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
751 | "OtherCleanTime" int NOT NULL DEFAULT ((0)), | ||
752 | "Dwell" int NOT NULL DEFAULT ((0)) | ||
753 | ); | ||
754 | |||
755 | INSERT INTO Tmp_land ("UUID", "RegionUUID", "LocalLandID", "Bitmap", "Name", "Description", "OwnerUUID", "IsGroupOwned", "Area", "AuctionID", "Category", "ClaimDate", "ClaimPrice", "GroupUUID", "SalePrice", "LandStatus", "LandFlags", "LandingType", "MediaAutoScale", "MediaTextureUUID", "MediaURL", "MusicURL", "PassHours", "PassPrice", "SnapshotUUID", "UserLocationX", "UserLocationY", "UserLocationZ", "UserLookAtX", "UserLookAtY", "UserLookAtZ", "AuthbuyerID", "OtherCleanTime", "Dwell") | ||
756 | SELECT cast("UUID" as uuid), cast("RegionUUID" as uuid), "LocalLandID", "Bitmap", "Name", "Description", cast("OwnerUUID" as uuid), "IsGroupOwned", "Area", "AuctionID", "Category", "ClaimDate", "ClaimPrice", cast("GroupUUID" as uuid), "SalePrice", "LandStatus", "LandFlags", "LandingType", "MediaAutoScale", cast("MediaTextureUUID" as uuid), "MediaURL", "MusicURL", "PassHours", "PassPrice", cast("SnapshotUUID" as uuid), "UserLocationX", "UserLocationY", "UserLocationZ", "UserLookAtX", "UserLookAtY", "UserLookAtZ", cast("AuthbuyerID" as uuid), "OtherCleanTime", "Dwell" | ||
757 | FROM land ; | ||
758 | |||
759 | DROP TABLE land; | ||
760 | |||
761 | alter table Tmp_land rename to land; | ||
762 | |||
763 | ALTER TABLE land ADD CONSTRAINT | ||
764 | PK__land__65A475E71BFD2C07 PRIMARY KEY | ||
765 | ( | ||
766 | "UUID" | ||
767 | ); | ||
768 | |||
769 | Create index on land (lower("Name")); | ||
770 | |||
771 | COMMIT; | ||
772 | |||
773 | |||
774 | |||
775 | :VERSION 18 | ||
776 | |||
777 | BEGIN TRANSACTION; | ||
778 | |||
779 | CREATE TABLE Tmp_landaccesslist | ||
780 | ( | ||
781 | "LandUUID" uuid NULL, | ||
782 | "AccessUUID" uuid NULL, | ||
783 | "Flags" int NULL | ||
784 | ); | ||
785 | |||
786 | INSERT INTO Tmp_landaccesslist ("LandUUID", "AccessUUID", "Flags") | ||
787 | SELECT cast("LandUUID" as uuid), cast("AccessUUID" as uuid), "Flags" | ||
788 | FROM landaccesslist ; | ||
789 | |||
790 | DROP TABLE landaccesslist; | ||
791 | |||
792 | alter table Tmp_landaccesslist rename to landaccesslist; | ||
793 | |||
794 | COMMIT; | ||
795 | |||
796 | |||
797 | |||
798 | :VERSION 19 | ||
799 | |||
800 | BEGIN TRANSACTION; | ||
801 | |||
802 | CREATE TABLE Tmp_regionban | ||
803 | ( | ||
804 | "regionUUID" uuid NOT NULL, | ||
805 | "bannedUUID" uuid NOT NULL, | ||
806 | "bannedIp" varchar(16) NOT NULL, | ||
807 | "bannedIpHostMask" varchar(16) NOT NULL | ||
808 | ); | ||
809 | |||
810 | INSERT INTO Tmp_regionban ("regionUUID", "bannedUUID", "bannedIp", "bannedIpHostMask") | ||
811 | SELECT cast("regionUUID" as uuid), cast("bannedUUID" as uuid), "bannedIp", "bannedIpHostMask" | ||
812 | FROM regionban ; | ||
813 | |||
814 | DROP TABLE regionban; | ||
815 | |||
816 | alter table Tmp_regionban rename to regionban; | ||
817 | |||
818 | COMMIT; | ||
819 | |||
820 | |||
821 | :VERSION 20 | ||
822 | |||
823 | BEGIN TRANSACTION; | ||
824 | |||
825 | CREATE TABLE Tmp_regionsettings | ||
826 | ( | ||
827 | "regionUUID" uuid NOT NULL, | ||
828 | "block_terraform" boolean NOT NULL, | ||
829 | "block_fly" boolean NOT NULL, | ||
830 | "allow_damage" boolean NOT NULL, | ||
831 | "restrict_pushing" boolean NOT NULL, | ||
832 | "allow_land_resell" boolean NOT NULL, | ||
833 | "allow_land_join_divide" boolean NOT NULL, | ||
834 | "block_show_in_search" boolean NOT NULL, | ||
835 | "agent_limit" int NOT NULL, | ||
836 | "object_bonus" double precision NOT NULL, | ||
837 | "maturity" int NOT NULL, | ||
838 | "disable_scripts" boolean NOT NULL, | ||
839 | "disable_collisions" boolean NOT NULL, | ||
840 | "disable_physics" boolean NOT NULL, | ||
841 | "terrain_texture_1" uuid NOT NULL, | ||
842 | "terrain_texture_2" uuid NOT NULL, | ||
843 | "terrain_texture_3" uuid NOT NULL, | ||
844 | "terrain_texture_4" uuid NOT NULL, | ||
845 | "elevation_1_nw" double precision NOT NULL, | ||
846 | "elevation_2_nw" double precision NOT NULL, | ||
847 | "elevation_1_ne" double precision NOT NULL, | ||
848 | "elevation_2_ne" double precision NOT NULL, | ||
849 | "elevation_1_se" double precision NOT NULL, | ||
850 | "elevation_2_se" double precision NOT NULL, | ||
851 | "elevation_1_sw" double precision NOT NULL, | ||
852 | "elevation_2_sw" double precision NOT NULL, | ||
853 | "water_height" double precision NOT NULL, | ||
854 | "terrain_raise_limit" double precision NOT NULL, | ||
855 | "terrain_lower_limit" double precision NOT NULL, | ||
856 | "use_estate_sun" boolean NOT NULL, | ||
857 | "fixed_sun" boolean NOT NULL, | ||
858 | "sun_position" double precision NOT NULL, | ||
859 | "covenant" uuid NULL DEFAULT (NULL), | ||
860 | "Sandbox" boolean NOT NULL, | ||
861 | "sunvectorx" double precision NOT NULL DEFAULT ((0)), | ||
862 | "sunvectory" double precision NOT NULL DEFAULT ((0)), | ||
863 | "sunvectorz" double precision NOT NULL DEFAULT ((0)) | ||
864 | ); | ||
865 | |||
866 | INSERT INTO Tmp_regionsettings ("regionUUID", "block_terraform", "block_fly", "allow_damage", "restrict_pushing", "allow_land_resell", "allow_land_join_divide", "block_show_in_search", "agent_limit", "object_bonus", "maturity", "disable_scripts", "disable_collisions", "disable_physics", "terrain_texture_1", "terrain_texture_2", "terrain_texture_3", "terrain_texture_4", "elevation_1_nw", "elevation_2_nw", "elevation_1_ne", "elevation_2_ne", "elevation_1_se", "elevation_2_se", "elevation_1_sw", "elevation_2_sw", "water_height", "terrain_raise_limit", "terrain_lower_limit", "use_estate_sun", "fixed_sun", "sun_position", "covenant", "Sandbox", "sunvectorx", "sunvectory", "sunvectorz") | ||
867 | SELECT cast("regionUUID" as uuid), "block_terraform", "block_fly", "allow_damage", "restrict_pushing", "allow_land_resell", "allow_land_join_divide", "block_show_in_search", "agent_limit", "object_bonus", "maturity", "disable_scripts", "disable_collisions", "disable_physics", cast("terrain_texture_1" as uuid), cast("terrain_texture_2" as uuid), cast("terrain_texture_3" as uuid), cast("terrain_texture_4" as uuid), "elevation_1_nw", "elevation_2_nw", "elevation_1_ne", "elevation_2_ne", "elevation_1_se", "elevation_2_se", "elevation_1_sw", "elevation_2_sw", "water_height", "terrain_raise_limit", "terrain_lower_limit", "use_estate_sun", "fixed_sun", "sun_position", cast("covenant" as uuid), "Sandbox", "sunvectorx", "sunvectory", "sunvectorz" | ||
868 | FROM regionsettings ; | ||
869 | |||
870 | DROP TABLE regionsettings; | ||
871 | |||
872 | alter table Tmp_regionsettings rename to regionsettings; | ||
873 | |||
874 | ALTER TABLE regionsettings ADD CONSTRAINT | ||
875 | PK__regionse__5B35159D21B6055D PRIMARY KEY | ||
876 | ( | ||
877 | "regionUUID" | ||
878 | ); | ||
879 | |||
880 | COMMIT; | ||
881 | |||
882 | |||
883 | :VERSION 21 | ||
884 | |||
885 | BEGIN TRANSACTION; | ||
886 | |||
887 | ALTER TABLE prims ADD "PassTouches" boolean not null default false; | ||
888 | |||
889 | COMMIT; | ||
890 | |||
891 | |||
892 | :VERSION 22 | ||
893 | |||
894 | BEGIN TRANSACTION; | ||
895 | |||
896 | ALTER TABLE regionsettings ADD "loaded_creation_date" varchar(20) ; | ||
897 | ALTER TABLE regionsettings ADD "loaded_creation_time" varchar(20) ; | ||
898 | ALTER TABLE regionsettings ADD "loaded_creation_id" varchar(64) ; | ||
899 | |||
900 | COMMIT; | ||
901 | |||
902 | :VERSION 23 | ||
903 | |||
904 | BEGIN TRANSACTION; | ||
905 | |||
906 | ALTER TABLE regionsettings DROP COLUMN "loaded_creation_date"; | ||
907 | ALTER TABLE regionsettings DROP COLUMN "loaded_creation_time"; | ||
908 | ALTER TABLE regionsettings ADD "loaded_creation_datetime" int NOT NULL default 0; | ||
909 | |||
910 | COMMIT; | ||
911 | |||
912 | :VERSION 24 | ||
913 | |||
914 | BEGIN TRANSACTION; | ||
915 | |||
916 | ALTER TABLE prims ADD "MediaURL" varchar(255); | ||
917 | ALTER TABLE primshapes ADD "Media" TEXT NULL; | ||
918 | |||
919 | COMMIT; | ||
920 | |||
921 | :VERSION 25 | ||
922 | |||
923 | BEGIN TRANSACTION; | ||
924 | CREATE TABLE regionwindlight ( | ||
925 | "region_id" varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY, | ||
926 | "water_color_r" double precision NOT NULL DEFAULT '4.000000', | ||
927 | water_color_g double precision NOT NULL DEFAULT '38.000000', | ||
928 | water_color_b double precision NOT NULL DEFAULT '64.000000', | ||
929 | water_fog_density_exponent double precision NOT NULL DEFAULT '4.0', | ||
930 | underwater_fog_modifier double precision NOT NULL DEFAULT '0.25', | ||
931 | reflection_wavelet_scale_1 double precision NOT NULL DEFAULT '2.0', | ||
932 | reflection_wavelet_scale_2 double precision NOT NULL DEFAULT '2.0', | ||
933 | reflection_wavelet_scale_3 double precision NOT NULL DEFAULT '2.0', | ||
934 | fresnel_scale double precision NOT NULL DEFAULT '0.40', | ||
935 | fresnel_offset double precision NOT NULL DEFAULT '0.50', | ||
936 | refract_scale_above double precision NOT NULL DEFAULT '0.03', | ||
937 | refract_scale_below double precision NOT NULL DEFAULT '0.20', | ||
938 | blur_multiplier double precision NOT NULL DEFAULT '0.040', | ||
939 | big_wave_direction_x double precision NOT NULL DEFAULT '1.05', | ||
940 | big_wave_direction_y double precision NOT NULL DEFAULT '-0.42', | ||
941 | little_wave_direction_x double precision NOT NULL DEFAULT '1.11', | ||
942 | little_wave_direction_y double precision NOT NULL DEFAULT '-1.16', | ||
943 | normal_map_texture varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4', | ||
944 | horizon_r double precision NOT NULL DEFAULT '0.25', | ||
945 | horizon_g double precision NOT NULL DEFAULT '0.25', | ||
946 | horizon_b double precision NOT NULL DEFAULT '0.32', | ||
947 | horizon_i double precision NOT NULL DEFAULT '0.32', | ||
948 | haze_horizon double precision NOT NULL DEFAULT '0.19', | ||
949 | blue_density_r double precision NOT NULL DEFAULT '0.12', | ||
950 | blue_density_g double precision NOT NULL DEFAULT '0.22', | ||
951 | blue_density_b double precision NOT NULL DEFAULT '0.38', | ||
952 | blue_density_i double precision NOT NULL DEFAULT '0.38', | ||
953 | haze_density double precision NOT NULL DEFAULT '0.70', | ||
954 | density_multiplier double precision NOT NULL DEFAULT '0.18', | ||
955 | distance_multiplier double precision NOT NULL DEFAULT '0.8', | ||
956 | max_altitude int NOT NULL DEFAULT '1605', | ||
957 | sun_moon_color_r double precision NOT NULL DEFAULT '0.24', | ||
958 | sun_moon_color_g double precision NOT NULL DEFAULT '0.26', | ||
959 | sun_moon_color_b double precision NOT NULL DEFAULT '0.30', | ||
960 | sun_moon_color_i double precision NOT NULL DEFAULT '0.30', | ||
961 | sun_moon_position double precision NOT NULL DEFAULT '0.317', | ||
962 | ambient_r double precision NOT NULL DEFAULT '0.35', | ||
963 | ambient_g double precision NOT NULL DEFAULT '0.35', | ||
964 | ambient_b double precision NOT NULL DEFAULT '0.35', | ||
965 | ambient_i double precision NOT NULL DEFAULT '0.35', | ||
966 | east_angle double precision NOT NULL DEFAULT '0.00', | ||
967 | sun_glow_focus double precision NOT NULL DEFAULT '0.10', | ||
968 | sun_glow_size double precision NOT NULL DEFAULT '1.75', | ||
969 | scene_gamma double precision NOT NULL DEFAULT '1.00', | ||
970 | star_brightness double precision NOT NULL DEFAULT '0.00', | ||
971 | cloud_color_r double precision NOT NULL DEFAULT '0.41', | ||
972 | cloud_color_g double precision NOT NULL DEFAULT '0.41', | ||
973 | cloud_color_b double precision NOT NULL DEFAULT '0.41', | ||
974 | cloud_color_i double precision NOT NULL DEFAULT '0.41', | ||
975 | cloud_x double precision NOT NULL DEFAULT '1.00', | ||
976 | cloud_y double precision NOT NULL DEFAULT '0.53', | ||
977 | cloud_density double precision NOT NULL DEFAULT '1.00', | ||
978 | cloud_coverage double precision NOT NULL DEFAULT '0.27', | ||
979 | cloud_scale double precision NOT NULL DEFAULT '0.42', | ||
980 | cloud_detail_x double precision NOT NULL DEFAULT '1.00', | ||
981 | cloud_detail_y double precision NOT NULL DEFAULT '0.53', | ||
982 | cloud_detail_density double precision NOT NULL DEFAULT '0.12', | ||
983 | cloud_scroll_x double precision NOT NULL DEFAULT '0.20', | ||
984 | cloud_scroll_x_lock smallint NOT NULL DEFAULT '0', | ||
985 | cloud_scroll_y double precision NOT NULL DEFAULT '0.01', | ||
986 | cloud_scroll_y_lock smallint NOT NULL DEFAULT '0', | ||
987 | draw_classic_clouds smallint NOT NULL DEFAULT '1' | ||
988 | ); | ||
989 | |||
990 | COMMIT; | ||
991 | |||
992 | :VERSION 26 | ||
993 | |||
994 | BEGIN TRANSACTION; | ||
995 | |||
996 | ALTER TABLE regionsettings ADD "map_tile_ID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
997 | |||
998 | COMMIT; | ||
999 | |||
1000 | :VERSION 27 #--------------------- | ||
1001 | |||
1002 | BEGIN TRANSACTION; | ||
1003 | ALTER TABLE land ADD "MediaType" VARCHAR(32) NOT NULL DEFAULT 'none/none' ; | ||
1004 | ALTER TABLE land ADD "MediaDescription" VARCHAR(255) NOT NULL DEFAULT ''; | ||
1005 | ALTER TABLE land ADD "MediaSize" VARCHAR(16) NOT NULL DEFAULT '0,0'; | ||
1006 | ALTER TABLE land ADD "MediaLoop" boolean NOT NULL DEFAULT false; | ||
1007 | ALTER TABLE land ADD "ObscureMusic" boolean NOT NULL DEFAULT false; | ||
1008 | ALTER TABLE land ADD "ObscureMedia" boolean NOT NULL DEFAULT false; | ||
1009 | COMMIT; | ||
1010 | |||
1011 | :VERSION 28 #--------------------- | ||
1012 | |||
1013 | BEGIN TRANSACTION; | ||
1014 | |||
1015 | ALTER TABLE prims | ||
1016 | alter column "CreatorID" set DEFAULT '00000000-0000-0000-0000-000000000000' ; | ||
1017 | |||
1018 | ALTER TABLE prims ALTER COLUMN "CreatorID" set NOT NULL; | ||
1019 | |||
1020 | ALTER TABLE primitems | ||
1021 | alter column "creatorID" set DEFAULT '00000000-0000-0000-0000-000000000000' ; | ||
1022 | |||
1023 | ALTER TABLE primitems ALTER COLUMN "creatorID" set NOT NULL; | ||
1024 | |||
1025 | COMMIT; | ||
1026 | |||
1027 | :VERSION 29 #----------------- Region Covenant changed time | ||
1028 | |||
1029 | BEGIN TRANSACTION; | ||
1030 | |||
1031 | ALTER TABLE regionsettings ADD "covenant_datetime" int NOT NULL default 0; | ||
1032 | |||
1033 | COMMIT; | ||
1034 | |||
1035 | :VERSION 30 #------------------Migrate "creatorID" storage to varchars instead of UUIDs for HG support | ||
1036 | |||
1037 | BEGIN TRANSACTION; | ||
1038 | |||
1039 | alter table prims rename column "CreatorID" to "CreatorIDOld"; | ||
1040 | alter table primitems rename column "creatorID" to "creatorIDOld"; | ||
1041 | |||
1042 | COMMIT; | ||
1043 | |||
1044 | :VERSION 31 #--------------------- | ||
1045 | |||
1046 | BEGIN TRANSACTION; | ||
1047 | |||
1048 | ALTER TABLE prims ADD "CreatorID" varchar(255); | ||
1049 | ALTER TABLE primitems ADD "creatorID" varchar(255); | ||
1050 | |||
1051 | COMMIT; | ||
1052 | |||
1053 | :VERSION 32 #--------------------- | ||
1054 | |||
1055 | BEGIN TRANSACTION; | ||
1056 | |||
1057 | UPDATE prims SET "CreatorID" = cast("CreatorIDOld" as varchar(255)); | ||
1058 | UPDATE primitems SET "creatorID" = cast("creatorIDOld" as varchar(255)); | ||
1059 | |||
1060 | COMMIT; | ||
1061 | |||
1062 | :VERSION 33 #--------------------- | ||
1063 | |||
1064 | BEGIN TRANSACTION; | ||
1065 | |||
1066 | ALTER TABLE prims alter column "CreatorID" set default '00000000-0000-0000-0000-000000000000' ; | ||
1067 | |||
1068 | ALTER TABLE prims ALTER COLUMN "CreatorID" set NOT NULL; | ||
1069 | |||
1070 | ALTER TABLE primitems alter column "creatorID" set DEFAULT '00000000-0000-0000-0000-000000000000' ; | ||
1071 | |||
1072 | ALTER TABLE primitems ALTER COLUMN "creatorID" set NOT NULL; | ||
1073 | |||
1074 | COMMIT; | ||
1075 | |||
1076 | :VERSION 34 #--------------- Telehub support | ||
1077 | |||
1078 | BEGIN TRANSACTION; | ||
1079 | |||
1080 | CREATE TABLE spawn_points( | ||
1081 | "RegionUUID" uuid NOT NULL PRIMARY KEY, | ||
1082 | "Yaw" double precision NOT NULL, | ||
1083 | "Pitch" double precision NOT NULL, | ||
1084 | "Distance" double precision NOT NULL | ||
1085 | ); | ||
1086 | |||
1087 | ALTER TABLE regionsettings ADD "TelehubObject" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
1088 | |||
1089 | COMMIT; | ||
1090 | |||
1091 | :VERSION 35 #---------------- Parcels for sale | ||
1092 | |||
1093 | BEGIN TRANSACTION; | ||
1094 | |||
1095 | ALTER TABLE regionsettings ADD "parcel_tile_ID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
1096 | |||
1097 | COMMIT; | ||
1098 | |||
1099 | :VERSION 36 #---------------- Timed bans/access | ||
1100 | |||
1101 | BEGIN TRANSACTION; | ||
1102 | |||
1103 | ALTER TABLE landaccesslist ADD "Expires" integer NOT NULL DEFAULT 0; | ||
1104 | |||
1105 | COMMIT; | ||
1106 | |||
1107 | :VERSION 37 #---------------- Environment Settings | ||
1108 | |||
1109 | BEGIN TRANSACTION; | ||
1110 | |||
1111 | CREATE TABLE regionenvironment( | ||
1112 | "region_id" uuid NOT NULL primary key, | ||
1113 | "llsd_settings" varchar NOT NULL | ||
1114 | ); | ||
1115 | |||
1116 | COMMIT; | ||
1117 | |||
1118 | :VERSION 38 #---------------- Dynamic attributes | ||
1119 | |||
1120 | BEGIN TRANSACTION; | ||
1121 | |||
1122 | ALTER TABLE prims ADD "DynAttrs" TEXT; | ||
1123 | |||
1124 | COMMIT; | ||
1125 | |||
1126 | :VERSION 39 #---------------- Extra physics params | ||
1127 | |||
1128 | BEGIN TRANSACTION; | ||
1129 | |||
1130 | ALTER TABLE prims ADD "PhysicsShapeType" smallint NOT NULL default '0'; | ||
1131 | ALTER TABLE prims ADD "Density" double precision NOT NULL default '1000'; | ||
1132 | ALTER TABLE prims ADD "GravityModifier" double precision NOT NULL default '1'; | ||
1133 | ALTER TABLE prims ADD "Friction" double precision NOT NULL default '0.6'; | ||
1134 | ALTER TABLE prims ADD "Restitution" double precision NOT NULL default '0.5'; | ||
1135 | |||
1136 | COMMIT; | ||
1137 | |||
1138 | :VERSION 40 #-- regionwindlight changed type from smallint to bool | ||
1139 | |||
1140 | BEGIN TRANSACTION; | ||
1141 | |||
1142 | ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_x_lock DROP DEFAULT; | ||
1143 | ALTER TABLE regionwindlight ALTER cloud_scroll_x_lock TYPE bool USING CASE WHEN cloud_scroll_x_lock=0 THEN FALSE ELSE TRUE END; | ||
1144 | ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_x_lock SET DEFAULT FALSE; | ||
1145 | |||
1146 | ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_y_lock DROP DEFAULT; | ||
1147 | ALTER TABLE regionwindlight ALTER cloud_scroll_y_lock TYPE bool USING CASE WHEN cloud_scroll_y_lock=0 THEN FALSE ELSE TRUE END; | ||
1148 | ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_y_lock SET DEFAULT FALSE; | ||
1149 | |||
1150 | ALTER TABLE regionwindlight ALTER COLUMN draw_classic_clouds DROP DEFAULT; | ||
1151 | ALTER TABLE regionwindlight ALTER draw_classic_clouds TYPE bool USING CASE WHEN draw_classic_clouds=0 THEN FALSE ELSE TRUE END; | ||
1152 | ALTER TABLE regionwindlight ALTER COLUMN draw_classic_clouds SET DEFAULT FALSE; | ||
1153 | |||
1154 | COMMIT; | ||
1155 | |||
1156 | VERSION 41 #-- Change Landlags to bigint | ||
1157 | |||
1158 | BEGIN TRANSACTION; | ||
1159 | |||
1160 | ALTER TABLE land ALTER "LandFlags" TYPE bigint; | ||
1161 | |||
1162 | COMMIT; | ||
diff --git a/OpenSim/Data/PGSQL/Resources/UserAccount.migrations b/OpenSim/Data/PGSQL/Resources/UserAccount.migrations new file mode 100644 index 0000000..c785463 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/UserAccount.migrations | |||
@@ -0,0 +1,51 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE UserAccounts ( | ||
4 | "PrincipalID" uuid NOT NULL Primary key, | ||
5 | "ScopeID" uuid NOT NULL, | ||
6 | "FirstName" varchar(64) NOT NULL, | ||
7 | "LastName" varchar(64) NOT NULL, | ||
8 | "Email" varchar(64) NULL, | ||
9 | "ServiceURLs" text NULL, | ||
10 | "Created" int default NULL | ||
11 | ); | ||
12 | |||
13 | |||
14 | :VERSION 2 | ||
15 | |||
16 | BEGIN TRANSACTION; | ||
17 | |||
18 | INSERT INTO UserAccounts ("PrincipalID", "ScopeID", "FirstName", "LastName", "Email", "ServiceURLs", "Created") | ||
19 | SELECT UUID AS "PrincipalID", '00000000-0000-0000-0000-000000000000' AS "ScopeID", | ||
20 | username AS "FirstName", | ||
21 | lastname AS "LastName", | ||
22 | email as "Email", ( | ||
23 | 'AssetServerURI=' + | ||
24 | userAssetURI + ' InventoryServerURI=' + userInventoryURI + ' GatewayURI= HomeURI=') AS "ServiceURLs", | ||
25 | created as "Created" FROM users; | ||
26 | |||
27 | COMMIT; | ||
28 | |||
29 | :VERSION 3 | ||
30 | |||
31 | BEGIN TRANSACTION; | ||
32 | |||
33 | CREATE UNIQUE INDEX "PrincipalID" ON UserAccounts("PrincipalID"); | ||
34 | CREATE INDEX "Email" ON UserAccounts("Email"); | ||
35 | CREATE INDEX "FirstName" ON UserAccounts("FirstName"); | ||
36 | CREATE INDEX "LastName" ON UserAccounts("LastName"); | ||
37 | CREATE INDEX Name ON UserAccounts("FirstName","LastName"); | ||
38 | |||
39 | COMMIT; | ||
40 | |||
41 | :VERSION 4 | ||
42 | |||
43 | BEGIN TRANSACTION; | ||
44 | |||
45 | ALTER TABLE UserAccounts ADD "UserLevel" integer NOT NULL DEFAULT 0; | ||
46 | ALTER TABLE UserAccounts ADD "UserFlags" integer NOT NULL DEFAULT 0; | ||
47 | ALTER TABLE UserAccounts ADD "UserTitle" varchar(64) NOT NULL DEFAULT ''; | ||
48 | |||
49 | COMMIT; | ||
50 | |||
51 | |||
diff --git a/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations b/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations new file mode 100644 index 0000000..a6bd8ca --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations | |||
@@ -0,0 +1,155 @@ | |||
1 | :VERSION 1 # ------------------------------- | ||
2 | |||
3 | begin; | ||
4 | |||
5 | CREATE TABLE classifieds ( | ||
6 | "classifieduuid" char(36) NOT NULL, | ||
7 | "creatoruuid" char(36) NOT NULL, | ||
8 | "creationdate" integer NOT NULL, | ||
9 | "expirationdate" integer NOT NULL, | ||
10 | "category" varchar(20) NOT NULL, | ||
11 | "name" varchar(255) NOT NULL, | ||
12 | "description" text NOT NULL, | ||
13 | "parceluuid" char(36) NOT NULL, | ||
14 | "parentestate" integer NOT NULL, | ||
15 | "snapshotuuid" char(36) NOT NULL, | ||
16 | "simname" varchar(255) NOT NULL, | ||
17 | "posglobal" varchar(255) NOT NULL, | ||
18 | "parcelname" varchar(255) NOT NULL, | ||
19 | "classifiedflags" integer NOT NULL, | ||
20 | "priceforlisting" integer NOT NULL, | ||
21 | constraint classifiedspk PRIMARY KEY ("classifieduuid") | ||
22 | ); | ||
23 | |||
24 | |||
25 | CREATE TABLE usernotes ( | ||
26 | "useruuid" varchar(36) NOT NULL, | ||
27 | "targetuuid" varchar(36) NOT NULL, | ||
28 | "notes" text NOT NULL, | ||
29 | constraint usernoteuk UNIQUE ("useruuid","targetuuid") | ||
30 | ); | ||
31 | |||
32 | |||
33 | CREATE TABLE userpicks ( | ||
34 | "pickuuid" varchar(36) NOT NULL, | ||
35 | "creatoruuid" varchar(36) NOT NULL, | ||
36 | "toppick" boolean NOT NULL, | ||
37 | "parceluuid" varchar(36) NOT NULL, | ||
38 | "name" varchar(255) NOT NULL, | ||
39 | "description" text NOT NULL, | ||
40 | "snapshotuuid" varchar(36) NOT NULL, | ||
41 | "user" varchar(255) NOT NULL, | ||
42 | "originalname" varchar(255) NOT NULL, | ||
43 | "simname" varchar(255) NOT NULL, | ||
44 | "posglobal" varchar(255) NOT NULL, | ||
45 | "sortorder" integer NOT NULL, | ||
46 | "enabled" boolean NOT NULL, | ||
47 | PRIMARY KEY ("pickuuid") | ||
48 | ); | ||
49 | |||
50 | |||
51 | CREATE TABLE userprofile ( | ||
52 | "useruuid" varchar(36) NOT NULL, | ||
53 | "profilePartner" varchar(36) NOT NULL, | ||
54 | "profileAllowPublish" bytea NOT NULL, | ||
55 | "profileMaturePublish" bytea NOT NULL, | ||
56 | "profileURL" varchar(255) NOT NULL, | ||
57 | "profileWantToMask" integer NOT NULL, | ||
58 | "profileWantToText" text NOT NULL, | ||
59 | "profileSkillsMask" integer NOT NULL, | ||
60 | "profileSkillsText" text NOT NULL, | ||
61 | "profileLanguages" text NOT NULL, | ||
62 | "profileImage" varchar(36) NOT NULL, | ||
63 | "profileAboutText" text NOT NULL, | ||
64 | "profileFirstImage" varchar(36) NOT NULL, | ||
65 | "profileFirstText" text NOT NULL, | ||
66 | PRIMARY KEY ("useruuid") | ||
67 | ); | ||
68 | |||
69 | commit; | ||
70 | |||
71 | :VERSION 2 # ------------------------------- | ||
72 | |||
73 | begin; | ||
74 | CREATE TABLE userdata ( | ||
75 | "UserId" char(36) NOT NULL, | ||
76 | "TagId" varchar(64) NOT NULL, | ||
77 | "DataKey" varchar(255), | ||
78 | "DataVal" varchar(255), | ||
79 | PRIMARY KEY ("UserId","TagId") | ||
80 | ); | ||
81 | |||
82 | commit; | ||
83 | |||
84 | :VERSION 3 # ------------------------------- | ||
85 | begin; | ||
86 | CREATE TABLE usersettings ( | ||
87 | "useruuid" char(36) NOT NULL, | ||
88 | "imviaemail" bytea NOT NULL, | ||
89 | "visible" bytea NOT NULL, | ||
90 | PRIMARY KEY ("useruuid") | ||
91 | ); | ||
92 | commit; | ||
93 | |||
94 | :VERSION 4 | ||
95 | |||
96 | BEGIN; | ||
97 | |||
98 | -- Classifieds | ||
99 | ALTER TABLE classifieds DROP CONSTRAINT classifiedspk; | ||
100 | ALTER TABLE classifieds ALTER COLUMN classifieduuid SET DATA TYPE uuid using classifieduuid::uuid; | ||
101 | ALTER TABLE classifieds ALTER COLUMN creatoruuid SET DATA TYPE uuid using creatoruuid::uuid; | ||
102 | ALTER TABLE classifieds ALTER COLUMN parceluuid SET DATA TYPE uuid using parceluuid::uuid; | ||
103 | ALTER TABLE classifieds ALTER COLUMN snapshotuuid SET DATA TYPE uuid using snapshotuuid::uuid; | ||
104 | ALTER TABLE classifieds ADD CONSTRAINT classifiedspk PRIMARY KEY (classifieduuid); | ||
105 | |||
106 | -- Notes | ||
107 | ALTER TABLE usernotes DROP CONSTRAINT usernoteuk; | ||
108 | ALTER TABLE usernotes ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid; | ||
109 | ALTER TABLE usernotes ALTER COLUMN targetuuid SET DATA TYPE uuid USING targetuuid::uuid; | ||
110 | ALTER TABLE usernotes ADD CONSTRAINT usernoteuk UNIQUE (useruuid,targetuuid); | ||
111 | |||
112 | |||
113 | -- Userpicks | ||
114 | ALTER TABLE userpicks DROP CONSTRAINT userpicks_pkey; | ||
115 | ALTER TABLE userpicks ALTER COLUMN pickuuid SET DATA TYPE uuid USING pickuuid::uuid; | ||
116 | ALTER TABLE userpicks ALTER COLUMN creatoruuid SET DATA TYPE uuid USING creatoruuid::uuid; | ||
117 | ALTER TABLE userpicks ALTER COLUMN parceluuid SET DATA TYPE uuid USING parceluuid::uuid; | ||
118 | ALTER TABLE userpicks ALTER COLUMN parceluuid SET DATA TYPE uuid USING parceluuid::uuid; | ||
119 | ALTER TABLE userpicks ADD PRIMARY KEY (pickuuid); | ||
120 | |||
121 | -- Userprofile | ||
122 | ALTER TABLE userprofile DROP CONSTRAINT userprofile_pkey; | ||
123 | ALTER TABLE userprofile ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid; | ||
124 | ALTER TABLE userprofile ALTER COLUMN "profilePartner" SET DATA TYPE uuid USING "profilePartner"::uuid; | ||
125 | -- Force column conversions | ||
126 | ALTER TABLE userprofile ALTER COLUMN "profileAllowPublish" SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END; | ||
127 | ALTER TABLE userprofile ALTER COLUMN "profileMaturePublish" SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END; | ||
128 | ALTER TABLE userprofile ALTER COLUMN "profileImage" SET DATA TYPE uuid USING "profileImage"::uuid; | ||
129 | ALTER TABLE userprofile ALTER COLUMN "profileFirstImage" SET DATA TYPE uuid USING "profileFirstImage"::uuid; | ||
130 | ALTER TABLE userprofile ADD PRIMARY KEY (useruuid); | ||
131 | |||
132 | -- Userdata | ||
133 | ALTER TABLE userdata DROP CONSTRAINT userdata_pkey; | ||
134 | ALTER TABLE userdata ALTER COLUMN "UserId" SET DATA TYPE uuid USING "UserId"::uuid; | ||
135 | ALTER TABLE userdata ALTER COLUMN "UserId" SET DATA TYPE uuid USING "UserId"::uuid; | ||
136 | ALTER TABLE userdata ADD PRIMARY KEY ("UserId","TagId"); | ||
137 | |||
138 | |||
139 | -- Usersettings | ||
140 | ALTER TABLE usersettings DROP CONSTRAINT usersettings_pkey; | ||
141 | ALTER TABLE usersettings ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid; | ||
142 | ALTER TABLE usersettings ALTER COLUMN visible SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END; | ||
143 | ALTER TABLE usersettings ADD COLUMN email varchar(254) NOT NULL; | ||
144 | ALTER TABLE usersettings ADD PRIMARY KEY (useruuid); | ||
145 | |||
146 | COMMIT; | ||
147 | |||
148 | |||
149 | :VERSION 5 # ------------------------------- | ||
150 | |||
151 | BEGIN; | ||
152 | |||
153 | ALTER TABLE usersettings ALTER COLUMN imviaemail SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END; | ||
154 | |||
155 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/PGSQL/Resources/UserStore.migrations b/OpenSim/Data/PGSQL/Resources/UserStore.migrations new file mode 100644 index 0000000..974d489 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/UserStore.migrations | |||
@@ -0,0 +1,404 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | CREATE TABLE users ( | ||
4 | "UUID" varchar(36) NOT NULL default '' Primary Key, | ||
5 | "username" varchar(32) NOT NULL, | ||
6 | "lastname" varchar(32) NOT NULL, | ||
7 | "passwordHash" varchar(32) NOT NULL, | ||
8 | "passwordSalt" varchar(32) NOT NULL, | ||
9 | "homeRegion" bigint default NULL, | ||
10 | "homeLocationX" double precision default NULL, | ||
11 | "homeLocationY" double precision default NULL, | ||
12 | "homeLocationZ" double precision default NULL, | ||
13 | "homeLookAtX" double precision default NULL, | ||
14 | "homeLookAtY" double precision default NULL, | ||
15 | "homeLookAtZ" double precision default NULL, | ||
16 | "created" int NOT NULL, | ||
17 | "lastLogin" int NOT NULL, | ||
18 | "userInventoryURI" varchar(255) default NULL, | ||
19 | "userAssetURI" varchar(255) default NULL, | ||
20 | "profileCanDoMask" int default NULL, | ||
21 | "profileWantDoMask" int default NULL, | ||
22 | "profileAboutText" text, | ||
23 | "profileFirstText" text, | ||
24 | "profileImage" varchar(36) default NULL, | ||
25 | "profileFirstImage" varchar(36) default NULL, | ||
26 | "webLoginKey" varchar(36) default NULL | ||
27 | ); | ||
28 | |||
29 | CREATE INDEX "usernames" ON users | ||
30 | ( | ||
31 | "username" ASC, | ||
32 | "lastname" ASC | ||
33 | ); | ||
34 | |||
35 | |||
36 | CREATE TABLE agents ( | ||
37 | "UUID" varchar(36) NOT NULL Primary Key, | ||
38 | "sessionID" varchar(36) NOT NULL, | ||
39 | "secureSessionID" varchar(36) NOT NULL, | ||
40 | "agentIP" varchar(16) NOT NULL, | ||
41 | "agentPort" int NOT NULL, | ||
42 | "agentOnline" smallint NOT NULL, | ||
43 | "loginTime" int NOT NULL, | ||
44 | "logoutTime" int NOT NULL, | ||
45 | "currentRegion" varchar(36) NOT NULL, | ||
46 | "currentHandle" bigint NOT NULL, | ||
47 | "currentPos" varchar(64) NOT NULL | ||
48 | ); | ||
49 | |||
50 | CREATE INDEX session ON agents | ||
51 | ( | ||
52 | "sessionID" ASC | ||
53 | ); | ||
54 | |||
55 | CREATE INDEX ssession ON agents | ||
56 | ( | ||
57 | "secureSessionID" ASC | ||
58 | ); | ||
59 | |||
60 | |||
61 | CREATE TABLE userfriends( | ||
62 | "ownerID" varchar(50) NOT NULL, | ||
63 | "friendID" varchar(50) NOT NULL, | ||
64 | "friendPerms" varchar(50) NOT NULL, | ||
65 | "datetimestamp" varchar(50) NOT NULL | ||
66 | ); | ||
67 | |||
68 | CREATE TABLE avatarappearance ( | ||
69 | "Owner" varchar(36) NOT NULL primary key, | ||
70 | "Serial" int NOT NULL, | ||
71 | "Visual_Params" bytea NOT NULL, | ||
72 | "Texture" bytea NOT NULL, | ||
73 | "Avatar_Height" double precision NOT NULL, | ||
74 | "Body_Item" varchar(36) NOT NULL, | ||
75 | "Body_Asset" varchar(36) NOT NULL, | ||
76 | "Skin_Item" varchar(36) NOT NULL, | ||
77 | "Skin_Asset" varchar(36) NOT NULL, | ||
78 | "Hair_Item" varchar(36) NOT NULL, | ||
79 | "Hair_Asset" varchar(36) NOT NULL, | ||
80 | "Eyes_Item" varchar(36) NOT NULL, | ||
81 | "Eyes_Asset" varchar(36) NOT NULL, | ||
82 | "Shirt_Item" varchar(36) NOT NULL, | ||
83 | "Shirt_Asset" varchar(36) NOT NULL, | ||
84 | "Pants_Item" varchar(36) NOT NULL, | ||
85 | "Pants_Asset" varchar(36) NOT NULL, | ||
86 | "Shoes_Item" varchar(36) NOT NULL, | ||
87 | "Shoes_Asset" varchar(36) NOT NULL, | ||
88 | "Socks_Item" varchar(36) NOT NULL, | ||
89 | "Socks_Asset" varchar(36) NOT NULL, | ||
90 | "Jacket_Item" varchar(36) NOT NULL, | ||
91 | "Jacket_Asset" varchar(36) NOT NULL, | ||
92 | "Gloves_Item" varchar(36) NOT NULL, | ||
93 | "Gloves_Asset" varchar(36) NOT NULL, | ||
94 | "Undershirt_Item" varchar(36) NOT NULL, | ||
95 | "Undershirt_Asset" varchar(36) NOT NULL, | ||
96 | "Underpants_Item" varchar(36) NOT NULL, | ||
97 | "Underpants_Asset" varchar(36) NOT NULL, | ||
98 | "Skirt_Item" varchar(36) NOT NULL, | ||
99 | "Skirt_Asset" varchar(36) NOT NULL | ||
100 | ); | ||
101 | |||
102 | :VERSION 2 | ||
103 | |||
104 | BEGIN TRANSACTION; | ||
105 | |||
106 | ALTER TABLE users ADD "homeRegionID" varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; | ||
107 | ALTER TABLE users ADD "userFlags" int NOT NULL default 0; | ||
108 | ALTER TABLE users ADD "godLevel" int NOT NULL default 0; | ||
109 | ALTER TABLE users ADD "customType" varchar(32) not null default ''; | ||
110 | ALTER TABLE users ADD "partner" varchar(36) not null default '00000000-0000-0000-0000-000000000000'; | ||
111 | |||
112 | COMMIT; | ||
113 | |||
114 | |||
115 | :VERSION 3 | ||
116 | |||
117 | BEGIN TRANSACTION; | ||
118 | |||
119 | CREATE TABLE avatarattachments ( | ||
120 | "UUID" varchar(36) NOT NULL | ||
121 | , "attachpoint" int NOT NULL | ||
122 | , item varchar(36) NOT NULL | ||
123 | , asset varchar(36) NOT NULL); | ||
124 | |||
125 | CREATE INDEX IX_avatarattachments ON avatarattachments | ||
126 | ( | ||
127 | "UUID" | ||
128 | ); | ||
129 | |||
130 | COMMIT; | ||
131 | |||
132 | |||
133 | :VERSION 4 | ||
134 | |||
135 | BEGIN TRANSACTION; | ||
136 | |||
137 | CREATE TABLE Tmp_userfriends | ||
138 | ( | ||
139 | "ownerID" varchar(36) NOT NULL, | ||
140 | "friendID" varchar(36) NOT NULL, | ||
141 | "friendPerms" int NOT NULL, | ||
142 | "datetimestamp" int NOT NULL | ||
143 | ); | ||
144 | |||
145 | INSERT INTO Tmp_userfriends ("ownerID", "friendID", "friendPerms", "datetimestamp") | ||
146 | SELECT cast("ownerID" as varchar(36)), cast("friendID" as varchar(36)), cast("friendPerms" as int), cast("datetimestamp" as int) | ||
147 | FROM userfriends; | ||
148 | |||
149 | DROP TABLE userfriends; | ||
150 | |||
151 | alter table Tmp_userfriends rename to userfriends; | ||
152 | |||
153 | CREATE INDEX IX_userfriends_ownerID ON userfriends | ||
154 | ( | ||
155 | "ownerID" | ||
156 | ); | ||
157 | |||
158 | CREATE INDEX IX_userfriends_friendID ON userfriends | ||
159 | ( | ||
160 | "friendID" | ||
161 | ); | ||
162 | |||
163 | COMMIT; | ||
164 | |||
165 | |||
166 | :VERSION 5 | ||
167 | |||
168 | BEGIN TRANSACTION; | ||
169 | |||
170 | ALTER TABLE users add "email" varchar(250); | ||
171 | |||
172 | COMMIT; | ||
173 | |||
174 | |||
175 | :VERSION 6 | ||
176 | |||
177 | BEGIN TRANSACTION; | ||
178 | |||
179 | CREATE TABLE Tmp_users | ||
180 | ( | ||
181 | "UUID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
182 | "username" varchar(32) NOT NULL, | ||
183 | "lastname" varchar(32) NOT NULL, | ||
184 | "passwordHash" varchar(32) NOT NULL, | ||
185 | "passwordSalt" varchar(32) NOT NULL, | ||
186 | "homeRegion" bigint NULL DEFAULT (NULL), | ||
187 | "homeLocationX" double precision NULL DEFAULT (NULL), | ||
188 | "homeLocationY" double precision NULL DEFAULT (NULL), | ||
189 | "homeLocationZ" double precision NULL DEFAULT (NULL), | ||
190 | "homeLookAtX" double precision NULL DEFAULT (NULL), | ||
191 | "homeLookAtY" double precision NULL DEFAULT (NULL), | ||
192 | "homeLookAtZ" double precision NULL DEFAULT (NULL), | ||
193 | "created" int NOT NULL, | ||
194 | "lastLogin" int NOT NULL, | ||
195 | "userInventoryURI" varchar(255) NULL DEFAULT (NULL), | ||
196 | "userAssetURI" varchar(255) NULL DEFAULT (NULL), | ||
197 | "profileCanDoMask" int NULL DEFAULT (NULL), | ||
198 | "profileWantDoMask" int NULL DEFAULT (NULL), | ||
199 | "profileAboutText" text NULL, | ||
200 | "profileFirstText" text NULL, | ||
201 | "profileImage" uuid NULL DEFAULT (NULL), | ||
202 | "profileFirstImage" uuid NULL DEFAULT (NULL), | ||
203 | "webLoginKey" uuid NULL DEFAULT (NULL), | ||
204 | "homeRegionID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
205 | "userFlags" int NOT NULL DEFAULT ((0)), | ||
206 | "godLevel" int NOT NULL DEFAULT ((0)), | ||
207 | "customType" varchar(32) NOT NULL DEFAULT (''), | ||
208 | "partner" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), | ||
209 | email varchar(250) NULL | ||
210 | ); | ||
211 | |||
212 | INSERT INTO Tmp_users ("UUID", "username", "lastname", "passwordHash", "passwordSalt", "homeRegion", "homeLocationX", "homeLocationY", "homeLocationZ", "homeLookAtX", "homeLookAtY", "homeLookAtZ", "created", "lastLogin", "userInventoryURI", "userAssetURI", "profileCanDoMask", "profileWantDoMask", "profileAboutText", "profileFirstText", "profileImage", "profileFirstImage", "webLoginKey", "homeRegionID", "userFlags", "godLevel", "customType", "partner", email) | ||
213 | SELECT cast("UUID" as uuid), "username", "lastname", "passwordHash", "passwordSalt", "homeRegion", "homeLocationX", "homeLocationY", "homeLocationZ", "homeLookAtX", "homeLookAtY", "homeLookAtZ", "created", "lastLogin", "userInventoryURI", "userAssetURI", "profileCanDoMask", "profileWantDoMask", "profileAboutText", "profileFirstText", cast("profileImage" as uuid), cast("profileFirstImage" as uuid), cast("webLoginKey" as uuid), cast("homeRegionID" as uuid), "userFlags", "godLevel", "customType", cast("partner" as uuid), email | ||
214 | FROM users ; | ||
215 | |||
216 | DROP TABLE users; | ||
217 | |||
218 | alter table Tmp_users rename to users; | ||
219 | |||
220 | ALTER TABLE users ADD CONSTRAINT | ||
221 | PK__users__65A475E737A5467C PRIMARY KEY | ||
222 | ( | ||
223 | "UUID" | ||
224 | ); | ||
225 | |||
226 | CREATE INDEX "usernames" ON users | ||
227 | ( | ||
228 | "username", | ||
229 | "lastname" | ||
230 | ); | ||
231 | |||
232 | COMMIT; | ||
233 | |||
234 | |||
235 | :VERSION 7 | ||
236 | |||
237 | BEGIN TRANSACTION; | ||
238 | |||
239 | CREATE TABLE Tmp_agents | ||
240 | ( | ||
241 | "UUID" uuid NOT NULL, | ||
242 | "sessionID" uuid NOT NULL, | ||
243 | "secureSessionID" uuid NOT NULL, | ||
244 | "agentIP" varchar(16) NOT NULL, | ||
245 | "agentPort" int NOT NULL, | ||
246 | "agentOnline" smallint NOT NULL, | ||
247 | "loginTime" int NOT NULL, | ||
248 | "logoutTime" int NOT NULL, | ||
249 | "currentRegion" uuid NOT NULL, | ||
250 | "currentHandle" bigint NOT NULL, | ||
251 | "currentPos" varchar(64) NOT NULL | ||
252 | ); | ||
253 | |||
254 | INSERT INTO Tmp_agents ("UUID", "sessionID", "secureSessionID", "agentIP", "agentPort", "agentOnline", "loginTime", "logoutTime", "currentRegion", "currentHandle", "currentPos") | ||
255 | SELECT cast("UUID" as uuid), cast("sessionID" as uuid), cast("secureSessionID" as uuid), "agentIP", "agentPort", "agentOnline", "loginTime", "logoutTime", cast("currentRegion" as uuid), "currentHandle", "currentPos" | ||
256 | FROM agents ; | ||
257 | |||
258 | DROP TABLE agents; | ||
259 | |||
260 | alter table Tmp_agents rename to agents; | ||
261 | |||
262 | ALTER TABLE agents ADD CONSTRAINT | ||
263 | PK__agents__65A475E749C3F6B7 PRIMARY KEY | ||
264 | ( | ||
265 | "UUID" | ||
266 | ) ; | ||
267 | |||
268 | CREATE INDEX session ON agents | ||
269 | ( | ||
270 | "sessionID" | ||
271 | ); | ||
272 | |||
273 | CREATE INDEX ssession ON agents | ||
274 | ( | ||
275 | "secureSessionID" | ||
276 | ); | ||
277 | |||
278 | COMMIT; | ||
279 | |||
280 | |||
281 | :VERSION 8 | ||
282 | |||
283 | BEGIN TRANSACTION; | ||
284 | |||
285 | CREATE TABLE Tmp_userfriends | ||
286 | ( | ||
287 | "ownerID" uuid NOT NULL, | ||
288 | "friendID" uuid NOT NULL, | ||
289 | "friendPerms" int NOT NULL, | ||
290 | "datetimestamp" int NOT NULL | ||
291 | ); | ||
292 | |||
293 | INSERT INTO Tmp_userfriends ("ownerID", "friendID", "friendPerms", "datetimestamp") | ||
294 | SELECT cast("ownerID" as uuid), cast( "friendID" as uuid), "friendPerms", "datetimestamp" | ||
295 | FROM userfriends; | ||
296 | |||
297 | DROP TABLE userfriends; | ||
298 | |||
299 | alter table Tmp_userfriends rename to userfriends; | ||
300 | |||
301 | CREATE INDEX IX_userfriends_ownerID ON userfriends | ||
302 | ( | ||
303 | "ownerID" | ||
304 | ); | ||
305 | |||
306 | CREATE INDEX IX_userfriends_friendID ON userfriends | ||
307 | ( | ||
308 | "friendID" | ||
309 | ); | ||
310 | |||
311 | COMMIT; | ||
312 | |||
313 | |||
314 | :VERSION 9 | ||
315 | |||
316 | BEGIN TRANSACTION; | ||
317 | |||
318 | CREATE TABLE Tmp_avatarappearance | ||
319 | ( | ||
320 | "Owner" uuid NOT NULL, | ||
321 | "Serial" int NOT NULL, | ||
322 | "Visual_Params" bytea NOT NULL, | ||
323 | "Texture" bytea NOT NULL, | ||
324 | "Avatar_Height" double precision NOT NULL, | ||
325 | "Body_Item" uuid NOT NULL, | ||
326 | "Body_Asset" uuid NOT NULL, | ||
327 | "Skin_Item" uuid NOT NULL, | ||
328 | "Skin_Asset" uuid NOT NULL, | ||
329 | "Hair_Item" uuid NOT NULL, | ||
330 | "Hair_Asset" uuid NOT NULL, | ||
331 | "Eyes_Item" uuid NOT NULL, | ||
332 | "Eyes_Asset" uuid NOT NULL, | ||
333 | "Shirt_Item" uuid NOT NULL, | ||
334 | "Shirt_Asset" uuid NOT NULL, | ||
335 | "Pants_Item" uuid NOT NULL, | ||
336 | "Pants_Asset" uuid NOT NULL, | ||
337 | "Shoes_Item" uuid NOT NULL, | ||
338 | "Shoes_Asset" uuid NOT NULL, | ||
339 | "Socks_Item" uuid NOT NULL, | ||
340 | "Socks_Asset" uuid NOT NULL, | ||
341 | "Jacket_Item" uuid NOT NULL, | ||
342 | "Jacket_Asset" uuid NOT NULL, | ||
343 | "Gloves_Item" uuid NOT NULL, | ||
344 | "Gloves_Asset" uuid NOT NULL, | ||
345 | "Undershirt_Item" uuid NOT NULL, | ||
346 | "Undershirt_Asset" uuid NOT NULL, | ||
347 | "Underpants_Item" uuid NOT NULL, | ||
348 | "Underpants_Asset" uuid NOT NULL, | ||
349 | "Skirt_Item" uuid NOT NULL, | ||
350 | "Skirt_Asset" uuid NOT NULL | ||
351 | ); | ||
352 | |||
353 | INSERT INTO Tmp_avatarappearance ("Owner", "Serial", "Visual_Params", "Texture", "Avatar_Height", "Body_Item", "Body_Asset", "Skin_Item", "Skin_Asset", "Hair_Item", "Hair_Asset", "Eyes_Item", "Eyes_Asset", "Shirt_Item", "Shirt_Asset", "Pants_Item", "Pants_Asset", "Shoes_Item", "Shoes_Asset", "Socks_Item", "Socks_Asset", "Jacket_Item", "Jacket_Asset", "Gloves_Item", "Gloves_Asset", "Undershirt_Item", "Undershirt_Asset", "Underpants_Item", "Underpants_Asset", "Skirt_Item", "Skirt_Asset") | ||
354 | SELECT cast("Owner" as uuid), "Serial", "Visual_Params", "Texture", "Avatar_Height", cast("Body_Item" as uuid), cast("Body_Asset" as uuid), cast("Skin_Item" as uuid), cast("Skin_Asset" as uuid), cast("Hair_Item" as uuid), cast("Hair_Asset" as uuid), cast("Eyes_Item" as uuid), cast("Eyes_Asset" as uuid), cast("Shirt_Item" as uuid), cast("Shirt_Asset" as uuid), cast("Pants_Item" as uuid), cast("Pants_Asset" as uuid), cast("Shoes_Item" as uuid), cast("Shoes_Asset" as uuid), cast("Socks_Item" as uuid), cast("Socks_Asset" as uuid), cast("Jacket_Item" as uuid), cast("Jacket_Asset" as uuid), cast("Gloves_Item" as uuid), cast("Gloves_Asset" as uuid), cast("Undershirt_Item" as uuid), cast("Undershirt_Asset" as uuid), cast("Underpants_Item" as uuid), cast("Underpants_Asset" as uuid), cast("Skirt_Item" as uuid), cast("Skirt_Asset" as uuid) | ||
355 | FROM avatarappearance ; | ||
356 | |||
357 | DROP TABLE avatarappearance; | ||
358 | |||
359 | alter table Tmp_avatarappearance rename to avatarappearance; | ||
360 | |||
361 | ALTER TABLE avatarappearance ADD CONSTRAINT | ||
362 | PK__avatarap__7DD115CC4E88ABD4 PRIMARY KEY | ||
363 | ( | ||
364 | "Owner" | ||
365 | ); | ||
366 | |||
367 | COMMIT; | ||
368 | |||
369 | |||
370 | :VERSION 10 | ||
371 | |||
372 | BEGIN TRANSACTION; | ||
373 | |||
374 | CREATE TABLE Tmp_avatarattachments | ||
375 | ( | ||
376 | "UUID" uuid NOT NULL, | ||
377 | "attachpoint" int NOT NULL, | ||
378 | item uuid NOT NULL, | ||
379 | asset uuid NOT NULL | ||
380 | ); | ||
381 | |||
382 | INSERT INTO Tmp_avatarattachments ("UUID", "attachpoint", item, asset) | ||
383 | SELECT cast("UUID" as uuid), "attachpoint", cast(item as uuid), cast(asset as uuid) | ||
384 | FROM avatarattachments ; | ||
385 | |||
386 | DROP TABLE avatarattachments; | ||
387 | |||
388 | alter table Tmp_avatarattachments rename to avatarattachments; | ||
389 | |||
390 | CREATE INDEX IX_avatarattachments ON avatarattachments | ||
391 | ( | ||
392 | "UUID" | ||
393 | ); | ||
394 | |||
395 | COMMIT; | ||
396 | |||
397 | |||
398 | :VERSION 11 | ||
399 | |||
400 | BEGIN TRANSACTION; | ||
401 | |||
402 | ALTER TABLE users ADD "scopeID" uuid not null default '00000000-0000-0000-0000-000000000000'; | ||
403 | |||
404 | COMMIT; | ||
diff --git a/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations b/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations new file mode 100644 index 0000000..df9d821 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/XAssetStore.migrations | |||
@@ -0,0 +1,80 @@ | |||
1 | # ----------------- | ||
2 | :VERSION 1 | ||
3 | |||
4 | BEGIN; | ||
5 | |||
6 | CREATE TABLE XAssetsMeta ( | ||
7 | "ID" char(36) NOT NULL, | ||
8 | "Hash" char(32) NOT NULL, | ||
9 | "Name" varchar(64) NOT NULL, | ||
10 | "Description" varchar(64) NOT NULL, | ||
11 | "AssetType" smallint NOT NULL, | ||
12 | "Local" smallint NOT NULL, | ||
13 | "Temporary" smallint NOT NULL, | ||
14 | "CreateTime" integer NOT NULL, | ||
15 | "AccessTime" integer NOT NULL, | ||
16 | "AssetFlags" integer NOT NULL, | ||
17 | "CreatorID" varchar(128) NOT NULL, | ||
18 | PRIMARY KEY ("ID") | ||
19 | ); | ||
20 | |||
21 | CREATE TABLE XAssetsData ( | ||
22 | "Hash" char(32) NOT NULL, | ||
23 | "Data" bytea NOT NULL, | ||
24 | PRIMARY KEY ("Hash") | ||
25 | ); | ||
26 | |||
27 | COMMIT; | ||
28 | |||
29 | |||
30 | :VERSION 2 | ||
31 | |||
32 | BEGIN; | ||
33 | |||
34 | ALTER TABLE xassetsmeta ALTER COLUMN "Local" SET DATA TYPE boolean USING CASE WHEN '0' THEN FALSE ELSE TRUE END; | ||
35 | ALTER TABLE xassetsmeta ALTER COLUMN "Temporary" SET DATA TYPE boolean USING CASE WHEN '0' THEN FALSE ELSE TRUE END; | ||
36 | ALTER TABLE xassetsmeta ALTER COLUMN "Hash" SET DATA TYPE char(66); | ||
37 | ALTER TABLE xassetsdata ALTER COLUMN "Hash" SET DATA TYPE char(66); | ||
38 | |||
39 | COMMIT; | ||
40 | |||
41 | :VERSION 3 | ||
42 | |||
43 | BEGIN; | ||
44 | |||
45 | ALTER TABLE xassetsmeta RENAME COLUMN "ID" TO id; | ||
46 | ALTER TABLE xassetsmeta RENAME COLUMN "Hash" TO hash; | ||
47 | ALTER TABLE xassetsmeta RENAME COLUMN "Name" TO name; | ||
48 | ALTER TABLE xassetsmeta RENAME COLUMN "Description" TO description; | ||
49 | ALTER TABLE xassetsmeta RENAME COLUMN "Local" to local; | ||
50 | ALTER TABLE xassetsmeta RENAME COLUMN "Temporary" TO temporary; | ||
51 | ALTER TABLE xassetsmeta RENAME COLUMN "CreateTime" TO create_time; | ||
52 | ALTER TABLE xassetsmeta RENAME COLUMN "AccessTime" TO access_time; | ||
53 | ALTER TABLE xassetsmeta RENAME COLUMN "AssetFlags" TO asset_flags; | ||
54 | ALTER TABLE xassetsmeta RENAME COLUMN "CreatorID" TO creatorid; | ||
55 | ALTER TABLE xassetsmeta DROP CONSTRAINT xassetsmeta_pkey; | ||
56 | ALTER TABLE xassetsmeta ADD PRIMARY KEY (id); | ||
57 | |||
58 | |||
59 | ALTER TABLE xassetsdata RENAME COLUMN "Hash" TO hash; | ||
60 | ALTER TABLE xassetsdata RENAME COLUMN "Data" TO data; | ||
61 | ALTER TABLE xassetsdata DROP CONSTRAINT xassetsdata_pkey; | ||
62 | ALTER TABLE xassetsdata ADD PRIMARY KEY (hash); | ||
63 | |||
64 | COMMIT; | ||
65 | |||
66 | |||
67 | :VERSION 4 | ||
68 | |||
69 | BEGIN; | ||
70 | |||
71 | ALTER TABLE xassetsmeta ALTER COLUMN id SET DATA TYPE uuid USING id::uuid; | ||
72 | ALTER TABLE xassetsmeta ALTER COLUMN hash SET DATA TYPE bytea USING hash::bytea; | ||
73 | ALTER TABLE xassetsdata ALTER COLUMN hash SET DATA TYPE bytea USING hash::bytea; | ||
74 | |||
75 | COMMIT; | ||
76 | |||
77 | :VERSION 5 | ||
78 | |||
79 | BEGIN; | ||
80 | COMMIT; | ||
diff --git a/OpenSim/Data/PGSQL/Resources/os_groups_Store.migrations b/OpenSim/Data/PGSQL/Resources/os_groups_Store.migrations new file mode 100644 index 0000000..74b07c3 --- /dev/null +++ b/OpenSim/Data/PGSQL/Resources/os_groups_Store.migrations | |||
@@ -0,0 +1,211 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE os_groups_groups ( | ||
6 | "GroupID" char(36) Primary Key NOT NULL default '', | ||
7 | "Location" varchar(255) NOT NULL default '', | ||
8 | "Name" varchar(255) NOT NULL default '', | ||
9 | "Charter" text NOT NULL, | ||
10 | "InsigniaID" char(36) NOT NULL default '', | ||
11 | "FounderID" char(36) NOT NULL default '', | ||
12 | "MembershipFee" integer NOT NULL default '0', | ||
13 | "OpenEnrollment" varchar(255) NOT NULL default '', | ||
14 | "ShowInList" integer NOT NULL default '0', | ||
15 | "AllowPublish" integer NOT NULL default '0', | ||
16 | "MaturePublish" integer NOT NULL default '0', | ||
17 | "OwnerRoleID" char(36) NOT NULL default '' | ||
18 | ); | ||
19 | |||
20 | |||
21 | CREATE TABLE os_groups_membership ( | ||
22 | "GroupID"char(36) NOT NULL default '', | ||
23 | "PrincipalID" VARCHAR(255) NOT NULL default '', | ||
24 | "SelectedRoleID" char(36) NOT NULL default '', | ||
25 | "Contribution" integer NOT NULL default '0', | ||
26 | "ListInProfile" integer NOT NULL default '1', | ||
27 | "AcceptNotices" integer NOT NULL default '1', | ||
28 | "AccessToken" char(36) NOT NULL default '', | ||
29 | constraint os_groupmemberpk primary key ("GroupID", "PrincipalID") | ||
30 | ); | ||
31 | |||
32 | |||
33 | |||
34 | CREATE TABLE os_groups_roles ( | ||
35 | "GroupID" char(36) NOT NULL default '', | ||
36 | "RoleID" char(36) NOT NULL default '', | ||
37 | "Name" varchar(255) NOT NULL default '', | ||
38 | "Description" varchar(255) NOT NULL default '', | ||
39 | "Title" varchar(255) NOT NULL default '', | ||
40 | "Powers" bigint NOT NULL default 0, | ||
41 | constraint os_grouprolepk PRIMARY KEY ("GroupID","RoleID") | ||
42 | ); | ||
43 | |||
44 | |||
45 | CREATE TABLE os_groups_rolemembership ( | ||
46 | "GroupID" char(36) NOT NULL default '', | ||
47 | "RoleID" char(36) NOT NULL default '', | ||
48 | "PrincipalID" VARCHAR(255) NOT NULL default '', | ||
49 | constraint os_grouprolememberpk PRIMARY KEY ("GroupID","RoleID","PrincipalID") | ||
50 | ); | ||
51 | |||
52 | |||
53 | CREATE TABLE os_groups_invites ( | ||
54 | "InviteID" char(36) NOT NULL default '', | ||
55 | "GroupID" char(36) NOT NULL default '', | ||
56 | "RoleID" char(36) NOT NULL default '', | ||
57 | "PrincipalID" VARCHAR(255) NOT NULL default '', | ||
58 | "TMStamp" timestamp NOT NULL default now(), | ||
59 | constraint os_groupinvitespk PRIMARY KEY ("InviteID") | ||
60 | ); | ||
61 | -- UNIQUE KEY "PrincipalGroup" ("GroupID","PrincipalID") | ||
62 | |||
63 | |||
64 | CREATE TABLE os_groups_notices ( | ||
65 | "GroupID" char(36) NOT NULL default '', | ||
66 | "NoticeID" char(36) NOT NULL default '', | ||
67 | "TMStamp" integer NOT NULL default '0', | ||
68 | "FromName" varchar(255) NOT NULL default '', | ||
69 | "Subject" varchar(255) NOT NULL default '', | ||
70 | "Message" text NOT NULL, | ||
71 | "HasAttachment" integer NOT NULL default '0', | ||
72 | "AttachmentType" integer NOT NULL default '0', | ||
73 | "AttachmentName" varchar(128) NOT NULL default '', | ||
74 | "AttachmentItemID" char(36) NOT NULL default '', | ||
75 | "AttachmentOwnerID" varchar(255) NOT NULL default '', | ||
76 | constraint os_groupsnoticespk PRIMARY KEY ("NoticeID") | ||
77 | ); | ||
78 | -- KEY "GroupID" ("GroupID"), | ||
79 | -- KEY "TMStamp" ("TMStamp") | ||
80 | |||
81 | CREATE TABLE os_groups_principals ( | ||
82 | "PrincipalID" VARCHAR(255) NOT NULL default '', | ||
83 | "ActiveGroupID" char(36) NOT NULL default '', | ||
84 | constraint os_groupprincpk PRIMARY KEY ("PrincipalID") | ||
85 | ); | ||
86 | |||
87 | COMMIT; | ||
88 | |||
89 | :VERSION 2 # -------------------------- | ||
90 | |||
91 | BEGIN; | ||
92 | |||
93 | |||
94 | COMMIT; | ||
95 | |||
96 | |||
97 | |||
98 | :VERSION 3 | ||
99 | |||
100 | BEGIN; | ||
101 | |||
102 | -- Not a pretty way to do this, but it did not work as-is | ||
103 | -- and nothing was found about converting between existing data | ||
104 | -- and the new type. | ||
105 | -- Since there should be nothing to preserve ... | ||
106 | |||
107 | DROP TABLE IF EXISTS os_groups_groups CASCADE; | ||
108 | |||
109 | CREATE TABLE os_groups_groups ( | ||
110 | "GroupID" uuid PRIMARY KEY NOT NULL, | ||
111 | "Location" varchar(255) NOT NULL DEFAULT '', | ||
112 | "Name" varchar(255) NOT NULL DEFAULT '', | ||
113 | "Charter" text NOT NULL, | ||
114 | "InsigniaID" uuid NOT NULL, | ||
115 | "FounderID" uuid NOT NULL, | ||
116 | "MembershipFee" integer NOT NULL DEFAULT '0', | ||
117 | "OpenEnrollment" varchar(255) NOT NULL DEFAULT '', | ||
118 | "ShowInList" integer NOT NULL DEFAULT '0', | ||
119 | "AllowPublish" integer NOT NULL DEFAULT '0', | ||
120 | "MaturePublish" integer NOT NULL DEFAULT '0', | ||
121 | "OwnerRoleID" uuid NOT NULL | ||
122 | ); | ||
123 | |||
124 | |||
125 | DROP TABLE IF EXISTS os_groups_membership; | ||
126 | |||
127 | CREATE TABLE os_groups_membership ( | ||
128 | "GroupID"uuid NOT NULL, | ||
129 | "PrincipalID" VARCHAR(255) NOT NULL DEFAULT '', | ||
130 | "SelectedRoleID" uuid NOT NULL, | ||
131 | "Contribution" integer NOT NULL DEFAULT '0', | ||
132 | "ListInProfile" integer NOT NULL DEFAULT '1', | ||
133 | "AcceptNotices" integer NOT NULL DEFAULT '1', | ||
134 | "AccessToken" uuid NOT NULL, | ||
135 | constraint os_groupmemberpk PRIMARY KEY ("GroupID", "PrincipalID") | ||
136 | ); | ||
137 | |||
138 | |||
139 | |||
140 | DROP TABLE IF EXISTS os_groups_roles; | ||
141 | |||
142 | CREATE TABLE os_groups_roles ( | ||
143 | "GroupID" uuid NOT NULL, | ||
144 | "RoleID" uuid NOT NULL, | ||
145 | "Name" varchar(255) NOT NULL DEFAULT '', | ||
146 | "Description" varchar(255) NOT NULL DEFAULT '', | ||
147 | "Title" varchar(255) NOT NULL DEFAULT '', | ||
148 | "Powers" varchar(36) NOT NULL DEFAULT '', | ||
149 | constraint os_grouprolepk PRIMARY KEY ("GroupID","RoleID") | ||
150 | ); | ||
151 | |||
152 | |||
153 | DROP TABLE IF EXISTS os_groups_rolemembership; | ||
154 | |||
155 | CREATE TABLE os_groups_rolemembership ( | ||
156 | "GroupID" uuid NOT NULL, | ||
157 | "RoleID" uuid NOT NULL, | ||
158 | "PrincipalID" VARCHAR(255) NOT NULL DEFAULT '', | ||
159 | constraint os_grouprolememberpk PRIMARY KEY ("GroupID","RoleID","PrincipalID") | ||
160 | ); | ||
161 | |||
162 | |||
163 | DROP TABLE IF EXISTS os_groups_invites; | ||
164 | |||
165 | CREATE TABLE os_groups_invites ( | ||
166 | "InviteID" uuid NOT NULL, | ||
167 | "GroupID" uuid NOT NULL, | ||
168 | "RoleID" uuid NOT NULL, | ||
169 | "PrincipalID" VARCHAR(255) NOT NULL DEFAULT '', | ||
170 | "TMStamp" timestamp NOT NULL DEFAULT now(), | ||
171 | constraint os_groupinvitespk PRIMARY KEY ("InviteID") | ||
172 | ); | ||
173 | |||
174 | |||
175 | DROP TABLE IF EXISTS os_groups_notices; | ||
176 | |||
177 | CREATE TABLE os_groups_notices ( | ||
178 | "GroupID" uuid NOT NULL, | ||
179 | "NoticeID" uuid NOT NULL, | ||
180 | "TMStamp" integer NOT NULL DEFAULT '0', | ||
181 | "FromName" varchar(255) NOT NULL DEFAULT '', | ||
182 | "Subject" varchar(255) NOT NULL DEFAULT '', | ||
183 | "Message" text NOT NULL, | ||
184 | "HasAttachment" integer NOT NULL DEFAULT '0', | ||
185 | "AttachmentType" integer NOT NULL DEFAULT '0', | ||
186 | "AttachmentName" varchar(128) NOT NULL DEFAULT '', | ||
187 | "AttachmentItemID" uuid NOT NULL, | ||
188 | "AttachmentOwnerID" varchar(255) NOT NULL DEFAULT '', | ||
189 | constraint os_groupsnoticespk PRIMARY KEY ("NoticeID") | ||
190 | ); | ||
191 | |||
192 | |||
193 | DROP TABLE IF EXISTS os_groups_principals; | ||
194 | |||
195 | CREATE TABLE os_groups_principals ( | ||
196 | "PrincipalID" VARCHAR(255) NOT NULL DEFAULT '', | ||
197 | "ActiveGroupID" uuid NOT NULL, | ||
198 | constraint os_groupprincpk PRIMARY KEY ("PrincipalID") | ||
199 | ); | ||
200 | |||
201 | COMMIT; | ||
202 | |||
203 | :VERSION 4 | ||
204 | |||
205 | BEGIN; | ||
206 | |||
207 | ALTER TABLE IF EXISTS os_groups_notices | ||
208 | ALTER COLUMN "AttachmentItemID" SET DEFAULT '00000000-0000-0000-0000-000000000000' | ||
209 | ; | ||
210 | |||
211 | COMMIT; | ||
diff --git a/OpenSim/Data/Properties/AssemblyInfo.cs b/OpenSim/Data/Properties/AssemblyInfo.cs index 0da1a6b..b1f234b 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.7.5.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | |
diff --git a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs index c9a8553..d2e62d2 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.7.5.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | |
diff --git a/OpenSim/Data/SQLite/Resources/AgentPrefs.migrations b/OpenSim/Data/SQLite/Resources/AgentPrefs.migrations new file mode 100644 index 0000000..7e0525d --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/AgentPrefs.migrations | |||
@@ -0,0 +1,36 @@ | |||
1 | :VERSION 1 | ||
2 | |||
3 | BEGIN TRANSACTION; | ||
4 | |||
5 | CREATE TABLE `AgentPrefs` ( | ||
6 | `PrincipalID` CHAR(36) NOT NULL, | ||
7 | `AccessPrefs` CHAR(2) NOT NULL DEFAULT 'M', | ||
8 | `HoverHeight` DOUBLE(30, 27) NOT NULL DEFAULT 0, | ||
9 | `Language` CHAR(5) NOT NULL DEFAULT 'en-us', | ||
10 | `LanguageIsPublic` BOOLEAN NOT NULL DEFAULT 1, | ||
11 | `PermEveryone` INT(6) NOT NULL DEFAULT 0, | ||
12 | `PermGroup` INT(6) NOT NULL DEFAULT 0, | ||
13 | `PermNextOwner` INT(6) NOT NULL DEFAULT 532480, | ||
14 | UNIQUE KEY `PrincipalID` (`PrincipalID`), | ||
15 | PRIMARY KEY(`PrincipalID`)); | ||
16 | |||
17 | COMMIT; | ||
18 | |||
19 | :VERSION 2 | ||
20 | |||
21 | BEGIN; | ||
22 | |||
23 | CREATE TABLE AgentPrefs( | ||
24 | PrincipalID CHAR(36) NOT NULL, | ||
25 | AccessPrefs CHAR(2) NOT NULL DEFAULT 'M', | ||
26 | HoverHeight DOUBLE(30, 27) NOT NULL DEFAULT 0, | ||
27 | Language CHAR(5) NOT NULL DEFAULT 'en-us', | ||
28 | LanguageIsPublic BOOLEAN NOT NULL DEFAULT 1, | ||
29 | PermEveryone INT(6) NOT NULL DEFAULT 0, | ||
30 | PermGroup INT(6) NOT NULL DEFAULT 0, | ||
31 | PermNextOwner INT(6) NOT NULL DEFAULT 532480, | ||
32 | UNIQUE(PrincipalID), | ||
33 | PRIMARY KEY(PrincipalID) | ||
34 | ); | ||
35 | |||
36 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/Resources/EstateStore.migrations b/OpenSim/Data/SQLite/Resources/EstateStore.migrations index 62f6464..0aec49b 100644 --- a/OpenSim/Data/SQLite/Resources/EstateStore.migrations +++ b/OpenSim/Data/SQLite/Resources/EstateStore.migrations | |||
@@ -86,3 +86,12 @@ begin; | |||
86 | alter table estate_settings add column DenyMinors tinyint not null default 0; | 86 | alter table estate_settings add column DenyMinors tinyint not null default 0; |
87 | 87 | ||
88 | commit; | 88 | commit; |
89 | |||
90 | :VERSION 9 | ||
91 | |||
92 | begin; | ||
93 | alter table estate_settings add column AllowLandmark tinyint not null default '1'; | ||
94 | alter table estate_settings add column AllowParcelChanges tinyint not null default '1'; | ||
95 | alter table estate_settings add column AllowSetHome tinyint not null default '1'; | ||
96 | commit; | ||
97 | |||
diff --git a/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations b/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..02612ce --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 2 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE hg_traveling_data( | ||
6 | SessionID VARCHAR(36) NOT NULL, | ||
7 | UserID VARCHAR(36) NOT NULL, | ||
8 | GridExternalName VARCHAR(255) NOT NULL DEFAULT "", | ||
9 | ServiceToken VARCHAR(255) NOT NULL DEFAULT "", | ||
10 | ClientIPAddress VARCHAR(16) NOT NULL DEFAULT "", | ||
11 | MyIPAddress VARCHAR(16) NOT NULL DEFAULT "", | ||
12 | TMStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
13 | PRIMARY KEY(SessionID), | ||
14 | UNIQUE(UserID) | ||
15 | ); | ||
16 | |||
17 | COMMIT; | ||
18 | |||
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations index e872977..901068f 100644 --- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations +++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations | |||
@@ -575,3 +575,40 @@ CREATE TABLE `regionenvironment` ( | |||
575 | ); | 575 | ); |
576 | 576 | ||
577 | COMMIT; | 577 | COMMIT; |
578 | |||
579 | :VERSION 27 | ||
580 | BEGIN; | ||
581 | ALTER TABLE prims ADD COLUMN DynAttrs TEXT; | ||
582 | COMMIT; | ||
583 | |||
584 | :VERSION 28 | ||
585 | |||
586 | BEGIN; | ||
587 | |||
588 | ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; | ||
589 | ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000'; | ||
590 | ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1'; | ||
591 | ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; | ||
592 | ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; | ||
593 | |||
594 | COMMIT; | ||
595 | |||
596 | :VERSION 29 #---------------- Keyframes | ||
597 | |||
598 | BEGIN; | ||
599 | |||
600 | ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; | ||
601 | |||
602 | COMMIT; | ||
603 | |||
604 | :VERSION 30 #---------------- Save Attachment info | ||
605 | |||
606 | BEGIN; | ||
607 | |||
608 | ALTER TABLE prims ADD COLUMN AttachedPosX double default '0'; | ||
609 | ALTER TABLE prims ADD COLUMN AttachedPosY double default '0'; | ||
610 | ALTER TABLE prims ADD COLUMN AttachedPosZ double default '0'; | ||
611 | ALTER TABLE primshapes ADD COLUMN LastAttachPoint int not null default '0'; | ||
612 | |||
613 | COMMIT; | ||
614 | |||
diff --git a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations new file mode 100644 index 0000000..86434e8 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations | |||
@@ -0,0 +1,102 @@ | |||
1 | :VERSION 1 # ------------------------------- | ||
2 | |||
3 | begin; | ||
4 | |||
5 | CREATE TABLE IF NOT EXISTS classifieds ( | ||
6 | classifieduuid char(36) NOT NULL PRIMARY KEY, | ||
7 | creatoruuid char(36) NOT NULL, | ||
8 | creationdate int(20) NOT NULL, | ||
9 | expirationdate int(20) NOT NULL, | ||
10 | category varchar(20) NOT NULL, | ||
11 | name varchar(255) NOT NULL, | ||
12 | description text NOT NULL, | ||
13 | parceluuid char(36) NOT NULL, | ||
14 | parentestate int(11) NOT NULL, | ||
15 | snapshotuuid char(36) NOT NULL, | ||
16 | simname varchar(255) NOT NULL, | ||
17 | posglobal varchar(255) NOT NULL, | ||
18 | parcelname varchar(255) NOT NULL, | ||
19 | classifiedflags int(8) NOT NULL, | ||
20 | priceforlisting int(5) NOT NULL | ||
21 | ); | ||
22 | |||
23 | commit; | ||
24 | |||
25 | begin; | ||
26 | |||
27 | CREATE TABLE IF NOT EXISTS usernotes ( | ||
28 | useruuid varchar(36) NOT NULL, | ||
29 | targetuuid varchar(36) NOT NULL, | ||
30 | notes text NOT NULL, | ||
31 | UNIQUE (useruuid,targetuuid) ON CONFLICT REPLACE | ||
32 | ); | ||
33 | |||
34 | commit; | ||
35 | |||
36 | begin; | ||
37 | |||
38 | CREATE TABLE IF NOT EXISTS userpicks ( | ||
39 | pickuuid varchar(36) NOT NULL PRIMARY KEY, | ||
40 | creatoruuid varchar(36) NOT NULL, | ||
41 | toppick int NOT NULL, | ||
42 | parceluuid varchar(36) NOT NULL, | ||
43 | name varchar(255) NOT NULL, | ||
44 | description text NOT NULL, | ||
45 | snapshotuuid varchar(36) NOT NULL, | ||
46 | user varchar(255) NOT NULL, | ||
47 | originalname varchar(255) NOT NULL, | ||
48 | simname varchar(255) NOT NULL, | ||
49 | posglobal varchar(255) NOT NULL, | ||
50 | sortorder int(2) NOT NULL, | ||
51 | enabled int NOT NULL | ||
52 | ); | ||
53 | |||
54 | commit; | ||
55 | |||
56 | begin; | ||
57 | |||
58 | CREATE TABLE IF NOT EXISTS userprofile ( | ||
59 | useruuid varchar(36) NOT NULL PRIMARY KEY, | ||
60 | profilePartner varchar(36) NOT NULL, | ||
61 | profileAllowPublish binary(1) NOT NULL, | ||
62 | profileMaturePublish binary(1) NOT NULL, | ||
63 | profileURL varchar(255) NOT NULL, | ||
64 | profileWantToMask int(3) NOT NULL, | ||
65 | profileWantToText text NOT NULL, | ||
66 | profileSkillsMask int(3) NOT NULL, | ||
67 | profileSkillsText text NOT NULL, | ||
68 | profileLanguages text NOT NULL, | ||
69 | profileImage varchar(36) NOT NULL, | ||
70 | profileAboutText text NOT NULL, | ||
71 | profileFirstImage varchar(36) NOT NULL, | ||
72 | profileFirstText text NOT NULL | ||
73 | ); | ||
74 | |||
75 | commit; | ||
76 | |||
77 | :VERSION 2 # ------------------------------- | ||
78 | |||
79 | begin; | ||
80 | |||
81 | CREATE TABLE IF NOT EXISTS userdata ( | ||
82 | UserId char(36) NOT NULL, | ||
83 | TagId varchar(64) NOT NULL, | ||
84 | DataKey varchar(255), | ||
85 | DataVal varchar(255), | ||
86 | PRIMARY KEY (UserId,TagId) | ||
87 | ); | ||
88 | |||
89 | commit; | ||
90 | |||
91 | |||
92 | :VERSION 3 # ------------------------------- | ||
93 | |||
94 | begin; | ||
95 | CREATE TABLE IF NOT EXISTS usersettings ( | ||
96 | useruuid char(36) NOT NULL, | ||
97 | imviaemail binary(1) NOT NULL, | ||
98 | visible binary(1) NOT NULL, | ||
99 | email varchar(254) NOT NULL, | ||
100 | PRIMARY KEY (useruuid) | ||
101 | ) | ||
102 | commit; \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/SQLiteAgentPreferencesData.cs b/OpenSim/Data/SQLite/SQLiteAgentPreferencesData.cs new file mode 100644 index 0000000..d22393d --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteAgentPreferencesData.cs | |||
@@ -0,0 +1,60 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | #if CSharpSqlite | ||
35 | using Community.CsharpSqlite.Sqlite; | ||
36 | #else | ||
37 | using Mono.Data.Sqlite; | ||
38 | #endif | ||
39 | |||
40 | namespace OpenSim.Data.SQLite | ||
41 | { | ||
42 | public class SQLiteAgentPreferencesData : SQLiteGenericTableHandler<AgentPreferencesData>, IAgentPreferencesData | ||
43 | { | ||
44 | public SQLiteAgentPreferencesData(string connectionString, string realm) | ||
45 | : base(connectionString, realm, "AgentPrefs") | ||
46 | { | ||
47 | } | ||
48 | |||
49 | public AgentPreferencesData GetPrefs(UUID agentID) | ||
50 | { | ||
51 | AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString()); | ||
52 | |||
53 | if (ret.Length == 0) | ||
54 | return null; | ||
55 | |||
56 | return ret[0]; | ||
57 | } | ||
58 | |||
59 | } | ||
60 | } | ||
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 61e7aaf..f0dda64 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Data.SQLite | |||
46 | /// </summary> | 46 | /// </summary> |
47 | public class SQLiteAssetData : AssetDataBase | 47 | public class SQLiteAssetData : AssetDataBase |
48 | { | 48 | { |
49 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; | 51 | private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; |
52 | private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID, CreatorID from assets limit :start, :count"; | 52 | private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID, CreatorID from assets limit :start, :count"; |
@@ -133,8 +133,26 @@ namespace OpenSim.Data.SQLite | |||
133 | /// <param name="asset">Asset Base</param> | 133 | /// <param name="asset">Asset Base</param> |
134 | override public void StoreAsset(AssetBase asset) | 134 | override public void StoreAsset(AssetBase asset) |
135 | { | 135 | { |
136 | string assetName = asset.Name; | ||
137 | if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) | ||
138 | { | ||
139 | assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); | ||
140 | m_log.WarnFormat( | ||
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); | ||
143 | } | ||
144 | |||
145 | string assetDescription = asset.Description; | ||
146 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) | ||
147 | { | ||
148 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); | ||
149 | m_log.WarnFormat( | ||
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); | ||
152 | } | ||
153 | |||
136 | //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); | 154 | //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); |
137 | if (ExistsAsset(asset.FullID)) | 155 | if (AssetsExist(new[] { asset.FullID })[0]) |
138 | { | 156 | { |
139 | //LogAssetLoad(asset); | 157 | //LogAssetLoad(asset); |
140 | 158 | ||
@@ -143,8 +161,8 @@ namespace OpenSim.Data.SQLite | |||
143 | using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) | 161 | using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) |
144 | { | 162 | { |
145 | cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); | 163 | cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); |
146 | cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); | 164 | cmd.Parameters.Add(new SqliteParameter(":Name", assetName)); |
147 | cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); | 165 | cmd.Parameters.Add(new SqliteParameter(":Description", assetDescription)); |
148 | cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); | 166 | cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); |
149 | cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); | 167 | cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); |
150 | cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); | 168 | cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); |
@@ -163,8 +181,8 @@ namespace OpenSim.Data.SQLite | |||
163 | using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) | 181 | using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) |
164 | { | 182 | { |
165 | cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); | 183 | cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); |
166 | cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); | 184 | cmd.Parameters.Add(new SqliteParameter(":Name", assetName)); |
167 | cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); | 185 | cmd.Parameters.Add(new SqliteParameter(":Description", assetDescription)); |
168 | cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); | 186 | cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); |
169 | cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); | 187 | cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); |
170 | cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); | 188 | cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); |
@@ -196,32 +214,39 @@ namespace OpenSim.Data.SQLite | |||
196 | // } | 214 | // } |
197 | 215 | ||
198 | /// <summary> | 216 | /// <summary> |
199 | /// Check if an asset exist in database | 217 | /// Check if the assets exist in the database. |
200 | /// </summary> | 218 | /// </summary> |
201 | /// <param name="uuid">The asset UUID</param> | 219 | /// <param name="uuids">The assets' IDs</param> |
202 | /// <returns>True if exist, or false.</returns> | 220 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
203 | override public bool ExistsAsset(UUID uuid) | 221 | public override bool[] AssetsExist(UUID[] uuids) |
204 | { | 222 | { |
205 | lock (this) | 223 | if (uuids.Length == 0) |
224 | return new bool[0]; | ||
225 | |||
226 | HashSet<UUID> exist = new HashSet<UUID>(); | ||
227 | |||
228 | string ids = "'" + string.Join("','", uuids) + "'"; | ||
229 | string sql = string.Format("select UUID from assets where UUID in ({0})", ids); | ||
230 | |||
231 | lock (this) | ||
206 | { | 232 | { |
207 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) | 233 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) |
208 | { | 234 | { |
209 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); | ||
210 | using (IDataReader reader = cmd.ExecuteReader()) | 235 | using (IDataReader reader = cmd.ExecuteReader()) |
211 | { | 236 | { |
212 | if (reader.Read()) | 237 | while (reader.Read()) |
213 | { | ||
214 | reader.Close(); | ||
215 | return true; | ||
216 | } | ||
217 | else | ||
218 | { | 238 | { |
219 | reader.Close(); | 239 | UUID id = new UUID((string)reader["UUID"]); |
220 | return false; | 240 | exist.Add(id); |
221 | } | 241 | } |
222 | } | 242 | } |
223 | } | 243 | } |
224 | } | 244 | } |
245 | |||
246 | bool[] results = new bool[uuids.Length]; | ||
247 | for (int i = 0; i < uuids.Length; i++) | ||
248 | results[i] = exist.Contains(uuids[i]); | ||
249 | return results; | ||
225 | } | 250 | } |
226 | 251 | ||
227 | /// <summary> | 252 | /// <summary> |
diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs index cab85eb..331f426 100644 --- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Data.SQLite | |||
67 | return Delete(principalID.ToString(), friend); | 67 | return Delete(principalID.ToString(), friend); |
68 | } | 68 | } |
69 | 69 | ||
70 | public bool Delete(string principalID, string friend) | 70 | public override bool Delete(string principalID, string friend) |
71 | { | 71 | { |
72 | using (SqliteCommand cmd = new SqliteCommand()) | 72 | using (SqliteCommand cmd = new SqliteCommand()) |
73 | { | 73 | { |
diff --git a/OpenSim/Data/SQLite/SQLiteGridUserData.cs b/OpenSim/Data/SQLite/SQLiteGridUserData.cs index 1bb5ed8..d8c52f8 100644 --- a/OpenSim/Data/SQLite/SQLiteGridUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridUserData.cs | |||
@@ -56,6 +56,10 @@ namespace OpenSim.Data.SQLite | |||
56 | return ret[0]; | 56 | return ret[0]; |
57 | } | 57 | } |
58 | 58 | ||
59 | public GridUserData[] GetAll(string userID) | ||
60 | { | ||
61 | return base.Get(String.Format("UserID LIKE '{0}%'", userID)); | ||
62 | } | ||
59 | 63 | ||
60 | } | 64 | } |
61 | } \ No newline at end of file | 65 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteHGTravelData.cs b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs new file mode 100644 index 0000000..db288b2 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs | |||
@@ -0,0 +1,82 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using Mono.Data.Sqlite; | ||
37 | |||
38 | namespace OpenSim.Data.SQLite | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A SQL Interface for user grid data | ||
42 | /// </summary> | ||
43 | public class SQLiteHGTravelData : SQLiteGenericTableHandler<HGTravelingData>, IHGTravelingData | ||
44 | { | ||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | public SQLiteHGTravelData(string connectionString, string realm) | ||
48 | : base(connectionString, realm, "HGTravelStore") {} | ||
49 | |||
50 | public HGTravelingData Get(UUID sessionID) | ||
51 | { | ||
52 | HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); | ||
53 | |||
54 | if (ret.Length == 0) | ||
55 | return null; | ||
56 | |||
57 | return ret[0]; | ||
58 | } | ||
59 | |||
60 | public HGTravelingData[] GetSessions(UUID userID) | ||
61 | { | ||
62 | return base.Get("UserID", userID.ToString()); | ||
63 | } | ||
64 | |||
65 | public bool Delete(UUID sessionID) | ||
66 | { | ||
67 | return Delete("SessionID", sessionID.ToString()); | ||
68 | } | ||
69 | |||
70 | public void DeleteOld() | ||
71 | { | ||
72 | using (SqliteCommand cmd = new SqliteCommand()) | ||
73 | { | ||
74 | cmd.CommandText = String.Format("delete from {0} where TMStamp < datetime('now', '-2 day') ", m_Realm); | ||
75 | |||
76 | DoQuery(cmd); | ||
77 | } | ||
78 | |||
79 | } | ||
80 | |||
81 | } | ||
82 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index ccbd154..7d493ca 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs | |||
@@ -239,7 +239,7 @@ namespace OpenSim.Data.SQLite | |||
239 | if (inventoryRow == null) | 239 | if (inventoryRow == null) |
240 | { | 240 | { |
241 | if (! add) | 241 | if (! add) |
242 | m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existant inventory folder: {0}", folder.ID); | 242 | m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existent inventory folder: {0}", folder.ID); |
243 | 243 | ||
244 | inventoryRow = inventoryFolderTable.NewRow(); | 244 | inventoryRow = inventoryFolderTable.NewRow(); |
245 | fillFolderRow(inventoryRow, folder); | 245 | fillFolderRow(inventoryRow, folder); |
@@ -298,7 +298,7 @@ namespace OpenSim.Data.SQLite | |||
298 | if (inventoryRow == null) | 298 | if (inventoryRow == null) |
299 | { | 299 | { |
300 | if (!add) | 300 | if (!add) |
301 | m_log.ErrorFormat("[INVENTORY DB]: Interface Misuse: Attempting to Update non-existant inventory item: {0}", item.ID); | 301 | m_log.ErrorFormat("[INVENTORY DB]: Interface Misuse: Attempting to Update non-existent inventory item: {0}", item.ID); |
302 | 302 | ||
303 | inventoryRow = inventoryItemTable.NewRow(); | 303 | inventoryRow = inventoryItemTable.NewRow(); |
304 | fillItemRow(inventoryRow, item); | 304 | fillItemRow(inventoryRow, item); |
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 29cac3c..6ed3d40 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Data.SQLite | |||
51 | public class SQLiteSimulationData : ISimulationDataStore | 51 | public class SQLiteSimulationData : ISimulationDataStore |
52 | { | 52 | { |
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | private static readonly string LogHeader = "[REGION DB SQLITE]"; | ||
54 | 55 | ||
55 | private const string primSelect = "select * from prims"; | 56 | private const string primSelect = "select * from prims"; |
56 | private const string shapeSelect = "select * from primshapes"; | 57 | private const string shapeSelect = "select * from primshapes"; |
@@ -732,9 +733,12 @@ namespace OpenSim.Data.SQLite | |||
732 | } | 733 | } |
733 | 734 | ||
734 | SceneObjectGroup group = new SceneObjectGroup(prim); | 735 | SceneObjectGroup group = new SceneObjectGroup(prim); |
736 | |||
735 | createdObjects.Add(group.UUID, group); | 737 | createdObjects.Add(group.UUID, group); |
736 | retvals.Add(group); | 738 | retvals.Add(group); |
737 | LoadItems(prim); | 739 | LoadItems(prim); |
740 | |||
741 | |||
738 | } | 742 | } |
739 | } | 743 | } |
740 | catch (Exception e) | 744 | catch (Exception e) |
@@ -816,45 +820,44 @@ namespace OpenSim.Data.SQLite | |||
816 | prim.Inventory.RestoreInventoryItems(inventory); | 820 | prim.Inventory.RestoreInventoryItems(inventory); |
817 | } | 821 | } |
818 | 822 | ||
823 | // Legacy entry point for when terrain was always a 256x256 hieghtmap | ||
824 | public void StoreTerrain(double[,] ter, UUID regionID) | ||
825 | { | ||
826 | StoreTerrain(new HeightmapTerrainData(ter), regionID); | ||
827 | } | ||
828 | |||
819 | /// <summary> | 829 | /// <summary> |
820 | /// Store a terrain revision in region storage | 830 | /// Store a terrain revision in region storage |
821 | /// </summary> | 831 | /// </summary> |
822 | /// <param name="ter">terrain heightfield</param> | 832 | /// <param name="ter">terrain heightfield</param> |
823 | /// <param name="regionID">region UUID</param> | 833 | /// <param name="regionID">region UUID</param> |
824 | public void StoreTerrain(double[,] ter, UUID regionID) | 834 | public void StoreTerrain(TerrainData terrData, UUID regionID) |
825 | { | 835 | { |
826 | lock (ds) | 836 | lock (ds) |
827 | { | 837 | { |
828 | int revision = Util.UnixTimeSinceEpoch(); | ||
829 | |||
830 | // This is added to get rid of the infinitely growing | ||
831 | // terrain databases which negatively impact on SQLite | ||
832 | // over time. Before reenabling this feature there | ||
833 | // needs to be a limitter put on the number of | ||
834 | // revisions in the database, as this old | ||
835 | // implementation is a DOS attack waiting to happen. | ||
836 | |||
837 | using ( | 838 | using ( |
838 | SqliteCommand cmd = | 839 | SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn)) |
839 | new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision", | ||
840 | m_conn)) | ||
841 | { | 840 | { |
842 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | 841 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); |
843 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); | ||
844 | cmd.ExecuteNonQuery(); | 842 | cmd.ExecuteNonQuery(); |
845 | } | 843 | } |
846 | 844 | ||
847 | // the following is an work around for .NET. The perf | 845 | // the following is an work around for .NET. The perf |
848 | // issues associated with it aren't as bad as you think. | 846 | // issues associated with it aren't as bad as you think. |
849 | m_log.Debug("[SQLITE REGION DB]: Storing terrain revision r" + revision.ToString()); | ||
850 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + | 847 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + |
851 | " values(:RegionUUID, :Revision, :Heightfield)"; | 848 | " values(:RegionUUID, :Revision, :Heightfield)"; |
852 | 849 | ||
850 | int terrainDBRevision; | ||
851 | Array terrainDBblob; | ||
852 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
853 | |||
854 | m_log.DebugFormat("{0} Storing terrain revision r {1}", LogHeader, terrainDBRevision); | ||
855 | |||
853 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) | 856 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) |
854 | { | 857 | { |
855 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | 858 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); |
856 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); | 859 | cmd.Parameters.Add(new SqliteParameter(":Revision", terrainDBRevision)); |
857 | cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); | 860 | cmd.Parameters.Add(new SqliteParameter(":Heightfield", terrainDBblob)); |
858 | cmd.ExecuteNonQuery(); | 861 | cmd.ExecuteNonQuery(); |
859 | } | 862 | } |
860 | } | 863 | } |
@@ -867,11 +870,20 @@ namespace OpenSim.Data.SQLite | |||
867 | /// <returns>Heightfield data</returns> | 870 | /// <returns>Heightfield data</returns> |
868 | public double[,] LoadTerrain(UUID regionID) | 871 | public double[,] LoadTerrain(UUID regionID) |
869 | { | 872 | { |
873 | double[,] ret = null; | ||
874 | TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); | ||
875 | if (terrData != null) | ||
876 | ret = terrData.GetDoubles(); | ||
877 | return ret; | ||
878 | } | ||
879 | |||
880 | // Returns 'null' if region not found | ||
881 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
882 | { | ||
883 | TerrainData terrData = null; | ||
884 | |||
870 | lock (ds) | 885 | lock (ds) |
871 | { | 886 | { |
872 | double[,] terret = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | ||
873 | terret.Initialize(); | ||
874 | |||
875 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + | 887 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + |
876 | " where RegionUUID=:RegionUUID order by Revision desc"; | 888 | " where RegionUUID=:RegionUUID order by Revision desc"; |
877 | 889 | ||
@@ -884,21 +896,9 @@ namespace OpenSim.Data.SQLite | |||
884 | int rev = 0; | 896 | int rev = 0; |
885 | if (row.Read()) | 897 | if (row.Read()) |
886 | { | 898 | { |
887 | // TODO: put this into a function | ||
888 | using (MemoryStream str = new MemoryStream((byte[])row["Heightfield"])) | ||
889 | { | ||
890 | using (BinaryReader br = new BinaryReader(str)) | ||
891 | { | ||
892 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
893 | { | ||
894 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
895 | { | ||
896 | terret[x, y] = br.ReadDouble(); | ||
897 | } | ||
898 | } | ||
899 | } | ||
900 | } | ||
901 | rev = Convert.ToInt32(row["Revision"]); | 899 | rev = Convert.ToInt32(row["Revision"]); |
900 | byte[] blob = (byte[])row["Heightfield"]; | ||
901 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
902 | } | 902 | } |
903 | else | 903 | else |
904 | { | 904 | { |
@@ -909,8 +909,8 @@ namespace OpenSim.Data.SQLite | |||
909 | m_log.Debug("[SQLITE REGION DB]: Loaded terrain revision r" + rev.ToString()); | 909 | m_log.Debug("[SQLITE REGION DB]: Loaded terrain revision r" + rev.ToString()); |
910 | } | 910 | } |
911 | } | 911 | } |
912 | return terret; | ||
913 | } | 912 | } |
913 | return terrData; | ||
914 | } | 914 | } |
915 | 915 | ||
916 | public void RemoveLandObject(UUID globalID) | 916 | public void RemoveLandObject(UUID globalID) |
@@ -1232,7 +1232,20 @@ namespace OpenSim.Data.SQLite | |||
1232 | createCol(prims, "VolumeDetect", typeof(Int16)); | 1232 | createCol(prims, "VolumeDetect", typeof(Int16)); |
1233 | 1233 | ||
1234 | createCol(prims, "MediaURL", typeof(String)); | 1234 | createCol(prims, "MediaURL", typeof(String)); |
1235 | |||
1236 | createCol(prims, "AttachedPosX", typeof(Double)); | ||
1237 | createCol(prims, "AttachedPosY", typeof(Double)); | ||
1238 | createCol(prims, "AttachedPosZ", typeof(Double)); | ||
1239 | |||
1240 | createCol(prims, "DynAttrs", typeof(String)); | ||
1241 | |||
1242 | createCol(prims, "PhysicsShapeType", typeof(Byte)); | ||
1243 | createCol(prims, "Density", typeof(Double)); | ||
1244 | createCol(prims, "GravityModifier", typeof(Double)); | ||
1245 | createCol(prims, "Friction", typeof(Double)); | ||
1246 | createCol(prims, "Restitution", typeof(Double)); | ||
1235 | 1247 | ||
1248 | createCol(prims, "KeyframeMotion", typeof(Byte[])); | ||
1236 | // Add in contraints | 1249 | // Add in contraints |
1237 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; | 1250 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; |
1238 | 1251 | ||
@@ -1592,7 +1605,7 @@ namespace OpenSim.Data.SQLite | |||
1592 | prim.SitName = (String)row["SitName"]; | 1605 | prim.SitName = (String)row["SitName"]; |
1593 | prim.TouchName = (String)row["TouchName"]; | 1606 | prim.TouchName = (String)row["TouchName"]; |
1594 | // permissions | 1607 | // permissions |
1595 | prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); | 1608 | prim.Flags = (PrimFlags)Convert.ToUInt32(row["ObjectFlags"]); |
1596 | prim.CreatorIdentification = (String)row["CreatorID"]; | 1609 | prim.CreatorIdentification = (String)row["CreatorID"]; |
1597 | prim.OwnerID = new UUID((String)row["OwnerID"]); | 1610 | prim.OwnerID = new UUID((String)row["OwnerID"]); |
1598 | prim.GroupID = new UUID((String)row["GroupID"]); | 1611 | prim.GroupID = new UUID((String)row["GroupID"]); |
@@ -1711,7 +1724,43 @@ namespace OpenSim.Data.SQLite | |||
1711 | // m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType()); | 1724 | // m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType()); |
1712 | prim.MediaUrl = (string)row["MediaURL"]; | 1725 | prim.MediaUrl = (string)row["MediaURL"]; |
1713 | } | 1726 | } |
1727 | |||
1728 | prim.AttachedPos = new Vector3( | ||
1729 | Convert.ToSingle(row["AttachedPosX"]), | ||
1730 | Convert.ToSingle(row["AttachedPosY"]), | ||
1731 | Convert.ToSingle(row["AttachedPosZ"]) | ||
1732 | ); | ||
1733 | |||
1734 | if (!(row["DynAttrs"] is System.DBNull)) | ||
1735 | { | ||
1736 | //m_log.DebugFormat("[SQLITE]: DynAttrs type [{0}]", row["DynAttrs"].GetType()); | ||
1737 | prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); | ||
1738 | } | ||
1739 | else | ||
1740 | { | ||
1741 | prim.DynAttrs = new DAMap(); | ||
1742 | } | ||
1743 | |||
1744 | prim.PhysicsShapeType = Convert.ToByte(row["PhysicsShapeType"]); | ||
1745 | prim.Density = Convert.ToSingle(row["Density"]); | ||
1746 | prim.GravityModifier = Convert.ToSingle(row["GravityModifier"]); | ||
1747 | prim.Friction = Convert.ToSingle(row["Friction"]); | ||
1748 | prim.Restitution = Convert.ToSingle(row["Restitution"]); | ||
1714 | 1749 | ||
1750 | |||
1751 | if (!(row["KeyframeMotion"] is DBNull)) | ||
1752 | { | ||
1753 | Byte[] data = (byte[])row["KeyframeMotion"]; | ||
1754 | if (data.Length > 0) | ||
1755 | prim.KeyframeMotion = KeyframeMotion.FromData(null, data); | ||
1756 | else | ||
1757 | prim.KeyframeMotion = null; | ||
1758 | } | ||
1759 | else | ||
1760 | { | ||
1761 | prim.KeyframeMotion = null; | ||
1762 | } | ||
1763 | |||
1715 | return prim; | 1764 | return prim; |
1716 | } | 1765 | } |
1717 | 1766 | ||
@@ -1967,40 +2016,6 @@ namespace OpenSim.Data.SQLite | |||
1967 | /// <summary> | 2016 | /// <summary> |
1968 | /// | 2017 | /// |
1969 | /// </summary> | 2018 | /// </summary> |
1970 | /// <param name="val"></param> | ||
1971 | /// <returns></returns> | ||
1972 | private static Array serializeTerrain(double[,] val) | ||
1973 | { | ||
1974 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
1975 | BinaryWriter bw = new BinaryWriter(str); | ||
1976 | |||
1977 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1978 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1979 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1980 | bw.Write(val[x, y]); | ||
1981 | |||
1982 | return str.ToArray(); | ||
1983 | } | ||
1984 | |||
1985 | // private void fillTerrainRow(DataRow row, UUID regionUUID, int rev, double[,] val) | ||
1986 | // { | ||
1987 | // row["RegionUUID"] = regionUUID; | ||
1988 | // row["Revision"] = rev; | ||
1989 | |||
1990 | // MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize)*sizeof (double)); | ||
1991 | // BinaryWriter bw = new BinaryWriter(str); | ||
1992 | |||
1993 | // // TODO: COMPATIBILITY - Add byte-order conversions | ||
1994 | // for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1995 | // for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1996 | // bw.Write(val[x, y]); | ||
1997 | |||
1998 | // row["Heightfield"] = str.ToArray(); | ||
1999 | // } | ||
2000 | |||
2001 | /// <summary> | ||
2002 | /// | ||
2003 | /// </summary> | ||
2004 | /// <param name="row"></param> | 2019 | /// <param name="row"></param> |
2005 | /// <param name="prim"></param> | 2020 | /// <param name="prim"></param> |
2006 | /// <param name="sceneGroupID"></param> | 2021 | /// <param name="sceneGroupID"></param> |
@@ -2019,7 +2034,7 @@ namespace OpenSim.Data.SQLite | |||
2019 | row["SitName"] = prim.SitName; | 2034 | row["SitName"] = prim.SitName; |
2020 | row["TouchName"] = prim.TouchName; | 2035 | row["TouchName"] = prim.TouchName; |
2021 | // permissions | 2036 | // permissions |
2022 | row["ObjectFlags"] = prim.ObjectFlags; | 2037 | row["ObjectFlags"] = (uint)prim.Flags; |
2023 | row["CreatorID"] = prim.CreatorIdentification.ToString(); | 2038 | row["CreatorID"] = prim.CreatorIdentification.ToString(); |
2024 | row["OwnerID"] = prim.OwnerID.ToString(); | 2039 | row["OwnerID"] = prim.OwnerID.ToString(); |
2025 | row["GroupID"] = prim.GroupID.ToString(); | 2040 | row["GroupID"] = prim.GroupID.ToString(); |
@@ -2133,6 +2148,28 @@ namespace OpenSim.Data.SQLite | |||
2133 | row["VolumeDetect"] = 0; | 2148 | row["VolumeDetect"] = 0; |
2134 | 2149 | ||
2135 | row["MediaURL"] = prim.MediaUrl; | 2150 | row["MediaURL"] = prim.MediaUrl; |
2151 | |||
2152 | row["AttachedPosX"] = prim.AttachedPos.X; | ||
2153 | row["AttachedPosY"] = prim.AttachedPos.Y; | ||
2154 | row["AttachedPosZ"] = prim.AttachedPos.Z; | ||
2155 | |||
2156 | if (prim.DynAttrs.CountNamespaces > 0) | ||
2157 | row["DynAttrs"] = prim.DynAttrs.ToXml(); | ||
2158 | else | ||
2159 | row["DynAttrs"] = null; | ||
2160 | |||
2161 | row["PhysicsShapeType"] = prim.PhysicsShapeType; | ||
2162 | row["Density"] = (double)prim.Density; | ||
2163 | row["GravityModifier"] = (double)prim.GravityModifier; | ||
2164 | row["Friction"] = (double)prim.Friction; | ||
2165 | row["Restitution"] = (double)prim.Restitution; | ||
2166 | |||
2167 | if (prim.KeyframeMotion != null) | ||
2168 | row["KeyframeMotion"] = prim.KeyframeMotion.Serialize(); | ||
2169 | else | ||
2170 | row["KeyframeMotion"] = new Byte[0]; | ||
2171 | |||
2172 | |||
2136 | } | 2173 | } |
2137 | 2174 | ||
2138 | /// <summary> | 2175 | /// <summary> |
@@ -2384,6 +2421,7 @@ namespace OpenSim.Data.SQLite | |||
2384 | s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); | 2421 | s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); |
2385 | s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); | 2422 | s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); |
2386 | s.State = Convert.ToByte(row["State"]); | 2423 | s.State = Convert.ToByte(row["State"]); |
2424 | s.LastAttachPoint = Convert.ToByte(row["LastAttachPoint"]); | ||
2387 | 2425 | ||
2388 | byte[] textureEntry = (byte[])row["Texture"]; | 2426 | byte[] textureEntry = (byte[])row["Texture"]; |
2389 | s.TextureEntry = textureEntry; | 2427 | s.TextureEntry = textureEntry; |
@@ -2392,7 +2430,7 @@ namespace OpenSim.Data.SQLite | |||
2392 | 2430 | ||
2393 | if (!(row["Media"] is System.DBNull)) | 2431 | if (!(row["Media"] is System.DBNull)) |
2394 | s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); | 2432 | s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); |
2395 | 2433 | ||
2396 | return s; | 2434 | return s; |
2397 | } | 2435 | } |
2398 | 2436 | ||
@@ -2433,6 +2471,7 @@ namespace OpenSim.Data.SQLite | |||
2433 | row["ProfileCurve"] = s.ProfileCurve; | 2471 | row["ProfileCurve"] = s.ProfileCurve; |
2434 | row["ProfileHollow"] = s.ProfileHollow; | 2472 | row["ProfileHollow"] = s.ProfileHollow; |
2435 | row["State"] = s.State; | 2473 | row["State"] = s.State; |
2474 | row["LastAttachPoint"] = s.LastAttachPoint; | ||
2436 | 2475 | ||
2437 | row["Texture"] = s.TextureEntry; | 2476 | row["Texture"] = s.TextureEntry; |
2438 | row["ExtraParams"] = s.ExtraParams; | 2477 | row["ExtraParams"] = s.ExtraParams; |
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs new file mode 100644 index 0000000..cd3e8b6 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | |||
@@ -0,0 +1,981 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | #if CSharpSqlite | ||
34 | using Community.CsharpSqlite.Sqlite; | ||
35 | #else | ||
36 | using Mono.Data.Sqlite; | ||
37 | #endif | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.StructuredData; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | |||
43 | namespace OpenSim.Data.SQLite | ||
44 | { | ||
45 | public class SQLiteUserProfilesData: IProfilesData | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private SqliteConnection m_connection; | ||
51 | private string m_connectionString; | ||
52 | |||
53 | private Dictionary<string, FieldInfo> m_FieldMap = | ||
54 | new Dictionary<string, FieldInfo>(); | ||
55 | |||
56 | protected virtual Assembly Assembly | ||
57 | { | ||
58 | get { return GetType().Assembly; } | ||
59 | } | ||
60 | |||
61 | public SQLiteUserProfilesData() | ||
62 | { | ||
63 | } | ||
64 | |||
65 | public SQLiteUserProfilesData(string connectionString) | ||
66 | { | ||
67 | Initialise(connectionString); | ||
68 | } | ||
69 | |||
70 | public void Initialise(string connectionString) | ||
71 | { | ||
72 | if (Util.IsWindows()) | ||
73 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
74 | |||
75 | m_connectionString = connectionString; | ||
76 | |||
77 | m_log.Info("[PROFILES_DATA]: Sqlite - connecting: "+m_connectionString); | ||
78 | |||
79 | m_connection = new SqliteConnection(m_connectionString); | ||
80 | m_connection.Open(); | ||
81 | |||
82 | Migration m = new Migration(m_connection, Assembly, "UserProfiles"); | ||
83 | m.Update(); | ||
84 | } | ||
85 | |||
86 | private string[] FieldList | ||
87 | { | ||
88 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } | ||
89 | } | ||
90 | |||
91 | #region IProfilesData implementation | ||
92 | public OSDArray GetClassifiedRecords(UUID creatorId) | ||
93 | { | ||
94 | OSDArray data = new OSDArray(); | ||
95 | string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id"; | ||
96 | IDataReader reader = null; | ||
97 | |||
98 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
99 | { | ||
100 | cmd.CommandText = query; | ||
101 | cmd.Parameters.AddWithValue(":Id", creatorId); | ||
102 | reader = cmd.ExecuteReader(); | ||
103 | } | ||
104 | |||
105 | while (reader.Read()) | ||
106 | { | ||
107 | OSDMap n = new OSDMap(); | ||
108 | UUID Id = UUID.Zero; | ||
109 | string Name = null; | ||
110 | try | ||
111 | { | ||
112 | UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id); | ||
113 | Name = Convert.ToString(reader["name"]); | ||
114 | } | ||
115 | catch (Exception e) | ||
116 | { | ||
117 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
118 | ": UserAccount exception {0}", e.Message); | ||
119 | } | ||
120 | n.Add("classifieduuid", OSD.FromUUID(Id)); | ||
121 | n.Add("name", OSD.FromString(Name)); | ||
122 | data.Add(n); | ||
123 | } | ||
124 | |||
125 | reader.Close(); | ||
126 | |||
127 | return data; | ||
128 | } | ||
129 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | ||
130 | { | ||
131 | string query = string.Empty; | ||
132 | |||
133 | query += "INSERT OR REPLACE INTO classifieds ("; | ||
134 | query += "`classifieduuid`,"; | ||
135 | query += "`creatoruuid`,"; | ||
136 | query += "`creationdate`,"; | ||
137 | query += "`expirationdate`,"; | ||
138 | query += "`category`,"; | ||
139 | query += "`name`,"; | ||
140 | query += "`description`,"; | ||
141 | query += "`parceluuid`,"; | ||
142 | query += "`parentestate`,"; | ||
143 | query += "`snapshotuuid`,"; | ||
144 | query += "`simname`,"; | ||
145 | query += "`posglobal`,"; | ||
146 | query += "`parcelname`,"; | ||
147 | query += "`classifiedflags`,"; | ||
148 | query += "`priceforlisting`) "; | ||
149 | query += "VALUES ("; | ||
150 | query += ":ClassifiedId,"; | ||
151 | query += ":CreatorId,"; | ||
152 | query += ":CreatedDate,"; | ||
153 | query += ":ExpirationDate,"; | ||
154 | query += ":Category,"; | ||
155 | query += ":Name,"; | ||
156 | query += ":Description,"; | ||
157 | query += ":ParcelId,"; | ||
158 | query += ":ParentEstate,"; | ||
159 | query += ":SnapshotId,"; | ||
160 | query += ":SimName,"; | ||
161 | query += ":GlobalPos,"; | ||
162 | query += ":ParcelName,"; | ||
163 | query += ":Flags,"; | ||
164 | query += ":ListingPrice ) "; | ||
165 | |||
166 | if(string.IsNullOrEmpty(ad.ParcelName)) | ||
167 | ad.ParcelName = "Unknown"; | ||
168 | if(ad.ParcelId == null) | ||
169 | ad.ParcelId = UUID.Zero; | ||
170 | if(string.IsNullOrEmpty(ad.Description)) | ||
171 | ad.Description = "No Description"; | ||
172 | |||
173 | DateTime epoch = new DateTime(1970, 1, 1); | ||
174 | DateTime now = DateTime.Now; | ||
175 | TimeSpan epochnow = now - epoch; | ||
176 | TimeSpan duration; | ||
177 | DateTime expiration; | ||
178 | TimeSpan epochexp; | ||
179 | |||
180 | if(ad.Flags == 2) | ||
181 | { | ||
182 | duration = new TimeSpan(7,0,0,0); | ||
183 | expiration = now.Add(duration); | ||
184 | epochexp = expiration - epoch; | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | duration = new TimeSpan(365,0,0,0); | ||
189 | expiration = now.Add(duration); | ||
190 | epochexp = expiration - epoch; | ||
191 | } | ||
192 | ad.CreationDate = (int)epochnow.TotalSeconds; | ||
193 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | ||
194 | |||
195 | try { | ||
196 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
197 | { | ||
198 | cmd.CommandText = query; | ||
199 | cmd.Parameters.AddWithValue(":ClassifiedId", ad.ClassifiedId.ToString()); | ||
200 | cmd.Parameters.AddWithValue(":CreatorId", ad.CreatorId.ToString()); | ||
201 | cmd.Parameters.AddWithValue(":CreatedDate", ad.CreationDate.ToString()); | ||
202 | cmd.Parameters.AddWithValue(":ExpirationDate", ad.ExpirationDate.ToString()); | ||
203 | cmd.Parameters.AddWithValue(":Category", ad.Category.ToString()); | ||
204 | cmd.Parameters.AddWithValue(":Name", ad.Name.ToString()); | ||
205 | cmd.Parameters.AddWithValue(":Description", ad.Description.ToString()); | ||
206 | cmd.Parameters.AddWithValue(":ParcelId", ad.ParcelId.ToString()); | ||
207 | cmd.Parameters.AddWithValue(":ParentEstate", ad.ParentEstate.ToString()); | ||
208 | cmd.Parameters.AddWithValue(":SnapshotId", ad.SnapshotId.ToString ()); | ||
209 | cmd.Parameters.AddWithValue(":SimName", ad.SimName.ToString()); | ||
210 | cmd.Parameters.AddWithValue(":GlobalPos", ad.GlobalPos.ToString()); | ||
211 | cmd.Parameters.AddWithValue(":ParcelName", ad.ParcelName.ToString()); | ||
212 | cmd.Parameters.AddWithValue(":Flags", ad.Flags.ToString()); | ||
213 | cmd.Parameters.AddWithValue(":ListingPrice", ad.Price.ToString ()); | ||
214 | |||
215 | cmd.ExecuteNonQuery(); | ||
216 | } | ||
217 | } | ||
218 | catch (Exception e) | ||
219 | { | ||
220 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
221 | ": ClassifiedesUpdate exception {0}", e.Message); | ||
222 | result = e.Message; | ||
223 | return false; | ||
224 | } | ||
225 | return true; | ||
226 | } | ||
227 | public bool DeleteClassifiedRecord(UUID recordId) | ||
228 | { | ||
229 | string query = string.Empty; | ||
230 | |||
231 | query += "DELETE FROM classifieds WHERE "; | ||
232 | query += "classifieduuid = :ClasifiedId"; | ||
233 | |||
234 | try | ||
235 | { | ||
236 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
237 | { | ||
238 | cmd.CommandText = query; | ||
239 | cmd.Parameters.AddWithValue(":ClassifiedId", recordId.ToString()); | ||
240 | |||
241 | cmd.ExecuteNonQuery(); | ||
242 | } | ||
243 | } | ||
244 | catch (Exception e) | ||
245 | { | ||
246 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
247 | ": DeleteClassifiedRecord exception {0}", e.Message); | ||
248 | return false; | ||
249 | } | ||
250 | return true; | ||
251 | } | ||
252 | |||
253 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | ||
254 | { | ||
255 | IDataReader reader = null; | ||
256 | string query = string.Empty; | ||
257 | |||
258 | query += "SELECT * FROM classifieds WHERE "; | ||
259 | query += "classifieduuid = :AdId"; | ||
260 | |||
261 | try | ||
262 | { | ||
263 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
264 | { | ||
265 | cmd.CommandText = query; | ||
266 | cmd.Parameters.AddWithValue(":AdId", ad.ClassifiedId.ToString()); | ||
267 | |||
268 | using (reader = cmd.ExecuteReader()) | ||
269 | { | ||
270 | if(reader.Read ()) | ||
271 | { | ||
272 | ad.CreatorId = new UUID(reader["creatoruuid"].ToString()); | ||
273 | ad.ParcelId = new UUID(reader["parceluuid"].ToString ()); | ||
274 | ad.SnapshotId = new UUID(reader["snapshotuuid"].ToString ()); | ||
275 | ad.CreationDate = Convert.ToInt32(reader["creationdate"]); | ||
276 | ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); | ||
277 | ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); | ||
278 | ad.Flags = (byte) Convert.ToUInt32(reader["classifiedflags"]); | ||
279 | ad.Category = Convert.ToInt32(reader["category"]); | ||
280 | ad.Price = Convert.ToInt16(reader["priceforlisting"]); | ||
281 | ad.Name = reader["name"].ToString(); | ||
282 | ad.Description = reader["description"].ToString(); | ||
283 | ad.SimName = reader["simname"].ToString(); | ||
284 | ad.GlobalPos = reader["posglobal"].ToString(); | ||
285 | ad.ParcelName = reader["parcelname"].ToString(); | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | catch (Exception e) | ||
291 | { | ||
292 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
293 | ": GetPickInfo exception {0}", e.Message); | ||
294 | } | ||
295 | return true; | ||
296 | } | ||
297 | |||
298 | public OSDArray GetAvatarPicks(UUID avatarId) | ||
299 | { | ||
300 | IDataReader reader = null; | ||
301 | string query = string.Empty; | ||
302 | |||
303 | query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; | ||
304 | query += "creatoruuid = :Id"; | ||
305 | OSDArray data = new OSDArray(); | ||
306 | |||
307 | try | ||
308 | { | ||
309 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
310 | { | ||
311 | cmd.CommandText = query; | ||
312 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
313 | |||
314 | using (reader = cmd.ExecuteReader()) | ||
315 | { | ||
316 | while (reader.Read()) | ||
317 | { | ||
318 | OSDMap record = new OSDMap(); | ||
319 | |||
320 | record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); | ||
321 | record.Add("name",OSD.FromString((string)reader["name"])); | ||
322 | data.Add(record); | ||
323 | } | ||
324 | } | ||
325 | } | ||
326 | } | ||
327 | catch (Exception e) | ||
328 | { | ||
329 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
330 | ": GetAvatarPicks exception {0}", e.Message); | ||
331 | } | ||
332 | return data; | ||
333 | } | ||
334 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | ||
335 | { | ||
336 | IDataReader reader = null; | ||
337 | string query = string.Empty; | ||
338 | UserProfilePick pick = new UserProfilePick(); | ||
339 | |||
340 | query += "SELECT * FROM userpicks WHERE "; | ||
341 | query += "creatoruuid = :CreatorId AND "; | ||
342 | query += "pickuuid = :PickId"; | ||
343 | |||
344 | try | ||
345 | { | ||
346 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
347 | { | ||
348 | cmd.CommandText = query; | ||
349 | cmd.Parameters.AddWithValue(":CreatorId", avatarId.ToString()); | ||
350 | cmd.Parameters.AddWithValue(":PickId", pickId.ToString()); | ||
351 | |||
352 | using (reader = cmd.ExecuteReader()) | ||
353 | { | ||
354 | |||
355 | while (reader.Read()) | ||
356 | { | ||
357 | string description = (string)reader["description"]; | ||
358 | |||
359 | if (string.IsNullOrEmpty(description)) | ||
360 | description = "No description given."; | ||
361 | |||
362 | UUID.TryParse((string)reader["pickuuid"], out pick.PickId); | ||
363 | UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); | ||
364 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); | ||
365 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); | ||
366 | pick.GlobalPos = (string)reader["posglobal"]; | ||
367 | bool.TryParse((string)reader["toppick"].ToString(), out pick.TopPick); | ||
368 | bool.TryParse((string)reader["enabled"].ToString(), out pick.Enabled); | ||
369 | pick.Name = (string)reader["name"]; | ||
370 | pick.Desc = description; | ||
371 | pick.ParcelName = (string)reader["user"]; | ||
372 | pick.OriginalName = (string)reader["originalname"]; | ||
373 | pick.SimName = (string)reader["simname"]; | ||
374 | pick.SortOrder = (int)reader["sortorder"]; | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | catch (Exception e) | ||
380 | { | ||
381 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
382 | ": GetPickInfo exception {0}", e.Message); | ||
383 | } | ||
384 | return pick; | ||
385 | } | ||
386 | |||
387 | public bool UpdatePicksRecord(UserProfilePick pick) | ||
388 | { | ||
389 | string query = string.Empty; | ||
390 | |||
391 | query += "INSERT OR REPLACE INTO userpicks ("; | ||
392 | query += "pickuuid, "; | ||
393 | query += "creatoruuid, "; | ||
394 | query += "toppick, "; | ||
395 | query += "parceluuid, "; | ||
396 | query += "name, "; | ||
397 | query += "description, "; | ||
398 | query += "snapshotuuid, "; | ||
399 | query += "user, "; | ||
400 | query += "originalname, "; | ||
401 | query += "simname, "; | ||
402 | query += "posglobal, "; | ||
403 | query += "sortorder, "; | ||
404 | query += "enabled ) "; | ||
405 | query += "VALUES ("; | ||
406 | query += ":PickId,"; | ||
407 | query += ":CreatorId,"; | ||
408 | query += ":TopPick,"; | ||
409 | query += ":ParcelId,"; | ||
410 | query += ":Name,"; | ||
411 | query += ":Desc,"; | ||
412 | query += ":SnapshotId,"; | ||
413 | query += ":User,"; | ||
414 | query += ":Original,"; | ||
415 | query += ":SimName,"; | ||
416 | query += ":GlobalPos,"; | ||
417 | query += ":SortOrder,"; | ||
418 | query += ":Enabled) "; | ||
419 | |||
420 | try | ||
421 | { | ||
422 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
423 | { | ||
424 | int top_pick; | ||
425 | int.TryParse(pick.TopPick.ToString(), out top_pick); | ||
426 | int enabled; | ||
427 | int.TryParse(pick.Enabled.ToString(), out enabled); | ||
428 | |||
429 | cmd.CommandText = query; | ||
430 | cmd.Parameters.AddWithValue(":PickId", pick.PickId.ToString()); | ||
431 | cmd.Parameters.AddWithValue(":CreatorId", pick.CreatorId.ToString()); | ||
432 | cmd.Parameters.AddWithValue(":TopPick", top_pick); | ||
433 | cmd.Parameters.AddWithValue(":ParcelId", pick.ParcelId.ToString()); | ||
434 | cmd.Parameters.AddWithValue(":Name", pick.Name.ToString()); | ||
435 | cmd.Parameters.AddWithValue(":Desc", pick.Desc.ToString()); | ||
436 | cmd.Parameters.AddWithValue(":SnapshotId", pick.SnapshotId.ToString()); | ||
437 | cmd.Parameters.AddWithValue(":User", pick.ParcelName.ToString()); | ||
438 | cmd.Parameters.AddWithValue(":Original", pick.OriginalName.ToString()); | ||
439 | cmd.Parameters.AddWithValue(":SimName",pick.SimName.ToString()); | ||
440 | cmd.Parameters.AddWithValue(":GlobalPos", pick.GlobalPos); | ||
441 | cmd.Parameters.AddWithValue(":SortOrder", pick.SortOrder.ToString ()); | ||
442 | cmd.Parameters.AddWithValue(":Enabled", enabled); | ||
443 | |||
444 | cmd.ExecuteNonQuery(); | ||
445 | } | ||
446 | } | ||
447 | catch (Exception e) | ||
448 | { | ||
449 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
450 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
451 | return false; | ||
452 | } | ||
453 | return true; | ||
454 | } | ||
455 | |||
456 | public bool DeletePicksRecord(UUID pickId) | ||
457 | { | ||
458 | string query = string.Empty; | ||
459 | |||
460 | query += "DELETE FROM userpicks WHERE "; | ||
461 | query += "pickuuid = :PickId"; | ||
462 | |||
463 | try | ||
464 | { | ||
465 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
466 | { | ||
467 | cmd.CommandText = query; | ||
468 | cmd.Parameters.AddWithValue(":PickId", pickId.ToString()); | ||
469 | cmd.ExecuteNonQuery(); | ||
470 | } | ||
471 | } | ||
472 | catch (Exception e) | ||
473 | { | ||
474 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
475 | ": DeleteUserPickRecord exception {0}", e.Message); | ||
476 | return false; | ||
477 | } | ||
478 | return true; | ||
479 | } | ||
480 | |||
481 | public bool GetAvatarNotes(ref UserProfileNotes notes) | ||
482 | { | ||
483 | IDataReader reader = null; | ||
484 | string query = string.Empty; | ||
485 | |||
486 | query += "SELECT `notes` FROM usernotes WHERE "; | ||
487 | query += "useruuid = :Id AND "; | ||
488 | query += "targetuuid = :TargetId"; | ||
489 | OSDArray data = new OSDArray(); | ||
490 | |||
491 | try | ||
492 | { | ||
493 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
494 | { | ||
495 | cmd.CommandText = query; | ||
496 | cmd.Parameters.AddWithValue(":Id", notes.UserId.ToString()); | ||
497 | cmd.Parameters.AddWithValue(":TargetId", notes.TargetId.ToString()); | ||
498 | |||
499 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
500 | { | ||
501 | while (reader.Read()) | ||
502 | { | ||
503 | notes.Notes = OSD.FromString((string)reader["notes"]); | ||
504 | } | ||
505 | } | ||
506 | } | ||
507 | } | ||
508 | catch (Exception e) | ||
509 | { | ||
510 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
511 | ": GetAvatarNotes exception {0}", e.Message); | ||
512 | } | ||
513 | return true; | ||
514 | } | ||
515 | |||
516 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | ||
517 | { | ||
518 | string query = string.Empty; | ||
519 | bool remove; | ||
520 | |||
521 | if(string.IsNullOrEmpty(note.Notes)) | ||
522 | { | ||
523 | remove = true; | ||
524 | query += "DELETE FROM usernotes WHERE "; | ||
525 | query += "useruuid=:UserId AND "; | ||
526 | query += "targetuuid=:TargetId"; | ||
527 | } | ||
528 | else | ||
529 | { | ||
530 | remove = false; | ||
531 | query += "INSERT OR REPLACE INTO usernotes VALUES ( "; | ||
532 | query += ":UserId,"; | ||
533 | query += ":TargetId,"; | ||
534 | query += ":Notes )"; | ||
535 | } | ||
536 | |||
537 | try | ||
538 | { | ||
539 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
540 | { | ||
541 | cmd.CommandText = query; | ||
542 | |||
543 | if(!remove) | ||
544 | cmd.Parameters.AddWithValue(":Notes", note.Notes); | ||
545 | cmd.Parameters.AddWithValue(":TargetId", note.TargetId.ToString ()); | ||
546 | cmd.Parameters.AddWithValue(":UserId", note.UserId.ToString()); | ||
547 | |||
548 | cmd.ExecuteNonQuery(); | ||
549 | } | ||
550 | } | ||
551 | catch (Exception e) | ||
552 | { | ||
553 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
554 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
555 | return false; | ||
556 | } | ||
557 | return true; | ||
558 | } | ||
559 | |||
560 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | ||
561 | { | ||
562 | IDataReader reader = null; | ||
563 | string query = string.Empty; | ||
564 | |||
565 | query += "SELECT * FROM userprofile WHERE "; | ||
566 | query += "useruuid = :Id"; | ||
567 | |||
568 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
569 | { | ||
570 | cmd.CommandText = query; | ||
571 | cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); | ||
572 | |||
573 | |||
574 | try | ||
575 | { | ||
576 | reader = cmd.ExecuteReader(); | ||
577 | } | ||
578 | catch(Exception e) | ||
579 | { | ||
580 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
581 | ": GetAvatarProperties exception {0}", e.Message); | ||
582 | result = e.Message; | ||
583 | return false; | ||
584 | } | ||
585 | if(reader != null && reader.Read()) | ||
586 | { | ||
587 | props.WebUrl = (string)reader["profileURL"]; | ||
588 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | ||
589 | props.AboutText = (string)reader["profileAboutText"]; | ||
590 | UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); | ||
591 | props.FirstLifeText = (string)reader["profileFirstText"]; | ||
592 | UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); | ||
593 | props.WantToMask = (int)reader["profileWantToMask"]; | ||
594 | props.WantToText = (string)reader["profileWantToText"]; | ||
595 | props.SkillsMask = (int)reader["profileSkillsMask"]; | ||
596 | props.SkillsText = (string)reader["profileSkillsText"]; | ||
597 | props.Language = (string)reader["profileLanguages"]; | ||
598 | } | ||
599 | else | ||
600 | { | ||
601 | props.WebUrl = string.Empty; | ||
602 | props.ImageId = UUID.Zero; | ||
603 | props.AboutText = string.Empty; | ||
604 | props.FirstLifeImageId = UUID.Zero; | ||
605 | props.FirstLifeText = string.Empty; | ||
606 | props.PartnerId = UUID.Zero; | ||
607 | props.WantToMask = 0; | ||
608 | props.WantToText = string.Empty; | ||
609 | props.SkillsMask = 0; | ||
610 | props.SkillsText = string.Empty; | ||
611 | props.Language = string.Empty; | ||
612 | props.PublishProfile = false; | ||
613 | props.PublishMature = false; | ||
614 | |||
615 | query = "INSERT INTO userprofile ("; | ||
616 | query += "useruuid, "; | ||
617 | query += "profilePartner, "; | ||
618 | query += "profileAllowPublish, "; | ||
619 | query += "profileMaturePublish, "; | ||
620 | query += "profileURL, "; | ||
621 | query += "profileWantToMask, "; | ||
622 | query += "profileWantToText, "; | ||
623 | query += "profileSkillsMask, "; | ||
624 | query += "profileSkillsText, "; | ||
625 | query += "profileLanguages, "; | ||
626 | query += "profileImage, "; | ||
627 | query += "profileAboutText, "; | ||
628 | query += "profileFirstImage, "; | ||
629 | query += "profileFirstText) VALUES ("; | ||
630 | query += ":userId, "; | ||
631 | query += ":profilePartner, "; | ||
632 | query += ":profileAllowPublish, "; | ||
633 | query += ":profileMaturePublish, "; | ||
634 | query += ":profileURL, "; | ||
635 | query += ":profileWantToMask, "; | ||
636 | query += ":profileWantToText, "; | ||
637 | query += ":profileSkillsMask, "; | ||
638 | query += ":profileSkillsText, "; | ||
639 | query += ":profileLanguages, "; | ||
640 | query += ":profileImage, "; | ||
641 | query += ":profileAboutText, "; | ||
642 | query += ":profileFirstImage, "; | ||
643 | query += ":profileFirstText)"; | ||
644 | |||
645 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
646 | { | ||
647 | put.CommandText = query; | ||
648 | put.Parameters.AddWithValue(":userId", props.UserId.ToString()); | ||
649 | put.Parameters.AddWithValue(":profilePartner", props.PartnerId.ToString()); | ||
650 | put.Parameters.AddWithValue(":profileAllowPublish", props.PublishProfile); | ||
651 | put.Parameters.AddWithValue(":profileMaturePublish", props.PublishMature); | ||
652 | put.Parameters.AddWithValue(":profileURL", props.WebUrl); | ||
653 | put.Parameters.AddWithValue(":profileWantToMask", props.WantToMask); | ||
654 | put.Parameters.AddWithValue(":profileWantToText", props.WantToText); | ||
655 | put.Parameters.AddWithValue(":profileSkillsMask", props.SkillsMask); | ||
656 | put.Parameters.AddWithValue(":profileSkillsText", props.SkillsText); | ||
657 | put.Parameters.AddWithValue(":profileLanguages", props.Language); | ||
658 | put.Parameters.AddWithValue(":profileImage", props.ImageId.ToString()); | ||
659 | put.Parameters.AddWithValue(":profileAboutText", props.AboutText); | ||
660 | put.Parameters.AddWithValue(":profileFirstImage", props.FirstLifeImageId.ToString()); | ||
661 | put.Parameters.AddWithValue(":profileFirstText", props.FirstLifeText); | ||
662 | |||
663 | put.ExecuteNonQuery(); | ||
664 | } | ||
665 | } | ||
666 | } | ||
667 | return true; | ||
668 | } | ||
669 | |||
670 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | ||
671 | { | ||
672 | string query = string.Empty; | ||
673 | |||
674 | query += "UPDATE userprofile SET "; | ||
675 | query += "profileURL=:profileURL, "; | ||
676 | query += "profileImage=:image, "; | ||
677 | query += "profileAboutText=:abouttext,"; | ||
678 | query += "profileFirstImage=:firstlifeimage,"; | ||
679 | query += "profileFirstText=:firstlifetext "; | ||
680 | query += "WHERE useruuid=:uuid"; | ||
681 | |||
682 | try | ||
683 | { | ||
684 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
685 | { | ||
686 | cmd.CommandText = query; | ||
687 | cmd.Parameters.AddWithValue(":profileURL", props.WebUrl); | ||
688 | cmd.Parameters.AddWithValue(":image", props.ImageId.ToString()); | ||
689 | cmd.Parameters.AddWithValue(":abouttext", props.AboutText); | ||
690 | cmd.Parameters.AddWithValue(":firstlifeimage", props.FirstLifeImageId.ToString()); | ||
691 | cmd.Parameters.AddWithValue(":firstlifetext", props.FirstLifeText); | ||
692 | cmd.Parameters.AddWithValue(":uuid", props.UserId.ToString()); | ||
693 | |||
694 | cmd.ExecuteNonQuery(); | ||
695 | } | ||
696 | } | ||
697 | catch (Exception e) | ||
698 | { | ||
699 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
700 | ": AgentPropertiesUpdate exception {0}", e.Message); | ||
701 | |||
702 | return false; | ||
703 | } | ||
704 | return true; | ||
705 | } | ||
706 | |||
707 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | ||
708 | { | ||
709 | string query = string.Empty; | ||
710 | |||
711 | query += "UPDATE userprofile SET "; | ||
712 | query += "profileWantToMask=:WantMask, "; | ||
713 | query += "profileWantToText=:WantText,"; | ||
714 | query += "profileSkillsMask=:SkillsMask,"; | ||
715 | query += "profileSkillsText=:SkillsText, "; | ||
716 | query += "profileLanguages=:Languages "; | ||
717 | query += "WHERE useruuid=:uuid"; | ||
718 | |||
719 | try | ||
720 | { | ||
721 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
722 | { | ||
723 | cmd.CommandText = query; | ||
724 | cmd.Parameters.AddWithValue(":WantMask", up.WantToMask); | ||
725 | cmd.Parameters.AddWithValue(":WantText", up.WantToText); | ||
726 | cmd.Parameters.AddWithValue(":SkillsMask", up.SkillsMask); | ||
727 | cmd.Parameters.AddWithValue(":SkillsText", up.SkillsText); | ||
728 | cmd.Parameters.AddWithValue(":Languages", up.Language); | ||
729 | cmd.Parameters.AddWithValue(":uuid", up.UserId.ToString()); | ||
730 | |||
731 | cmd.ExecuteNonQuery(); | ||
732 | } | ||
733 | } | ||
734 | catch (Exception e) | ||
735 | { | ||
736 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
737 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
738 | result = e.Message; | ||
739 | return false; | ||
740 | } | ||
741 | return true; | ||
742 | } | ||
743 | |||
744 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | ||
745 | { | ||
746 | string query = string.Empty; | ||
747 | |||
748 | query += "UPDATE usersettings SET "; | ||
749 | query += "imviaemail=:ImViaEmail, "; | ||
750 | query += "visible=:Visible, "; | ||
751 | query += "email=:EMail "; | ||
752 | query += "WHERE useruuid=:uuid"; | ||
753 | |||
754 | try | ||
755 | { | ||
756 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
757 | { | ||
758 | cmd.CommandText = query; | ||
759 | cmd.Parameters.AddWithValue(":ImViaEmail", pref.IMViaEmail); | ||
760 | cmd.Parameters.AddWithValue(":Visible", pref.Visible); | ||
761 | cmd.Parameters.AddWithValue(":EMail", pref.EMail); | ||
762 | cmd.Parameters.AddWithValue(":uuid", pref.UserId.ToString()); | ||
763 | |||
764 | cmd.ExecuteNonQuery(); | ||
765 | } | ||
766 | } | ||
767 | catch (Exception e) | ||
768 | { | ||
769 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
770 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
771 | result = e.Message; | ||
772 | return false; | ||
773 | } | ||
774 | return true; | ||
775 | } | ||
776 | |||
777 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | ||
778 | { | ||
779 | IDataReader reader = null; | ||
780 | string query = string.Empty; | ||
781 | |||
782 | query += "SELECT imviaemail,visible,email FROM "; | ||
783 | query += "usersettings WHERE "; | ||
784 | query += "useruuid = :Id"; | ||
785 | |||
786 | OSDArray data = new OSDArray(); | ||
787 | |||
788 | try | ||
789 | { | ||
790 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
791 | { | ||
792 | cmd.CommandText = query; | ||
793 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); | ||
794 | |||
795 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
796 | { | ||
797 | if(reader.Read()) | ||
798 | { | ||
799 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | ||
800 | bool.TryParse((string)reader["visible"], out pref.Visible); | ||
801 | pref.EMail = (string)reader["email"]; | ||
802 | } | ||
803 | else | ||
804 | { | ||
805 | query = "INSERT INTO usersettings VALUES "; | ||
806 | query += "(:Id,'false','false', :Email)"; | ||
807 | |||
808 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
809 | { | ||
810 | put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); | ||
811 | put.Parameters.AddWithValue(":Email", pref.EMail); | ||
812 | put.ExecuteNonQuery(); | ||
813 | |||
814 | } | ||
815 | } | ||
816 | } | ||
817 | } | ||
818 | } | ||
819 | catch (Exception e) | ||
820 | { | ||
821 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
822 | ": Get preferences exception {0}", e.Message); | ||
823 | result = e.Message; | ||
824 | return false; | ||
825 | } | ||
826 | return true; | ||
827 | } | ||
828 | |||
829 | public bool GetUserAppData(ref UserAppData props, ref string result) | ||
830 | { | ||
831 | IDataReader reader = null; | ||
832 | string query = string.Empty; | ||
833 | |||
834 | query += "SELECT * FROM `userdata` WHERE "; | ||
835 | query += "UserId = :Id AND "; | ||
836 | query += "TagId = :TagId"; | ||
837 | |||
838 | try | ||
839 | { | ||
840 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
841 | { | ||
842 | cmd.CommandText = query; | ||
843 | cmd.Parameters.AddWithValue(":Id", props.UserId.ToString()); | ||
844 | cmd.Parameters.AddWithValue (":TagId", props.TagId.ToString()); | ||
845 | |||
846 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
847 | { | ||
848 | if(reader.Read()) | ||
849 | { | ||
850 | props.DataKey = (string)reader["DataKey"]; | ||
851 | props.DataVal = (string)reader["DataVal"]; | ||
852 | } | ||
853 | else | ||
854 | { | ||
855 | query += "INSERT INTO userdata VALUES ( "; | ||
856 | query += ":UserId,"; | ||
857 | query += ":TagId,"; | ||
858 | query += ":DataKey,"; | ||
859 | query += ":DataVal) "; | ||
860 | |||
861 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
862 | { | ||
863 | put.Parameters.AddWithValue(":Id", props.UserId.ToString()); | ||
864 | put.Parameters.AddWithValue(":TagId", props.TagId.ToString()); | ||
865 | put.Parameters.AddWithValue(":DataKey", props.DataKey.ToString()); | ||
866 | put.Parameters.AddWithValue(":DataVal", props.DataVal.ToString()); | ||
867 | |||
868 | put.ExecuteNonQuery(); | ||
869 | } | ||
870 | } | ||
871 | } | ||
872 | } | ||
873 | } | ||
874 | catch (Exception e) | ||
875 | { | ||
876 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
877 | ": Requst application data exception {0}", e.Message); | ||
878 | result = e.Message; | ||
879 | return false; | ||
880 | } | ||
881 | return true; | ||
882 | } | ||
883 | public bool SetUserAppData(UserAppData props, ref string result) | ||
884 | { | ||
885 | string query = string.Empty; | ||
886 | |||
887 | query += "UPDATE userdata SET "; | ||
888 | query += "TagId = :TagId, "; | ||
889 | query += "DataKey = :DataKey, "; | ||
890 | query += "DataVal = :DataVal WHERE "; | ||
891 | query += "UserId = :UserId AND "; | ||
892 | query += "TagId = :TagId"; | ||
893 | |||
894 | try | ||
895 | { | ||
896 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
897 | { | ||
898 | cmd.CommandText = query; | ||
899 | cmd.Parameters.AddWithValue(":UserId", props.UserId.ToString()); | ||
900 | cmd.Parameters.AddWithValue(":TagId", props.TagId.ToString ()); | ||
901 | cmd.Parameters.AddWithValue(":DataKey", props.DataKey.ToString ()); | ||
902 | cmd.Parameters.AddWithValue(":DataVal", props.DataKey.ToString ()); | ||
903 | |||
904 | cmd.ExecuteNonQuery(); | ||
905 | } | ||
906 | } | ||
907 | catch (Exception e) | ||
908 | { | ||
909 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
910 | ": SetUserData exception {0}", e.Message); | ||
911 | return false; | ||
912 | } | ||
913 | return true; | ||
914 | } | ||
915 | public OSDArray GetUserImageAssets(UUID avatarId) | ||
916 | { | ||
917 | IDataReader reader = null; | ||
918 | OSDArray data = new OSDArray(); | ||
919 | string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = :Id"; | ||
920 | |||
921 | // Get classified image assets | ||
922 | |||
923 | |||
924 | try | ||
925 | { | ||
926 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
927 | { | ||
928 | cmd.CommandText = query; | ||
929 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
930 | |||
931 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
932 | { | ||
933 | while(reader.Read()) | ||
934 | { | ||
935 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString())); | ||
936 | } | ||
937 | } | ||
938 | } | ||
939 | |||
940 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
941 | { | ||
942 | cmd.CommandText = query; | ||
943 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
944 | |||
945 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
946 | { | ||
947 | if(reader.Read()) | ||
948 | { | ||
949 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
950 | } | ||
951 | } | ||
952 | } | ||
953 | |||
954 | query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = :Id"; | ||
955 | |||
956 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
957 | { | ||
958 | cmd.CommandText = query; | ||
959 | cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); | ||
960 | |||
961 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
962 | { | ||
963 | if(reader.Read()) | ||
964 | { | ||
965 | data.Add(new OSDString((string)reader["profileImage"].ToString ())); | ||
966 | data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); | ||
967 | } | ||
968 | } | ||
969 | } | ||
970 | } | ||
971 | catch (Exception e) | ||
972 | { | ||
973 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
974 | ": GetAvatarNotes exception {0}", e.Message); | ||
975 | } | ||
976 | return data; | ||
977 | } | ||
978 | #endregion | ||
979 | } | ||
980 | } | ||
981 | |||
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs index 8cb2ee0..5d7b169 100644 --- a/OpenSim/Data/Tests/AssetTests.cs +++ b/OpenSim/Data/Tests/AssetTests.cs | |||
@@ -40,9 +40,6 @@ using log4net; | |||
40 | using MySql.Data.MySqlClient; | 40 | using MySql.Data.MySqlClient; |
41 | using OpenSim.Data.MySQL; | 41 | using OpenSim.Data.MySQL; |
42 | 42 | ||
43 | using System.Data.SqlClient; | ||
44 | using OpenSim.Data.MSSQL; | ||
45 | |||
46 | using Mono.Data.Sqlite; | 43 | using Mono.Data.Sqlite; |
47 | using OpenSim.Data.SQLite; | 44 | using OpenSim.Data.SQLite; |
48 | 45 | ||
@@ -58,11 +55,6 @@ namespace OpenSim.Data.Tests | |||
58 | { | 55 | { |
59 | } | 56 | } |
60 | 57 | ||
61 | [TestFixture(Description = "Asset store tests (MS SQL Server)")] | ||
62 | public class MSSQLAssetTests : AssetTests<SqlConnection, MSSQLAssetData> | ||
63 | { | ||
64 | } | ||
65 | |||
66 | public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> | 58 | public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> |
67 | where TConn : DbConnection, new() | 59 | where TConn : DbConnection, new() |
68 | where TAssetData : AssetDataBase, new() | 60 | where TAssetData : AssetDataBase, new() |
@@ -107,10 +99,11 @@ namespace OpenSim.Data.Tests | |||
107 | public void T001_LoadEmpty() | 99 | public void T001_LoadEmpty() |
108 | { | 100 | { |
109 | TestHelpers.InMethod(); | 101 | TestHelpers.InMethod(); |
110 | 102 | ||
111 | Assert.That(m_db.ExistsAsset(uuid1), Is.False); | 103 | bool[] exist = m_db.AssetsExist(new[] { uuid1, uuid2, uuid3 }); |
112 | Assert.That(m_db.ExistsAsset(uuid2), Is.False); | 104 | Assert.IsFalse(exist[0]); |
113 | Assert.That(m_db.ExistsAsset(uuid3), Is.False); | 105 | Assert.IsFalse(exist[1]); |
106 | Assert.IsFalse(exist[2]); | ||
114 | } | 107 | } |
115 | 108 | ||
116 | [Test] | 109 | [Test] |
@@ -159,9 +152,10 @@ namespace OpenSim.Data.Tests | |||
159 | AssetBase a3b = m_db.GetAsset(uuid3); | 152 | AssetBase a3b = m_db.GetAsset(uuid3); |
160 | Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); | 153 | Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); |
161 | 154 | ||
162 | Assert.That(m_db.ExistsAsset(uuid1), Is.True); | 155 | bool[] exist = m_db.AssetsExist(new[] { uuid1, uuid2, uuid3 }); |
163 | Assert.That(m_db.ExistsAsset(uuid2), Is.True); | 156 | Assert.IsTrue(exist[0]); |
164 | Assert.That(m_db.ExistsAsset(uuid3), Is.True); | 157 | Assert.IsTrue(exist[1]); |
158 | Assert.IsTrue(exist[2]); | ||
165 | 159 | ||
166 | List<AssetMetadata> metadatas = m_db.FetchAssetMetadataSet(0, 1000); | 160 | List<AssetMetadata> metadatas = m_db.FetchAssetMetadataSet(0, 1000); |
167 | 161 | ||
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs index 69b79bf..acfebd0 100644 --- a/OpenSim/Data/Tests/BasicDataServiceTest.cs +++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs | |||
@@ -99,6 +99,9 @@ namespace OpenSim.Data.Tests | |||
99 | if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd")) | 99 | if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd")) |
100 | Assert.Ignore(); | 100 | Assert.Ignore(); |
101 | 101 | ||
102 | if (Util.IsWindows()) | ||
103 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
104 | |||
102 | // for SQLite, if no explicit conn string is specified, use a temp file | 105 | // for SQLite, if no explicit conn string is specified, use a temp file |
103 | if (String.IsNullOrEmpty(m_connStr)) | 106 | if (String.IsNullOrEmpty(m_connStr)) |
104 | { | 107 | { |
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs index 3e47bcf..e2b2d12 100644 --- a/OpenSim/Data/Tests/EstateTests.cs +++ b/OpenSim/Data/Tests/EstateTests.cs | |||
@@ -41,9 +41,6 @@ using System.Data.Common; | |||
41 | using MySql.Data.MySqlClient; | 41 | using MySql.Data.MySqlClient; |
42 | using OpenSim.Data.MySQL; | 42 | using OpenSim.Data.MySQL; |
43 | 43 | ||
44 | using System.Data.SqlClient; | ||
45 | using OpenSim.Data.MSSQL; | ||
46 | |||
47 | using Mono.Data.Sqlite; | 44 | using Mono.Data.Sqlite; |
48 | using OpenSim.Data.SQLite; | 45 | using OpenSim.Data.SQLite; |
49 | 46 | ||
@@ -59,11 +56,6 @@ namespace OpenSim.Data.Tests | |||
59 | { | 56 | { |
60 | } | 57 | } |
61 | 58 | ||
62 | [TestFixture(Description = "Estate store tests (MS SQL Server)")] | ||
63 | public class MSSQLEstateTests : EstateTests<SqlConnection, MSSQLEstateStore> | ||
64 | { | ||
65 | } | ||
66 | |||
67 | public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore> | 59 | public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore> |
68 | where TConn : DbConnection, new() | 60 | where TConn : DbConnection, new() |
69 | where TEstateStore : class, IEstateDataStore, new() | 61 | where TEstateStore : class, IEstateDataStore, new() |
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs index 5b6b61b..3edf89d 100644 --- a/OpenSim/Data/Tests/InventoryTests.cs +++ b/OpenSim/Data/Tests/InventoryTests.cs | |||
@@ -39,9 +39,6 @@ using System.Data.Common; | |||
39 | using MySql.Data.MySqlClient; | 39 | using MySql.Data.MySqlClient; |
40 | using OpenSim.Data.MySQL; | 40 | using OpenSim.Data.MySQL; |
41 | 41 | ||
42 | using System.Data.SqlClient; | ||
43 | using OpenSim.Data.MSSQL; | ||
44 | |||
45 | using Mono.Data.Sqlite; | 42 | using Mono.Data.Sqlite; |
46 | using OpenSim.Data.SQLite; | 43 | using OpenSim.Data.SQLite; |
47 | 44 | ||
@@ -57,11 +54,6 @@ namespace OpenSim.Data.Tests | |||
57 | { | 54 | { |
58 | } | 55 | } |
59 | 56 | ||
60 | [TestFixture(Description = "Inventory store tests (MS SQL Server)")] | ||
61 | public class MSSQLInventoryTests : InventoryTests<SqlConnection, MSSQLInventoryData> | ||
62 | { | ||
63 | } | ||
64 | |||
65 | public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore> | 57 | public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore> |
66 | where TConn : DbConnection, new() | 58 | where TConn : DbConnection, new() |
67 | where TInvStore : class, IInventoryDataPlugin, new() | 59 | where TInvStore : class, IInventoryDataPlugin, new() |
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs index dbed8f6..8d4249a 100644 --- a/OpenSim/Data/Tests/RegionTests.cs +++ b/OpenSim/Data/Tests/RegionTests.cs | |||
@@ -44,9 +44,6 @@ using System.Data.Common; | |||
44 | using MySql.Data.MySqlClient; | 44 | using MySql.Data.MySqlClient; |
45 | using OpenSim.Data.MySQL; | 45 | using OpenSim.Data.MySQL; |
46 | 46 | ||
47 | using System.Data.SqlClient; | ||
48 | using OpenSim.Data.MSSQL; | ||
49 | |||
50 | using Mono.Data.Sqlite; | 47 | using Mono.Data.Sqlite; |
51 | using OpenSim.Data.SQLite; | 48 | using OpenSim.Data.SQLite; |
52 | 49 | ||
@@ -62,11 +59,6 @@ namespace OpenSim.Data.Tests | |||
62 | { | 59 | { |
63 | } | 60 | } |
64 | 61 | ||
65 | [TestFixture(Description = "Region store tests (MS SQL Server)")] | ||
66 | public class MSSQLRegionTests : RegionTests<SqlConnection, MSSQLSimulationData> | ||
67 | { | ||
68 | } | ||
69 | |||
70 | public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> | 62 | public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> |
71 | where TConn : DbConnection, new() | 63 | where TConn : DbConnection, new() |
72 | where TRegStore : class, ISimulationDataStore, new() | 64 | where TRegStore : class, ISimulationDataStore, new() |