aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
authorJeff Ames2008-06-26 12:38:03 +0000
committerJeff Ames2008-06-26 12:38:03 +0000
commitca724636d4615c6c58d3830fa8ccd620250886ea (patch)
treef7ed9fa821879d378a627e0f2a62d19d6836d873 /OpenSim/Data/MySQL/MySQLDataStore.cs
parentMantis#1595. Thank you, Melanie for a patch that: (diff)
downloadopensim-SC-ca724636d4615c6c58d3830fa8ccd620250886ea.zip
opensim-SC-ca724636d4615c6c58d3830fa8ccd620250886ea.tar.gz
opensim-SC-ca724636d4615c6c58d3830fa8ccd620250886ea.tar.bz2
opensim-SC-ca724636d4615c6c58d3830fa8ccd620250886ea.tar.xz
Apply patch from bug #1601 -- more documentation for Data/MySQL. Thanks kerunix_Flan!
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLDataStore.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLDataStore.cs259
1 files changed, 223 insertions, 36 deletions
diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs
index 2b4702b..aa4c111 100644
--- a/OpenSim/Data/MySQL/MySQLDataStore.cs
+++ b/OpenSim/Data/MySQL/MySQLDataStore.cs
@@ -40,6 +40,9 @@ using OpenSim.Region.Environment.Scenes;
40 40
41namespace OpenSim.Data.MySQL 41namespace OpenSim.Data.MySQL
42{ 42{
43 /// <summary>
44 /// A MySQL Interface for the Region Server
45 /// </summary>
43 public class MySQLDataStore : IRegionDataStore 46 public class MySQLDataStore : IRegionDataStore
44 { 47 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -76,7 +79,7 @@ namespace OpenSim.Data.MySQL
76 private DataTable m_landAccessListTable; 79 private DataTable m_landAccessListTable;
77 private DataTable m_regionBanListTable; 80 private DataTable m_regionBanListTable;
78 81
79 // Temporary attribute while this is experimental 82 /// <value>Temporary attribute while this is experimental</value>
80 private bool persistPrimInventories; 83 private bool persistPrimInventories;
81 84
82 /*********************************************************************** 85 /***********************************************************************
@@ -177,7 +180,8 @@ namespace OpenSim.Data.MySQL
177 /// <summary> 180 /// <summary>
178 /// Given a list of tables, return the version of the tables, as seen in the database 181 /// Given a list of tables, return the version of the tables, as seen in the database
179 /// </summary> 182 /// </summary>
180 /// <param name="tableList"></param> 183 /// <param name="tableList">The list of table</param>
184 /// <param name="dbcon">The database connection handler</param>
181 public void GetTableVersion(Dictionary<string, string> tableList, MySqlConnection dbcon) 185 public void GetTableVersion(Dictionary<string, string> tableList, MySqlConnection dbcon)
182 { 186 {
183 lock (dbcon) 187 lock (dbcon)
@@ -226,6 +230,7 @@ namespace OpenSim.Data.MySQL
226 /// Execute a SQL statement stored in a resource, as a string 230 /// Execute a SQL statement stored in a resource, as a string
227 /// </summary> 231 /// </summary>
228 /// <param name="name">the ressource name</param> 232 /// <param name="name">the ressource name</param>
233 /// <param name="dbcon">The database connection handler</param>
229 public void ExecuteResourceSql(string name, MySqlConnection dbcon) 234 public void ExecuteResourceSql(string name, MySqlConnection dbcon)
230 { 235 {
231 MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); 236 MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon);
@@ -260,9 +265,13 @@ namespace OpenSim.Data.MySQL
260 } 265 }
261 266
262 /// <summary> 267 /// <summary>
268 /// <list type="bullet">
269 /// <item>Execute CreateLandTable.sql if oldVersion == null</item>
270 /// <item>Execute UpgradeLandTable.sqm if oldVersion contain "Rev."</item>
271 /// </list>
263 /// </summary> 272 /// </summary>
264 /// <param name="oldVersion"></param> 273 /// <param name="oldVersion"></param>
265 /// <param name="dbconn"></param> 274 /// <param name="dbconn">The database connection handler</param>
266 private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) 275 private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn)
267 { 276 {
268 // null as the version, indicates that the table didn't exist 277 // null as the version, indicates that the table didn't exist
@@ -280,8 +289,8 @@ namespace OpenSim.Data.MySQL
280 /// <summary> 289 /// <summary>
281 /// Adds an object into region storage 290 /// Adds an object into region storage
282 /// </summary> 291 /// </summary>
283 /// <param name="obj"></param> 292 /// <param name="obj">The object</param>
284 /// <param name="regionUUID"></param> 293 /// <param name="regionUUID">The region UUID</param>
285 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) 294 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
286 { 295 {
287 lock (m_dataSet) 296 lock (m_dataSet)
@@ -307,8 +316,8 @@ namespace OpenSim.Data.MySQL
307 /// <summary> 316 /// <summary>
308 /// removes an object from region storage 317 /// removes an object from region storage
309 /// </summary> 318 /// </summary>
310 /// <param name="obj"></param> 319 /// <param name="obj">The object</param>
311 /// <param name="regionUUID"></param> 320 /// <param name="regionUUID">The Region UUID</param>
312 public void RemoveObject(LLUUID obj, LLUUID regionUUID) 321 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
313 { 322 {
314 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); 323 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID);
@@ -362,6 +371,7 @@ namespace OpenSim.Data.MySQL
362 /// Load persisted objects from region storage. 371 /// Load persisted objects from region storage.
363 /// </summary> 372 /// </summary>
364 /// <param name="regionUUID">the Region UUID</param> 373 /// <param name="regionUUID">the Region UUID</param>
374 /// <returns>List of loaded groups</returns>
365 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) 375 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
366 { 376 {
367 Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>(); 377 Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>();
@@ -448,7 +458,7 @@ namespace OpenSim.Data.MySQL
448 /// <summary> 458 /// <summary>
449 /// Load in a prim's persisted inventory. 459 /// Load in a prim's persisted inventory.
450 /// </summary> 460 /// </summary>
451 /// <param name="prim"></param> 461 /// <param name="prim">The prim</param>
452 private void LoadItems(SceneObjectPart prim) 462 private void LoadItems(SceneObjectPart prim)
453 { 463 {
454 lock (m_dataSet) 464 lock (m_dataSet)
@@ -484,7 +494,7 @@ namespace OpenSim.Data.MySQL
484 /// <summary> 494 /// <summary>
485 /// Store a terrain revision in region storage 495 /// Store a terrain revision in region storage
486 /// </summary> 496 /// </summary>
487 /// <param name="ter">terrain data</param> 497 /// <param name="ter">HeightField data</param>
488 /// <param name="regionID">region UUID</param> 498 /// <param name="regionID">region UUID</param>
489 public void StoreTerrain(double[,] ter, LLUUID regionID) 499 public void StoreTerrain(double[,] ter, LLUUID regionID)
490 { 500 {
@@ -513,7 +523,7 @@ namespace OpenSim.Data.MySQL
513 /// Load the latest terrain revision from region storage 523 /// Load the latest terrain revision from region storage
514 /// </summary> 524 /// </summary>
515 /// <param name="regionID">the region UUID</param> 525 /// <param name="regionID">the region UUID</param>
516 /// <returns></returns> 526 /// <returns>Heightfield data</returns>
517 public double[,] LoadTerrain(LLUUID regionID) 527 public double[,] LoadTerrain(LLUUID regionID)
518 { 528 {
519 double[,] terret = new double[256,256]; 529 double[,] terret = new double[256,256];
@@ -563,8 +573,10 @@ namespace OpenSim.Data.MySQL
563 } 573 }
564 574
565 /// <summary> 575 /// <summary>
566 /// delete from land where UUID=globalID 576 /// <list type="bullet">
567 /// delete from landaccesslist where LandUUID=globalID 577 /// <item>delete from land where UUID=globalID</item>
578 /// <item>delete from landaccesslist where LandUUID=globalID</item>
579 /// </list>
568 /// </summary> 580 /// </summary>
569 /// <param name="globalID"></param> 581 /// <param name="globalID"></param>
570 public void RemoveLandObject(LLUUID globalID) 582 public void RemoveLandObject(LLUUID globalID)
@@ -629,10 +641,10 @@ namespace OpenSim.Data.MySQL
629 } 641 }
630 642
631 /// <summary> 643 /// <summary>
632 /// 644 /// Load (fetch?) a region banlist
633 /// </summary> 645 /// </summary>
634 /// <param name="regionUUID"></param> 646 /// <param name="regionUUID">The region UUID</param>
635 /// <returns></returns> 647 /// <returns>The Region banlist</returns>
636 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID) 648 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
637 { 649 {
638 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>(); 650 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
@@ -660,9 +672,9 @@ namespace OpenSim.Data.MySQL
660 } 672 }
661 673
662 /// <summary> 674 /// <summary>
663 /// 675 /// Add an item to region banlist
664 /// </summary> 676 /// </summary>
665 /// <param name="item"></param> 677 /// <param name="item">The item</param>
666 public void AddToRegionBanlist(RegionBanListItem item) 678 public void AddToRegionBanlist(RegionBanListItem item)
667 { 679 {
668 lock (m_dataSet) 680 lock (m_dataSet)
@@ -684,9 +696,9 @@ namespace OpenSim.Data.MySQL
684 } 696 }
685 697
686 /// <summary> 698 /// <summary>
687 /// 699 /// Remove an item from region banlist
688 /// </summary> 700 /// </summary>
689 /// <param name="item"></param> 701 /// <param name="item">The item</param>
690 public void RemoveFromRegionBanlist(RegionBanListItem item) 702 public void RemoveFromRegionBanlist(RegionBanListItem item)
691 { 703 {
692 lock (m_dataSet) 704 lock (m_dataSet)
@@ -783,7 +795,7 @@ namespace OpenSim.Data.MySQL
783 } 795 }
784 796
785 /// <summary> 797 /// <summary>
786 /// 798 /// See <see cref="Commit"/>
787 /// </summary> 799 /// </summary>
788 public void Shutdown() 800 public void Shutdown()
789 { 801 {
@@ -798,6 +810,13 @@ namespace OpenSim.Data.MySQL
798 * 810 *
799 **********************************************************************/ 811 **********************************************************************/
800 812
813 /// <summary>
814 ///
815 /// </summary>
816 /// <param name="dt"></param>
817 /// <param name="name"></param>
818 /// <param name="type"></param>
819 /// <returns></returns>
801 private static DataColumn createCol(DataTable dt, string name, Type type) 820 private static DataColumn createCol(DataTable dt, string name, Type type)
802 { 821 {
803 DataColumn col = new DataColumn(name, type); 822 DataColumn col = new DataColumn(name, type);
@@ -805,6 +824,10 @@ namespace OpenSim.Data.MySQL
805 return col; 824 return col;
806 } 825 }
807 826
827 /// <summary>
828 /// Create the "terrain" table
829 /// </summary>
830 /// <returns></returns>
808 private static DataTable createTerrainTable() 831 private static DataTable createTerrainTable()
809 { 832 {
810 DataTable terrain = new DataTable("terrain"); 833 DataTable terrain = new DataTable("terrain");
@@ -815,6 +838,10 @@ namespace OpenSim.Data.MySQL
815 return terrain; 838 return terrain;
816 } 839 }
817 840
841 /// <summary>
842 /// Create the "regionban" table
843 /// </summary>
844 /// <returns></returns>
818 private static DataTable createRegionBanTable() 845 private static DataTable createRegionBanTable()
819 { 846 {
820 DataTable regionban = new DataTable("regionban"); 847 DataTable regionban = new DataTable("regionban");
@@ -826,6 +853,10 @@ namespace OpenSim.Data.MySQL
826 853
827 } 854 }
828 855
856 /// <summary>
857 /// Create the "prims" table
858 /// </summary>
859 /// <returns></returns>
829 private static DataTable createPrimTable() 860 private static DataTable createPrimTable()
830 { 861 {
831 DataTable prims = new DataTable("prims"); 862 DataTable prims = new DataTable("prims");
@@ -890,6 +921,10 @@ namespace OpenSim.Data.MySQL
890 return prims; 921 return prims;
891 } 922 }
892 923
924 /// <summary>
925 /// Create the "land" table
926 /// </summary>
927 /// <returns></returns>
893 private static DataTable createLandTable() 928 private static DataTable createLandTable()
894 { 929 {
895 DataTable land = new DataTable("land"); 930 DataTable land = new DataTable("land");
@@ -934,6 +969,10 @@ namespace OpenSim.Data.MySQL
934 return land; 969 return land;
935 } 970 }
936 971
972 /// <summary>
973 /// Create the "landaccesslist" table
974 /// </summary>
975 /// <returns></returns>
937 private static DataTable createLandAccessListTable() 976 private static DataTable createLandAccessListTable()
938 { 977 {
939 DataTable landaccess = new DataTable("landaccesslist"); 978 DataTable landaccess = new DataTable("landaccesslist");
@@ -944,6 +983,10 @@ namespace OpenSim.Data.MySQL
944 return landaccess; 983 return landaccess;
945 } 984 }
946 985
986 /// <summary>
987 /// Create the "primshapes" table
988 /// </summary>
989 /// <returns></returns>
947 private static DataTable createShapeTable() 990 private static DataTable createShapeTable()
948 { 991 {
949 DataTable shapes = new DataTable("primshapes"); 992 DataTable shapes = new DataTable("primshapes");
@@ -984,6 +1027,10 @@ namespace OpenSim.Data.MySQL
984 return shapes; 1027 return shapes;
985 } 1028 }
986 1029
1030 /// <summary>
1031 /// Create the "primitems" table
1032 /// </summary>
1033 /// <returns></returns>
987 private static DataTable createItemsTable() 1034 private static DataTable createItemsTable()
988 { 1035 {
989 DataTable items = new DataTable("primitems"); 1036 DataTable items = new DataTable("primitems");
@@ -1025,6 +1072,11 @@ namespace OpenSim.Data.MySQL
1025 * 1072 *
1026 **********************************************************************/ 1073 **********************************************************************/
1027 1074
1075 /// <summary>
1076 ///
1077 /// </summary>
1078 /// <param name="row"></param>
1079 /// <returns></returns>
1028 private SceneObjectPart buildPrim(DataRow row) 1080 private SceneObjectPart buildPrim(DataRow row)
1029 { 1081 {
1030 SceneObjectPart prim = new SceneObjectPart(); 1082 SceneObjectPart prim = new SceneObjectPart();
@@ -1153,6 +1205,11 @@ namespace OpenSim.Data.MySQL
1153 return taskItem; 1205 return taskItem;
1154 } 1206 }
1155 1207
1208 /// <summary>
1209 ///
1210 /// </summary>
1211 /// <param name="row"></param>
1212 /// <returns></returns>
1156 private static LandData buildLandData(DataRow row) 1213 private static LandData buildLandData(DataRow row)
1157 { 1214 {
1158 LandData newData = new LandData(); 1215 LandData newData = new LandData();
@@ -1214,6 +1271,11 @@ namespace OpenSim.Data.MySQL
1214 return newData; 1271 return newData;
1215 } 1272 }
1216 1273
1274 /// <summary>
1275 ///
1276 /// </summary>
1277 /// <param name="row"></param>
1278 /// <returns></returns>
1217 private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) 1279 private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row)
1218 { 1280 {
1219 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 1281 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
@@ -1223,6 +1285,11 @@ namespace OpenSim.Data.MySQL
1223 return entry; 1285 return entry;
1224 } 1286 }
1225 1287
1288 /// <summary>
1289 ///
1290 /// </summary>
1291 /// <param name="val"></param>
1292 /// <returns></returns>
1226 private static Array serializeTerrain(double[,] val) 1293 private static Array serializeTerrain(double[,] val)
1227 { 1294 {
1228 MemoryStream str = new MemoryStream(65536*sizeof (double)); 1295 MemoryStream str = new MemoryStream(65536*sizeof (double));
@@ -1242,6 +1309,13 @@ namespace OpenSim.Data.MySQL
1242 return str.ToArray(); 1309 return str.ToArray();
1243 } 1310 }
1244 1311
1312 /// <summary>
1313 ///
1314 /// </summary>
1315 /// <param name="row"></param>
1316 /// <param name="prim"></param>
1317 /// <param name="sceneGroupID"></param>
1318 /// <param name="regionUUID"></param>
1245 private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) 1319 private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID)
1246 { 1320 {
1247 row["UUID"] = Util.ToRawUuidString(prim.UUID); 1321 row["UUID"] = Util.ToRawUuidString(prim.UUID);
@@ -1318,6 +1392,11 @@ namespace OpenSim.Data.MySQL
1318 } 1392 }
1319 } 1393 }
1320 1394
1395 /// <summary>
1396 ///
1397 /// </summary>
1398 /// <param name="row"></param>
1399 /// <param name="taskItem"></param>
1321 private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) 1400 private static void fillItemRow(DataRow row, TaskInventoryItem taskItem)
1322 { 1401 {
1323 row["itemID"] = taskItem.ItemID; 1402 row["itemID"] = taskItem.ItemID;
@@ -1343,6 +1422,12 @@ namespace OpenSim.Data.MySQL
1343 row["flags"] = taskItem.Flags; 1422 row["flags"] = taskItem.Flags;
1344 } 1423 }
1345 1424
1425 /// <summary>
1426 ///
1427 /// </summary>
1428 /// <param name="row"></param>
1429 /// <param name="land"></param>
1430 /// <param name="regionUUID"></param>
1346 private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) 1431 private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)
1347 { 1432 {
1348 row["UUID"] = Util.ToRawUuidString(land.globalID); 1433 row["UUID"] = Util.ToRawUuidString(land.globalID);
@@ -1382,6 +1467,12 @@ namespace OpenSim.Data.MySQL
1382 row["AuthBuyerID"] = land.authBuyerID; 1467 row["AuthBuyerID"] = land.authBuyerID;
1383 } 1468 }
1384 1469
1470 /// <summary>
1471 ///
1472 /// </summary>
1473 /// <param name="row"></param>
1474 /// <param name="entry"></param>
1475 /// <param name="parcelID"></param>
1385 private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) 1476 private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID)
1386 { 1477 {
1387 row["LandUUID"] = Util.ToRawUuidString(parcelID); 1478 row["LandUUID"] = Util.ToRawUuidString(parcelID);
@@ -1389,6 +1480,11 @@ namespace OpenSim.Data.MySQL
1389 row["Flags"] = entry.Flags; 1480 row["Flags"] = entry.Flags;
1390 } 1481 }
1391 1482
1483 /// <summary>
1484 ///
1485 /// </summary>
1486 /// <param name="row"></param>
1487 /// <returns></returns>
1392 private PrimitiveBaseShape buildShape(DataRow row) 1488 private PrimitiveBaseShape buildShape(DataRow row)
1393 { 1489 {
1394 PrimitiveBaseShape s = new PrimitiveBaseShape(); 1490 PrimitiveBaseShape s = new PrimitiveBaseShape();
@@ -1447,6 +1543,11 @@ namespace OpenSim.Data.MySQL
1447 return s; 1543 return s;
1448 } 1544 }
1449 1545
1546 /// <summary>
1547 ///
1548 /// </summary>
1549 /// <param name="row"></param>
1550 /// <param name="prim"></param>
1450 private void fillShapeRow(DataRow row, SceneObjectPart prim) 1551 private void fillShapeRow(DataRow row, SceneObjectPart prim)
1451 { 1552 {
1452 PrimitiveBaseShape s = prim.Shape; 1553 PrimitiveBaseShape s = prim.Shape;
@@ -1502,6 +1603,12 @@ namespace OpenSim.Data.MySQL
1502 } 1603 }
1503 } 1604 }
1504 1605
1606 /// <summary>
1607 ///
1608 /// </summary>
1609 /// <param name="prim"></param>
1610 /// <param name="sceneGroupID"></param>
1611 /// <param name="regionUUID"></param>
1505 private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) 1612 private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID)
1506 { 1613 {
1507 lock (m_dataSet) 1614 lock (m_dataSet)
@@ -1535,7 +1642,11 @@ namespace OpenSim.Data.MySQL
1535 } 1642 }
1536 } 1643 }
1537 1644
1538 // see IRegionDatastore 1645 /// <summary>
1646 /// see IRegionDatastore
1647 /// </summary>
1648 /// <param name="primID"></param>
1649 /// <param name="items"></param>
1539 public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items) 1650 public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items)
1540 { 1651 {
1541 if (!persistPrimInventories) 1652 if (!persistPrimInventories)
@@ -1576,17 +1687,24 @@ namespace OpenSim.Data.MySQL
1576 * 1687 *
1577 **********************************************************************/ 1688 **********************************************************************/
1578 1689
1690 /// <summary>
1691 /// Create a MySQL insert command
1692 /// </summary>
1693 /// <param name="table"></param>
1694 /// <param name="dt"></param>
1695 /// <returns></returns>
1696 /// <remarks>
1697 /// This is subtle enough to deserve some commentary.
1698 /// Instead of doing *lots* and *lots of hardcoded strings
1699 /// for database definitions we'll use the fact that
1700 /// realistically all insert statements look like "insert
1701 /// into A(b, c) values(:b, :c) on the parameterized query
1702 /// front. If we just have a list of b, c, etc... we can
1703 /// generate these strings instead of typing them out.
1704 /// </remarks>
1579 private static MySqlCommand createInsertCommand(string table, DataTable dt) 1705 private static MySqlCommand createInsertCommand(string table, DataTable dt)
1580 { 1706 {
1581 /** 1707
1582 * This is subtle enough to deserve some commentary.
1583 * Instead of doing *lots* and *lots of hardcoded strings
1584 * for database definitions we'll use the fact that
1585 * realistically all insert statements look like "insert
1586 * into A(b, c) values(:b, :c) on the parameterized query
1587 * front. If we just have a list of b, c, etc... we can
1588 * generate these strings instead of typing them out.
1589 */
1590 string[] cols = new string[dt.Columns.Count]; 1708 string[] cols = new string[dt.Columns.Count];
1591 for (int i = 0; i < dt.Columns.Count; i++) 1709 for (int i = 0; i < dt.Columns.Count; i++)
1592 { 1710 {
@@ -1611,6 +1729,13 @@ namespace OpenSim.Data.MySQL
1611 return cmd; 1729 return cmd;
1612 } 1730 }
1613 1731
1732 /// <summary>
1733 /// Create a MySQL update command
1734 /// </summary>
1735 /// <param name="table"></param>
1736 /// <param name="pk"></param>
1737 /// <param name="dt"></param>
1738 /// <returns></returns>
1614 private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) 1739 private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt)
1615 { 1740 {
1616 string sql = "update " + table + " set "; 1741 string sql = "update " + table + " set ";
@@ -1638,6 +1763,11 @@ namespace OpenSim.Data.MySQL
1638 return cmd; 1763 return cmd;
1639 } 1764 }
1640 1765
1766 /// <summary>
1767 ///
1768 /// </summary>
1769 /// <param name="dt"></param>
1770 /// <returns></returns>
1641 private static string defineTable(DataTable dt) 1771 private static string defineTable(DataTable dt)
1642 { 1772 {
1643 string sql = "create table " + dt.TableName + "("; 1773 string sql = "create table " + dt.TableName + "(";
@@ -1673,16 +1803,18 @@ namespace OpenSim.Data.MySQL
1673 **********************************************************************/ 1803 **********************************************************************/
1674 1804
1675 ///<summary> 1805 ///<summary>
1676 /// This is a convenience function that collapses 5 repetitive 1806 /// <para>This is a convenience function that collapses 5 repetitive
1677 /// lines for defining MySqlParameters to 2 parameters: 1807 /// lines for defining MySqlParameters to 2 parameters:
1678 /// column name and database type. 1808 /// column name and database type.
1679 /// 1809 /// </para>
1810 /// <para>
1680 /// It assumes certain conventions like ?param as the param 1811 /// It assumes certain conventions like ?param as the param
1681 /// name to replace in parametrized queries, and that source 1812 /// name to replace in parametrized queries, and that source
1682 /// version is always current version, both of which are fine 1813 /// version is always current version, both of which are fine
1683 /// for us. 1814 /// for us.
1684 ///</summary> 1815 /// </para>
1685 ///<returns>a built MySql parameter</returns> 1816 /// </summary>
1817 /// <returns>a built MySql parameter</returns>
1686 private static MySqlParameter createMySqlParameter(string name, Type type) 1818 private static MySqlParameter createMySqlParameter(string name, Type type)
1687 { 1819 {
1688 MySqlParameter param = new MySqlParameter(); 1820 MySqlParameter param = new MySqlParameter();
@@ -1693,6 +1825,11 @@ namespace OpenSim.Data.MySQL
1693 return param; 1825 return param;
1694 } 1826 }
1695 1827
1828 /// <summary>
1829 ///
1830 /// </summary>
1831 /// <param name="da"></param>
1832 /// <param name="conn"></param>
1696 private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) 1833 private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn)
1697 { 1834 {
1698 MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); 1835 MySqlCommand insertCommand = createInsertCommand("prims", m_primTable);
@@ -1709,6 +1846,11 @@ namespace OpenSim.Data.MySQL
1709 da.DeleteCommand = delete; 1846 da.DeleteCommand = delete;
1710 } 1847 }
1711 1848
1849 /// <summary>
1850 ///
1851 /// </summary>
1852 /// <param name="da"></param>
1853 /// <param name="conn"></param>
1712 private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) 1854 private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn)
1713 { 1855 {
1714 da.InsertCommand = createInsertCommand("primitems", m_itemsTable); 1856 da.InsertCommand = createInsertCommand("primitems", m_itemsTable);
@@ -1722,6 +1864,12 @@ namespace OpenSim.Data.MySQL
1722 delete.Connection = conn; 1864 delete.Connection = conn;
1723 da.DeleteCommand = delete; 1865 da.DeleteCommand = delete;
1724 } 1866 }
1867
1868 /// <summary>
1869 ///
1870 /// </summary>
1871 /// <param name="da"></param>
1872 /// <param name="conn"></param>
1725 private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn) 1873 private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn)
1726 { 1874 {
1727 da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable); 1875 da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable);
@@ -1736,12 +1884,23 @@ namespace OpenSim.Data.MySQL
1736 delete.Connection = conn; 1884 delete.Connection = conn;
1737 da.DeleteCommand = delete; 1885 da.DeleteCommand = delete;
1738 } 1886 }
1887
1888 /// <summary>
1889 ///
1890 /// </summary>
1891 /// <param name="da"></param>
1892 /// <param name="conn"></param>
1739 private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) 1893 private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn)
1740 { 1894 {
1741 da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); 1895 da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]);
1742 da.InsertCommand.Connection = conn; 1896 da.InsertCommand.Connection = conn;
1743 } 1897 }
1744 1898
1899 /// <summary>
1900 ///
1901 /// </summary>
1902 /// <param name="da"></param>
1903 /// <param name="conn"></param>
1745 private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn) 1904 private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn)
1746 { 1905 {
1747 da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); 1906 da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]);
@@ -1751,12 +1910,22 @@ namespace OpenSim.Data.MySQL
1751 da.UpdateCommand.Connection = conn; 1910 da.UpdateCommand.Connection = conn;
1752 } 1911 }
1753 1912
1913 /// <summary>
1914 ///
1915 /// </summary>
1916 /// <param name="da"></param>
1917 /// <param name="conn"></param>
1754 private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn) 1918 private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn)
1755 { 1919 {
1756 da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); 1920 da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]);
1757 da.InsertCommand.Connection = conn; 1921 da.InsertCommand.Connection = conn;
1758 } 1922 }
1759 1923
1924 /// <summary>
1925 ///
1926 /// </summary>
1927 /// <param name="da"></param>
1928 /// <param name="conn"></param>
1760 private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn) 1929 private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn)
1761 { 1930 {
1762 da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); 1931 da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]);
@@ -1771,6 +1940,10 @@ namespace OpenSim.Data.MySQL
1771 da.DeleteCommand = delete; 1940 da.DeleteCommand = delete;
1772 } 1941 }
1773 1942
1943 /// <summary>
1944 ///
1945 /// </summary>
1946 /// <param name="conn">MySQL connection handler</param>
1774 private static void InitDB(MySqlConnection conn) 1947 private static void InitDB(MySqlConnection conn)
1775 { 1948 {
1776 string createPrims = defineTable(createPrimTable()); 1949 string createPrims = defineTable(createPrimTable());
@@ -1859,6 +2032,12 @@ namespace OpenSim.Data.MySQL
1859 conn.Close(); 2032 conn.Close();
1860 } 2033 }
1861 2034
2035 /// <summary>
2036 ///
2037 /// </summary>
2038 /// <param name="conn"></param>
2039 /// <param name="m"></param>
2040 /// <returns></returns>
1862 private bool TestTables(MySqlConnection conn, Migration m) 2041 private bool TestTables(MySqlConnection conn, Migration m)
1863 { 2042 {
1864 // we already have migrations, get out of here 2043 // we already have migrations, get out of here
@@ -1968,6 +2147,11 @@ namespace OpenSim.Data.MySQL
1968 * 2147 *
1969 **********************************************************************/ 2148 **********************************************************************/
1970 2149
2150 /// <summary>
2151 /// Type conversion functions
2152 /// </summary>
2153 /// <param name="type"></param>
2154 /// <returns></returns>
1971 private static DbType dbtypeFromType(Type type) 2155 private static DbType dbtypeFromType(Type type)
1972 { 2156 {
1973 if (type == typeof (String)) 2157 if (type == typeof (String))
@@ -2000,8 +2184,11 @@ namespace OpenSim.Data.MySQL
2000 } 2184 }
2001 } 2185 }
2002 2186
2003 // this is something we'll need to implement for each db 2187 /// <summary>
2004 // slightly differently. 2188 /// </summary>
2189 /// <param name="type"></param>
2190 /// <returns></returns>
2191 /// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
2005 private static string MySqlType(Type type) 2192 private static string MySqlType(Type type)
2006 { 2193 {
2007 if (type == typeof (String)) 2194 if (type == typeof (String))