diff options
author | Homer Horwitz | 2008-11-15 21:27:10 +0000 |
---|---|---|
committer | Homer Horwitz | 2008-11-15 21:27:10 +0000 |
commit | 9a6cdf662b60e7d6f6843826da6a84637d4798b9 (patch) | |
tree | 0ac44924346d5c94b355844ccee83612a3c96ad2 /OpenSim/Data/MSSQL/MSSQLAssetData.cs | |
parent | - Change llSetRot behavior so it matches the SL behavior (in particular, the (diff) | |
download | opensim-SC-9a6cdf662b60e7d6f6843826da6a84637d4798b9.zip opensim-SC-9a6cdf662b60e7d6f6843826da6a84637d4798b9.tar.gz opensim-SC-9a6cdf662b60e7d6f6843826da6a84637d4798b9.tar.bz2 opensim-SC-9a6cdf662b60e7d6f6843826da6a84637d4798b9.tar.xz |
Mantis#2626: Thank you Ruud Lathrop, for a patch that cleans up MSSQL code.
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLAssetData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 75 |
1 files changed, 2 insertions, 73 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 4d5ca1c..2a959fd 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -26,9 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.Data; | 29 | using System.Data; |
31 | using System.Data.SqlClient; | ||
32 | using System.Reflection; | 30 | using System.Reflection; |
33 | using OpenMetaverse; | 31 | using OpenMetaverse; |
34 | using log4net; | 32 | using log4net; |
@@ -57,6 +55,7 @@ namespace OpenSim.Data.MSSQL | |||
57 | /// <summary> | 55 | /// <summary> |
58 | /// <para>Initialises asset interface</para> | 56 | /// <para>Initialises asset interface</para> |
59 | /// </summary> | 57 | /// </summary> |
58 | [Obsolete("Cannot be default-initialized!")] | ||
60 | override public void Initialise() | 59 | override public void Initialise() |
61 | { | 60 | { |
62 | m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!"); | 61 | m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!"); |
@@ -72,7 +71,7 @@ namespace OpenSim.Data.MSSQL | |||
72 | /// <param name="connectionString">connect string</param> | 71 | /// <param name="connectionString">connect string</param> |
73 | override public void Initialise(string connectionString) | 72 | override public void Initialise(string connectionString) |
74 | { | 73 | { |
75 | if (string.IsNullOrEmpty(connectionString)) | 74 | if (!string.IsNullOrEmpty(connectionString)) |
76 | { | 75 | { |
77 | database = new MSSQLManager(connectionString); | 76 | database = new MSSQLManager(connectionString); |
78 | } | 77 | } |
@@ -91,9 +90,6 @@ namespace OpenSim.Data.MSSQL | |||
91 | settingPassword); | 90 | settingPassword); |
92 | } | 91 | } |
93 | 92 | ||
94 | //TODO can be removed at some time!! | ||
95 | TestTables(); | ||
96 | |||
97 | //New migration to check for DB changes | 93 | //New migration to check for DB changes |
98 | database.CheckMigration(_migrationStore); | 94 | database.CheckMigration(_migrationStore); |
99 | } | 95 | } |
@@ -228,72 +224,5 @@ namespace OpenSim.Data.MSSQL | |||
228 | } | 224 | } |
229 | 225 | ||
230 | #endregion | 226 | #endregion |
231 | |||
232 | #region Private Methods | ||
233 | |||
234 | /// <summary> | ||
235 | /// Migration method | ||
236 | /// <list type="bullet"> | ||
237 | /// <item>Execute "CreateAssetsTable.sql" if tableName == null</item> | ||
238 | /// </list> | ||
239 | /// </summary> | ||
240 | /// <param name="tableName">Name of table</param> | ||
241 | private void UpgradeAssetsTable(string tableName) | ||
242 | { | ||
243 | // null as the version, indicates that the table didn't exist | ||
244 | if (tableName == null) | ||
245 | { | ||
246 | m_log.Info("[ASSET DB]: Creating new database tables"); | ||
247 | database.ExecuteResourceSql("CreateAssetsTable.sql"); | ||
248 | return; | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /// <summary> | ||
253 | /// Ensure that the assets related tables exists and are at the latest version | ||
254 | /// </summary> | ||
255 | private void TestTables() | ||
256 | { | ||
257 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | ||
258 | |||
259 | tableList["assets"] = null; | ||
260 | database.GetTableVersion(tableList); | ||
261 | |||
262 | UpgradeAssetsTable(tableList["assets"]); | ||
263 | |||
264 | //Special for Migrations | ||
265 | using (AutoClosingSqlCommand cmd = database.Query("select * from migrations where name = '" + _migrationStore + "'")) | ||
266 | { | ||
267 | try | ||
268 | { | ||
269 | bool insert = true; | ||
270 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
271 | { | ||
272 | if (reader.Read()) insert = false; | ||
273 | } | ||
274 | if (insert) | ||
275 | { | ||
276 | cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)"; | ||
277 | cmd.ExecuteNonQuery(); | ||
278 | } | ||
279 | } | ||
280 | catch | ||
281 | { | ||
282 | //No migrations table | ||
283 | //HACK create one and add data | ||
284 | cmd.CommandText = "create table migrations(name varchar(100), version int)"; | ||
285 | cmd.ExecuteNonQuery(); | ||
286 | |||
287 | cmd.CommandText = "insert into migrations(name, version) values('migrations', 1)"; | ||
288 | cmd.ExecuteNonQuery(); | ||
289 | |||
290 | cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)"; | ||
291 | cmd.ExecuteNonQuery(); | ||
292 | } | ||
293 | } | ||
294 | |||
295 | } | ||
296 | |||
297 | #endregion | ||
298 | } | 227 | } |
299 | } | 228 | } |