Merge commit 'd4043c084a86da5f462356ec5c65eab2b861564d' into bigmerge

avinationmerge
Melanie 2011-10-11 21:31:48 +01:00
commit 0fa21b7b5e
3 changed files with 71 additions and 7 deletions

View File

@ -218,23 +218,27 @@ namespace OpenSim.Data.MSSQL
if (words.Length > 2) if (words.Length > 2)
return new UserAccountData[0]; return new UserAccountData[0];
string sql = "";
using (SqlConnection conn = new SqlConnection(m_ConnectionString)) using (SqlConnection conn = new SqlConnection(m_ConnectionString))
using (SqlCommand cmd = new SqlCommand()) using (SqlCommand cmd = new SqlCommand())
{ {
if (words.Length == 1) if (words.Length == 1)
{ {
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); 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);
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%")); cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%"));
} }
else else
{ {
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); 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);
cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%")); cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%"));
cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%")); cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%"));
cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString())); cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString()));
} }
cmd.Connection = conn;
cmd.CommandText = sql;
conn.Open();
return DoQuery(cmd); return DoQuery(cmd);
} }
} }

View File

@ -20,3 +20,31 @@ INSERT INTO Friends (PrincipalID, Friend, Flags, Offered)
SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends; SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends;
COMMIT COMMIT
:VERSION 3
BEGIN TRANSACTION
CREATE TABLE [Tmp_Friends]
([PrincipalID] varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
[Friend] varchar(255) NOT NULL,
[Flags] char(16) NOT NULL DEFAULT '0',
[Offered] varchar(32) NOT NULL DEFAULT 0)
ON [PRIMARY]
IF EXISTS(SELECT * FROM dbo.Friends)
EXEC('INSERT INTO dbo.Tmp_Friends (PrincipalID, Friend, Flags, Offered)
SELECT CONVERT(varchar(255),PrincipalID), Friend, Flags, Offered FROM dbo.Friends WITH (HOLDLOCK TABLOCKX)')
DROP TABLE dbo.Friends
EXECUTE sp_rename N'dbo.Tmp_Friends', N'Friends', 'OBJECT'
ALTER TABLE dbo.Friends ADD
PRIMARY KEY CLUSTERED
(
[PrincipalID] ASC, [Friend] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
COMMIT

View File

@ -245,3 +245,35 @@ ADD CONSTRAINT DF_inventoryitems_creatorID
DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID
:GO :GO
:VERSION 9
BEGIN TRANSACTION
# CreatorID goes up to VARCHAR(255)
exec sp_rename 'inventoryitems.CreatorID', 'cr_old', 'COLUMN'
:GO
alter table inventoryitems
add creatorID varchar(255) NULL
:GO
update inventoryitems set creatorID = cr_old
alter table inventoryitems
drop CONSTRAINT DF_inventoryitems_creatorID
:GO
alter table inventoryitems
drop column cr_old
:GO
COMMIT
ALTER TABLE inventoryitems
ADD CONSTRAINT DF_inventoryitems_creatorID
DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID
:GO