aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs4
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs96
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs43
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations2
4 files changed, 95 insertions, 50 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index a743479..a22dc0a 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -155,7 +155,7 @@ namespace OpenSim.Data.MySQL
155 /// </summary> 155 /// </summary>
156 /// <param name="asset">Asset UUID to create</param> 156 /// <param name="asset">Asset UUID to create</param>
157 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 157 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
158 override public void StoreAsset(AssetBase asset) 158 override public bool StoreAsset(AssetBase asset)
159 { 159 {
160 lock (m_dbLock) 160 lock (m_dbLock)
161 { 161 {
@@ -203,12 +203,14 @@ namespace OpenSim.Data.MySQL
203 cmd.Parameters.AddWithValue("?data", asset.Data); 203 cmd.Parameters.AddWithValue("?data", asset.Data);
204 cmd.ExecuteNonQuery(); 204 cmd.ExecuteNonQuery();
205 cmd.Dispose(); 205 cmd.Dispose();
206 return true;
206 } 207 }
207 } 208 }
208 catch (Exception e) 209 catch (Exception e)
209 { 210 {
210 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", 211 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
211 asset.FullID, asset.Name, e.Message); 212 asset.FullID, asset.Name, e.Message);
213 return false;
212 } 214 }
213 } 215 }
214 } 216 }
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 6d14b82..40619de 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Data.MySQL
66 Initialise(connectionString); 66 Initialise(connectionString);
67 } 67 }
68 68
69 public void Initialise(string connectionString) 69 public virtual void Initialise(string connectionString)
70 { 70 {
71 m_connectionString = connectionString; 71 m_connectionString = connectionString;
72 72
@@ -113,7 +113,7 @@ namespace OpenSim.Data.MySQL
113 113
114 public void Dispose() {} 114 public void Dispose() {}
115 115
116 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 116 public virtual void StoreObject(SceneObjectGroup obj, UUID regionUUID)
117 { 117 {
118 uint flags = obj.RootPart.GetEffectiveObjectFlags(); 118 uint flags = obj.RootPart.GetEffectiveObjectFlags();
119 119
@@ -241,7 +241,7 @@ namespace OpenSim.Data.MySQL
241 } 241 }
242 } 242 }
243 243
244 public void RemoveObject(UUID obj, UUID regionUUID) 244 public virtual void RemoveObject(UUID obj, UUID regionUUID)
245 { 245 {
246// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); 246// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID);
247 247
@@ -390,7 +390,7 @@ namespace OpenSim.Data.MySQL
390 } 390 }
391 } 391 }
392 392
393 public List<SceneObjectGroup> LoadObjects(UUID regionID) 393 public virtual List<SceneObjectGroup> LoadObjects(UUID regionID)
394 { 394 {
395 const int ROWS_PER_QUERY = 5000; 395 const int ROWS_PER_QUERY = 5000;
396 396
@@ -559,36 +559,51 @@ namespace OpenSim.Data.MySQL
559 } 559 }
560 } 560 }
561 561
562 public void StoreTerrain(double[,] ter, UUID regionID) 562 public virtual void StoreTerrain(double[,] ter, UUID regionID)
563 { 563 {
564 m_log.Info("[REGION DB]: Storing terrain"); 564 Util.FireAndForget(delegate(object x)
565
566 lock (m_dbLock)
567 { 565 {
568 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 566 double[,] oldTerrain = LoadTerrain(regionID);
569 {
570 dbcon.Open();
571 567
572 using (MySqlCommand cmd = dbcon.CreateCommand()) 568 m_log.Info("[REGION DB]: Storing terrain");
569
570 lock (m_dbLock)
571 {
572 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
573 { 573 {
574 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; 574 dbcon.Open();
575 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
576 575
577 ExecuteNonQuery(cmd); 576 using (MySqlCommand cmd = dbcon.CreateCommand())
577 {
578 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
579 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
578 580
579 cmd.CommandText = "insert into terrain (RegionUUID, " + 581 using (MySqlCommand cmd2 = dbcon.CreateCommand())
580 "Revision, Heightfield) values (?RegionUUID, " + 582 {
581 "1, ?Heightfield)"; 583 try
584 {
585 cmd2.CommandText = "insert into terrain (RegionUUID, " +
586 "Revision, Heightfield) values (?RegionUUID, " +
587 "1, ?Heightfield)";
582 588
583 cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); 589 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
590 cmd2.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter, oldTerrain));
584 591
585 ExecuteNonQuery(cmd); 592 ExecuteNonQuery(cmd);
593 ExecuteNonQuery(cmd2);
594 }
595 catch (Exception e)
596 {
597 m_log.ErrorFormat(e.ToString());
598 }
599 }
600 }
586 } 601 }
587 } 602 }
588 } 603 });
589 } 604 }
590 605
591 public double[,] LoadTerrain(UUID regionID) 606 public virtual double[,] LoadTerrain(UUID regionID)
592 { 607 {
593 double[,] terrain = null; 608 double[,] terrain = null;
594 609
@@ -638,7 +653,7 @@ namespace OpenSim.Data.MySQL
638 return terrain; 653 return terrain;
639 } 654 }
640 655
641 public void RemoveLandObject(UUID globalID) 656 public virtual void RemoveLandObject(UUID globalID)
642 { 657 {
643 lock (m_dbLock) 658 lock (m_dbLock)
644 { 659 {
@@ -657,7 +672,7 @@ namespace OpenSim.Data.MySQL
657 } 672 }
658 } 673 }
659 674
660 public void StoreLandObject(ILandObject parcel) 675 public virtual void StoreLandObject(ILandObject parcel)
661 { 676 {
662 lock (m_dbLock) 677 lock (m_dbLock)
663 { 678 {
@@ -714,7 +729,7 @@ namespace OpenSim.Data.MySQL
714 } 729 }
715 } 730 }
716 731
717 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 732 public virtual RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
718 { 733 {
719 RegionLightShareData nWP = new RegionLightShareData(); 734 RegionLightShareData nWP = new RegionLightShareData();
720 nWP.OnSave += StoreRegionWindlightSettings; 735 nWP.OnSave += StoreRegionWindlightSettings;
@@ -736,7 +751,7 @@ namespace OpenSim.Data.MySQL
736 { 751 {
737 //No result, so store our default windlight profile and return it 752 //No result, so store our default windlight profile and return it
738 nWP.regionID = regionUUID; 753 nWP.regionID = regionUUID;
739 StoreRegionWindlightSettings(nWP); 754 // StoreRegionWindlightSettings(nWP);
740 return nWP; 755 return nWP;
741 } 756 }
742 else 757 else
@@ -811,7 +826,7 @@ namespace OpenSim.Data.MySQL
811 return nWP; 826 return nWP;
812 } 827 }
813 828
814 public RegionSettings LoadRegionSettings(UUID regionUUID) 829 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
815 { 830 {
816 RegionSettings rs = null; 831 RegionSettings rs = null;
817 832
@@ -849,7 +864,7 @@ namespace OpenSim.Data.MySQL
849 return rs; 864 return rs;
850 } 865 }
851 866
852 public void StoreRegionWindlightSettings(RegionLightShareData wl) 867 public virtual void StoreRegionWindlightSettings(RegionLightShareData wl)
853 { 868 {
854 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 869 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
855 { 870 {
@@ -952,7 +967,7 @@ namespace OpenSim.Data.MySQL
952 } 967 }
953 } 968 }
954 969
955 public void RemoveRegionWindlightSettings(UUID regionID) 970 public virtual void RemoveRegionWindlightSettings(UUID regionID)
956 { 971 {
957 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 972 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
958 { 973 {
@@ -967,7 +982,7 @@ namespace OpenSim.Data.MySQL
967 } 982 }
968 } 983 }
969 984
970 public void StoreRegionSettings(RegionSettings rs) 985 public virtual void StoreRegionSettings(RegionSettings rs)
971 { 986 {
972 lock (m_dbLock) 987 lock (m_dbLock)
973 { 988 {
@@ -994,7 +1009,7 @@ namespace OpenSim.Data.MySQL
994 "use_estate_sun, fixed_sun, sun_position, " + 1009 "use_estate_sun, fixed_sun, sun_position, " +
995 "covenant, Sandbox, sunvectorx, sunvectory, " + 1010 "covenant, Sandbox, sunvectorx, sunvectory, " +
996 "sunvectorz, loaded_creation_datetime, " + 1011 "sunvectorz, loaded_creation_datetime, " +
997 "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + 1012 "loaded_creation_id, map_tile_ID, block_search, casino) values (?RegionUUID, ?BlockTerraform, " +
998 "?BlockFly, ?AllowDamage, ?RestrictPushing, " + 1013 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
999 "?AllowLandResell, ?AllowLandJoinDivide, " + 1014 "?AllowLandResell, ?AllowLandJoinDivide, " +
1000 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + 1015 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
@@ -1009,7 +1024,7 @@ namespace OpenSim.Data.MySQL
1009 "?SunPosition, ?Covenant, ?Sandbox, " + 1024 "?SunPosition, ?Covenant, ?Sandbox, " +
1010 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + 1025 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1011 "?LoadedCreationDateTime, ?LoadedCreationID, " + 1026 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1012 "?TerrainImageID)"; 1027 "?TerrainImageID, ?block_search, ?casino)";
1013 1028
1014 FillRegionSettingsCommand(cmd, rs); 1029 FillRegionSettingsCommand(cmd, rs);
1015 1030
@@ -1019,7 +1034,7 @@ namespace OpenSim.Data.MySQL
1019 } 1034 }
1020 } 1035 }
1021 1036
1022 public List<LandData> LoadLandObjects(UUID regionUUID) 1037 public virtual List<LandData> LoadLandObjects(UUID regionUUID)
1023 { 1038 {
1024 List<LandData> landData = new List<LandData>(); 1039 List<LandData> landData = new List<LandData>();
1025 1040
@@ -1297,6 +1312,9 @@ namespace OpenSim.Data.MySQL
1297 1312
1298 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); 1313 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
1299 1314
1315 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
1316 newSettings.Casino = Convert.ToBoolean(row["casino"]);
1317
1300 return newSettings; 1318 return newSettings;
1301 } 1319 }
1302 1320
@@ -1394,7 +1412,7 @@ namespace OpenSim.Data.MySQL
1394 /// </summary> 1412 /// </summary>
1395 /// <param name="val"></param> 1413 /// <param name="val"></param>
1396 /// <returns></returns> 1414 /// <returns></returns>
1397 private static Array SerializeTerrain(double[,] val) 1415 private static Array SerializeTerrain(double[,] val, double[,] oldTerrain)
1398 { 1416 {
1399 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); 1417 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
1400 BinaryWriter bw = new BinaryWriter(str); 1418 BinaryWriter bw = new BinaryWriter(str);
@@ -1403,7 +1421,11 @@ namespace OpenSim.Data.MySQL
1403 for (int x = 0; x < (int)Constants.RegionSize; x++) 1421 for (int x = 0; x < (int)Constants.RegionSize; x++)
1404 for (int y = 0; y < (int)Constants.RegionSize; y++) 1422 for (int y = 0; y < (int)Constants.RegionSize; y++)
1405 { 1423 {
1406 double height = val[x, y]; 1424 double height = 20.0;
1425 if (oldTerrain != null)
1426 height = oldTerrain[x, y];
1427 if (!double.IsNaN(val[x, y]))
1428 height = val[x, y];
1407 if (height == 0.0) 1429 if (height == 0.0)
1408 height = double.Epsilon; 1430 height = double.Epsilon;
1409 1431
@@ -1626,6 +1648,8 @@ namespace OpenSim.Data.MySQL
1626 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); 1648 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
1627 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); 1649 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
1628 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); 1650 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
1651 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
1652 cmd.Parameters.AddWithValue("casino", settings.Casino);
1629 1653
1630 } 1654 }
1631 1655
@@ -1784,7 +1808,7 @@ namespace OpenSim.Data.MySQL
1784 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); 1808 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
1785 } 1809 }
1786 1810
1787 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 1811 public virtual void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
1788 { 1812 {
1789 lock (m_dbLock) 1813 lock (m_dbLock)
1790 { 1814 {
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index aa69d68..a18ac66 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -46,17 +46,21 @@ namespace OpenSim.Data.MySQL
46 { 46 {
47 string[] words = query.Split(new char[] {' '}); 47 string[] words = query.Split(new char[] {' '});
48 48
49 bool valid = false;
50
49 for (int i = 0 ; i < words.Length ; i++) 51 for (int i = 0 ; i < words.Length ; i++)
50 { 52 {
51 if (words[i].Length < 3) 53 if (words[i].Length > 2)
52 { 54 valid = true;
53 if (i != words.Length - 1) 55// if (words[i].Length < 3)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1); 56// {
55 Array.Resize(ref words, words.Length - 1); 57// if (i != words.Length - 1)
56 } 58// Array.Copy(words, i + 1, words, i, words.Length - i - 1);
59// Array.Resize(ref words, words.Length - 1);
60// }
57 } 61 }
58 62
59 if (words.Length == 0) 63 if ((!valid) || words.Length == 0)
60 return new UserAccountData[0]; 64 return new UserAccountData[0];
61 65
62 if (words.Length > 2) 66 if (words.Length > 2)
@@ -66,18 +70,33 @@ namespace OpenSim.Data.MySQL
66 70
67 if (words.Length == 1) 71 if (words.Length == 1)
68 { 72 {
69 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
70 cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); 74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
71 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
72 } 76 }
73 else 77 else
74 { 78 {
75 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); 79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm);
76 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); 80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%");
77 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); 81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%");
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
83 }
84
85 return DoQuery(cmd);
86 }
87
88 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
89 {
90 MySqlCommand cmd = new MySqlCommand();
91
92 if (scopeID != UUID.Zero)
93 {
94 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")";
78 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 95 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
79 } 96 }
80 97
98 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm);
99
81 return DoQuery(cmd); 100 return DoQuery(cmd);
82 } 101 }
83 } 102 }
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index 987625b..c2b130c 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -717,7 +717,7 @@ ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT
717 717
718COMMIT; 718COMMIT;
719 719
720:VERSION 32 720:VERSION 32 #---------------------
721 721
722BEGIN; 722BEGIN;
723CREATE TABLE `regionwindlight` ( 723CREATE TABLE `regionwindlight` (