aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorSean Dague2008-08-27 18:51:36 +0000
committerSean Dague2008-08-27 18:51:36 +0000
commit53afa236086c31663cfbae1f2c906e135b44c96b (patch)
treea3f5bfac53454f56f7dcec118772192f3ea6db07 /OpenSim/Data
parentMake the check on inventory cache clearing more robust. Addresses (diff)
downloadopensim-SC_OLD-53afa236086c31663cfbae1f2c906e135b44c96b.zip
opensim-SC_OLD-53afa236086c31663cfbae1f2c906e135b44c96b.tar.gz
opensim-SC_OLD-53afa236086c31663cfbae1f2c906e135b44c96b.tar.bz2
opensim-SC_OLD-53afa236086c31663cfbae1f2c906e135b44c96b.tar.xz
we're past checkin 6000, so now cleaning up all the cruft of the pre
migration database upgrade paths. This is coming in in stages.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs305
1 files changed, 3 insertions, 302 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index f6b49af..5c86570 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -138,13 +138,9 @@ namespace OpenSim.Data.MySQL
138 // This actually does the roll forward assembly stuff 138 // This actually does the roll forward assembly stuff
139 Assembly assem = GetType().Assembly; 139 Assembly assem = GetType().Assembly;
140 Migration m = new Migration(m_connection, assem, "RegionStore"); 140 Migration m = new Migration(m_connection, assem, "RegionStore");
141
142 // TODO: After rev 6000, remove this. People should have
143 // been rolled onto the new migration code by then.
144 TestTables(m_connection, m);
145
146 m.Update(); 141 m.Update();
147 142
143
148 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); 144 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
149 m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); 145 m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
150 146
@@ -166,6 +162,7 @@ namespace OpenSim.Data.MySQL
166 MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); 162 MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection);
167 m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); 163 m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd);
168 164
165 // TODO: move out the ADO.NET pieces here and just go to the db directly
169 lock (m_dataSet) 166 lock (m_dataSet)
170 { 167 {
171 m_primTable = createPrimTable(); 168 m_primTable = createPrimTable();
@@ -294,18 +291,6 @@ namespace OpenSim.Data.MySQL
294 } 291 }
295 } 292 }
296 } 293 }
297 // private void TestTablesVersionable(MySqlConnection dbconn)
298 // {
299 // Dictionary<string, string> tableList = new Dictionary<string, string>();
300
301 // tableList["land"] = null;
302 // dbconn.Open();
303 // GetTableVersion(tableList,dbconn);
304
305 // UpgradeLandTable(tableList["land"], dbconn);
306 // //database.Close();
307
308 // }
309 294
310 /// <summary> 295 /// <summary>
311 /// Execute a SQL statement stored in a resource, as a string 296 /// Execute a SQL statement stored in a resource, as a string
@@ -346,28 +331,6 @@ namespace OpenSim.Data.MySQL
346 } 331 }
347 332
348 /// <summary> 333 /// <summary>
349 /// <list type="bullet">
350 /// <item>Execute CreateLandTable.sql if oldVersion == null</item>
351 /// <item>Execute UpgradeLandTable.sqm if oldVersion contain "Rev."</item>
352 /// </list>
353 /// </summary>
354 /// <param name="oldVersion"></param>
355 /// <param name="dbconn">The database connection handler</param>
356 // private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn)
357 // {
358 // // null as the version, indicates that the table didn't exist
359 // if (oldVersion == null)
360 // {
361 // ExecuteResourceSql("CreateLandTable.sql",dbconn);
362 // oldVersion = "Rev. 2; InnoDB free: 0 kB";
363 // }
364 // if (!oldVersion.Contains("Rev."))
365 // {
366 // ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn);
367 // }
368 // }
369
370 /// <summary>
371 /// Adds an object into region storage 334 /// Adds an object into region storage
372 /// </summary> 335 /// </summary>
373 /// <param name="obj">The object</param> 336 /// <param name="obj">The object</param>
@@ -816,7 +779,7 @@ namespace OpenSim.Data.MySQL
816 m_primDataAdapter.Update(m_primTable); 779 m_primDataAdapter.Update(m_primTable);
817 m_shapeDataAdapter.Update(m_shapeTable); 780 m_shapeDataAdapter.Update(m_shapeTable);
818 781
819 m_itemsDataAdapter.Update(m_itemsTable); 782 m_itemsDataAdapter.Update(m_itemsTable);
820 783
821 m_terrainDataAdapter.Update(m_terrainTable); 784 m_terrainDataAdapter.Update(m_terrainTable);
822 m_landDataAdapter.Update(m_landTable); 785 m_landDataAdapter.Update(m_landTable);
@@ -2005,36 +1968,6 @@ namespace OpenSim.Data.MySQL
2005 return cmd; 1968 return cmd;
2006 } 1969 }
2007 1970
2008 /// <summary>
2009 ///
2010 /// </summary>
2011 /// <param name="dt"></param>
2012 /// <returns></returns>
2013 // private static string defineTable(DataTable dt)
2014 // {
2015 // string sql = "create table " + dt.TableName + "(";
2016 // string subsql = String.Empty;
2017 // foreach (DataColumn col in dt.Columns)
2018 // {
2019 // if (subsql.Length > 0)
2020 // {
2021 // // a map function would rock so much here
2022 // subsql += ",\n";
2023 // }
2024 // subsql += col.ColumnName + " " + MySqlType(col.DataType);
2025 // if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0])
2026 // {
2027 // subsql += " primary key";
2028 // }
2029 // }
2030 // sql += subsql;
2031 // sql += ")";
2032
2033 // //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql);
2034
2035 // return sql;
2036 // }
2037
2038 /*********************************************************************** 1971 /***********************************************************************
2039 * 1972 *
2040 * Database Binding functions 1973 * Database Binding functions
@@ -2176,206 +2109,6 @@ namespace OpenSim.Data.MySQL
2176 da.DeleteCommand = delete; 2109 da.DeleteCommand = delete;
2177 } 2110 }
2178 2111
2179 /// <summary>
2180 ///
2181 /// </summary>
2182 /// <param name="conn">MySQL connection handler</param>
2183 // private static void InitDB(MySqlConnection conn)
2184 // {
2185 // string createPrims = defineTable(createPrimTable());
2186 // string createShapes = defineTable(createShapeTable());
2187 // string createItems = defineTable(createItemsTable());
2188 // string createTerrain = defineTable(createTerrainTable());
2189
2190 // // Land table is created from the Versionable Test Table routine now.
2191 // //string createLand = defineTable(createLandTable());
2192 // string createLandAccessList = defineTable(createLandAccessListTable());
2193
2194 // MySqlCommand pcmd = new MySqlCommand(createPrims, conn);
2195 // MySqlCommand scmd = new MySqlCommand(createShapes, conn);
2196 // MySqlCommand icmd = new MySqlCommand(createItems, conn);
2197 // MySqlCommand tcmd = new MySqlCommand(createTerrain, conn);
2198 // //MySqlCommand lcmd = new MySqlCommand(createLand, conn);
2199 // MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn);
2200
2201 // if (conn.State != ConnectionState.Open)
2202 // {
2203 // try
2204 // {
2205 // conn.Open();
2206 // }
2207 // catch (Exception ex)
2208 // {
2209 // m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message);
2210 // m_log.Error("[REGION DB]: Application is terminating!");
2211 // Thread.CurrentThread.Abort();
2212 // }
2213 // }
2214
2215 // try
2216 // {
2217 // pcmd.ExecuteNonQuery();
2218 // }
2219 // catch (MySqlException e)
2220 // {
2221 // m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e);
2222 // }
2223
2224 // try
2225 // {
2226 // scmd.ExecuteNonQuery();
2227 // }
2228 // catch (MySqlException e)
2229 // {
2230 // m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e);
2231 // }
2232
2233 // try
2234 // {
2235 // icmd.ExecuteNonQuery();
2236 // }
2237 // catch (MySqlException e)
2238 // {
2239 // m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e);
2240 // }
2241
2242 // try
2243 // {
2244 // tcmd.ExecuteNonQuery();
2245 // }
2246 // catch (MySqlException e)
2247 // {
2248 // m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e);
2249 // }
2250
2251 // //try
2252 // //{
2253 // //lcmd.ExecuteNonQuery();
2254 // //}
2255 // //catch (MySqlException e)
2256 // //{
2257 // //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e);
2258 // //}
2259
2260 // try
2261 // {
2262 // lalcmd.ExecuteNonQuery();
2263 // }
2264 // catch (MySqlException e)
2265 // {
2266 // m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e);
2267 // }
2268 // conn.Close();
2269 // }
2270
2271 /// <summary>
2272 ///
2273 /// </summary>
2274 /// <param name="conn"></param>
2275 /// <param name="m"></param>
2276 /// <returns></returns>
2277 private bool TestTables(MySqlConnection conn, Migration m)
2278 {
2279 // we already have migrations, get out of here
2280 if (m.Version > 0)
2281 return false;
2282
2283 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn);
2284 MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd);
2285 MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn);
2286 MySqlDataAdapter sDa = new MySqlDataAdapter(shapeSelectCmd);
2287 MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, conn);
2288 MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd);
2289 MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, conn);
2290 MySqlDataAdapter tDa = new MySqlDataAdapter(terrainSelectCmd);
2291 MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, conn);
2292 MySqlDataAdapter lDa = new MySqlDataAdapter(landSelectCmd);
2293 MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, conn);
2294 MySqlDataAdapter lalDa = new MySqlDataAdapter(landAccessListSelectCmd);
2295
2296 DataSet tmpDS = new DataSet();
2297 try
2298 {
2299 pDa.Fill(tmpDS, "prims");
2300 sDa.Fill(tmpDS, "primshapes");
2301
2302 iDa.Fill(tmpDS, "primitems");
2303
2304 tDa.Fill(tmpDS, "terrain");
2305 lDa.Fill(tmpDS, "land");
2306 lalDa.Fill(tmpDS, "landaccesslist");
2307 }
2308 catch (MySqlException)
2309 {
2310 m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating");
2311 return false;
2312 }
2313
2314 // we have tables, but not a migration model yet
2315 if (m.Version == 0)
2316 m.Version = 1;
2317
2318 return true;
2319
2320 // pDa.Fill(tmpDS, "prims");
2321 // sDa.Fill(tmpDS, "primshapes");
2322
2323 // iDa.Fill(tmpDS, "primitems");
2324
2325 // tDa.Fill(tmpDS, "terrain");
2326 // lDa.Fill(tmpDS, "land");
2327 // lalDa.Fill(tmpDS, "landaccesslist");
2328
2329 // foreach (DataColumn col in createPrimTable().Columns)
2330 // {
2331 // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
2332 // {
2333 // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
2334 // return false;
2335 // }
2336 // }
2337
2338 // foreach (DataColumn col in createShapeTable().Columns)
2339 // {
2340 // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
2341 // {
2342 // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
2343 // return false;
2344 // }
2345 // }
2346
2347 // // XXX primitems should probably go here eventually
2348
2349 // foreach (DataColumn col in createTerrainTable().Columns)
2350 // {
2351 // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
2352 // {
2353 // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
2354 // return false;
2355 // }
2356 // }
2357
2358 // foreach (DataColumn col in createLandTable().Columns)
2359 // {
2360 // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
2361 // {
2362 // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
2363 // return false;
2364 // }
2365 // }
2366
2367 // foreach (DataColumn col in createLandAccessListTable().Columns)
2368 // {
2369 // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
2370 // {
2371 // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
2372 // return false;
2373 // }
2374 // }
2375
2376 // return true;
2377 }
2378
2379 /*********************************************************************** 2112 /***********************************************************************
2380 * 2113 *
2381 * Type conversion functions 2114 * Type conversion functions
@@ -2419,37 +2152,5 @@ namespace OpenSim.Data.MySQL
2419 } 2152 }
2420 } 2153 }
2421 2154
2422 /// <summary>
2423 /// </summary>
2424 /// <param name="type"></param>
2425 /// <returns></returns>
2426 /// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
2427 // private static string MySqlType(Type type)
2428 // {
2429 // if (type == typeof (String))
2430 // {
2431 // return "varchar(255)";
2432 // }
2433 // else if (type == typeof (Int32))
2434 // {
2435 // return "integer";
2436 // }
2437 // else if (type == typeof (Int64))
2438 // {
2439 // return "bigint";
2440 // }
2441 // else if (type == typeof (Double))
2442 // {
2443 // return "float";
2444 // }
2445 // else if (type == typeof (Byte[]))
2446 // {
2447 // return "longblob";
2448 // }
2449 // else
2450 // {
2451 // return "string";
2452 // }
2453 // }
2454 } 2155 }
2455} 2156}