diff options
author | Charles Krinke | 2009-05-17 18:18:48 +0000 |
---|---|---|
committer | Charles Krinke | 2009-05-17 18:18:48 +0000 |
commit | 7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7 (patch) | |
tree | 2b8d4a2dac75de73ef32e9ea8631a939d3090233 | |
parent | Thank you kindly, Jonc, for a patch that solves (diff) | |
download | opensim-SC-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.zip opensim-SC-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.tar.gz opensim-SC-7a8a481f8801d9840a9ec05dd18adb2a1ccaebf7.tar.bz2 opensim-SC-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 '')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 39 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLEstateData.cs | 9 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGridData.cs | 9 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLUserData.cs | 261 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/Resources/005_GridStore.sql | 5 |
5 files changed, 168 insertions, 155 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Data.SqlClient; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
32 | using OpenMetaverse; | 33 | using 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"]; |
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index 3002fe3..1b0151d 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs | |||
@@ -108,7 +108,7 @@ namespace OpenSim.Data.MSSQL | |||
108 | { | 108 | { |
109 | cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID)); | 109 | cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID)); |
110 | 110 | ||
111 | using (IDataReader reader = cmd.ExecuteReader()) | 111 | using (SqlDataReader reader = cmd.ExecuteReader()) |
112 | { | 112 | { |
113 | if (reader.Read()) | 113 | if (reader.Read()) |
114 | { | 114 | { |
@@ -323,7 +323,7 @@ namespace OpenSim.Data.MSSQL | |||
323 | idParameter.Value = es.EstateID; | 323 | idParameter.Value = es.EstateID; |
324 | cmd.Parameters.Add(idParameter); | 324 | cmd.Parameters.Add(idParameter); |
325 | 325 | ||
326 | using (IDataReader reader = cmd.ExecuteReader()) | 326 | using (SqlDataReader reader = cmd.ExecuteReader()) |
327 | { | 327 | { |
328 | while (reader.Read()) | 328 | while (reader.Read()) |
329 | { | 329 | { |
@@ -351,7 +351,7 @@ namespace OpenSim.Data.MSSQL | |||
351 | { | 351 | { |
352 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID)); | 352 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID)); |
353 | 353 | ||
354 | using (IDataReader reader = cmd.ExecuteReader()) | 354 | using (SqlDataReader reader = cmd.ExecuteReader()) |
355 | { | 355 | { |
356 | while (reader.Read()) | 356 | while (reader.Read()) |
357 | { | 357 | { |
@@ -385,11 +385,8 @@ namespace OpenSim.Data.MSSQL | |||
385 | foreach (EstateBan b in es.EstateBans) | 385 | foreach (EstateBan b in es.EstateBans) |
386 | { | 386 | { |
387 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID)); | 387 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID)); |
388 | |||
389 | cmd.Parameters.Add(_Database.CreateParameter("@bannedUUID", b.BannedUserID)); | 388 | cmd.Parameters.Add(_Database.CreateParameter("@bannedUUID", b.BannedUserID)); |
390 | |||
391 | cmd.ExecuteNonQuery(); | 389 | cmd.ExecuteNonQuery(); |
392 | |||
393 | cmd.Parameters.Clear(); | 390 | cmd.Parameters.Clear(); |
394 | } | 391 | } |
395 | } | 392 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index 027796a..c7e5ec8 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs | |||
@@ -445,9 +445,7 @@ namespace OpenSim.Data.MSSQL | |||
445 | // World Map Addition | 445 | // World Map Addition |
446 | retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]); | 446 | retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]); |
447 | retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]); | 447 | retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]); |
448 | // UUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); | 448 | retval.maturity = Convert.ToUInt32(reader["access"]); |
449 | // UUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); | ||
450 | |||
451 | return retval; | 449 | return retval; |
452 | } | 450 | } |
453 | 451 | ||
@@ -535,11 +533,11 @@ namespace OpenSim.Data.MSSQL | |||
535 | [serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], | 533 | [serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], |
536 | [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey], | 534 | [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey], |
537 | [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], | 535 | [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], |
538 | [serverRemotingPort], [owner_uuid], [originUUID]) | 536 | [serverRemotingPort], [owner_uuid], [originUUID], [access]) |
539 | VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, | 537 | VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, |
540 | @serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, | 538 | @serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, |
541 | @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey, | 539 | @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey, |
542 | @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID);"; | 540 | @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);"; |
543 | 541 | ||
544 | using (AutoClosingSqlCommand command = database.Query(sql)) | 542 | using (AutoClosingSqlCommand command = database.Query(sql)) |
545 | { | 543 | { |
@@ -571,6 +569,7 @@ namespace OpenSim.Data.MSSQL | |||
571 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | 569 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); |
572 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | 570 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); |
573 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | 571 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); |
572 | command.Parameters.Add(database.CreateParameter("access", profile.maturity)); | ||
574 | 573 | ||
575 | try | 574 | try |
576 | { | 575 | { |
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs index 379b8bf..1bff28d 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs | |||
@@ -69,7 +69,6 @@ namespace OpenSim.Data.MSSQL | |||
69 | /// <remarks>use mssql_connection.ini</remarks> | 69 | /// <remarks>use mssql_connection.ini</remarks> |
70 | override public void Initialise(string connect) | 70 | override public void Initialise(string connect) |
71 | { | 71 | { |
72 | |||
73 | if (!string.IsNullOrEmpty(connect)) | 72 | if (!string.IsNullOrEmpty(connect)) |
74 | { | 73 | { |
75 | database = new MSSQLManager(connect); | 74 | database = new MSSQLManager(connect); |
@@ -106,11 +105,12 @@ namespace OpenSim.Data.MSSQL | |||
106 | /// <returns>A user profile</returns> | 105 | /// <returns>A user profile</returns> |
107 | override public UserProfileData GetUserByName(string user, string last) | 106 | override public UserProfileData GetUserByName(string user, string last) |
108 | { | 107 | { |
109 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second")) | 108 | string sql = string.Format(@"SELECT * FROM {0} |
109 | WHERE username = @first AND lastname = @second", m_usersTableName); | ||
110 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
110 | { | 111 | { |
111 | command.Parameters.Add(database.CreateParameter("first", user)); | 112 | command.Parameters.Add(database.CreateParameter("first", user)); |
112 | command.Parameters.Add(database.CreateParameter("second", last)); | 113 | command.Parameters.Add(database.CreateParameter("second", last)); |
113 | |||
114 | try | 114 | try |
115 | { | 115 | { |
116 | using (SqlDataReader reader = command.ExecuteReader()) | 116 | using (SqlDataReader reader = command.ExecuteReader()) |
@@ -120,7 +120,7 @@ namespace OpenSim.Data.MSSQL | |||
120 | } | 120 | } |
121 | catch (Exception e) | 121 | catch (Exception e) |
122 | { | 122 | { |
123 | m_log.Error("[USER DB] Error getting user profile, error: " + e.Message); | 123 | m_log.ErrorFormat("[USER DB] Error getting user profile for {0} {1}: {2}", user, last, e.Message); |
124 | return null; | 124 | return null; |
125 | } | 125 | } |
126 | } | 126 | } |
@@ -133,20 +133,20 @@ namespace OpenSim.Data.MSSQL | |||
133 | /// <returns></returns> | 133 | /// <returns></returns> |
134 | override public UserProfileData GetUserByUUID(UUID uuid) | 134 | override public UserProfileData GetUserByUUID(UUID uuid) |
135 | { | 135 | { |
136 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid")) | 136 | string sql = string.Format("SELECT * FROM {0} WHERE UUID = @uuid", m_usersTableName); |
137 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
137 | { | 138 | { |
138 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | 139 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); |
139 | |||
140 | try | 140 | try |
141 | { | 141 | { |
142 | using (IDataReader reader = command.ExecuteReader()) | 142 | using (SqlDataReader reader = command.ExecuteReader()) |
143 | { | 143 | { |
144 | return ReadUserRow(reader); | 144 | return ReadUserRow(reader); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | catch (Exception e) | 147 | catch (Exception e) |
148 | { | 148 | { |
149 | m_log.Error("[USER DB] Error getting user profile by UUID, error: " + e.Message); | 149 | m_log.ErrorFormat("[USER DB] Error getting user profile by UUID {0}, error: {1}", uuid, e.Message); |
150 | return null; | 150 | return null; |
151 | } | 151 | } |
152 | } | 152 | } |
@@ -173,7 +173,7 @@ namespace OpenSim.Data.MSSQL | |||
173 | } | 173 | } |
174 | catch (Exception e) | 174 | catch (Exception e) |
175 | { | 175 | { |
176 | m_log.Error("[USER DB] Error adding new profile, error: " + e.Message); | 176 | m_log.ErrorFormat("[USER DB] Error adding new profile, error: {0}", e.Message); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
@@ -184,36 +184,37 @@ namespace OpenSim.Data.MSSQL | |||
184 | /// <returns></returns> | 184 | /// <returns></returns> |
185 | override public bool UpdateUserProfile(UserProfileData user) | 185 | override public bool UpdateUserProfile(UserProfileData user) |
186 | { | 186 | { |
187 | using (AutoClosingSqlCommand command = database.Query("UPDATE " + m_usersTableName + " set UUID = @uuid, " + | 187 | string sql = string.Format(@"UPDATE {0} |
188 | "username = @username, " + | 188 | SET UUID = @uuid, |
189 | "lastname = @lastname," + | 189 | username = @username, |
190 | "email = @email," + | 190 | lastname = @lastname, |
191 | "passwordHash = @passwordHash," + | 191 | email = @email, |
192 | "passwordSalt = @passwordSalt," + | 192 | passwordHash = @passwordHash, |
193 | "homeRegion = @homeRegion," + | 193 | passwordSalt = @passwordSalt, |
194 | "homeLocationX = @homeLocationX," + | 194 | homeRegion = @homeRegion, |
195 | "homeLocationY = @homeLocationY," + | 195 | homeLocationX = @homeLocationX, |
196 | "homeLocationZ = @homeLocationZ," + | 196 | homeLocationY = @homeLocationY, |
197 | "homeLookAtX = @homeLookAtX," + | 197 | homeLocationZ = @homeLocationZ, |
198 | "homeLookAtY = @homeLookAtY," + | 198 | homeLookAtX = @homeLookAtX, |
199 | "homeLookAtZ = @homeLookAtZ," + | 199 | homeLookAtY = @homeLookAtY, |
200 | "created = @created," + | 200 | homeLookAtZ = @homeLookAtZ, |
201 | "lastLogin = @lastLogin," + | 201 | created = @created, |
202 | "userInventoryURI = @userInventoryURI," + | 202 | lastLogin = @lastLogin, |
203 | "userAssetURI = @userAssetURI," + | 203 | userInventoryURI = @userInventoryURI, |
204 | "profileCanDoMask = @profileCanDoMask," + | 204 | userAssetURI = @userAssetURI, |
205 | "profileWantDoMask = @profileWantDoMask," + | 205 | profileCanDoMask = @profileCanDoMask, |
206 | "profileAboutText = @profileAboutText," + | 206 | profileWantDoMask = @profileWantDoMask, |
207 | "profileFirstText = @profileFirstText," + | 207 | profileAboutText = @profileAboutText, |
208 | "profileImage = @profileImage," + | 208 | profileFirstText = @profileFirstText, |
209 | "profileFirstImage = @profileFirstImage, " + | 209 | profileImage = @profileImage, |
210 | "webLoginKey = @webLoginKey, " + | 210 | profileFirstImage = @profileFirstImage, |
211 | "homeRegionID = @homeRegionID, " + | 211 | webLoginKey = @webLoginKey, |
212 | "userFlags = @userFlags, " + | 212 | homeRegionID = @homeRegionID, |
213 | "godLevel = @godLevel, " + | 213 | userFlags = @userFlags, |
214 | "customType = @customType, " + | 214 | godLevel = @godLevel, |
215 | "partner = @partner where " + | 215 | customType = @customType, |
216 | "UUID = @keyUUUID;")) | 216 | partner = @partner WHERE UUID = @keyUUUID;",m_usersTableName); |
217 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
217 | { | 218 | { |
218 | command.Parameters.Add(database.CreateParameter("uuid", user.ID)); | 219 | command.Parameters.Add(database.CreateParameter("uuid", user.ID)); |
219 | command.Parameters.Add(database.CreateParameter("username", user.FirstName)); | 220 | command.Parameters.Add(database.CreateParameter("username", user.FirstName)); |
@@ -239,7 +240,6 @@ namespace OpenSim.Data.MSSQL | |||
239 | command.Parameters.Add(database.CreateParameter("profileImage", user.Image)); | 240 | command.Parameters.Add(database.CreateParameter("profileImage", user.Image)); |
240 | command.Parameters.Add(database.CreateParameter("profileFirstImage", user.FirstLifeImage)); | 241 | command.Parameters.Add(database.CreateParameter("profileFirstImage", user.FirstLifeImage)); |
241 | command.Parameters.Add(database.CreateParameter("webLoginKey", user.WebLoginKey)); | 242 | command.Parameters.Add(database.CreateParameter("webLoginKey", user.WebLoginKey)); |
242 | // | ||
243 | command.Parameters.Add(database.CreateParameter("homeRegionID", user.HomeRegionID)); | 243 | command.Parameters.Add(database.CreateParameter("homeRegionID", user.HomeRegionID)); |
244 | command.Parameters.Add(database.CreateParameter("userFlags", user.UserFlags)); | 244 | command.Parameters.Add(database.CreateParameter("userFlags", user.UserFlags)); |
245 | command.Parameters.Add(database.CreateParameter("godLevel", user.GodLevel)); | 245 | command.Parameters.Add(database.CreateParameter("godLevel", user.GodLevel)); |
@@ -254,7 +254,7 @@ namespace OpenSim.Data.MSSQL | |||
254 | } | 254 | } |
255 | catch (Exception e) | 255 | catch (Exception e) |
256 | { | 256 | { |
257 | m_log.Error("[USER DB] Error updating profile, error: " + e.Message); | 257 | m_log.ErrorFormat("[USER DB] Error updating profile, error: {0}", e.Message); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | return false; | 260 | return false; |
@@ -293,7 +293,8 @@ namespace OpenSim.Data.MSSQL | |||
293 | /// <returns>The users session</returns> | 293 | /// <returns>The users session</returns> |
294 | override public UserAgentData GetAgentByUUID(UUID uuid) | 294 | override public UserAgentData GetAgentByUUID(UUID uuid) |
295 | { | 295 | { |
296 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid")) | 296 | string sql = string.Format("SELECT * FROM {0} WHERE UUID = @uuid", m_agentsTableName); |
297 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
297 | { | 298 | { |
298 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | 299 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); |
299 | try | 300 | try |
@@ -305,7 +306,7 @@ namespace OpenSim.Data.MSSQL | |||
305 | } | 306 | } |
306 | catch (Exception e) | 307 | catch (Exception e) |
307 | { | 308 | { |
308 | m_log.Error("[USER DB] Error updating agentdata by UUID, error: " + e.Message); | 309 | m_log.ErrorFormat("[USER DB] Error updating agentdata by UUID, error: {0}", e.Message); |
309 | return null; | 310 | return null; |
310 | } | 311 | } |
311 | } | 312 | } |
@@ -323,7 +324,7 @@ namespace OpenSim.Data.MSSQL | |||
323 | } | 324 | } |
324 | catch (Exception e) | 325 | catch (Exception e) |
325 | { | 326 | { |
326 | m_log.Error("[USER DB] Error adding new agentdata, error: " + e.Message); | 327 | m_log.ErrorFormat("[USER DB] Error adding new agentdata, error: {0}", e.Message); |
327 | } | 328 | } |
328 | } | 329 | } |
329 | 330 | ||
@@ -340,12 +341,11 @@ namespace OpenSim.Data.MSSQL | |||
340 | override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | 341 | override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) |
341 | { | 342 | { |
342 | int dtvalue = Util.UnixTimeSinceEpoch(); | 343 | int dtvalue = Util.UnixTimeSinceEpoch(); |
343 | 344 | string sql = string.Format(@"INSERT INTO {0} | |
344 | using (AutoClosingSqlCommand command = database.Query( | 345 | (ownerID,friendID,friendPerms,datetimestamp) |
345 | "INSERT INTO " + m_userFriendsTableName + " " + | 346 | VALUES |
346 | "(ownerID,friendID,friendPerms,datetimestamp) " + | 347 | (@ownerID,@friendID,@friendPerms,@datetimestamp)", m_userFriendsTableName); |
347 | "VALUES " + | 348 | using (AutoClosingSqlCommand command = database.Query(sql)) |
348 | "(@ownerID,@friendID,@friendPerms,@datetimestamp)")) | ||
349 | { | 349 | { |
350 | command.Parameters.Add(database.CreateParameter("ownerID", friendlistowner)); | 350 | command.Parameters.Add(database.CreateParameter("ownerID", friendlistowner)); |
351 | command.Parameters.Add(database.CreateParameter("friendID", friend)); | 351 | command.Parameters.Add(database.CreateParameter("friendID", friend)); |
@@ -355,14 +355,16 @@ namespace OpenSim.Data.MSSQL | |||
355 | 355 | ||
356 | try | 356 | try |
357 | { | 357 | { |
358 | command.CommandText = string.Format("INSERT INTO {0} (ownerID,friendID,friendPerms,datetimestamp) VALUES (@friendID,@ownerID,@friendPerms,@datetimestamp)", | 358 | sql = string.Format(@"INSERT INTO {0} |
359 | m_userFriendsTableName); | 359 | (ownerID,friendID,friendPerms,datetimestamp) |
360 | 360 | VALUES | |
361 | (@friendID,@ownerID,@friendPerms,@datetimestamp)", m_userFriendsTableName); | ||
362 | command.CommandText = sql; | ||
361 | command.ExecuteNonQuery(); | 363 | command.ExecuteNonQuery(); |
362 | } | 364 | } |
363 | catch (Exception e) | 365 | catch (Exception e) |
364 | { | 366 | { |
365 | m_log.Error("[USER DB] Error adding new userfriend, error: " + e.Message); | 367 | m_log.ErrorFormat("[USER DB] Error adding new userfriend, error: {0}", e.Message); |
366 | return; | 368 | return; |
367 | } | 369 | } |
368 | } | 370 | } |
@@ -375,21 +377,25 @@ namespace OpenSim.Data.MSSQL | |||
375 | /// <param name="friend">UUID of the not-so-friendly user to remove from the list</param> | 377 | /// <param name="friend">UUID of the not-so-friendly user to remove from the list</param> |
376 | override public void RemoveUserFriend(UUID friendlistowner, UUID friend) | 378 | override public void RemoveUserFriend(UUID friendlistowner, UUID friend) |
377 | { | 379 | { |
378 | using (AutoClosingSqlCommand command = database.Query("delete from " + m_userFriendsTableName + " where ownerID = @ownerID and friendID = @friendID")) | 380 | string sql = string.Format(@"DELETE from {0} |
381 | WHERE ownerID = @ownerID | ||
382 | AND friendID = @friendID", m_userFriendsTableName); | ||
383 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
379 | { | 384 | { |
380 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); | 385 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); |
381 | command.Parameters.Add(database.CreateParameter("@friendID", friend)); | 386 | command.Parameters.Add(database.CreateParameter("@friendID", friend)); |
382 | command.ExecuteNonQuery(); | 387 | command.ExecuteNonQuery(); |
383 | 388 | sql = string.Format(@"DELETE from {0} | |
384 | command.CommandText = "delete from " + m_userFriendsTableName + | 389 | WHERE ownerID = @friendID |
385 | " where ownerID = @friendID and friendID = @ownerID"; | 390 | AND friendID = @ownerID", m_userFriendsTableName); |
391 | command.CommandText = sql; | ||
386 | try | 392 | try |
387 | { | 393 | { |
388 | command.ExecuteNonQuery(); | 394 | command.ExecuteNonQuery(); |
389 | } | 395 | } |
390 | catch (Exception e) | 396 | catch (Exception e) |
391 | { | 397 | { |
392 | m_log.Error("[USER DB] Error removing userfriend, error: " + e.Message); | 398 | m_log.ErrorFormat("[USER DB] Error removing userfriend, error: {0}", e.Message); |
393 | } | 399 | } |
394 | } | 400 | } |
395 | } | 401 | } |
@@ -402,10 +408,10 @@ namespace OpenSim.Data.MSSQL | |||
402 | /// <param name="perms">new permission flag</param> | 408 | /// <param name="perms">new permission flag</param> |
403 | override public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | 409 | override public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) |
404 | { | 410 | { |
405 | using (AutoClosingSqlCommand command = database.Query( | 411 | string sql = string.Format(@"UPDATE {0} SET friendPerms = @friendPerms |
406 | "update " + m_userFriendsTableName + | 412 | WHERE ownerID = @ownerID |
407 | " SET friendPerms = @friendPerms " + | 413 | AND friendID = @friendID", m_userFriendsTableName); |
408 | "where ownerID = @ownerID and friendID = @friendID")) | 414 | using (AutoClosingSqlCommand command = database.Query(sql)) |
409 | { | 415 | { |
410 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); | 416 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); |
411 | command.Parameters.Add(database.CreateParameter("@friendID", friend)); | 417 | command.Parameters.Add(database.CreateParameter("@friendID", friend)); |
@@ -417,7 +423,7 @@ namespace OpenSim.Data.MSSQL | |||
417 | } | 423 | } |
418 | catch (Exception e) | 424 | catch (Exception e) |
419 | { | 425 | { |
420 | m_log.Error("[USER DB] Error updating userfriend, error: " + e.Message); | 426 | m_log.ErrorFormat("[USER DB] Error updating userfriend, error: {0}", e.Message); |
421 | } | 427 | } |
422 | } | 428 | } |
423 | } | 429 | } |
@@ -432,15 +438,17 @@ namespace OpenSim.Data.MSSQL | |||
432 | List<FriendListItem> friendList = new List<FriendListItem>(); | 438 | List<FriendListItem> friendList = new List<FriendListItem>(); |
433 | 439 | ||
434 | //Left Join userfriends to itself | 440 | //Left Join userfriends to itself |
435 | using (AutoClosingSqlCommand command = database.Query( | 441 | string sql = string.Format(@"SELECT a.ownerID, a.friendID, a.friendPerms, b.friendPerms AS ownerperms |
436 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | 442 | FROM {0} as a, {0} as b |
437 | " where a.ownerID = @ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID")) | 443 | WHERE a.ownerID = @ownerID |
444 | AND b.ownerID = a.friendID | ||
445 | AND b.friendID = a.ownerID", m_userFriendsTableName); | ||
446 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
438 | { | 447 | { |
439 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); | 448 | command.Parameters.Add(database.CreateParameter("@ownerID", friendlistowner)); |
440 | |||
441 | try | 449 | try |
442 | { | 450 | { |
443 | using (IDataReader reader = command.ExecuteReader()) | 451 | using (SqlDataReader reader = command.ExecuteReader()) |
444 | { | 452 | { |
445 | while (reader.Read()) | 453 | while (reader.Read()) |
446 | { | 454 | { |
@@ -451,17 +459,15 @@ namespace OpenSim.Data.MSSQL | |||
451 | 459 | ||
452 | // This is not a real column in the database table, it's a joined column from the opposite record | 460 | // This is not a real column in the database table, it's a joined column from the opposite record |
453 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); | 461 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); |
454 | |||
455 | friendList.Add(fli); | 462 | friendList.Add(fli); |
456 | } | 463 | } |
457 | } | 464 | } |
458 | } | 465 | } |
459 | catch (Exception e) | 466 | catch (Exception e) |
460 | { | 467 | { |
461 | m_log.Error("[USER DB] Error updating userfriend, error: " + e.Message); | 468 | m_log.ErrorFormat("[USER DB] Error updating userfriend, error: {0}", e.Message); |
462 | } | 469 | } |
463 | } | 470 | } |
464 | |||
465 | return friendList; | 471 | return friendList; |
466 | } | 472 | } |
467 | 473 | ||
@@ -472,12 +478,12 @@ namespace OpenSim.Data.MSSQL | |||
472 | { | 478 | { |
473 | foreach (UUID uuid in uuids) | 479 | foreach (UUID uuid in uuids) |
474 | { | 480 | { |
475 | using (AutoClosingSqlCommand command = database.Query( | 481 | string sql = string.Format(@"SELECT agentOnline,currentHandle |
476 | "select agentOnline,currentHandle from " + m_agentsTableName + " where UUID = @uuid")) | 482 | FROM {0} WHERE UUID = @uuid", m_agentsTableName); |
483 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
477 | { | 484 | { |
478 | command.Parameters.Add(database.CreateParameter("@uuid", uuid)); | 485 | command.Parameters.Add(database.CreateParameter("@uuid", uuid)); |
479 | 486 | using (SqlDataReader reader = command.ExecuteReader()) | |
480 | using (IDataReader reader = command.ExecuteReader()) | ||
481 | { | 487 | { |
482 | while (reader.Read()) | 488 | while (reader.Read()) |
483 | { | 489 | { |
@@ -541,11 +547,11 @@ namespace OpenSim.Data.MSSQL | |||
541 | try | 547 | try |
542 | { | 548 | { |
543 | AvatarAppearance appearance = new AvatarAppearance(); | 549 | AvatarAppearance appearance = new AvatarAppearance(); |
544 | 550 | string sql = "SELECT * FROM avatarappearance WHERE owner = @UUID"; | |
545 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID")) | 551 | using (AutoClosingSqlCommand command = database.Query(sql)) |
546 | { | 552 | { |
547 | command.Parameters.Add(database.CreateParameter("@UUID", user)); | 553 | command.Parameters.Add(database.CreateParameter("@UUID", user)); |
548 | using (IDataReader reader = command.ExecuteReader()) | 554 | using (SqlDataReader reader = command.ExecuteReader()) |
549 | { | 555 | { |
550 | if (reader.Read()) | 556 | if (reader.Read()) |
551 | appearance = readUserAppearance(reader); | 557 | appearance = readUserAppearance(reader); |
@@ -564,12 +570,11 @@ namespace OpenSim.Data.MSSQL | |||
564 | } | 570 | } |
565 | catch (Exception e) | 571 | catch (Exception e) |
566 | { | 572 | { |
567 | m_log.Error("[USER DB] Error updating userfriend, error: " + e.Message); | 573 | m_log.ErrorFormat("[USER DB] Error updating userfriend, error: {0}", e.Message); |
568 | } | 574 | } |
569 | return null; | 575 | return null; |
570 | } | 576 | } |
571 | 577 | ||
572 | |||
573 | /// <summary> | 578 | /// <summary> |
574 | /// Update a user appearence into database | 579 | /// Update a user appearence into database |
575 | /// </summary> | 580 | /// </summary> |
@@ -577,20 +582,23 @@ namespace OpenSim.Data.MSSQL | |||
577 | /// <param name="appearance">the appearence</param> | 582 | /// <param name="appearance">the appearence</param> |
578 | override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | 583 | override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) |
579 | { | 584 | { |
580 | m_log.Error("[USER DB] updating user appearance for user ID " + user.Guid); | 585 | string sql = @"DELETE FROM avatarappearance WHERE owner=@owner; |
581 | string sql = String.Empty; | 586 | INSERT INTO avatarappearance |
582 | sql += "DELETE FROM avatarappearance WHERE owner=@owner "; | 587 | (owner, serial, visual_params, texture, avatar_height, |
583 | sql += "INSERT INTO avatarappearance "; | 588 | body_item, body_asset, skin_item, skin_asset, hair_item, |
584 | sql += "(owner, serial, visual_params, texture, avatar_height, "; | 589 | hair_asset, eyes_item, eyes_asset, shirt_item, shirt_asset, |
585 | sql += "body_item, body_asset, skin_item, skin_asset, hair_item, hair_asset, eyes_item, eyes_asset, "; | 590 | pants_item, pants_asset, shoes_item, shoes_asset, socks_item, |
586 | sql += "shirt_item, shirt_asset, pants_item, pants_asset, shoes_item, shoes_asset, socks_item, socks_asset, "; | 591 | socks_asset, jacket_item, jacket_asset, gloves_item, gloves_asset, |
587 | sql += "jacket_item, jacket_asset, gloves_item, gloves_asset, undershirt_item, undershirt_asset, underpants_item, underpants_asset, "; | 592 | undershirt_item, undershirt_asset, underpants_item, underpants_asset, |
588 | sql += "skirt_item, skirt_asset) values ("; | 593 | skirt_item, skirt_asset) |
589 | sql += "@owner, @serial, @visual_params, @texture, @avatar_height, "; | 594 | VALUES |
590 | sql += "@body_item, @body_asset, @skin_item, @skin_asset, @hair_item, @hair_asset, @eyes_item, @eyes_asset, "; | 595 | (@owner, @serial, @visual_params, @texture, @avatar_height, |
591 | sql += "@shirt_item, @shirt_asset, @pants_item, @pants_asset, @shoes_item, @shoes_asset, @socks_item, @socks_asset, "; | 596 | @body_item, @body_asset, @skin_item, @skin_asset, @hair_item, |
592 | sql += "@jacket_item, @jacket_asset, @gloves_item, @gloves_asset, @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, "; | 597 | @hair_asset, @eyes_item, @eyes_asset, @shirt_item, @shirt_asset, |
593 | sql += "@skirt_item, @skirt_asset)"; | 598 | @pants_item, @pants_asset, @shoes_item, @shoes_asset, @socks_item, |
599 | @socks_asset, @jacket_item, @jacket_asset, @gloves_item, @gloves_asset, | ||
600 | @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, | ||
601 | @skirt_item, @skirt_asset)"; | ||
594 | 602 | ||
595 | using (AutoClosingSqlCommand cmd = database.Query(sql)) | 603 | using (AutoClosingSqlCommand cmd = database.Query(sql)) |
596 | { | 604 | { |
@@ -632,10 +640,9 @@ namespace OpenSim.Data.MSSQL | |||
632 | } | 640 | } |
633 | catch (Exception e) | 641 | catch (Exception e) |
634 | { | 642 | { |
635 | m_log.Error("[USER DB] Error updating user appearance, error: " + e.Message); | 643 | m_log.ErrorFormat("[USER DB] Error updating user appearance, error: {0}", e.Message); |
636 | } | 644 | } |
637 | } | 645 | } |
638 | |||
639 | UpdateUserAttachments(user, appearance.GetAttachments()); | 646 | UpdateUserAttachments(user, appearance.GetAttachments()); |
640 | } | 647 | } |
641 | 648 | ||
@@ -651,7 +658,8 @@ namespace OpenSim.Data.MSSQL | |||
651 | public Hashtable GetUserAttachments(UUID agentID) | 658 | public Hashtable GetUserAttachments(UUID agentID) |
652 | { | 659 | { |
653 | Hashtable returnTable = new Hashtable(); | 660 | Hashtable returnTable = new Hashtable(); |
654 | using (AutoClosingSqlCommand command = database.Query("select attachpoint, item, asset from avatarattachments where UUID = @uuid", database.CreateParameter("@uuid", agentID))) | 661 | string sql = "select attachpoint, item, asset from avatarattachments where UUID = @uuid"; |
662 | using (AutoClosingSqlCommand command = database.Query(sql, database.CreateParameter("@uuid", agentID))) | ||
655 | { | 663 | { |
656 | using (SqlDataReader reader = command.ExecuteReader()) | 664 | using (SqlDataReader reader = command.ExecuteReader()) |
657 | { | 665 | { |
@@ -678,7 +686,7 @@ namespace OpenSim.Data.MSSQL | |||
678 | /// <param name="data">data with all items on attachmentpoints</param> | 686 | /// <param name="data">data with all items on attachmentpoints</param> |
679 | public void UpdateUserAttachments(UUID agentID, Hashtable data) | 687 | public void UpdateUserAttachments(UUID agentID, Hashtable data) |
680 | { | 688 | { |
681 | string sql = "delete from avatarattachments where UUID = @uuid"; | 689 | string sql = "DELETE FROM avatarattachments WHERE UUID = @uuid"; |
682 | 690 | ||
683 | using (AutoClosingSqlCommand command = database.Query(sql)) | 691 | using (AutoClosingSqlCommand command = database.Query(sql)) |
684 | { | 692 | { |
@@ -688,7 +696,8 @@ namespace OpenSim.Data.MSSQL | |||
688 | if (data == null) | 696 | if (data == null) |
689 | return; | 697 | return; |
690 | 698 | ||
691 | sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (@uuid, @attachpoint, @item, @asset)"; | 699 | sql = @"INSERT INTO avatarattachments (UUID, attachpoint, item, asset) |
700 | VALUES (@uuid, @attachpoint, @item, @asset)"; | ||
692 | 701 | ||
693 | using (AutoClosingSqlCommand command = database.Query(sql)) | 702 | using (AutoClosingSqlCommand command = database.Query(sql)) |
694 | { | 703 | { |
@@ -730,7 +739,8 @@ namespace OpenSim.Data.MSSQL | |||
730 | /// <param name="agentID">agentID.</param> | 739 | /// <param name="agentID">agentID.</param> |
731 | override public void ResetAttachments(UUID agentID) | 740 | override public void ResetAttachments(UUID agentID) |
732 | { | 741 | { |
733 | using (AutoClosingSqlCommand command = database.Query("update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = @uuid")) | 742 | string sql = "UPDATE avatarattachments SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = @uuid"; |
743 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
734 | { | 744 | { |
735 | command.Parameters.Add(database.CreateParameter("uuid", agentID)); | 745 | command.Parameters.Add(database.CreateParameter("uuid", agentID)); |
736 | command.ExecuteNonQuery(); | 746 | command.ExecuteNonQuery(); |
@@ -759,12 +769,14 @@ namespace OpenSim.Data.MSSQL | |||
759 | { | 769 | { |
760 | try | 770 | try |
761 | { | 771 | { |
762 | using (AutoClosingSqlCommand command = database.Query("SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username LIKE @first AND lastname LIKE @second")) | 772 | string sql = string.Format(@"SELECT UUID,username,lastname FROM {0} |
773 | WHERE username LIKE @first AND lastname LIKE @second", m_usersTableName); | ||
774 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
763 | { | 775 | { |
764 | //Add wildcard to the search | 776 | //Add wildcard to the search |
765 | command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%")); | 777 | command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%")); |
766 | command.Parameters.Add(database.CreateParameter("second", querysplit[1] + "%")); | 778 | command.Parameters.Add(database.CreateParameter("second", querysplit[1] + "%")); |
767 | using (IDataReader reader = command.ExecuteReader()) | 779 | using (SqlDataReader reader = command.ExecuteReader()) |
768 | { | 780 | { |
769 | while (reader.Read()) | 781 | while (reader.Read()) |
770 | { | 782 | { |
@@ -786,11 +798,13 @@ namespace OpenSim.Data.MSSQL | |||
786 | { | 798 | { |
787 | try | 799 | try |
788 | { | 800 | { |
789 | using (AutoClosingSqlCommand command = database.Query("SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username LIKE @first OR lastname LIKE @first")) | 801 | string sql = string.Format(@"SELECT UUID,username,lastname FROM {0} |
802 | WHERE username LIKE @first OR lastname LIKE @first", m_usersTableName); | ||
803 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
790 | { | 804 | { |
791 | command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%")); | 805 | command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%")); |
792 | 806 | ||
793 | using (IDataReader reader = command.ExecuteReader()) | 807 | using (SqlDataReader reader = command.ExecuteReader()) |
794 | { | 808 | { |
795 | while (reader.Read()) | 809 | while (reader.Read()) |
796 | { | 810 | { |
@@ -822,7 +836,6 @@ namespace OpenSim.Data.MSSQL | |||
822 | UserProfileData user = GetUserByUUID(AgentID); | 836 | UserProfileData user = GetUserByUUID(AgentID); |
823 | user.WebLoginKey = WebLoginKey; | 837 | user.WebLoginKey = WebLoginKey; |
824 | UpdateUserProfile(user); | 838 | UpdateUserProfile(user); |
825 | |||
826 | } | 839 | } |
827 | 840 | ||
828 | /// <summary> | 841 | /// <summary> |
@@ -852,7 +865,7 @@ namespace OpenSim.Data.MSSQL | |||
852 | /// </summary> | 865 | /// </summary> |
853 | /// <param name="reader">The SQL Result</param> | 866 | /// <param name="reader">The SQL Result</param> |
854 | /// <returns>the item read</returns> | 867 | /// <returns>the item read</returns> |
855 | private static AvatarAppearance readUserAppearance(IDataReader reader) | 868 | private static AvatarAppearance readUserAppearance(SqlDataReader reader) |
856 | { | 869 | { |
857 | try | 870 | try |
858 | { | 871 | { |
@@ -962,7 +975,7 @@ ELSE | |||
962 | /// </summary> | 975 | /// </summary> |
963 | /// <param name="reader">An active database reader</param> | 976 | /// <param name="reader">An active database reader</param> |
964 | /// <returns>A user session agent</returns> | 977 | /// <returns>A user session agent</returns> |
965 | private UserAgentData readAgentRow(IDataReader reader) | 978 | private UserAgentData readAgentRow(SqlDataReader reader) |
966 | { | 979 | { |
967 | UserAgentData retval = new UserAgentData(); | 980 | UserAgentData retval = new UserAgentData(); |
968 | 981 | ||
@@ -1038,18 +1051,20 @@ ELSE | |||
1038 | UUID profileImage, UUID firstImage, UUID webLoginKey, UUID homeRegionID, | 1051 | UUID profileImage, UUID firstImage, UUID webLoginKey, UUID homeRegionID, |
1039 | int godLevel, int userFlags, string customType, UUID partnerID) | 1052 | int godLevel, int userFlags, string customType, UUID partnerID) |
1040 | { | 1053 | { |
1041 | string sql = "INSERT INTO " + m_usersTableName; | 1054 | string sql = string.Format(@"INSERT INTO {0} |
1042 | sql += " ([UUID], [username], [lastname], [email], [passwordHash], [passwordSalt], [homeRegion], "; | 1055 | ([UUID], [username], [lastname], [email], [passwordHash], [passwordSalt], |
1043 | sql += "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], "; | 1056 | [homeRegion], [homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], |
1044 | sql += "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], "; | 1057 | [homeLookAtY], [homeLookAtZ], [created], [lastLogin], [userInventoryURI], |
1045 | sql += "[profileFirstText], [profileImage], [profileFirstImage], [webLoginKey], "; | 1058 | [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], |
1046 | sql += "[homeRegionID], [userFlags], [godLevel], [customType], [partner]) VALUES "; | 1059 | [profileFirstText], [profileImage], [profileFirstImage], [webLoginKey], |
1047 | 1060 | [homeRegionID], [userFlags], [godLevel], [customType], [partner]) | |
1048 | sql += "(@UUID, @username, @lastname, @email, @passwordHash, @passwordSalt, @homeRegion, "; | 1061 | VALUES |
1049 | sql += "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, "; | 1062 | (@UUID, @username, @lastname, @email, @passwordHash, @passwordSalt, |
1050 | sql += "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, "; | 1063 | @homeRegion, @homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, |
1051 | sql += "@profileFirstText, @profileImage, @profileFirstImage, @webLoginKey, "; | 1064 | @homeLookAtY, @homeLookAtZ, @created, @lastLogin, @userInventoryURI, |
1052 | sql += "@homeRegionID, @userFlags, @godLevel, @customType, @partner)"; | 1065 | @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, |
1066 | @profileFirstText, @profileImage, @profileFirstImage, @webLoginKey, | ||
1067 | @homeRegionID, @userFlags, @godLevel, @customType, @partner)", m_usersTableName); | ||
1053 | 1068 | ||
1054 | try | 1069 | try |
1055 | { | 1070 | { |
@@ -1079,13 +1094,11 @@ ELSE | |||
1079 | command.Parameters.Add(database.CreateParameter("profileImage", profileImage)); | 1094 | command.Parameters.Add(database.CreateParameter("profileImage", profileImage)); |
1080 | command.Parameters.Add(database.CreateParameter("profileFirstImage", firstImage)); | 1095 | command.Parameters.Add(database.CreateParameter("profileFirstImage", firstImage)); |
1081 | command.Parameters.Add(database.CreateParameter("webLoginKey", webLoginKey)); | 1096 | command.Parameters.Add(database.CreateParameter("webLoginKey", webLoginKey)); |
1082 | // | ||
1083 | command.Parameters.Add(database.CreateParameter("homeRegionID", homeRegionID)); | 1097 | command.Parameters.Add(database.CreateParameter("homeRegionID", homeRegionID)); |
1084 | command.Parameters.Add(database.CreateParameter("userFlags", userFlags)); | 1098 | command.Parameters.Add(database.CreateParameter("userFlags", userFlags)); |
1085 | command.Parameters.Add(database.CreateParameter("godLevel", godLevel)); | 1099 | command.Parameters.Add(database.CreateParameter("godLevel", godLevel)); |
1086 | command.Parameters.Add(database.CreateParameter("customType", customType)); | 1100 | command.Parameters.Add(database.CreateParameter("customType", customType)); |
1087 | command.Parameters.Add(database.CreateParameter("partner", partnerID)); | 1101 | command.Parameters.Add(database.CreateParameter("partner", partnerID)); |
1088 | |||
1089 | 1102 | ||
1090 | command.ExecuteNonQuery(); | 1103 | command.ExecuteNonQuery(); |
1091 | return; | 1104 | return; |
@@ -1096,7 +1109,6 @@ ELSE | |||
1096 | m_log.Error(e.ToString()); | 1109 | m_log.Error(e.ToString()); |
1097 | return; | 1110 | return; |
1098 | } | 1111 | } |
1099 | |||
1100 | } | 1112 | } |
1101 | 1113 | ||
1102 | /// <summary> | 1114 | /// <summary> |
@@ -1104,7 +1116,7 @@ ELSE | |||
1104 | /// </summary> | 1116 | /// </summary> |
1105 | /// <param name="reader">An active database reader</param> | 1117 | /// <param name="reader">An active database reader</param> |
1106 | /// <returns>A user profile</returns> | 1118 | /// <returns>A user profile</returns> |
1107 | private static UserProfileData ReadUserRow(IDataReader reader) | 1119 | private static UserProfileData ReadUserRow(SqlDataReader reader) |
1108 | { | 1120 | { |
1109 | UserProfileData retval = new UserProfileData(); | 1121 | UserProfileData retval = new UserProfileData(); |
1110 | 1122 | ||
@@ -1149,7 +1161,6 @@ ELSE | |||
1149 | } | 1161 | } |
1150 | return retval; | 1162 | return retval; |
1151 | } | 1163 | } |
1152 | |||
1153 | #endregion | 1164 | #endregion |
1154 | } | 1165 | } |
1155 | 1166 | ||
diff --git a/OpenSim/Data/MSSQL/Resources/005_GridStore.sql b/OpenSim/Data/MSSQL/Resources/005_GridStore.sql new file mode 100644 index 0000000..cee98af --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/005_GridStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN TRANSACTION | ||
2 | |||
3 | ALTER TABLE regions ADD access int default 0; | ||
4 | |||
5 | COMMIT | ||