aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLEstateData.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-19 18:09:10 +0000
committerJustin Clarke Casey2009-02-19 18:09:10 +0000
commit07609565617aa7936758acba5fd625877564a10d (patch)
tree73123e37f14fea5f171cbe04753c21758f25afc1 /OpenSim/Data/MSSQL/MSSQLEstateData.cs
parent* Okay, so finally got my head around this. Problem is that upstream Prebuild... (diff)
downloadopensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.zip
opensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.tar.gz
opensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.tar.bz2
opensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=3142
* Changes varchar(36) columns to UUID type in MSSQL - this will be much more efficient * ===As always, please, please backup your database before applying this patch=== * Thanks Ruud Lathrop (for the patch) and StrawberryFride (for the review)
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLEstateData.cs')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLEstateData.cs116
1 files changed, 59 insertions, 57 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
index 815e7ff..4d5c116 100644
--- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Data.MSSQL
106 106
107 using (AutoClosingSqlCommand cmd = _Database.Query(sql)) 107 using (AutoClosingSqlCommand cmd = _Database.Query(sql))
108 { 108 {
109 cmd.Parameters.AddWithValue("@RegionID", regionID.ToString()); 109 cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID));
110 110
111 using (IDataReader reader = cmd.ExecuteReader()) 111 using (IDataReader reader = cmd.ExecuteReader())
112 { 112 {
@@ -124,10 +124,10 @@ namespace OpenSim.Data.MSSQL
124 } 124 }
125 else if (_FieldMap[name].GetValue(es) is UUID) 125 else if (_FieldMap[name].GetValue(es) is UUID)
126 { 126 {
127 UUID uuid; 127// UUID uuid;
128 UUID.TryParse(reader[name].ToString(), out uuid); 128// UUID.TryParse(reader[name].ToString(), out uuid);
129 129
130 _FieldMap[name].SetValue(es, uuid); 130 _FieldMap[name].SetValue(es, new UUID((Guid) reader[name])); // uuid);
131 } 131 }
132 else 132 else
133 { 133 {
@@ -162,28 +162,29 @@ namespace OpenSim.Data.MSSQL
162 162
163 foreach (string name in names) 163 foreach (string name in names)
164 { 164 {
165 if (_FieldMap[name].GetValue(es) is bool) 165 insertCommand.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
166 { 166// if (_FieldMap[name].GetValue(es) is bool)
167 SqlParameter tempBool = new SqlParameter("@" + name, SqlDbType.Bit); 167// {
168 168// SqlParameter tempBool = new SqlParameter("@" + name, SqlDbType.Bit);
169 if ((bool) _FieldMap[name].GetValue(es)) 169//
170 tempBool.Value = 1; 170// if ((bool) _FieldMap[name].GetValue(es))
171 else 171// tempBool.Value = 1;
172 tempBool.Value = 0; 172// else
173 173// tempBool.Value = 0;
174 insertCommand.Parameters.Add(tempBool); 174//
175 } 175// insertCommand.Parameters.Add(tempBool);
176 else 176// }
177 { 177// else
178 //cmd.Parameters.AddWithValue("@" + name, _FieldMap[name].GetValue(es)); 178// {
179 SqlParameter tempPar = new SqlParameter("@" + name, 179// //cmd.Parameters.AddWithValue("@" + name, _FieldMap[name].GetValue(es));
180 _Database.DbtypeFromType(_FieldMap[name].FieldType)); 180// SqlParameter tempPar = new SqlParameter("@" + name,
181 tempPar.Value = _FieldMap[name].GetValue(es).ToString(); 181// _Database.DbtypeFromType(_FieldMap[name].FieldType));
182 182// tempPar.Value = _FieldMap[name].GetValue(es).ToString();
183 insertCommand.Parameters.Add(tempPar); 183//
184 } 184// insertCommand.Parameters.Add(tempPar);
185// }
185 } 186 }
186 187// insertCommand.Parameters.Add(_Database.CreateParameter("@ID", es.EstateID, true));
187 SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int); 188 SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int);
188 idParameter.Direction = ParameterDirection.Output; 189 idParameter.Direction = ParameterDirection.Output;
189 insertCommand.Parameters.Add(idParameter); 190 insertCommand.Parameters.Add(idParameter);
@@ -196,7 +197,7 @@ namespace OpenSim.Data.MSSQL
196 197
197 using (AutoClosingSqlCommand cmd = _Database.Query("INSERT INTO [estate_map] ([RegionID] ,[EstateID]) VALUES (@RegionID, @EstateID)")) 198 using (AutoClosingSqlCommand cmd = _Database.Query("INSERT INTO [estate_map] ([RegionID] ,[EstateID]) VALUES (@RegionID, @EstateID)"))
198 { 199 {
199 cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID.ToString())); 200 cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID));
200 cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID)); 201 cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
201 // This will throw on dupe key 202 // This will throw on dupe key
202 try 203 try
@@ -264,32 +265,33 @@ namespace OpenSim.Data.MSSQL
264 { 265 {
265 foreach (string name in names) 266 foreach (string name in names)
266 { 267 {
267 if (_FieldMap[name].GetValue(es) is bool) 268 cmd.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
268 { 269// if (_FieldMap[name].GetValue(es) is bool)
269 SqlParameter tempBool = new SqlParameter("@" + name, SqlDbType.Bit); 270// {
270 271// SqlParameter tempBool = new SqlParameter("@" + name, SqlDbType.Bit);
271 if ((bool)_FieldMap[name].GetValue(es)) 272//
272 tempBool.Value = 1; 273// if ((bool)_FieldMap[name].GetValue(es))
273 else 274// tempBool.Value = 1;
274 tempBool.Value = 0; 275// else
275 276// tempBool.Value = 0;
276 cmd.Parameters.Add(tempBool); 277//
277 } 278// cmd.Parameters.Add(tempBool);
278 else 279// }
279 { 280// else
280 //cmd.Parameters.AddWithValue("@" + name, _FieldMap[name].GetValue(es)); 281// {
281 SqlParameter tempPar = new SqlParameter("@" + name, 282// //cmd.Parameters.AddWithValue("@" + name, _FieldMap[name].GetValue(es));
282 _Database.DbtypeFromType(_FieldMap[name].FieldType)); 283// SqlParameter tempPar = new SqlParameter("@" + name,
283 tempPar.Value = _FieldMap[name].GetValue(es).ToString(); 284// _Database.DbtypeFromType(_FieldMap[name].FieldType));
284 285// tempPar.Value = _FieldMap[name].GetValue(es).ToString();
285 cmd.Parameters.Add(tempPar); 286//
286 } 287// cmd.Parameters.Add(tempPar);
288// }
287 } 289 }
288 290
289 291 cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
290 SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int); 292// SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int);
291 idParameter.Value = es.EstateID; 293// idParameter.Value = es.EstateID;
292 cmd.Parameters.Add(idParameter); 294// cmd.Parameters.Add(idParameter);
293 295
294 cmd.ExecuteNonQuery(); 296 cmd.ExecuteNonQuery();
295 } 297 }
@@ -327,10 +329,10 @@ namespace OpenSim.Data.MSSQL
327 { 329 {
328 EstateBan eb = new EstateBan(); 330 EstateBan eb = new EstateBan();
329 331
330 UUID uuid; 332// UUID uuid;
331 UUID.TryParse(reader["bannedUUID"].ToString(), out uuid); 333// UUID.TryParse(reader["bannedUUID"].ToString(), out uuid);
332 334
333 eb.bannedUUID = uuid; 335 eb.bannedUUID = new UUID((Guid)reader["bannedUUID"]); //uuid;
334 eb.bannedIP = "0.0.0.0"; 336 eb.bannedIP = "0.0.0.0";
335 eb.bannedIPHostMask = "0.0.0.0"; 337 eb.bannedIPHostMask = "0.0.0.0";
336 es.AddBan(eb); 338 es.AddBan(eb);
@@ -355,10 +357,10 @@ namespace OpenSim.Data.MSSQL
355 { 357 {
356 // EstateBan eb = new EstateBan(); 358 // EstateBan eb = new EstateBan();
357 359
358 UUID uuid; 360// UUID uuid;
359 UUID.TryParse(reader["uuid"].ToString(), out uuid); 361// UUID.TryParse(reader["uuid"].ToString(), out uuid);
360 362
361 uuids.Add(uuid); 363 uuids.Add(new UUID((Guid)reader["uuid"])); //uuid);
362 } 364 }
363 } 365 }
364 } 366 }
@@ -418,7 +420,7 @@ namespace OpenSim.Data.MSSQL
418 createParamOnce = false; 420 createParamOnce = false;
419 } 421 }
420 else 422 else
421 cmd.Parameters["@uuid"].Value = uuid.ToString(); 423 cmd.Parameters["@uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works
422 424
423 cmd.ExecuteNonQuery(); 425 cmd.ExecuteNonQuery();
424 } 426 }