diff options
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 8475b22..5d1e170 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -210,7 +210,7 @@ namespace OpenSim.Data.MSSQL | |||
210 | /// <param name="asset">the asset</param> | 210 | /// <param name="asset">the asset</param> |
211 | private void UpdateAsset(AssetBase asset) | 211 | private void UpdateAsset(AssetBase asset) |
212 | { | 212 | { |
213 | string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType, | 213 | string sql = @"UPDATE assets set name = @name, description = @description, assetType = @assetType, |
214 | local = @local, temporary = @temporary, data = @data | 214 | local = @local, temporary = @temporary, data = @data |
215 | WHERE id = @keyId;"; | 215 | WHERE id = @keyId;"; |
216 | 216 | ||
@@ -231,14 +231,13 @@ namespace OpenSim.Data.MSSQL | |||
231 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 231 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
232 | using (SqlCommand command = new SqlCommand(sql, conn)) | 232 | using (SqlCommand command = new SqlCommand(sql, conn)) |
233 | { | 233 | { |
234 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | 234 | command.Parameters.Add(m_database.CreateParameter("keyId", asset.FullID)); |
235 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); | 235 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); |
236 | command.Parameters.Add(m_database.CreateParameter("description", assetDescription)); | 236 | command.Parameters.Add(m_database.CreateParameter("description", assetDescription)); |
237 | command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type)); | 237 | command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type)); |
238 | command.Parameters.Add(m_database.CreateParameter("local", asset.Local)); | 238 | command.Parameters.Add(m_database.CreateParameter("local", asset.Local)); |
239 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); | 239 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); |
240 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | 240 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); |
241 | command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID)); | ||
242 | conn.Open(); | 241 | conn.Open(); |
243 | try | 242 | try |
244 | { | 243 | { |
@@ -295,15 +294,21 @@ namespace OpenSim.Data.MSSQL | |||
295 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) | 294 | public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) |
296 | { | 295 | { |
297 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 296 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
298 | string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() | 297 | string sql = @"WITH OrderedAssets AS |
299 | OVER (ORDER BY (some column to order by)) | 298 | ( |
300 | WHERE Row >= @Start AND Row < @Start + @Count"; | 299 | SELECT id, name, description, assetType, temporary, |
300 | Row = ROW_NUMBER() OVER (ORDER BY id) | ||
301 | FROM assets | ||
302 | ) | ||
303 | SELECT * | ||
304 | FROM OrderedAssets | ||
305 | WHERE RowNumber BETWEEN @start AND @stop;"; | ||
301 | 306 | ||
302 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 307 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
303 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 308 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
304 | { | 309 | { |
305 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | 310 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); |
306 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | 311 | cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1)); |
307 | conn.Open(); | 312 | conn.Open(); |
308 | using (SqlDataReader reader = cmd.ExecuteReader()) | 313 | using (SqlDataReader reader = cmd.ExecuteReader()) |
309 | { | 314 | { |