aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLAssetData.cs
diff options
context:
space:
mode:
authorCharles Krinke2009-05-17 18:18:48 +0000
committerCharles Krinke2009-05-17 18:18:48 +0000
commit7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7 (patch)
tree2b8d4a2dac75de73ef32e9ea8631a939d3090233 /OpenSim/Data/MSSQL/MSSQLAssetData.cs
parentThank you kindly, Jonc, for a patch that solves (diff)
downloadopensim-SC_OLD-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.zip
opensim-SC_OLD-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.tar.gz
opensim-SC_OLD-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.tar.bz2
opensim-SC_OLD-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.tar.xz
Thank you kindly, StrawberryFride, for a patch that:
Adds maturity & access logic for MSSQL platform to mirror that of MySQL as committed in 9502.
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLAssetData.cs')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs39
1 files changed, 20 insertions, 19 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 927b02b..e4fcb8a 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Data; 29using System.Data;
30using System.Data.SqlClient;
30using System.Reflection; 31using System.Reflection;
31using System.Collections.Generic; 32using System.Collections.Generic;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -124,10 +125,11 @@ namespace OpenSim.Data.MSSQL
124 /// <returns></returns> 125 /// <returns></returns>
125 override protected AssetBase FetchStoredAsset(UUID assetID) 126 override protected AssetBase FetchStoredAsset(UUID assetID)
126 { 127 {
127 using (AutoClosingSqlCommand command = m_database.Query("SELECT * FROM assets WHERE id = @id")) 128 string sql = "SELECT * FROM assets WHERE id = @id";
129 using (AutoClosingSqlCommand command = m_database.Query(sql))
128 { 130 {
129 command.Parameters.Add(m_database.CreateParameter("id", assetID)); 131 command.Parameters.Add(m_database.CreateParameter("id", assetID));
130 using (IDataReader reader = command.ExecuteReader()) 132 using (SqlDataReader reader = command.ExecuteReader())
131 { 133 {
132 if (reader.Read()) 134 if (reader.Read())
133 { 135 {
@@ -157,11 +159,13 @@ namespace OpenSim.Data.MSSQL
157 { 159 {
158 return; 160 return;
159 } 161 }
160 162 string sql = @"INSERT INTO assets
161 using (AutoClosingSqlCommand command = m_database.Query( 163 ([id], [name], [description], [assetType], [local],
162 "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" + 164 [temporary], [create_time], [access_time], [data])
163 " VALUES " + 165 VALUES
164 "(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)")) 166 (@id, @name, @description, @assetType, @local,
167 @temporary, @create_time, @access_time, @data)";
168 using (AutoClosingSqlCommand command = m_database.Query(sql))
165 { 169 {
166 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); 170 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
167 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); 171 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
@@ -184,14 +188,10 @@ namespace OpenSim.Data.MSSQL
184 /// <param name="asset">the asset</param> 188 /// <param name="asset">the asset</param>
185 override public void UpdateAsset(AssetBase asset) 189 override public void UpdateAsset(AssetBase asset)
186 { 190 {
187 using (AutoClosingSqlCommand command = m_database.Query("UPDATE assets set id = @id, " + 191 string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType,
188 "name = @name, " + 192 local = @local, temporary = @temporary, data = @data
189 "description = @description," + 193 WHERE id = @keyId;";
190 "assetType = @assetType," + 194 using (AutoClosingSqlCommand command = m_database.Query(sql))
191 "local = @local," +
192 "temporary = @temporary," +
193 "data = @data where " +
194 "id = @keyId;"))
195 { 195 {
196 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); 196 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
197 command.Parameters.Add(m_database.CreateParameter("name", asset.Name)); 197 command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
@@ -257,18 +257,19 @@ namespace OpenSim.Data.MSSQL
257 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count) 257 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
258 { 258 {
259 List<AssetMetadata> retList = new List<AssetMetadata>(count); 259 List<AssetMetadata> retList = new List<AssetMetadata>(count);
260 260 string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER()
261 using (AutoClosingSqlCommand command = m_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")) 261 OVER (ORDER BY (some column to order by))
262 WHERE Row >= @Start AND Row < @Start + @Count";
263 using (AutoClosingSqlCommand command = m_database.Query(sql))
262 { 264 {
263 command.Parameters.Add(m_database.CreateParameter("start", start)); 265 command.Parameters.Add(m_database.CreateParameter("start", start));
264 command.Parameters.Add(m_database.CreateParameter("count", count)); 266 command.Parameters.Add(m_database.CreateParameter("count", count));
265 267
266 using (IDataReader reader = command.ExecuteReader()) 268 using (SqlDataReader reader = command.ExecuteReader())
267 { 269 {
268 while (reader.Read()) 270 while (reader.Read())
269 { 271 {
270 AssetMetadata metadata = new AssetMetadata(); 272 AssetMetadata metadata = new AssetMetadata();
271 // Region Main
272 metadata.FullID = new UUID((Guid)reader["id"]); 273 metadata.FullID = new UUID((Guid)reader["id"]);
273 metadata.Name = (string)reader["name"]; 274 metadata.Name = (string)reader["name"];
274 metadata.Description = (string)reader["description"]; 275 metadata.Description = (string)reader["description"];