diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 106 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLEstateData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 51 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/AssetStore.migrations | 6 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/InventoryStore.migrations | 70 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/Mssql-agents.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/Mssql-logs.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/Mssql-regions.sql | 0 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/Mssql-users.sql | 0 |
14 files changed, 141 insertions, 94 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 8475b22..c7488d8 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -121,15 +121,16 @@ namespace OpenSim.Data.MSSQL | |||
121 | if (reader.Read()) | 121 | if (reader.Read()) |
122 | { | 122 | { |
123 | AssetBase asset = new AssetBase( | 123 | AssetBase asset = new AssetBase( |
124 | new UUID((Guid)reader["id"]), | 124 | DBGuid.FromDB(reader["id"]), |
125 | (string)reader["name"], | 125 | (string)reader["name"], |
126 | Convert.ToSByte(reader["assetType"]), | 126 | Convert.ToSByte(reader["assetType"]), |
127 | String.Empty | 127 | reader["creatorid"].ToString() |
128 | ); | 128 | ); |
129 | // Region Main | 129 | // Region Main |
130 | asset.Description = (string)reader["description"]; | 130 | asset.Description = (string)reader["description"]; |
131 | asset.Local = Convert.ToBoolean(reader["local"]); | 131 | asset.Local = Convert.ToBoolean(reader["local"]); |
132 | asset.Temporary = Convert.ToBoolean(reader["temporary"]); | 132 | asset.Temporary = Convert.ToBoolean(reader["temporary"]); |
133 | asset.Flags = (AssetFlags)(Convert.ToInt32(reader["asset_flags"])); | ||
133 | asset.Data = (byte[])reader["data"]; | 134 | asset.Data = (byte[])reader["data"]; |
134 | return asset; | 135 | return asset; |
135 | } | 136 | } |
@@ -144,26 +145,19 @@ namespace OpenSim.Data.MSSQL | |||
144 | /// <param name="asset">the asset</param> | 145 | /// <param name="asset">the asset</param> |
145 | override public void StoreAsset(AssetBase asset) | 146 | override public void StoreAsset(AssetBase asset) |
146 | { | 147 | { |
147 | if (ExistsAsset(asset.FullID)) | 148 | |
148 | UpdateAsset(asset); | 149 | string sql = |
149 | else | 150 | @"IF EXISTS(SELECT * FROM assets WHERE id=@id) |
150 | InsertAsset(asset); | 151 | UPDATE assets set name = @name, description = @description, assetType = @assetType, |
151 | } | 152 | local = @local, temporary = @temporary, creatorid = @creatorid, data = @data |
152 | 153 | WHERE id=@id | |
153 | 154 | ELSE | |
154 | private void InsertAsset(AssetBase asset) | 155 | INSERT INTO assets |
155 | { | 156 | ([id], [name], [description], [assetType], [local], |
156 | if (ExistsAsset(asset.FullID)) | 157 | [temporary], [create_time], [access_time], [creatorid], [asset_flags], [data]) |
157 | { | 158 | VALUES |
158 | return; | 159 | (@id, @name, @description, @assetType, @local, |
159 | } | 160 | @temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)"; |
160 | |||
161 | string sql = @"INSERT INTO assets | ||
162 | ([id], [name], [description], [assetType], [local], | ||
163 | [temporary], [create_time], [access_time], [data]) | ||
164 | VALUES | ||
165 | (@id, @name, @description, @assetType, @local, | ||
166 | @temporary, @create_time, @access_time, @data)"; | ||
167 | 161 | ||
168 | string assetName = asset.Name; | 162 | string assetName = asset.Name; |
169 | if (asset.Name.Length > 64) | 163 | if (asset.Name.Length > 64) |
@@ -191,6 +185,8 @@ namespace OpenSim.Data.MSSQL | |||
191 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); | 185 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); |
192 | command.Parameters.Add(m_database.CreateParameter("access_time", now)); | 186 | command.Parameters.Add(m_database.CreateParameter("access_time", now)); |
193 | command.Parameters.Add(m_database.CreateParameter("create_time", now)); | 187 | command.Parameters.Add(m_database.CreateParameter("create_time", now)); |
188 | command.Parameters.Add(m_database.CreateParameter("asset_flags", (int)asset.Flags)); | ||
189 | command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID)); | ||
194 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | 190 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); |
195 | conn.Open(); | 191 | conn.Open(); |
196 | try | 192 | try |
@@ -199,57 +195,11 @@ namespace OpenSim.Data.MSSQL | |||
199 | } | 195 | } |
200 | catch(Exception e) | 196 | catch(Exception e) |
201 | { | 197 | { |
202 | m_log.Error("[ASSET DB]: Error inserting item :" + e.Message); | 198 | m_log.Error("[ASSET DB]: Error storing item :" + e.Message); |
203 | } | 199 | } |
204 | } | 200 | } |
205 | } | 201 | } |
206 | 202 | ||
207 | /// <summary> | ||
208 | /// Update asset in m_database | ||
209 | /// </summary> | ||
210 | /// <param name="asset">the asset</param> | ||
211 | private void UpdateAsset(AssetBase asset) | ||
212 | { | ||
213 | string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType, | ||
214 | local = @local, temporary = @temporary, data = @data | ||
215 | WHERE id = @keyId;"; | ||
216 | |||
217 | string assetName = asset.Name; | ||
218 | if (asset.Name.Length > 64) | ||
219 | { | ||
220 | assetName = asset.Name.Substring(0, 64); | ||
221 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on update"); | ||
222 | } | ||
223 | |||
224 | string assetDescription = asset.Description; | ||
225 | if (asset.Description.Length > 64) | ||
226 | { | ||
227 | assetDescription = asset.Description.Substring(0, 64); | ||
228 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update"); | ||
229 | } | ||
230 | |||
231 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
232 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
233 | { | ||
234 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | ||
235 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); | ||
236 | command.Parameters.Add(m_database.CreateParameter("description", assetDescription)); | ||
237 | command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type)); | ||
238 | command.Parameters.Add(m_database.CreateParameter("local", asset.Local)); | ||
239 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); | ||
240 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | ||
241 | command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID)); | ||
242 | conn.Open(); | ||
243 | try | ||
244 | { | ||
245 | command.ExecuteNonQuery(); | ||
246 | } | ||
247 | catch (Exception e) | ||
248 | { | ||
249 | m_log.Error(e.ToString()); | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | 203 | ||
254 | // Commented out since currently unused - this probably should be called in GetAsset() | 204 | // Commented out since currently unused - this probably should be called in GetAsset() |
255 | // private void UpdateAccessTime(AssetBase asset) | 205 | // private void UpdateAccessTime(AssetBase asset) |
@@ -295,26 +245,34 @@ namespace OpenSim.Data.MSSQL | |||
295 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | 245 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) |
296 | { | 246 | { |
297 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 247 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
298 | string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() | 248 | string sql = @"WITH OrderedAssets AS |
299 | OVER (ORDER BY (some column to order by)) | 249 | ( |
300 | WHERE Row >= @Start AND Row < @Start + @Count"; | 250 | SELECT id, name, description, assetType, temporary, creatorid, |
251 | RowNumber = ROW_NUMBER() OVER (ORDER BY id) | ||
252 | FROM assets | ||
253 | ) | ||
254 | SELECT * | ||
255 | FROM OrderedAssets | ||
256 | WHERE RowNumber BETWEEN @start AND @stop;"; | ||
301 | 257 | ||
302 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 258 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
303 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 259 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
304 | { | 260 | { |
305 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | 261 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); |
306 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | 262 | cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1)); |
307 | conn.Open(); | 263 | conn.Open(); |
308 | using (SqlDataReader reader = cmd.ExecuteReader()) | 264 | using (SqlDataReader reader = cmd.ExecuteReader()) |
309 | { | 265 | { |
310 | while (reader.Read()) | 266 | while (reader.Read()) |
311 | { | 267 | { |
312 | AssetMetadata metadata = new AssetMetadata(); | 268 | AssetMetadata metadata = new AssetMetadata(); |
313 | metadata.FullID = new UUID((Guid)reader["id"]); | 269 | metadata.FullID = DBGuid.FromDB(reader["id"]); |
314 | metadata.Name = (string)reader["name"]; | 270 | metadata.Name = (string)reader["name"]; |
315 | metadata.Description = (string)reader["description"]; | 271 | metadata.Description = (string)reader["description"]; |
316 | metadata.Type = Convert.ToSByte(reader["assetType"]); | 272 | metadata.Type = Convert.ToSByte(reader["assetType"]); |
317 | metadata.Temporary = Convert.ToBoolean(reader["temporary"]); | 273 | metadata.Temporary = Convert.ToBoolean(reader["temporary"]); |
274 | metadata.CreatorID = (string)reader["creatorid"]; | ||
275 | retList.Add(metadata); | ||
318 | } | 276 | } |
319 | } | 277 | } |
320 | } | 278 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index 66931e2..80bf106 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs | |||
@@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
37 | 37 | ||
38 | namespace OpenSim.Data.MSSQL | 38 | namespace OpenSim.Data.MSSQL |
39 | { | 39 | { |
40 | public class MSSQLEstateData : IEstateDataStore | 40 | public class MSSQLEstateStore : IEstateDataStore |
41 | { | 41 | { |
42 | private const string _migrationStore = "EstateStore"; | 42 | private const string _migrationStore = "EstateStore"; |
43 | 43 | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index 4815700..4d06377 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs | |||
@@ -111,6 +111,9 @@ namespace OpenSim.Data.MSSQL | |||
111 | /// <returns>A list of folder objects</returns> | 111 | /// <returns>A list of folder objects</returns> |
112 | public List<InventoryFolderBase> getUserRootFolders(UUID user) | 112 | public List<InventoryFolderBase> getUserRootFolders(UUID user) |
113 | { | 113 | { |
114 | if (user == UUID.Zero) | ||
115 | return new List<InventoryFolderBase>(); | ||
116 | |||
114 | return getInventoryFolders(UUID.Zero, user); | 117 | return getInventoryFolders(UUID.Zero, user); |
115 | } | 118 | } |
116 | 119 | ||
@@ -184,7 +187,19 @@ namespace OpenSim.Data.MSSQL | |||
184 | //Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way. | 187 | //Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way. |
185 | //Note this is changed so it opens only one connection to the database and not everytime it wants to get data. | 188 | //Note this is changed so it opens only one connection to the database and not everytime it wants to get data. |
186 | 189 | ||
190 | /* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for | ||
191 | * every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL | ||
192 | * inventory for a specific user at once. | ||
193 | * | ||
194 | * Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never | ||
195 | * be used, so check for that and return an empty list. | ||
196 | */ | ||
197 | |||
187 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 198 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
199 | |||
200 | if (parentID == UUID.Zero) | ||
201 | return folders; | ||
202 | |||
188 | string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID"; | 203 | string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID"; |
189 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 204 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
190 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 205 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
@@ -249,13 +264,12 @@ namespace OpenSim.Data.MSSQL | |||
249 | /// <param name="folder">Folder to update</param> | 264 | /// <param name="folder">Folder to update</param> |
250 | public void updateInventoryFolder(InventoryFolderBase folder) | 265 | public void updateInventoryFolder(InventoryFolderBase folder) |
251 | { | 266 | { |
252 | string sql = @"UPDATE inventoryfolders SET folderID = @folderID, | 267 | string sql = @"UPDATE inventoryfolders SET agentID = @agentID, |
253 | agentID = @agentID, | ||
254 | parentFolderID = @parentFolderID, | 268 | parentFolderID = @parentFolderID, |
255 | folderName = @folderName, | 269 | folderName = @folderName, |
256 | type = @type, | 270 | type = @type, |
257 | version = @version | 271 | version = @version |
258 | WHERE folderID = @keyFolderID"; | 272 | WHERE folderID = @folderID"; |
259 | 273 | ||
260 | string folderName = folder.Name; | 274 | string folderName = folder.Name; |
261 | if (folderName.Length > 64) | 275 | if (folderName.Length > 64) |
@@ -272,7 +286,6 @@ namespace OpenSim.Data.MSSQL | |||
272 | cmd.Parameters.Add(database.CreateParameter("folderName", folderName)); | 286 | cmd.Parameters.Add(database.CreateParameter("folderName", folderName)); |
273 | cmd.Parameters.Add(database.CreateParameter("type", folder.Type)); | 287 | cmd.Parameters.Add(database.CreateParameter("type", folder.Type)); |
274 | cmd.Parameters.Add(database.CreateParameter("version", folder.Version)); | 288 | cmd.Parameters.Add(database.CreateParameter("version", folder.Version)); |
275 | cmd.Parameters.Add(database.CreateParameter("@keyFolderID", folder.ID)); | ||
276 | conn.Open(); | 289 | conn.Open(); |
277 | try | 290 | try |
278 | { | 291 | { |
@@ -296,7 +309,7 @@ namespace OpenSim.Data.MSSQL | |||
296 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 309 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
297 | { | 310 | { |
298 | cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); | 311 | cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); |
299 | cmd.Parameters.Add(database.CreateParameter("@folderID", folder.ID)); | 312 | cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID)); |
300 | conn.Open(); | 313 | conn.Open(); |
301 | try | 314 | try |
302 | { | 315 | { |
@@ -489,8 +502,7 @@ namespace OpenSim.Data.MSSQL | |||
489 | /// <param name="item">Inventory item to update</param> | 502 | /// <param name="item">Inventory item to update</param> |
490 | public void updateInventoryItem(InventoryItemBase item) | 503 | public void updateInventoryItem(InventoryItemBase item) |
491 | { | 504 | { |
492 | string sql = @"UPDATE inventoryitems SET inventoryID = @inventoryID, | 505 | string sql = @"UPDATE inventoryitems SET assetID = @assetID, |
493 | assetID = @assetID, | ||
494 | assetType = @assetType, | 506 | assetType = @assetType, |
495 | parentFolderID = @parentFolderID, | 507 | parentFolderID = @parentFolderID, |
496 | avatarID = @avatarID, | 508 | avatarID = @avatarID, |
@@ -502,13 +514,14 @@ namespace OpenSim.Data.MSSQL | |||
502 | creatorID = @creatorID, | 514 | creatorID = @creatorID, |
503 | inventoryBasePermissions = @inventoryBasePermissions, | 515 | inventoryBasePermissions = @inventoryBasePermissions, |
504 | inventoryEveryOnePermissions = @inventoryEveryOnePermissions, | 516 | inventoryEveryOnePermissions = @inventoryEveryOnePermissions, |
517 | inventoryGroupPermissions = @inventoryGroupPermissions, | ||
505 | salePrice = @salePrice, | 518 | salePrice = @salePrice, |
506 | saleType = @saleType, | 519 | saleType = @saleType, |
507 | creationDate = @creationDate, | 520 | creationDate = @creationDate, |
508 | groupID = @groupID, | 521 | groupID = @groupID, |
509 | groupOwned = @groupOwned, | 522 | groupOwned = @groupOwned, |
510 | flags = @flags | 523 | flags = @flags |
511 | WHERE inventoryID = @keyInventoryID"; | 524 | WHERE inventoryID = @inventoryID"; |
512 | 525 | ||
513 | string itemName = item.Name; | 526 | string itemName = item.Name; |
514 | if (item.Name.Length > 64) | 527 | if (item.Name.Length > 64) |
@@ -537,16 +550,16 @@ namespace OpenSim.Data.MSSQL | |||
537 | command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions)); | 550 | command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions)); |
538 | command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions)); | 551 | command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions)); |
539 | command.Parameters.Add(database.CreateParameter("invType", item.InvType)); | 552 | command.Parameters.Add(database.CreateParameter("invType", item.InvType)); |
540 | command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorIdAsUuid)); | 553 | command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId)); |
541 | command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions)); | 554 | command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions)); |
542 | 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)); | ||
543 | command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice)); | 557 | command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice)); |
544 | command.Parameters.Add(database.CreateParameter("saleType", item.SaleType)); | 558 | command.Parameters.Add(database.CreateParameter("saleType", item.SaleType)); |
545 | command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate)); | 559 | command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate)); |
546 | command.Parameters.Add(database.CreateParameter("groupID", item.GroupID)); | 560 | command.Parameters.Add(database.CreateParameter("groupID", item.GroupID)); |
547 | command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned)); | 561 | command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned)); |
548 | command.Parameters.Add(database.CreateParameter("flags", item.Flags)); | 562 | command.Parameters.Add(database.CreateParameter("flags", item.Flags)); |
549 | command.Parameters.Add(database.CreateParameter("keyInventoryID", item.ID)); | ||
550 | conn.Open(); | 563 | conn.Open(); |
551 | try | 564 | try |
552 | { | 565 | { |
@@ -732,9 +745,9 @@ namespace OpenSim.Data.MSSQL | |||
732 | try | 745 | try |
733 | { | 746 | { |
734 | InventoryFolderBase folder = new InventoryFolderBase(); | 747 | InventoryFolderBase folder = new InventoryFolderBase(); |
735 | folder.Owner = new UUID((Guid)reader["agentID"]); | 748 | folder.Owner = DBGuid.FromDB(reader["agentID"]); |
736 | folder.ParentID = new UUID((Guid)reader["parentFolderID"]); | 749 | folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]); |
737 | folder.ID = new UUID((Guid)reader["folderID"]); | 750 | folder.ID = DBGuid.FromDB(reader["folderID"]); |
738 | folder.Name = (string)reader["folderName"]; | 751 | folder.Name = (string)reader["folderName"]; |
739 | folder.Type = (short)reader["type"]; | 752 | folder.Type = (short)reader["type"]; |
740 | folder.Version = Convert.ToUInt16(reader["version"]); | 753 | folder.Version = Convert.ToUInt16(reader["version"]); |
@@ -760,24 +773,24 @@ namespace OpenSim.Data.MSSQL | |||
760 | { | 773 | { |
761 | InventoryItemBase item = new InventoryItemBase(); | 774 | InventoryItemBase item = new InventoryItemBase(); |
762 | 775 | ||
763 | item.ID = new UUID((Guid)reader["inventoryID"]); | 776 | item.ID = DBGuid.FromDB(reader["inventoryID"]); |
764 | item.AssetID = new UUID((Guid)reader["assetID"]); | 777 | item.AssetID = DBGuid.FromDB(reader["assetID"]); |
765 | item.AssetType = Convert.ToInt32(reader["assetType"].ToString()); | 778 | item.AssetType = Convert.ToInt32(reader["assetType"].ToString()); |
766 | item.Folder = new UUID((Guid)reader["parentFolderID"]); | 779 | item.Folder = DBGuid.FromDB(reader["parentFolderID"]); |
767 | item.Owner = new UUID((Guid)reader["avatarID"]); | 780 | item.Owner = DBGuid.FromDB(reader["avatarID"]); |
768 | item.Name = reader["inventoryName"].ToString(); | 781 | item.Name = reader["inventoryName"].ToString(); |
769 | item.Description = reader["inventoryDescription"].ToString(); | 782 | item.Description = reader["inventoryDescription"].ToString(); |
770 | item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]); | 783 | item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]); |
771 | item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]); | 784 | item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]); |
772 | item.InvType = Convert.ToInt32(reader["invType"].ToString()); | 785 | item.InvType = Convert.ToInt32(reader["invType"].ToString()); |
773 | item.CreatorId = ((Guid)reader["creatorID"]).ToString(); | 786 | item.CreatorId = reader["creatorID"].ToString(); |
774 | item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]); | 787 | item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]); |
775 | item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]); | 788 | item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]); |
776 | item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]); | 789 | item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]); |
777 | item.SalePrice = Convert.ToInt32(reader["salePrice"]); | 790 | item.SalePrice = Convert.ToInt32(reader["salePrice"]); |
778 | item.SaleType = Convert.ToByte(reader["saleType"]); | 791 | item.SaleType = Convert.ToByte(reader["saleType"]); |
779 | item.CreationDate = Convert.ToInt32(reader["creationDate"]); | 792 | item.CreationDate = Convert.ToInt32(reader["creationDate"]); |
780 | item.GroupID = new UUID((Guid)reader["groupID"]); | 793 | item.GroupID = DBGuid.FromDB(reader["groupID"]); |
781 | item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); | 794 | item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); |
782 | item.Flags = Convert.ToUInt32(reader["flags"]); | 795 | item.Flags = Convert.ToUInt32(reader["flags"]); |
783 | 796 | ||
diff --git a/OpenSim/Data/MSSQL/Resources/AssetStore.migrations b/OpenSim/Data/MSSQL/Resources/AssetStore.migrations index beb82b9..8664ce9 100644 --- a/OpenSim/Data/MSSQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/AssetStore.migrations | |||
@@ -97,4 +97,10 @@ COMMIT | |||
97 | 97 | ||
98 | DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621'; | 98 | DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621'; |
99 | 99 | ||
100 | :VERSION 6 | ||
100 | 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/AvatarAppearance.sql b/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql b/OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/CreateFoldersTable.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/CreateItemsTable.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/CreateUserFriendsTable.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations index cd5dfdc..e2a8d57 100644 --- a/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/InventoryStore.migrations | |||
@@ -171,4 +171,74 @@ CREATE NONCLUSTERED INDEX folder ON dbo.inventoryitems | |||
171 | 171 | ||
172 | COMMIT | 172 | COMMIT |
173 | 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 | |||
242 | |||
243 | |||
174 | 244 | ||
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-agents.sql b/OpenSim/Data/MSSQL/Resources/Mssql-agents.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/Mssql-agents.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-logs.sql b/OpenSim/Data/MSSQL/Resources/Mssql-logs.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/Mssql-logs.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-regions.sql b/OpenSim/Data/MSSQL/Resources/Mssql-regions.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/Mssql-regions.sql +++ /dev/null | |||
diff --git a/OpenSim/Data/MSSQL/Resources/Mssql-users.sql b/OpenSim/Data/MSSQL/Resources/Mssql-users.sql deleted file mode 100644 index e69de29..0000000 --- a/OpenSim/Data/MSSQL/Resources/Mssql-users.sql +++ /dev/null | |||