* Some small syntax and refactoring tweaks for asset and inventory MSSQL
* This means the MSSQL db plugin now requires SQL Server 2005
0.6.5-rc1
Justin Clarke Casey 2009-03-09 18:04:23 +00:00
parent 5a6bc26600
commit ee73d72f1d
3 changed files with 45 additions and 43 deletions

View File

@ -79,6 +79,7 @@ Patches
* SachaMagne * SachaMagne
* Salahzar Stenvaag * Salahzar Stenvaag
* sempuki * sempuki
* Strawberry Fride
* tglion * tglion
* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud) * tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud)
* tyre * tyre

View File

@ -258,7 +258,7 @@ namespace OpenSim.Data.MSSQL
{ {
List<AssetMetadata> retList = new List<AssetMetadata>(count); List<AssetMetadata> retList = new List<AssetMetadata>(count);
using (AutoClosingSqlCommand command = database.Query("SELECT name,description,assetType,temporary,id FROM assets LIMIT @start, @count")) using (AutoClosingSqlCommand command = database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count"))
{ {
command.Parameters.Add(database.CreateParameter("start", start)); command.Parameters.Add(database.CreateParameter("start", start));
command.Parameters.Add(database.CreateParameter("count", count)); command.Parameters.Add(database.CreateParameter("count", count));

View File

@ -224,9 +224,8 @@ namespace OpenSim.Data.MSSQL
/// <param name="folder">Folder to create</param> /// <param name="folder">Folder to create</param>
public void addInventoryFolder(InventoryFolderBase folder) public void addInventoryFolder(InventoryFolderBase folder)
{ {
string sql = string sql = @"INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version])
"INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version]) VALUES "; VALUES (@folderID, @agentID, @parentFolderID, @folderName, @type, @version);";
sql += "(@folderID, @agentID, @parentFolderID, @folderName, @type, @version);";
using (AutoClosingSqlCommand command = database.Query(sql)) using (AutoClosingSqlCommand command = database.Query(sql))
@ -256,13 +255,14 @@ namespace OpenSim.Data.MSSQL
/// <param name="folder">Folder to update</param> /// <param name="folder">Folder to update</param>
public void updateInventoryFolder(InventoryFolderBase folder) public void updateInventoryFolder(InventoryFolderBase folder)
{ {
using (AutoClosingSqlCommand command = database.Query("UPDATE inventoryfolders set folderID = @folderID, " + string sql = @"UPDATE inventoryfolders SET folderID = @folderID,
"agentID = @agentID, " + agentID = @agentID,
"parentFolderID = @parentFolderID," + parentFolderID = @parentFolderID,
"folderName = @folderName," + folderName = @folderName,
"type = @type," + type = @type,
"version = @version where " + version = @version
"folderID = @keyFolderID;")) WHERE folderID = @keyFolderID";
using (AutoClosingSqlCommand command = database.Query(sql))
{ {
command.Parameters.Add(database.CreateParameter("folderID", folder.ID)); command.Parameters.Add(database.CreateParameter("folderID", folder.ID));
command.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); command.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
@ -288,9 +288,8 @@ namespace OpenSim.Data.MSSQL
/// <param name="folder">Folder to update</param> /// <param name="folder">Folder to update</param>
public void moveInventoryFolder(InventoryFolderBase folder) public void moveInventoryFolder(InventoryFolderBase folder)
{ {
using (IDbCommand command = database.Query("UPDATE inventoryfolders set " + string sql = @"UPDATE inventoryfolders SET parentFolderID = @parentFolderID WHERE folderID = @folderID";
"parentFolderID = @parentFolderID where " + using (IDbCommand command = database.Query(sql))
"folderID = @folderID;"))
{ {
command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
command.Parameters.Add(database.CreateParameter("@folderID", folder.ID)); command.Parameters.Add(database.CreateParameter("@folderID", folder.ID));
@ -402,15 +401,16 @@ namespace OpenSim.Data.MSSQL
return; return;
} }
string sql = "INSERT INTO inventoryitems"; string sql = @"INSERT INTO inventoryitems
sql += "([inventoryID], [assetID], [assetType], [parentFolderID], [avatarID], [inventoryName]" ([inventoryID], [assetID], [assetType], [parentFolderID], [avatarID], [inventoryName],
+ ", [inventoryDescription], [inventoryNextPermissions], [inventoryCurrentPermissions]" [inventoryDescription], [inventoryNextPermissions], [inventoryCurrentPermissions],
+ ", [invType], [creatorID], [inventoryBasePermissions], [inventoryEveryOnePermissions], [inventoryGroupPermissions]" [invType], [creatorID], [inventoryBasePermissions], [inventoryEveryOnePermissions], [inventoryGroupPermissions],
+ ", [salePrice], [saleType], [creationDate], [groupID], [groupOwned], [flags]) VALUES "; [salePrice], [saleType], [creationDate], [groupID], [groupOwned], [flags])
sql += "(@inventoryID, @assetID, @assetType, @parentFolderID, @avatarID, @inventoryName, @inventoryDescription" VALUES
+ ", @inventoryNextPermissions, @inventoryCurrentPermissions, @invType, @creatorID" (@inventoryID, @assetID, @assetType, @parentFolderID, @avatarID, @inventoryName, @inventoryDescription,
+ ", @inventoryBasePermissions, @inventoryEveryOnePermissions, @inventoryGroupPermissions, @salePrice, @saleType" @inventoryNextPermissions, @inventoryCurrentPermissions, @invType, @creatorID,
+ ", @creationDate, @groupID, @groupOwned, @flags);"; @inventoryBasePermissions, @inventoryEveryOnePermissions, @inventoryGroupPermissions, @salePrice, @saleType,
@creationDate, @groupID, @groupOwned, @flags)";
using (AutoClosingSqlCommand command = database.Query(sql)) using (AutoClosingSqlCommand command = database.Query(sql))
{ {
@ -453,26 +453,27 @@ namespace OpenSim.Data.MSSQL
/// <param name="item">Inventory item to update</param> /// <param name="item">Inventory item to update</param>
public void updateInventoryItem(InventoryItemBase item) public void updateInventoryItem(InventoryItemBase item)
{ {
using (AutoClosingSqlCommand command = database.Query("UPDATE inventoryitems set inventoryID = @inventoryID, " + string sql = @"UPDATE inventoryitems SET inventoryID = @inventoryID,
"assetID = @assetID, " + assetID = @assetID,
"assetType = @assetType," + assetType = @assetType,
"parentFolderID = @parentFolderID," + parentFolderID = @parentFolderID,
"avatarID = @avatarID," + avatarID = @avatarID,
"inventoryName = @inventoryName," + inventoryName = @inventoryName,
"inventoryDescription = @inventoryDescription," + inventoryDescription = @inventoryDescription,
"inventoryNextPermissions = @inventoryNextPermissions," + inventoryNextPermissions = @inventoryNextPermissions,
"inventoryCurrentPermissions = @inventoryCurrentPermissions," + inventoryCurrentPermissions = @inventoryCurrentPermissions,
"invType = @invType," + invType = @invType,
"creatorID = @creatorID," + creatorID = @creatorID,
"inventoryBasePermissions = @inventoryBasePermissions," + inventoryBasePermissions = @inventoryBasePermissions,
"inventoryEveryOnePermissions = @inventoryEveryOnePermissions," + inventoryEveryOnePermissions = @inventoryEveryOnePermissions,
"salePrice = @salePrice," + salePrice = @salePrice,
"saleType = @saleType," + saleType = @saleType,
"creationDate = @creationDate," + creationDate = @creationDate,
"groupID = @groupID," + groupID = @groupID,
"groupOwned = @groupOwned," + groupOwned = @groupOwned,
"flags = @flags where " + flags = @flags
"inventoryID = @keyInventoryID;")) WHERE inventoryID = @keyInventoryID";
using (AutoClosingSqlCommand command = database.Query(sql))
{ {
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID)); command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));