aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLGridData.cs
diff options
context:
space:
mode:
authorlbsa712008-04-11 09:56:22 +0000
committerlbsa712008-04-11 09:56:22 +0000
commitcbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c (patch)
treef2172eccc3652e6f5bccc2be3cf71ec838801f47 /OpenSim/Data/MSSQL/MSSQLGridData.cs
parent* Added a "regionload_regionsdir" option to OpenSim.ini which determines wher... (diff)
downloadopensim-SC_OLD-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.zip
opensim-SC_OLD-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.tar.gz
opensim-SC_OLD-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.tar.bz2
opensim-SC_OLD-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.tar.xz
* Discerned between AddProfile and UpdateProfile in region registration
:: Believe it or not, but INSERT/UPDATE is actually a better pattern than REPLACE, since, with INSERT/UPDATE you can catch erroneous UPDATES to non-INSERTed items as well as catch erroneous re-INSERTS. in 95% of the cases, you SHOULD have a clear INSERT context, and a clear and separate UPDATE context. If you think your case falls within the 5%, maybe you should re-evaluate your code. ::
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGridData.cs81
1 files changed, 73 insertions, 8 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs
index 03af53c..5617900 100644
--- a/OpenSim/Data/MSSQL/MSSQLGridData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs
@@ -228,19 +228,19 @@ namespace OpenSim.Data.MSSQL
228 /// <returns>A dataresponse enum indicating success</returns> 228 /// <returns>A dataresponse enum indicating success</returns>
229 override public DataResponse AddProfile(RegionProfileData profile) 229 override public DataResponse AddProfile(RegionProfileData profile)
230 { 230 {
231 try 231 if (insertRegionRow(profile))
232 { 232 {
233 if (GetProfileByLLUUID(profile.UUID) != null) 233 return DataResponse.RESPONSE_OK;
234 {
235 return DataResponse.RESPONSE_OK;
236 }
237 } 234 }
238 catch (Exception) 235 else
239 { 236 {
240 System.Console.WriteLine("No regions found. Create new one."); 237 return DataResponse.RESPONSE_ERROR;
241 } 238 }
239 }
242 240
243 if (insertRegionRow(profile)) 241 public override DataResponse UpdateProfile(RegionProfileData profile)
242 {
243 if (updateRegionRow(profile))
244 { 244 {
245 return DataResponse.RESPONSE_OK; 245 return DataResponse.RESPONSE_OK;
246 } 246 }
@@ -250,6 +250,71 @@ namespace OpenSim.Data.MSSQL
250 } 250 }
251 } 251 }
252 252
253 public bool updateRegionRow(RegionProfileData profile)
254 {
255 //Insert new region
256 string sql =
257 "UPDATE " + m_regionsTableName + @" SET
258 [regionHandle]=@regionHandle, [regionName]=@regionName,
259 [regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
260 [regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
261 [locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
262 [westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
263 [northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
264 [regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
265 [regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
266 [regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
267 [serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid
268 where [uuid]=@uuid";
269
270 Dictionary<string, string> parameters = new Dictionary<string, string>();
271
272 parameters["regionHandle"] = profile.regionHandle.ToString();
273 parameters["regionName"] = profile.regionName;
274 parameters["uuid"] = profile.UUID.ToString();
275 parameters["regionRecvKey"] = profile.regionRecvKey;
276 parameters["regionSecret"] = profile.regionSecret;
277 parameters["regionSendKey"] = profile.regionSendKey;
278 parameters["regionDataURI"] = profile.regionDataURI;
279 parameters["serverIP"] = profile.serverIP;
280 parameters["serverPort"] = profile.serverPort.ToString();
281 parameters["serverURI"] = profile.serverURI;
282 parameters["locX"] = profile.regionLocX.ToString();
283 parameters["locY"] = profile.regionLocY.ToString();
284 parameters["locZ"] = profile.regionLocZ.ToString();
285 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
286 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
287 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
288 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
289 parameters["regionAssetURI"] = profile.regionAssetURI;
290 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
291 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
292 parameters["regionUserURI"] = profile.regionUserURI;
293 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
294 parameters["regionUserSendKey"] = profile.regionUserSendKey;
295 parameters["regionMapTexture"] = profile.regionMapTextureID.ToString();
296 parameters["serverHttpPort"] = profile.httpPort.ToString();
297 parameters["serverRemotingPort"] = profile.remotingPort.ToString();
298 parameters["owner_uuid"] = profile.owner_uuid.ToString();
299
300 bool returnval = false;
301
302 try
303 {
304 IDbCommand result = database.Query(sql, parameters);
305
306 if (result.ExecuteNonQuery() == 1)
307 returnval = true;
308
309 result.Dispose();
310 }
311 catch (Exception e)
312 {
313 m_log.Error("MSSQLManager : " + e.ToString());
314 }
315
316 return returnval;
317 }
253 /// <summary> 318 /// <summary>
254 /// Creates a new region in the database 319 /// Creates a new region in the database
255 /// </summary> 320 /// </summary>