diff options
author | Chris Hart | 2011-09-13 16:55:30 -0400 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-09-16 19:09:46 +0100 |
commit | d4043c084a86da5f462356ec5c65eab2b861564d (patch) | |
tree | 115685d90fd7c12ce5d7191f0106008bd2f9a1c3 | |
parent | Reattaching a region was failing if the estate name had not changed (issue 50... (diff) | |
download | opensim-SC-d4043c084a86da5f462356ec5c65eab2b861564d.zip opensim-SC-d4043c084a86da5f462356ec5c65eab2b861564d.tar.gz opensim-SC-d4043c084a86da5f462356ec5c65eab2b861564d.tar.bz2 opensim-SC-d4043c084a86da5f462356ec5c65eab2b861564d.tar.xz |
MSSQL Bug fix in user account retrieval, plus migrations for FriendsStore and InventoryStore
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | 18 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/FriendsStore.migrations | 28 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/InventoryStore.migrations | 32 |
3 files changed, 71 insertions, 7 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs index e7c8dc5..7feec91 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | |||
@@ -218,23 +218,27 @@ namespace OpenSim.Data.MSSQL | |||
218 | if (words.Length > 2) | 218 | if (words.Length > 2) |
219 | return new UserAccountData[0]; | 219 | return new UserAccountData[0]; |
220 | 220 | ||
221 | string sql = ""; | ||
222 | |||
221 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 223 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
222 | using (SqlCommand cmd = new SqlCommand()) | 224 | using (SqlCommand cmd = new SqlCommand()) |
223 | { | 225 | { |
224 | if (words.Length == 1) | 226 | if (words.Length == 1) |
225 | { | 227 | { |
226 | cmd.CommandText = String.Format("select * from {0} where ([ScopeID]=@ScopeID or [ScopeID]='00000000-0000-0000-0000-000000000000') and ([FirstName] like @search or [LastName] like @search)", m_Realm); | 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); |
227 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); | 229 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); |
228 | cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%")); | 230 | cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%")); |
229 | } | 231 | } |
230 | else | 232 | else |
231 | { | 233 | { |
232 | cmd.CommandText = String.Format("select * from {0} where ([ScopeID]=@ScopeID or [ScopeID]='00000000-0000-0000-0000-000000000000') and ([FirstName] like @searchFirst or [LastName] like @searchLast)", m_Realm); | 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); |
233 | cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%")); | 235 | cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%")); |
234 | cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%")); | 236 | cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%")); |
235 | cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString())); | 237 | cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString())); |
236 | } | 238 | } |
237 | 239 | cmd.Connection = conn; | |
240 | cmd.CommandText = sql; | ||
241 | conn.Open(); | ||
238 | return DoQuery(cmd); | 242 | return DoQuery(cmd); |
239 | } | 243 | } |
240 | } | 244 | } |
diff --git a/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations b/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations index 4d8ab0f..cc94c4e 100644 --- a/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/FriendsStore.migrations | |||
@@ -19,4 +19,32 @@ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[userf | |||
19 | INSERT INTO Friends (PrincipalID, Friend, Flags, Offered) | 19 | INSERT INTO Friends (PrincipalID, Friend, Flags, Offered) |
20 | SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends; | 20 | SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends; |
21 | 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 | |||
22 | COMMIT \ No newline at end of file | 50 | COMMIT \ No newline at end of file |
diff --git a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations index 4a3cb27..4e43653 100644 --- a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations | |||
@@ -244,4 +244,36 @@ ALTER TABLE inventoryitems | |||
244 | ADD CONSTRAINT DF_inventoryitems_creatorID | 244 | ADD CONSTRAINT DF_inventoryitems_creatorID |
245 | DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID | 245 | DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID |
246 | 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 | |||
247 | :GO \ No newline at end of file | 279 | :GO \ No newline at end of file |