From c1352350004064a1722c2aeaaff313c4cc51181a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 7 Mar 2010 23:20:23 +0000 Subject: MSSQL tweaks for latest ROBUST - friends handling fixed, GridUserData placeholder added. Signed-off-by: Melanie --- OpenSim/Data/MSSQL/MSSQLFriendsData.cs | 2 +- OpenSim/Data/MSSQL/MSSQLGridUserData.cs | 68 +++++++++++++++++++++++ OpenSim/Data/MSSQL/Resources/001_FriendsStore.sql | 2 +- OpenSim/Data/MSSQL/Resources/001_UserAccount.sql | 14 +++++ OpenSim/Data/MSSQL/Resources/002_FriendsStore.sql | 2 +- OpenSim/Data/MSSQL/Resources/003_UserAccount.sql | 9 +++ OpenSim/Data/MSSQL/Resources/004_UserAccount.sql | 7 +++ 7 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Data/MSSQL/MSSQLGridUserData.cs create mode 100644 OpenSim/Data/MSSQL/Resources/001_UserAccount.sql create mode 100644 OpenSim/Data/MSSQL/Resources/003_UserAccount.sql create mode 100644 OpenSim/Data/MSSQL/Resources/004_UserAccount.sql (limited to 'OpenSim/Data/MSSQL') diff --git a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs b/OpenSim/Data/MSSQL/MSSQLFriendsData.cs index 34da943..af4fd9b 100644 --- a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs +++ b/OpenSim/Data/MSSQL/MSSQLFriendsData.cs @@ -72,7 +72,7 @@ namespace OpenSim.Data.MSSQL using (SqlCommand cmd = new SqlCommand()) { - cmd.CommandText = String.Format("select a.*,b.Flags 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 and b.Flags is not null", m_Realm); + 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); cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); cmd.Connection = conn; conn.Open(); diff --git a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs new file mode 100644 index 0000000..b4a945c --- /dev/null +++ b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs @@ -0,0 +1,68 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using System.Data.SqlClient; + +namespace OpenSim.Data.MSSQL +{ + /// + /// A MSSQL Interface for Avatar Storage + /// + public class MSSQLGridUserData : MSSQLGenericTableHandler, + IGridUserData + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MSSQLGridUserData(string connectionString, string realm) : + base(connectionString, realm, "UserGrid") + { + } + + public GridUserData GetGridUserData(string userID) + { + GridUserData[] ret = Get("UserID", userID); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public bool StoreGridUserData(GridUserData data) + { + return Store(data); + } + } +} diff --git a/OpenSim/Data/MSSQL/Resources/001_FriendsStore.sql b/OpenSim/Data/MSSQL/Resources/001_FriendsStore.sql index f6480f7..94d240b 100644 --- a/OpenSim/Data/MSSQL/Resources/001_FriendsStore.sql +++ b/OpenSim/Data/MSSQL/Resources/001_FriendsStore.sql @@ -2,7 +2,7 @@ BEGIN TRANSACTION CREATE TABLE [Friends] ( [PrincipalID] uniqueidentifier NOT NULL, -[FriendID] varchar(255) NOT NULL, +[Friend] varchar(255) NOT NULL, [Flags] char(16) NOT NULL DEFAULT '0', [Offered] varchar(32) NOT NULL DEFAULT 0) ON [PRIMARY] diff --git a/OpenSim/Data/MSSQL/Resources/001_UserAccount.sql b/OpenSim/Data/MSSQL/Resources/001_UserAccount.sql new file mode 100644 index 0000000..3dbf8a4 --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/001_UserAccount.sql @@ -0,0 +1,14 @@ +CREATE TABLE [UserAccounts] ( + [PrincipalID] uniqueidentifier NOT NULL, + [ScopeID] uniqueidentifier NOT NULL, + [FirstName] [varchar](64) NOT NULL, + [LastName] [varchar](64) NOT NULL, + [Email] [varchar](64) NULL, + [ServiceURLs] [text] NULL, + [Created] [int] default NULL, + + PRIMARY KEY CLUSTERED +( + [PrincipalID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] diff --git a/OpenSim/Data/MSSQL/Resources/002_FriendsStore.sql b/OpenSim/Data/MSSQL/Resources/002_FriendsStore.sql index 7762a26..e67d20e 100644 --- a/OpenSim/Data/MSSQL/Resources/002_FriendsStore.sql +++ b/OpenSim/Data/MSSQL/Resources/002_FriendsStore.sql @@ -1,6 +1,6 @@ BEGIN TRANSACTION -INSERT INTO Friends (PrincipalID, FriendID, Flags, Offered) SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends; +INSERT INTO Friends (PrincipalID, Friend, Flags, Offered) SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends; COMMIT \ No newline at end of file diff --git a/OpenSim/Data/MSSQL/Resources/003_UserAccount.sql b/OpenSim/Data/MSSQL/Resources/003_UserAccount.sql new file mode 100644 index 0000000..da0395b --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/003_UserAccount.sql @@ -0,0 +1,9 @@ +BEGIN TRANSACTION + +CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); +CREATE INDEX Email ON UserAccounts(Email); +CREATE INDEX FirstName ON UserAccounts(FirstName); +CREATE INDEX LastName ON UserAccounts(LastName); +CREATE INDEX Name ON UserAccounts(FirstName,LastName); + +COMMIT \ No newline at end of file diff --git a/OpenSim/Data/MSSQL/Resources/004_UserAccount.sql b/OpenSim/Data/MSSQL/Resources/004_UserAccount.sql new file mode 100644 index 0000000..a9a9021 --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/004_UserAccount.sql @@ -0,0 +1,7 @@ +BEGIN TRANSACTION + +ALTER TABLE UserAccounts ADD UserLevel integer NOT NULL DEFAULT 0; +ALTER TABLE UserAccounts ADD UserFlags integer NOT NULL DEFAULT 0; +ALTER TABLE UserAccounts ADD UserTitle varchar(64) NOT NULL DEFAULT ''; + +COMMIT \ No newline at end of file -- cgit v1.1