From c52c68f314c67c76c7181a6d0828f476290fbd66 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 2 Apr 2008 15:24:31 +0000 Subject: whole lot more moving --- OpenSim/Data/MySQL/MySQLAssetData.cs | 198 +++ OpenSim/Data/MySQL/MySQLDataStore.cs | 1722 ++++++++++++++++++++ OpenSim/Data/MySQL/MySQLGridData.cs | 402 +++++ OpenSim/Data/MySQL/MySQLInventoryData.cs | 648 ++++++++ OpenSim/Data/MySQL/MySQLLogData.cs | 106 ++ OpenSim/Data/MySQL/MySQLManager.cs | 909 +++++++++++ OpenSim/Data/MySQL/MySQLUserData.cs | 643 ++++++++ OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 65 + OpenSim/Data/MySQL/Resources/AvatarAppearance.sql | 42 + OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql | 24 + OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql | 11 + .../Data/MySQL/Resources/CreateFoldersTable.sql | 11 + OpenSim/Data/MySQL/Resources/CreateItemsTable.sql | 18 + OpenSim/Data/MySQL/Resources/CreateLogsTable.sql | 10 + .../Data/MySQL/Resources/CreateRegionsTable.sql | 32 + .../MySQL/Resources/CreateUserFriendsTable.sql | 11 + OpenSim/Data/MySQL/Resources/CreateUsersTable.sql | 35 + .../Resources/UpgradeFoldersTableToVersion2.sql | 4 + .../Resources/UpgradeItemsTableToVersion2.sql | 9 + .../Resources/UpgradeRegionsTableToVersion2.sql | 4 + .../Resources/UpgradeRegionsTableToVersion3.sql | 18 + .../Resources/UpgradeUsersTableToVersion2.sql | 3 + 22 files changed, 4925 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLAssetData.cs create mode 100644 OpenSim/Data/MySQL/MySQLDataStore.cs create mode 100644 OpenSim/Data/MySQL/MySQLGridData.cs create mode 100644 OpenSim/Data/MySQL/MySQLInventoryData.cs create mode 100644 OpenSim/Data/MySQL/MySQLLogData.cs create mode 100644 OpenSim/Data/MySQL/MySQLManager.cs create mode 100644 OpenSim/Data/MySQL/MySQLUserData.cs create mode 100644 OpenSim/Data/MySQL/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Data/MySQL/Resources/AvatarAppearance.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateItemsTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateLogsTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateUsersTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs new file mode 100644 index 0000000..79994ae --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -0,0 +1,198 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using libsecondlife; +using MySql.Data.MySqlClient; +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Data.MySQL +{ + internal class MySQLAssetData : AssetDataBase, IPlugin + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + private MySQLManager _dbConnection; + + #region IAssetProvider Members + + private void UpgradeAssetsTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + m_log.Info("[ASSETS]: Creating new database tables"); + _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); + return; + } + } + + /// + /// Ensure that the assets related tables exists and are at the latest version + /// + private void TestTables() + { + Dictionary tableList = new Dictionary(); + + tableList["assets"] = null; + _dbConnection.GetTableVersion(tableList); + + UpgradeAssetsTable(tableList["assets"]); + } + + override public AssetBase FetchAsset(LLUUID assetID) + { + AssetBase asset = null; + lock (_dbConnection) + { + MySqlCommand cmd = + new MySqlCommand( + "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", + _dbConnection.Connection); + MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); + p.Value = assetID.GetBytes(); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + asset = new AssetBase(); + asset.Data = (byte[]) dbReader["data"]; + asset.Description = (string) dbReader["description"]; + asset.FullID = assetID; + asset.InvType = (sbyte) dbReader["invType"]; + asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false; + asset.Name = (string) dbReader["name"]; + asset.Type = (sbyte) dbReader["assetType"]; + } + dbReader.Close(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", assetID); + _dbConnection.Reconnect(); + } + } + return asset; + } + + override public void CreateAsset(AssetBase asset) + { + lock (_dbConnection) + { + MySqlCommand cmd = + new MySqlCommand( + "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", + _dbConnection.Connection); + + // need to ensure we dispose + try + { + using (cmd) + { + MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); + p.Value = asset.FullID.GetBytes(); + cmd.Parameters.AddWithValue("?name", asset.Name); + cmd.Parameters.AddWithValue("?description", asset.Description); + cmd.Parameters.AddWithValue("?assetType", asset.Type); + cmd.Parameters.AddWithValue("?invType", asset.InvType); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS]: " + + "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + _dbConnection.Reconnect(); + } + } + } + + override public void UpdateAsset(AssetBase asset) + { + CreateAsset(asset); + } + + override public bool ExistsAsset(LLUUID uuid) + { + throw new Exception("The method or operation is not implemented."); + } + + /// + /// All writes are immediately commited to the database, so this is a no-op + /// + override public void CommitAssets() + { + } + + #endregion + + #region IPlugin Members + + override public void Initialise() + { + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string database = GridDataMySqlFile.ParseFileReadValue("database"); + string username = GridDataMySqlFile.ParseFileReadValue("username"); + string password = GridDataMySqlFile.ParseFileReadValue("password"); + string pooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string port = GridDataMySqlFile.ParseFileReadValue("port"); + + _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port); + + TestTables(); + } + + override public string Version + { + get { return _dbConnection.getVersion(); } + } + + override public string Name + { + get { return "MySQL Asset storage engine"; } + } + + #endregion + } +} diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs new file mode 100644 index 0000000..eaa7f14 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -0,0 +1,1722 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.IO; +using libsecondlife; +using MySql.Data.MySqlClient; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Framework.Data.MySQL +{ + public class MySQLDataStore : IRegionDataStore + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + private const string m_primSelect = "select * from prims"; + private const string m_shapeSelect = "select * from primshapes"; + private const string m_itemsSelect = "select * from primitems"; + private const string m_terrainSelect = "select * from terrain limit 1"; + private const string m_landSelect = "select * from land"; + private const string m_landAccessListSelect = "select * from landaccesslist"; + + private DataSet m_dataSet; + private MySqlDataAdapter m_primDataAdapter; + private MySqlDataAdapter m_shapeDataAdapter; + private MySqlDataAdapter m_itemsDataAdapter; + private MySqlConnection m_connection; + private MySqlDataAdapter m_terrainDataAdapter; + private MySqlDataAdapter m_landDataAdapter; + private MySqlDataAdapter m_landAccessListDataAdapter; + + private DataTable m_primTable; + private DataTable m_shapeTable; + private DataTable m_itemsTable; + private DataTable m_terrainTable; + private DataTable m_landTable; + private DataTable m_landAccessListTable; + + // Temporary attribute while this is experimental + private bool persistPrimInventories; + + /*********************************************************************** + * + * Public Interface Functions + * + **********************************************************************/ + + // see IRegionDataStore + public void Initialise(string connectionstring, bool persistPrimInventories) + { + m_dataSet = new DataSet(); + this.persistPrimInventories = persistPrimInventories; + + m_log.Info("[DATASTORE]: MySql - connecting: " + connectionstring); + m_connection = new MySqlConnection(connectionstring); + + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); + m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); + + MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, m_connection); + m_shapeDataAdapter = new MySqlDataAdapter(shapeSelectCmd); + + MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, m_connection); + m_itemsDataAdapter = new MySqlDataAdapter(itemsSelectCmd); + + MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, m_connection); + m_terrainDataAdapter = new MySqlDataAdapter(terrainSelectCmd); + + MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, m_connection); + m_landDataAdapter = new MySqlDataAdapter(landSelectCmd); + + MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); + m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); + + TestTables(m_connection); + + lock (m_dataSet) + { + m_primTable = createPrimTable(); + m_dataSet.Tables.Add(m_primTable); + SetupPrimCommands(m_primDataAdapter, m_connection); + m_primDataAdapter.Fill(m_primTable); + + m_shapeTable = createShapeTable(); + m_dataSet.Tables.Add(m_shapeTable); + SetupShapeCommands(m_shapeDataAdapter, m_connection); + m_shapeDataAdapter.Fill(m_shapeTable); + + if (persistPrimInventories) + { + m_itemsTable = createItemsTable(); + m_dataSet.Tables.Add(m_itemsTable); + SetupItemsCommands(m_itemsDataAdapter, m_connection); + m_itemsDataAdapter.Fill(m_itemsTable); + } + + m_terrainTable = createTerrainTable(); + m_dataSet.Tables.Add(m_terrainTable); + SetupTerrainCommands(m_terrainDataAdapter, m_connection); + m_terrainDataAdapter.Fill(m_terrainTable); + + m_landTable = createLandTable(); + m_dataSet.Tables.Add(m_landTable); + setupLandCommands(m_landDataAdapter, m_connection); + m_landDataAdapter.Fill(m_landTable); + + m_landAccessListTable = createLandAccessListTable(); + m_dataSet.Tables.Add(m_landAccessListTable); + setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); + m_landAccessListDataAdapter.Fill(m_landAccessListTable); + } + } + + public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) + { + lock (m_dataSet) + { + foreach (SceneObjectPart prim in obj.Children.Values) + { + if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) + { + m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + addPrim(prim, obj.UUID, regionUUID); + } + else + { + // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); + } + } + Commit(); + } + } + + public void RemoveObject(LLUUID obj, LLUUID regionUUID) + { + m_log.InfoFormat("[DATASTORE]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + + DataTable prims = m_primTable; + DataTable shapes = m_shapeTable; + + string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'"; + lock (m_dataSet) + { + DataRow[] primRows = prims.Select(selectExp); + foreach (DataRow row in primRows) + { + // Remove shapes row + LLUUID uuid = new LLUUID((string) row["UUID"]); + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); + if (shapeRow != null) + { + shapeRow.Delete(); + } + + if (persistPrimInventories) + { + RemoveItems(uuid); + } + + // Remove prim row + row.Delete(); + } + Commit(); + } + } + + /// + /// Remove all persisted items of the given prim. + /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. + /// + private void RemoveItems(LLUUID uuid) + { + String sql = String.Format("primID = '{0}'", uuid); + DataRow[] itemRows = m_itemsTable.Select(sql); + + foreach (DataRow itemRow in itemRows) + { + itemRow.Delete(); + } + } + + /// + /// Load persisted objects from region storage. + /// + public List LoadObjects(LLUUID regionUUID) + { + Dictionary createdObjects = new Dictionary(); + + List retvals = new List(); + + DataTable prims = m_primTable; + DataTable shapes = m_shapeTable; + + string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; + string orderByParent = "ParentID ASC"; + + lock (m_dataSet) + { + DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); + m_log.Info("[DATASTORE]: " + + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); + + foreach (DataRow primRow in primsForRegion) + { + try + { + string uuid = (string) primRow["UUID"]; + string objID = (string) primRow["SceneGroupID"]; + + SceneObjectPart prim = buildPrim(primRow); + + if (uuid == objID) //is new SceneObjectGroup ? + { + SceneObjectGroup group = new SceneObjectGroup(); + + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow != null) + { + prim.Shape = buildShape(shapeRow); + } + else + { + m_log.Info( + "No shape found for prim in storage, so setting default box shape"); + prim.Shape = PrimitiveBaseShape.Default; + } + group.AddPart(prim); + group.RootPart = prim; + + createdObjects.Add(group.UUID, group); + retvals.Add(group); + } + else + { + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow != null) + { + prim.Shape = buildShape(shapeRow); + } + else + { + m_log.Info( + "No shape found for prim in storage, so setting default box shape"); + prim.Shape = PrimitiveBaseShape.Default; + } + createdObjects[new LLUUID(objID)].AddPart(prim); + } + + if (persistPrimInventories) + { + LoadItems(prim); + } + } + catch (Exception e) + { + m_log.Error("[DATASTORE]: Failed create prim object, exception and data follows"); + m_log.Info("[DATASTORE]: " + e.ToString()); + foreach (DataColumn col in prims.Columns) + { + m_log.Info("[DATASTORE]: Col: " + col.ColumnName + " => " + primRow[col]); + } + } + } + } + return retvals; + } + + /// + /// Load in a prim's persisted inventory. + /// + /// + private void LoadItems(SceneObjectPart prim) + { + //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); + + DataTable dbItems = m_itemsTable; + + String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); + DataRow[] dbItemRows = dbItems.Select(sql); + + IList inventory = new List(); + + foreach (DataRow row in dbItemRows) + { + TaskInventoryItem item = buildItem(row); + inventory.Add(item); + + //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); + } + + prim.RestoreInventoryItems(inventory); + + // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in + // every item). This data should really be stored in the prim table itself. + if (dbItemRows.Length > 0) + { + prim.FolderID = inventory[0].ParentID; + } + } + + public void StoreTerrain(double[,] ter, LLUUID regionID) + { + int revision = Util.UnixTimeSinceEpoch(); + m_log.Info("[DATASTORE]: Storing terrain revision r" + revision.ToString()); + + DataTable terrain = m_dataSet.Tables["terrain"]; + lock (m_dataSet) + { + MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + + " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); + using (cmd) + { + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); + cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); + cmd.ExecuteNonQuery(); + } + } + } + + public double[,] LoadTerrain(LLUUID regionID) + { + double[,] terret = new double[256,256]; + terret.Initialize(); + + MySqlCommand cmd = new MySqlCommand( + @"select RegionUUID, Revision, Heightfield from terrain + where RegionUUID=?RegionUUID order by Revision desc limit 1" + , m_connection); + + MySqlParameter param = new MySqlParameter(); + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + + if (m_connection.State != ConnectionState.Open) + { + m_connection.Open(); + } + + lock (m_dataSet) + { + using (MySqlDataReader row = cmd.ExecuteReader()) + { + int rev = 0; + if (row.Read()) + { + MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); + BinaryReader br = new BinaryReader(str); + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + terret[x, y] = br.ReadDouble(); + } + } + rev = (int) row["Revision"]; + } + else + { + m_log.Info("[DATASTORE]: No terrain found for region"); + return null; + } + + m_log.Info("[DATASTORE]: Loaded terrain revision r" + rev.ToString()); + } + } + return terret; + } + + public void RemoveLandObject(LLUUID globalID) + { + lock (m_dataSet) + { + using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection)) + { + cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); + cmd.ExecuteNonQuery(); + } + + using ( + MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?UUID", m_connection) + ) + { + cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); + cmd.ExecuteNonQuery(); + } + } + } + + public void StoreLandObject(ILandObject parcel) + { + lock (m_dataSet) + { + DataTable land = m_landTable; + DataTable landaccesslist = m_landAccessListTable; + + DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.globalID)); + if (landRow == null) + { + landRow = land.NewRow(); + fillLandRow(landRow, parcel.landData, parcel.regionUUID); + land.Rows.Add(landRow); + } + else + { + fillLandRow(landRow, parcel.landData, parcel.regionUUID); + } + + using ( + MySqlCommand cmd = + new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) + { + cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); + cmd.ExecuteNonQuery(); + } + + foreach (ParcelManager.ParcelAccessEntry entry in parcel.landData.parcelAccessList) + { + DataRow newAccessRow = landaccesslist.NewRow(); + fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID); + landaccesslist.Rows.Add(newAccessRow); + } + + Commit(); + } + } + + public List LoadLandObjects(LLUUID regionUUID) + { + List landDataForRegion = new List(); + lock (m_dataSet) + { + DataTable land = m_landTable; + DataTable landaccesslist = m_landAccessListTable; + string searchExp = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; + DataRow[] rawDataForRegion = land.Select(searchExp); + foreach (DataRow rawDataLand in rawDataForRegion) + { + LandData newLand = buildLandData(rawDataLand); + string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.globalID) + "'"; + DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); + foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) + { + newLand.parcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); + } + + landDataForRegion.Add(newLand); + } + } + return landDataForRegion; + } + +// TODO: unused +// private void DisplayDataSet(DataSet ds, string title) +// { +// Debug.WriteLine(title); +// //--- Loop through the DataTables +// foreach (DataTable table in ds.Tables) +// { +// Debug.WriteLine("*** DataTable: " + table.TableName + "***"); +// //--- Loop through each DataTable's DataRows +// foreach (DataRow row in table.Rows) +// { +// //--- Display the original values, if there are any. +// if (row.HasVersion(DataRowVersion.Original)) +// { +// Debug.Write("Original Row Values ===> "); +// foreach (DataColumn column in table.Columns) +// Debug.Write(column.ColumnName + " = " + +// row[column, DataRowVersion.Original] + ", "); +// Debug.WriteLine(String.Empty); +// } +// //--- Display the current values, if there are any. +// if (row.HasVersion(DataRowVersion.Current)) +// { +// Debug.Write("Current Row Values ====> "); +// foreach (DataColumn column in table.Columns) +// Debug.Write(column.ColumnName + " = " + +// row[column, DataRowVersion.Current] + ", "); +// Debug.WriteLine(String.Empty); +// } +// Debug.WriteLine(String.Empty); +// } +// } +// } + + public void Commit() + { + if (m_connection.State != ConnectionState.Open) + { + m_connection.Open(); + } + + lock (m_dataSet) + { + // DisplayDataSet(m_dataSet, "Region DataSet"); + + m_primDataAdapter.Update(m_primTable); + m_shapeDataAdapter.Update(m_shapeTable); + + if (persistPrimInventories) + { + m_itemsDataAdapter.Update(m_itemsTable); + } + + m_terrainDataAdapter.Update(m_terrainTable); + m_landDataAdapter.Update(m_landTable); + m_landAccessListDataAdapter.Update(m_landAccessListTable); + + m_dataSet.AcceptChanges(); + } + } + + + public void Shutdown() + { + Commit(); + } + + /*********************************************************************** + * + * Database Definition Functions + * + * This should be db agnostic as we define them in ADO.NET terms + * + **********************************************************************/ + + private DataColumn createCol(DataTable dt, string name, Type type) + { + DataColumn col = new DataColumn(name, type); + dt.Columns.Add(col); + return col; + } + + private DataTable createTerrainTable() + { + DataTable terrain = new DataTable("terrain"); + + createCol(terrain, "RegionUUID", typeof (String)); + createCol(terrain, "Revision", typeof (Int32)); + DataColumn heightField = createCol(terrain, "Heightfield", typeof (Byte[])); + return terrain; + } + + private DataTable createPrimTable() + { + DataTable prims = new DataTable("prims"); + + createCol(prims, "UUID", typeof (String)); + createCol(prims, "RegionUUID", typeof (String)); + createCol(prims, "ParentID", typeof (Int32)); + createCol(prims, "CreationDate", typeof (Int32)); + createCol(prims, "Name", typeof (String)); + createCol(prims, "SceneGroupID", typeof (String)); + // various text fields + createCol(prims, "Text", typeof (String)); + createCol(prims, "Description", typeof (String)); + createCol(prims, "SitName", typeof (String)); + createCol(prims, "TouchName", typeof (String)); + // permissions + createCol(prims, "ObjectFlags", typeof (Int32)); + createCol(prims, "CreatorID", typeof (String)); + createCol(prims, "OwnerID", typeof (String)); + createCol(prims, "GroupID", typeof (String)); + createCol(prims, "LastOwnerID", typeof (String)); + createCol(prims, "OwnerMask", typeof (Int32)); + createCol(prims, "NextOwnerMask", typeof (Int32)); + createCol(prims, "GroupMask", typeof (Int32)); + createCol(prims, "EveryoneMask", typeof (Int32)); + createCol(prims, "BaseMask", typeof (Int32)); + // vectors + createCol(prims, "PositionX", typeof (Double)); + createCol(prims, "PositionY", typeof (Double)); + createCol(prims, "PositionZ", typeof (Double)); + createCol(prims, "GroupPositionX", typeof (Double)); + createCol(prims, "GroupPositionY", typeof (Double)); + createCol(prims, "GroupPositionZ", typeof (Double)); + createCol(prims, "VelocityX", typeof (Double)); + createCol(prims, "VelocityY", typeof (Double)); + createCol(prims, "VelocityZ", typeof (Double)); + createCol(prims, "AngularVelocityX", typeof (Double)); + createCol(prims, "AngularVelocityY", typeof (Double)); + createCol(prims, "AngularVelocityZ", typeof (Double)); + createCol(prims, "AccelerationX", typeof (Double)); + createCol(prims, "AccelerationY", typeof (Double)); + createCol(prims, "AccelerationZ", typeof (Double)); + // quaternions + createCol(prims, "RotationX", typeof (Double)); + createCol(prims, "RotationY", typeof (Double)); + createCol(prims, "RotationZ", typeof (Double)); + createCol(prims, "RotationW", typeof (Double)); + // sit target + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); + + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); + + + // Add in contraints + prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; + + return prims; + } + + private DataTable createLandTable() + { + DataTable land = new DataTable("land"); + createCol(land, "UUID", typeof (String)); + createCol(land, "RegionUUID", typeof (String)); + createCol(land, "LocalLandID", typeof (Int32)); + + // Bitmap is a byte[512] + createCol(land, "Bitmap", typeof (Byte[])); + + createCol(land, "Name", typeof (String)); + createCol(land, "Description", typeof (String)); + createCol(land, "OwnerUUID", typeof (String)); + createCol(land, "IsGroupOwned", typeof (Int32)); + createCol(land, "Area", typeof (Int32)); + createCol(land, "AuctionID", typeof (Int32)); //Unemplemented + createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory + createCol(land, "ClaimDate", typeof (Int32)); + createCol(land, "ClaimPrice", typeof (Int32)); + createCol(land, "GroupUUID", typeof (String)); + createCol(land, "SalePrice", typeof (Int32)); + createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus + createCol(land, "LandFlags", typeof (Int32)); + createCol(land, "LandingType", typeof (Int32)); + createCol(land, "MediaAutoScale", typeof (Int32)); + createCol(land, "MediaTextureUUID", typeof (String)); + createCol(land, "MediaURL", typeof (String)); + createCol(land, "MusicURL", typeof (String)); + createCol(land, "PassHours", typeof (Double)); + createCol(land, "PassPrice", typeof (Int32)); + createCol(land, "SnapshotUUID", typeof (String)); + createCol(land, "UserLocationX", typeof (Double)); + createCol(land, "UserLocationY", typeof (Double)); + createCol(land, "UserLocationZ", typeof (Double)); + createCol(land, "UserLookAtX", typeof (Double)); + createCol(land, "UserLookAtY", typeof (Double)); + createCol(land, "UserLookAtZ", typeof (Double)); + + land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; + + return land; + } + + private DataTable createLandAccessListTable() + { + DataTable landaccess = new DataTable("landaccesslist"); + createCol(landaccess, "LandUUID", typeof (String)); + createCol(landaccess, "AccessUUID", typeof (String)); + createCol(landaccess, "Flags", typeof (Int32)); + + return landaccess; + } + + private DataTable createShapeTable() + { + DataTable shapes = new DataTable("primshapes"); + createCol(shapes, "UUID", typeof (String)); + // shape is an enum + createCol(shapes, "Shape", typeof (Int32)); + // vectors + createCol(shapes, "ScaleX", typeof (Double)); + createCol(shapes, "ScaleY", typeof (Double)); + createCol(shapes, "ScaleZ", typeof (Double)); + // paths + createCol(shapes, "PCode", typeof (Int32)); + createCol(shapes, "PathBegin", typeof (Int32)); + createCol(shapes, "PathEnd", typeof (Int32)); + createCol(shapes, "PathScaleX", typeof (Int32)); + createCol(shapes, "PathScaleY", typeof (Int32)); + createCol(shapes, "PathShearX", typeof (Int32)); + createCol(shapes, "PathShearY", typeof (Int32)); + createCol(shapes, "PathSkew", typeof (Int32)); + createCol(shapes, "PathCurve", typeof (Int32)); + createCol(shapes, "PathRadiusOffset", typeof (Int32)); + createCol(shapes, "PathRevolutions", typeof (Int32)); + createCol(shapes, "PathTaperX", typeof (Int32)); + createCol(shapes, "PathTaperY", typeof (Int32)); + createCol(shapes, "PathTwist", typeof (Int32)); + createCol(shapes, "PathTwistBegin", typeof (Int32)); + // profile + createCol(shapes, "ProfileBegin", typeof (Int32)); + createCol(shapes, "ProfileEnd", typeof (Int32)); + createCol(shapes, "ProfileCurve", typeof (Int32)); + createCol(shapes, "ProfileHollow", typeof (Int32)); + createCol(shapes, "State", typeof(Int32)); + createCol(shapes, "Texture", typeof (Byte[])); + createCol(shapes, "ExtraParams", typeof (Byte[])); + + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; + + return shapes; + } + + private DataTable createItemsTable() + { + DataTable items = new DataTable("primitems"); + + createCol(items, "itemID", typeof (String)); + createCol(items, "primID", typeof (String)); + createCol(items, "assetID", typeof (String)); + createCol(items, "parentFolderID", typeof (String)); + + createCol(items, "invType", typeof (Int32)); + createCol(items, "assetType", typeof (Int32)); + + createCol(items, "name", typeof (String)); + createCol(items, "description", typeof (String)); + + createCol(items, "creationDate", typeof (Int64)); + createCol(items, "creatorID", typeof (String)); + createCol(items, "ownerID", typeof (String)); + createCol(items, "lastOwnerID", typeof (String)); + createCol(items, "groupID", typeof (String)); + + createCol(items, "nextPermissions", typeof (Int32)); + createCol(items, "currentPermissions", typeof (Int32)); + createCol(items, "basePermissions", typeof (Int32)); + createCol(items, "everyonePermissions", typeof (Int32)); + createCol(items, "groupPermissions", typeof (Int32)); + + items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; + + return items; + } + + /*********************************************************************** + * + * Convert between ADO.NET <=> OpenSim Objects + * + * These should be database independant + * + **********************************************************************/ + + private SceneObjectPart buildPrim(DataRow row) + { + SceneObjectPart prim = new SceneObjectPart(); + prim.UUID = new LLUUID((String) row["UUID"]); + // explicit conversion of integers is required, which sort + // of sucks. No idea if there is a shortcut here or not. + prim.ParentID = Convert.ToUInt32(row["ParentID"]); + prim.CreationDate = Convert.ToInt32(row["CreationDate"]); + prim.Name = (String) row["Name"]; + // various text fields + prim.Text = (String) row["Text"]; + prim.Description = (String) row["Description"]; + prim.SitName = (String) row["SitName"]; + prim.TouchName = (String) row["TouchName"]; + // permissions + prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); + prim.CreatorID = new LLUUID((String) row["CreatorID"]); + prim.OwnerID = new LLUUID((String) row["OwnerID"]); + prim.GroupID = new LLUUID((String) row["GroupID"]); + prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); + prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); + prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); + prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); + prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); + prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); + // vectors + prim.OffsetPosition = new LLVector3( + Convert.ToSingle(row["PositionX"]), + Convert.ToSingle(row["PositionY"]), + Convert.ToSingle(row["PositionZ"]) + ); + prim.GroupPosition = new LLVector3( + Convert.ToSingle(row["GroupPositionX"]), + Convert.ToSingle(row["GroupPositionY"]), + Convert.ToSingle(row["GroupPositionZ"]) + ); + prim.Velocity = new LLVector3( + Convert.ToSingle(row["VelocityX"]), + Convert.ToSingle(row["VelocityY"]), + Convert.ToSingle(row["VelocityZ"]) + ); + prim.AngularVelocity = new LLVector3( + Convert.ToSingle(row["AngularVelocityX"]), + Convert.ToSingle(row["AngularVelocityY"]), + Convert.ToSingle(row["AngularVelocityZ"]) + ); + prim.Acceleration = new LLVector3( + Convert.ToSingle(row["AccelerationX"]), + Convert.ToSingle(row["AccelerationY"]), + Convert.ToSingle(row["AccelerationZ"]) + ); + // quaternions + prim.RotationOffset = new LLQuaternion( + Convert.ToSingle(row["RotationX"]), + Convert.ToSingle(row["RotationY"]), + Convert.ToSingle(row["RotationZ"]), + Convert.ToSingle(row["RotationW"]) + ); + try + { + prim.SetSitTargetLL(new LLVector3( + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"]))); + } + catch (InvalidCastException) + { + // Database table was created before we got here and needs to be created! :P + + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + return prim; + } + + + /// + /// Build a prim inventory item from the persisted data. + /// + /// + /// + private TaskInventoryItem buildItem(DataRow row) + { + TaskInventoryItem taskItem = new TaskInventoryItem(); + + taskItem.ItemID = new LLUUID((String)row["itemID"]); + taskItem.ParentPartID = new LLUUID((String)row["primID"]); + taskItem.AssetID = new LLUUID((String)row["assetID"]); + taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); + + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); + + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorID = new LLUUID((String)row["creatorID"]); + taskItem.OwnerID = new LLUUID((String)row["ownerID"]); + taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); + taskItem.GroupID = new LLUUID((String)row["groupID"]); + + taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]); + taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); + + return taskItem; + } + + private LandData buildLandData(DataRow row) + { + LandData newData = new LandData(); + + newData.globalID = new LLUUID((String) row["UUID"]); + newData.localID = Convert.ToInt32(row["LocalLandID"]); + + // Bitmap is a byte[512] + newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; + + newData.landName = (String) row["Name"]; + newData.landDesc = (String) row["Description"]; + newData.ownerID = (String) row["OwnerUUID"]; + newData.isGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); + newData.area = Convert.ToInt32(row["Area"]); + newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented + newData.category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory + newData.claimDate = Convert.ToInt32(row["ClaimDate"]); + newData.claimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.groupID = new LLUUID((String) row["GroupUUID"]); + newData.salePrice = Convert.ToInt32(row["SalePrice"]); + newData.landStatus = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus + newData.landFlags = Convert.ToUInt32(row["LandFlags"]); + newData.landingType = Convert.ToByte(row["LandingType"]); + newData.mediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); + newData.mediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.mediaURL = (String) row["MediaURL"]; + newData.musicURL = (String) row["MusicURL"]; + newData.passHours = Convert.ToSingle(row["PassHours"]); + newData.passPrice = Convert.ToInt32(row["PassPrice"]); + newData.snapshotID = (String) row["SnapshotUUID"]; + + newData.userLocation = + new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.userLookAt = + new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); + newData.parcelAccessList = new List(); + + return newData; + } + + private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = new LLUUID((string) row["AccessUUID"]); + entry.Flags = (ParcelManager.AccessList) Convert.ToInt32(row["Flags"]); + entry.Time = new DateTime(); + return entry; + } + + private Array serializeTerrain(double[,] val) + { + MemoryStream str = new MemoryStream(65536*sizeof (double)); + BinaryWriter bw = new BinaryWriter(str); + + // TODO: COMPATIBILITY - Add byte-order conversions + for (int x = 0; x < 256; x++) + for (int y = 0; y < 256; y++) + bw.Write(val[x, y]); + + return str.ToArray(); + } + + private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) + { + row["UUID"] = Util.ToRawUuidString(prim.UUID); + row["RegionUUID"] = Util.ToRawUuidString(regionUUID); + row["ParentID"] = prim.ParentID; + row["CreationDate"] = prim.CreationDate; + row["Name"] = prim.Name; + row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); + // the UUID of the root part for this SceneObjectGroup + // various text fields + row["Text"] = prim.Text; + row["Description"] = prim.Description; + row["SitName"] = prim.SitName; + row["TouchName"] = prim.TouchName; + // permissions + row["ObjectFlags"] = prim.ObjectFlags; + row["CreatorID"] = Util.ToRawUuidString(prim.CreatorID); + row["OwnerID"] = Util.ToRawUuidString(prim.OwnerID); + row["GroupID"] = Util.ToRawUuidString(prim.GroupID); + row["LastOwnerID"] = Util.ToRawUuidString(prim.LastOwnerID); + row["OwnerMask"] = prim.OwnerMask; + row["NextOwnerMask"] = prim.NextOwnerMask; + row["GroupMask"] = prim.GroupMask; + row["EveryoneMask"] = prim.EveryoneMask; + row["BaseMask"] = prim.BaseMask; + // vectors + row["PositionX"] = prim.OffsetPosition.X; + row["PositionY"] = prim.OffsetPosition.Y; + row["PositionZ"] = prim.OffsetPosition.Z; + row["GroupPositionX"] = prim.GroupPosition.X; + row["GroupPositionY"] = prim.GroupPosition.Y; + row["GroupPositionZ"] = prim.GroupPosition.Z; + row["VelocityX"] = prim.Velocity.X; + row["VelocityY"] = prim.Velocity.Y; + row["VelocityZ"] = prim.Velocity.Z; + row["AngularVelocityX"] = prim.AngularVelocity.X; + row["AngularVelocityY"] = prim.AngularVelocity.Y; + row["AngularVelocityZ"] = prim.AngularVelocity.Z; + row["AccelerationX"] = prim.Acceleration.X; + row["AccelerationY"] = prim.Acceleration.Y; + row["AccelerationZ"] = prim.Acceleration.Z; + // quaternions + row["RotationX"] = prim.RotationOffset.X; + row["RotationY"] = prim.RotationOffset.Y; + row["RotationZ"] = prim.RotationOffset.Z; + row["RotationW"] = prim.RotationOffset.W; + + try + { + // Sit target + LLVector3 sitTargetPos = prim.GetSitTargetPositionLL(); + row["SitTargetOffsetX"] = sitTargetPos.X; + row["SitTargetOffsetY"] = sitTargetPos.Y; + row["SitTargetOffsetZ"] = sitTargetPos.Z; + + LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL(); + row["SitTargetOrientW"] = sitTargetOrient.W; + row["SitTargetOrientX"] = sitTargetOrient.X; + row["SitTargetOrientY"] = sitTargetOrient.Y; + row["SitTargetOrientZ"] = sitTargetOrient.Z; + } + catch (MySqlException) + { + // Database table was created before we got here and needs to be created! :P + + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + } + + private void fillItemRow(DataRow row, TaskInventoryItem taskItem) + { + row["itemID"] = taskItem.ItemID; + row["primID"] = taskItem.ParentPartID; + row["assetID"] = taskItem.AssetID; + row["parentFolderID"] = taskItem.ParentID; + + row["invType"] = taskItem.InvType; + row["assetType"] = taskItem.Type; + + row["name"] = taskItem.Name; + row["description"] = taskItem.Description; + row["creationDate"] = taskItem.CreationDate; + row["creatorID"] = taskItem.CreatorID; + row["ownerID"] = taskItem.OwnerID; + row["lastOwnerID"] = taskItem.LastOwnerID; + row["groupID"] = taskItem.GroupID; + row["nextPermissions"] = taskItem.NextOwnerMask; + row["currentPermissions"] = taskItem.OwnerMask; + row["basePermissions"] = taskItem.BaseMask; + row["everyonePermissions"] = taskItem.EveryoneMask; + row["groupPermissions"] = taskItem.GroupMask; + } + + private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) + { + row["UUID"] = Util.ToRawUuidString(land.globalID); + row["RegionUUID"] = Util.ToRawUuidString(regionUUID); + row["LocalLandID"] = land.localID; + + // Bitmap is a byte[512] + row["Bitmap"] = land.landBitmapByteArray; + + row["Name"] = land.landName; + row["Description"] = land.landDesc; + row["OwnerUUID"] = Util.ToRawUuidString(land.ownerID); + row["IsGroupOwned"] = land.isGroupOwned; + row["Area"] = land.area; + row["AuctionID"] = land.auctionID; //Unemplemented + row["Category"] = land.category; //Enum libsecondlife.Parcel.ParcelCategory + row["ClaimDate"] = land.claimDate; + row["ClaimPrice"] = land.claimPrice; + row["GroupUUID"] = Util.ToRawUuidString(land.groupID); + row["SalePrice"] = land.salePrice; + row["LandStatus"] = land.landStatus; //Enum. libsecondlife.Parcel.ParcelStatus + row["LandFlags"] = land.landFlags; + row["LandingType"] = land.landingType; + row["MediaAutoScale"] = land.mediaAutoScale; + row["MediaTextureUUID"] = Util.ToRawUuidString(land.mediaID); + row["MediaURL"] = land.mediaURL; + row["MusicURL"] = land.musicURL; + row["PassHours"] = land.passHours; + row["PassPrice"] = land.passPrice; + row["SnapshotUUID"] = Util.ToRawUuidString(land.snapshotID); + row["UserLocationX"] = land.userLocation.X; + row["UserLocationY"] = land.userLocation.Y; + row["UserLocationZ"] = land.userLocation.Z; + row["UserLookAtX"] = land.userLookAt.X; + row["UserLookAtY"] = land.userLookAt.Y; + row["UserLookAtZ"] = land.userLookAt.Z; + } + + private void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) + { + row["LandUUID"] = Util.ToRawUuidString(parcelID); + row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); + row["Flags"] = entry.Flags; + } + + private PrimitiveBaseShape buildShape(DataRow row) + { + PrimitiveBaseShape s = new PrimitiveBaseShape(); + s.Scale = new LLVector3( + Convert.ToSingle(row["ScaleX"]), + Convert.ToSingle(row["ScaleY"]), + Convert.ToSingle(row["ScaleZ"]) + ); + // paths + s.PCode = Convert.ToByte(row["PCode"]); + s.PathBegin = Convert.ToUInt16(row["PathBegin"]); + s.PathEnd = Convert.ToUInt16(row["PathEnd"]); + s.PathScaleX = Convert.ToByte(row["PathScaleX"]); + s.PathScaleY = Convert.ToByte(row["PathScaleY"]); + s.PathShearX = Convert.ToByte(row["PathShearX"]); + s.PathShearY = Convert.ToByte(row["PathShearY"]); + s.PathSkew = Convert.ToSByte(row["PathSkew"]); + s.PathCurve = Convert.ToByte(row["PathCurve"]); + s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); + s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); + s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); + s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); + s.PathTwist = Convert.ToSByte(row["PathTwist"]); + s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); + // profile + s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); + s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); + s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); + s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); + + byte[] textureEntry = (byte[]) row["Texture"]; + s.TextureEntry = textureEntry; + + s.ExtraParams = (byte[]) row["ExtraParams"]; + + try + { + s.State = Convert.ToByte(row["State"]); + } + catch (InvalidCastException) + { + // Database table was created before we got here and needs to be created! :P + + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + + return s; + } + + private void fillShapeRow(DataRow row, SceneObjectPart prim) + { + PrimitiveBaseShape s = prim.Shape; + row["UUID"] = Util.ToRawUuidString(prim.UUID); + // shape is an enum + row["Shape"] = 0; + // vectors + row["ScaleX"] = s.Scale.X; + row["ScaleY"] = s.Scale.Y; + row["ScaleZ"] = s.Scale.Z; + // paths + row["PCode"] = s.PCode; + row["PathBegin"] = s.PathBegin; + row["PathEnd"] = s.PathEnd; + row["PathScaleX"] = s.PathScaleX; + row["PathScaleY"] = s.PathScaleY; + row["PathShearX"] = s.PathShearX; + row["PathShearY"] = s.PathShearY; + row["PathSkew"] = s.PathSkew; + row["PathCurve"] = s.PathCurve; + row["PathRadiusOffset"] = s.PathRadiusOffset; + row["PathRevolutions"] = s.PathRevolutions; + row["PathTaperX"] = s.PathTaperX; + row["PathTaperY"] = s.PathTaperY; + row["PathTwist"] = s.PathTwist; + row["PathTwistBegin"] = s.PathTwistBegin; + // profile + row["ProfileBegin"] = s.ProfileBegin; + row["ProfileEnd"] = s.ProfileEnd; + row["ProfileCurve"] = s.ProfileCurve; + row["ProfileHollow"] = s.ProfileHollow; + row["Texture"] = s.TextureEntry; + row["ExtraParams"] = s.ExtraParams; + try + { + row["State"] = s.State; + } + catch (MySqlException) + { + // Database table was created before we got here and needs to be created! :P + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + } + + private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) + { + DataTable prims = m_dataSet.Tables["prims"]; + DataTable shapes = m_dataSet.Tables["primshapes"]; + + DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (primRow == null) + { + primRow = prims.NewRow(); + fillPrimRow(primRow, prim, sceneGroupID, regionUUID); + prims.Rows.Add(primRow); + } + else + { + fillPrimRow(primRow, prim, sceneGroupID, regionUUID); + } + + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow == null) + { + shapeRow = shapes.NewRow(); + fillShapeRow(shapeRow, prim); + shapes.Rows.Add(shapeRow); + } + else + { + fillShapeRow(shapeRow, prim); + } + } + + // see IRegionDatastore + public void StorePrimInventory(LLUUID primID, ICollection items) + { + if (!persistPrimInventories) + return; + + m_log.InfoFormat("[DATASTORE]: Persisting Prim Inventory with prim ID {0}", primID); + + // For now, we're just going to crudely remove all the previous inventory items + // no matter whether they have changed or not, and replace them with the current set. + lock (m_dataSet) + { + RemoveItems(primID); + + // repalce with current inventory details + foreach (TaskInventoryItem newItem in items) + { +// m_log.InfoFormat( +// "[DATASTORE]: " + +// "Adding item {0}, {1} to prim ID {2}", +// newItem.Name, newItem.ItemID, newItem.ParentPartID); + + DataRow newItemRow = m_itemsTable.NewRow(); + fillItemRow(newItemRow, newItem); + m_itemsTable.Rows.Add(newItemRow); + } + } + + Commit(); + } + + /*********************************************************************** + * + * SQL Statement Creation Functions + * + * These functions create SQL statements for update, insert, and create. + * They can probably be factored later to have a db independant + * portion and a db specific portion + * + **********************************************************************/ + + private MySqlCommand createInsertCommand(string table, DataTable dt) + { + /** + * This is subtle enough to deserve some commentary. + * Instead of doing *lots* and *lots of hardcoded strings + * for database definitions we'll use the fact that + * realistically all insert statements look like "insert + * into A(b, c) values(:b, :c) on the parameterized query + * front. If we just have a list of b, c, etc... we can + * generate these strings instead of typing them out. + */ + string[] cols = new string[dt.Columns.Count]; + for (int i = 0; i < dt.Columns.Count; i++) + { + DataColumn col = dt.Columns[i]; + cols[i] = col.ColumnName; + } + + string sql = "insert into " + table + "("; + sql += String.Join(", ", cols); + // important, the first ':' needs to be here, the rest get added in the join + sql += ") values (?"; + sql += String.Join(", ?", cols); + sql += ")"; + MySqlCommand cmd = new MySqlCommand(sql); + + // this provides the binding for all our parameters, so + // much less code than it used to be + foreach (DataColumn col in dt.Columns) + { + cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); + } + return cmd; + } + + private MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) + { + string sql = "update " + table + " set "; + string subsql = String.Empty; + foreach (DataColumn col in dt.Columns) + { + if (subsql.Length > 0) + { + // a map function would rock so much here + subsql += ", "; + } + subsql += col.ColumnName + "=?" + col.ColumnName; + } + sql += subsql; + sql += " where " + pk; + MySqlCommand cmd = new MySqlCommand(sql); + + // this provides the binding for all our parameters, so + // much less code than it used to be + + foreach (DataColumn col in dt.Columns) + { + cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); + } + return cmd; + } + + private string defineTable(DataTable dt) + { + string sql = "create table " + dt.TableName + "("; + string subsql = String.Empty; + foreach (DataColumn col in dt.Columns) + { + if (subsql.Length > 0) + { + // a map function would rock so much here + subsql += ",\n"; + } + subsql += col.ColumnName + " " + MySqlType(col.DataType); + if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) + { + subsql += " primary key"; + } + } + sql += subsql; + sql += ")"; + + //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); + + return sql; + } + + /*********************************************************************** + * + * Database Binding functions + * + * These will be db specific due to typing, and minor differences + * in databases. + * + **********************************************************************/ + + /// + /// This is a convenience function that collapses 5 repetitive + /// lines for defining MySqlParameters to 2 parameters: + /// column name and database type. + /// + /// It assumes certain conventions like ?param as the param + /// name to replace in parametrized queries, and that source + /// version is always current version, both of which are fine + /// for us. + /// + ///a built MySql parameter + private MySqlParameter createMySqlParameter(string name, Type type) + { + MySqlParameter param = new MySqlParameter(); + param.ParameterName = "?" + name; + param.DbType = dbtypeFromType(type); + param.SourceColumn = name; + param.SourceVersion = DataRowVersion.Current; + return param; + } + +// TODO: unused +// private MySqlParameter createParamWithValue(string name, Type type, Object o) +// { +// MySqlParameter param = createMySqlParameter(name, type); +// param.Value = o; +// return param; +// } + + private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) + { + MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); + insertCommand.Connection = conn; + da.InsertCommand = insertCommand; + + MySqlCommand updateCommand = createUpdateCommand("prims", "UUID=?UUID", m_primTable); + updateCommand.Connection = conn; + da.UpdateCommand = updateCommand; + + MySqlCommand delete = new MySqlCommand("delete from prims where UUID=?UUID"); + delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("primitems", m_itemsTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("primitems", "itemID = ?itemID", m_itemsTable); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from primitems where itemID = ?itemID"); + delete.Parameters.Add(createMySqlParameter("itemID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); + da.InsertCommand.Connection = conn; + } + + private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("land", "UUID=?UUID", m_dataSet.Tables["land"]); + da.UpdateCommand.Connection = conn; + } + + private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); + da.InsertCommand.Connection = conn; + } + + private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("primshapes", "UUID=?UUID", m_dataSet.Tables["primshapes"]); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from primshapes where UUID = ?UUID"); + delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + private void InitDB(MySqlConnection conn) + { + string createPrims = defineTable(createPrimTable()); + string createShapes = defineTable(createShapeTable()); + string createItems = defineTable(createItemsTable()); + string createTerrain = defineTable(createTerrainTable()); + string createLand = defineTable(createLandTable()); + string createLandAccessList = defineTable(createLandAccessListTable()); + + MySqlCommand pcmd = new MySqlCommand(createPrims, conn); + MySqlCommand scmd = new MySqlCommand(createShapes, conn); + MySqlCommand icmd = new MySqlCommand(createItems, conn); + MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); + MySqlCommand lcmd = new MySqlCommand(createLand, conn); + MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); + + if (conn.State != ConnectionState.Open) + { + try + { + conn.Open(); + } + catch (Exception ex) + { + m_log.Error("[MySql]: Error connecting to MySQL server: " + ex.Message); + m_log.Error("[MySql]: Application is terminating!"); + System.Threading.Thread.CurrentThread.Abort(); + } + } + + try + { + pcmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + m_log.WarnFormat("[MySql]: Primitives Table Already Exists: {0}", e); + } + + try + { + scmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + m_log.WarnFormat("[MySql]: Shapes Table Already Exists: {0}", e); + } + + try + { + icmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + m_log.WarnFormat("[MySql]: Items Table Already Exists: {0}", e); + } + + try + { + tcmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + m_log.WarnFormat("[MySql]: Terrain Table Already Exists: {0}", e); + } + + try + { + lcmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); + } + + try + { + lalcmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + m_log.WarnFormat("[MySql]: LandAccessList Table Already Exists: {0}", e); + } + conn.Close(); + } + + private bool TestTables(MySqlConnection conn) + { + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); + MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); + MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); + MySqlDataAdapter sDa = new MySqlDataAdapter(shapeSelectCmd); + MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, conn); + MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd); + MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, conn); + MySqlDataAdapter tDa = new MySqlDataAdapter(terrainSelectCmd); + MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, conn); + MySqlDataAdapter lDa = new MySqlDataAdapter(landSelectCmd); + MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, conn); + MySqlDataAdapter lalDa = new MySqlDataAdapter(landAccessListSelectCmd); + + DataSet tmpDS = new DataSet(); + try + { + pDa.Fill(tmpDS, "prims"); + sDa.Fill(tmpDS, "primshapes"); + + if (persistPrimInventories) + iDa.Fill(tmpDS, "primitems"); + + tDa.Fill(tmpDS, "terrain"); + lDa.Fill(tmpDS, "land"); + lalDa.Fill(tmpDS, "landaccesslist"); + } + catch (MySqlException) + { + m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); + InitDB(conn); + } + + pDa.Fill(tmpDS, "prims"); + sDa.Fill(tmpDS, "primshapes"); + + if (persistPrimInventories) + iDa.Fill(tmpDS, "primitems"); + + tDa.Fill(tmpDS, "terrain"); + lDa.Fill(tmpDS, "land"); + lalDa.Fill(tmpDS, "landaccesslist"); + + foreach (DataColumn col in createPrimTable().Columns) + { + if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) + { + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); + return false; + } + } + + foreach (DataColumn col in createShapeTable().Columns) + { + if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) + { + m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); + return false; + } + } + + // XXX primitems should probably go here eventually + + foreach (DataColumn col in createTerrainTable().Columns) + { + if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) + { + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + return false; + } + } + + foreach (DataColumn col in createLandTable().Columns) + { + if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) + { + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + return false; + } + } + + foreach (DataColumn col in createLandAccessListTable().Columns) + { + if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) + { + m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + return false; + } + } + + return true; + } + + /*********************************************************************** + * + * Type conversion functions + * + **********************************************************************/ + + private DbType dbtypeFromType(Type type) + { + if (type == typeof (String)) + { + return DbType.String; + } + else if (type == typeof (Int32)) + { + return DbType.Int32; + } + else if (type == typeof (Double)) + { + return DbType.Double; + } + else if (type == typeof (Byte)) + { + return DbType.Byte; + } + else if (type == typeof (Double)) + { + return DbType.Double; + } + else if (type == typeof (Byte[])) + { + return DbType.Binary; + } + else + { + return DbType.String; + } + } + + // this is something we'll need to implement for each db + // slightly differently. + private string MySqlType(Type type) + { + if (type == typeof (String)) + { + return "varchar(255)"; + } + else if (type == typeof (Int32)) + { + return "integer"; + } + else if (type == typeof (Int64)) + { + return "bigint"; + } + else if (type == typeof (Double)) + { + return "float"; + } + else if (type == typeof (Byte[])) + { + return "longblob"; + } + else + { + return "string"; + } + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs new file mode 100644 index 0000000..61ab067 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -0,0 +1,402 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; +using libsecondlife; +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Data.MySQL +{ + /// + /// A MySQL Interface for the Grid Server + /// + public class MySQLGridData : GridDataBase + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// MySQL Database Manager + /// + private MySQLManager database; + + /// + /// Initialises the Grid Interface + /// + override public void Initialise() + { + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); + string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); + string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); + string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + + TestTables(); + } + + #region Test and initialization code + + /// + /// Ensure that the user related tables exists and are at the latest version + /// + private void TestTables() + { + Dictionary tableList = new Dictionary(); + + tableList["regions"] = null; + database.GetTableVersion(tableList); + + UpgradeRegionsTable(tableList["regions"]); + } + + /// + /// Create or upgrade the table if necessary + /// + /// A null indicates that the table does not + /// currently exist + private void UpgradeRegionsTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateRegionsTable.sql"); + return; + } + if (oldVersion.Contains("Rev. 1")) + { + database.ExecuteResourceSql("UpgradeRegionsTableToVersion2.sql"); + return; + } + if (oldVersion.Contains("Rev. 2")) + { + database.ExecuteResourceSql("UpgradeRegionsTableToVersion3.sql"); + return; + } + } + + #endregion + + /// + /// Shuts down the grid interface + /// + override public void Close() + { + database.Close(); + } + + /// + /// Returns the plugin name + /// + /// Plugin name + override public string getName() + { + return "MySql OpenGridData"; + } + + /// + /// Returns the plugin version + /// + /// Plugin version + override public string getVersion() + { + return "0.1"; + } + + /// + /// Returns all the specified region profiles within coordates -- coordinates are inclusive + /// + /// Minimum X coordinate + /// Minimum Y coordinate + /// Maximum X coordinate + /// Maximum Y coordinate + /// + override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?xmin"] = xmin.ToString(); + param["?ymin"] = ymin.ToString(); + param["?xmax"] = xmax.ToString(); + param["?ymax"] = ymax.ToString(); + + IDbCommand result = + database.Query( + "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row; + + List rows = new List(); + + while ((row = database.readSimRow(reader)) != null) + { + rows.Add(row); + } + reader.Close(); + result.Dispose(); + + return rows.ToArray(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Returns a sim profile from it's location + /// + /// Region location handle + /// Sim profile + override public RegionProfileData GetProfileByHandle(ulong handle) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?handle"] = handle.ToString(); + + IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = database.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Returns a sim profile from it's UUID + /// + /// The region UUID + /// The sim profile + override public RegionProfileData GetProfileByLLUUID(LLUUID uuid) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); + + IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = database.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Returns a sim profile from it's Region name string + /// + /// The region name search query + /// The sim profile + override public RegionProfileData GetProfileByString(string regionName) + { + if (regionName.Length > 2) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + // Add % because this is a like query. + param["?regionName"] = regionName + "%"; + // Order by statement will return shorter matches first. Only returns one record or no record. + IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = database.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + else + { + m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); + return null; + } + } + + /// + /// Adds a new profile to the database + /// + /// The profile to add + /// Successful? + override public DataResponse AddProfile(RegionProfileData profile) + { + lock (database) + { + if (database.insertRegion(profile)) + { + return DataResponse.RESPONSE_OK; + } + else + { + return DataResponse.RESPONSE_ERROR; + } + } + } + + /// + /// Deletes a profile from the database + /// + /// The profile to delete + /// Successful? + //public DataResponse DeleteProfile(RegionProfileData profile) + public DataResponse DeleteProfile(string uuid) + { + lock (database) + { + if (database.deleteRegion(uuid)) + { + return DataResponse.RESPONSE_OK; + } + else + { + return DataResponse.RESPONSE_ERROR; + } + } + } + + /// + /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. + /// + /// The UUID of the challenger + /// The attempted regionHandle of the challenger + /// The secret + /// Whether the secret and regionhandle match the database entry for UUID + override public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) + { + bool throwHissyFit = false; // Should be true by 1.0 + + if (throwHissyFit) + throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); + + RegionProfileData data = GetProfileByLLUUID(uuid); + + return (handle == data.regionHandle && authkey == data.regionSecret); + } + + /// + /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region + /// + /// This requires a security audit. + /// + /// + /// + /// + /// + public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge) + { + SHA512Managed HashProvider = new SHA512Managed(); + ASCIIEncoding TextProvider = new ASCIIEncoding(); + + byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); + byte[] hash = HashProvider.ComputeHash(stream); + + return false; + } + + override public ReservationData GetReservationAtPoint(uint x, uint y) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + IDbCommand result = + database.Query( + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param); + IDataReader reader = result.ExecuteReader(); + + ReservationData row = database.readReservationRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs new file mode 100644 index 0000000..4165d8f --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -0,0 +1,648 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using libsecondlife; +using MySql.Data.MySqlClient; +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Data.MySQL +{ + /// + /// A MySQL interface for the inventory server + /// + public class MySQLInventoryData : IInventoryData + { + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// The database manager + /// + private MySQLManager database; + + /// + /// Loads and initialises this database plugin + /// + public void Initialise() + { + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); + string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); + string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); + string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + TestTables(database.Connection); + } + + #region Test and initialization code + + private void UpgradeFoldersTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateFoldersTable.sql"); + return; + } + + // if the table is already at the current version, then we can exit immediately +// if (oldVersion == "Rev. 2") +// return; + +// database.ExecuteResourceSql("UpgradeFoldersTableToVersion2.sql"); + } + + private void UpgradeItemsTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateItemsTable.sql"); + return; + } + + // if the table is already at the current version, then we can exit immediately +// if (oldVersion == "Rev. 2") +// return; + +// database.ExecuteResourceSql("UpgradeItemsTableToVersion2.sql"); + } + + private void TestTables(MySqlConnection conn) + { + Dictionary tableList = new Dictionary(); + + tableList["inventoryfolders"] = null; + tableList["inventoryitems"] = null; + + database.GetTableVersion(tableList); + m_log.Info("[MYSQL]: Inventory Folder Version: " + tableList["inventoryfolders"]); + m_log.Info("[MYSQL]: Inventory Items Version: " + tableList["inventoryitems"]); + + UpgradeFoldersTable(tableList["inventoryfolders"]); + UpgradeItemsTable(tableList["inventoryitems"]); + } + + #endregion + + /// + /// The name of this DB provider + /// + /// Name of DB provider + public string getName() + { + return "MySQL Inventory Data Interface"; + } + + /// + /// Closes this DB provider + /// + public void Close() + { + // Do nothing. + } + + /// + /// Returns the version of this DB provider + /// + /// A string containing the DB provider + public string getVersion() + { + return database.getVersion(); + } + + /// + /// Returns a list of items in a specified folder + /// + /// The folder to search + /// A list containing inventory items + public List getInventoryInFolder(LLUUID folderID) + { + try + { + lock (database) + { + List items = new List(); + + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + while (reader.Read()) + items.Add(readInventoryItem(reader)); + + reader.Close(); + result.Dispose(); + + return items; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Returns a list of the root folders within a users inventory + /// + /// The user whos inventory is to be searched + /// A list of folder objects + public List getUserRootFolders(LLUUID user) + { + try + { + lock (database) + { + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); + + + reader.Close(); + result.Dispose(); + + return items; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + // see InventoryItemBase.getUserRootFolder + public InventoryFolderBase getUserRootFolder(LLUUID user) + { + try + { + lock (database) + { + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToString()); + + MySqlDataReader reader = result.ExecuteReader(); + + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); + + InventoryFolderBase rootFolder = null; + + // There should only ever be one root folder for a user. However, if there's more + // than one we'll simply use the first one rather than failing. It would be even + // nicer to print some message to this effect, but this feels like it's too low a + // to put such a message out, and it's too minor right now to spare the time to + // suitably refactor. + if (items.Count > 0) + { + rootFolder = items[0]; + } + + reader.Close(); + result.Dispose(); + + return rootFolder; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Return a list of folders in a users inventory contained within the specified folder. + /// This method is only used in tests - in normal operation the user always have one, + /// and only one, root folder. + /// + /// The folder to search + /// A list of inventory folders + public List getInventoryFolders(LLUUID parentID) + { + try + { + lock (database) + { + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + List items = new List(); + + while (reader.Read()) + items.Add(readInventoryFolder(reader)); + + reader.Close(); + result.Dispose(); + + return items; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Reads a one item from an SQL result + /// + /// The SQL Result + /// the item read + private InventoryItemBase readInventoryItem(MySqlDataReader reader) + { + try + { + InventoryItemBase item = new InventoryItemBase(); + + item.inventoryID = new LLUUID((string) reader["inventoryID"]); + item.assetID = new LLUUID((string) reader["assetID"]); + item.assetType = (int) reader["assetType"]; + item.parentFolderID = new LLUUID((string) reader["parentFolderID"]); + item.avatarID = new LLUUID((string) reader["avatarID"]); + item.inventoryName = (string) reader["inventoryName"]; + item.inventoryDescription = (string) reader["inventoryDescription"]; + item.inventoryNextPermissions = (uint) reader["inventoryNextPermissions"]; + item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; + item.invType = (int) reader["invType"]; + item.creatorsID = new LLUUID((string) reader["creatorID"]); + item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"]; + item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + return item; + } + catch (MySqlException e) + { + m_log.Error(e.ToString()); + } + + return null; + } + + /// + /// Returns a specified inventory item + /// + /// The item to return + /// An inventory item + public InventoryItemBase getInventoryItem(LLUUID itemID) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); + result.Parameters.AddWithValue("?uuid", itemID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + InventoryItemBase item = null; + if (reader.Read()) + item = readInventoryItem(reader); + + reader.Close(); + result.Dispose(); + + return item; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } + return null; + } + + /// + /// Reads a list of inventory folders returned by a query. + /// + /// A MySQL Data Reader + /// A List containing inventory folders + protected InventoryFolderBase readInventoryFolder(MySqlDataReader reader) + { + try + { + InventoryFolderBase folder = new InventoryFolderBase(); + folder.agentID = new LLUUID((string) reader["agentID"]); + folder.parentID = new LLUUID((string) reader["parentFolderID"]); + folder.folderID = new LLUUID((string) reader["folderID"]); + folder.name = (string) reader["folderName"]; + folder.type = (short) reader["type"]; + folder.version = (ushort) ((int) reader["version"]); + return folder; + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + + return null; + } + + + /// + /// Returns a specified inventory folder + /// + /// The folder to return + /// A folder class + public InventoryFolderBase getInventoryFolder(LLUUID folderID) + { + try + { + lock (database) + { + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + reader.Read(); + InventoryFolderBase folder = readInventoryFolder(reader); + reader.Close(); + result.Dispose(); + + return folder; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Adds a specified item to the database + /// + /// The inventory item + public void addInventoryItem(InventoryItemBase item) + { + string sql = + "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES "; + sql += + "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)"; + + try + { + MySqlCommand result = new MySqlCommand(sql, database.Connection); + result.Parameters.AddWithValue("?inventoryID", item.inventoryID.ToString()); + result.Parameters.AddWithValue("?assetID", item.assetID.ToString()); + result.Parameters.AddWithValue("?assetType", item.assetType.ToString()); + result.Parameters.AddWithValue("?parentFolderID", item.parentFolderID.ToString()); + result.Parameters.AddWithValue("?avatarID", item.avatarID.ToString()); + result.Parameters.AddWithValue("?inventoryName", item.inventoryName); + result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription); + result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); + result.Parameters.AddWithValue("?inventoryCurrentPermissions", + item.inventoryCurrentPermissions.ToString()); + result.Parameters.AddWithValue("?invType", item.invType); + result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToString()); + result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions); + result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.inventoryEveryOnePermissions); + result.ExecuteNonQuery(); + result.Dispose(); + } + catch (MySqlException e) + { + m_log.Error(e.ToString()); + } + } + + /// + /// Updates the specified inventory item + /// + /// Inventory item to update + public void updateInventoryItem(InventoryItemBase item) + { + addInventoryItem(item); + } + + /// + /// + /// + /// + public void deleteInventoryItem(LLUUID itemID) + { + try + { + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); + cmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } + } + + /// + /// Creates a new inventory folder + /// + /// Folder to create + public void addInventoryFolder(InventoryFolderBase folder) + { + string sql = + "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; + sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; + + MySqlCommand cmd = new MySqlCommand(sql, database.Connection); + cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString()); + cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString()); + cmd.Parameters.AddWithValue("?folderName", folder.name); + cmd.Parameters.AddWithValue("?type", (short) folder.type); + cmd.Parameters.AddWithValue("?version", folder.version); + + try + { + lock (database) + { + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + + /// + /// Updates an inventory folder + /// + /// Folder to update + public void updateInventoryFolder(InventoryFolderBase folder) + { + addInventoryFolder(folder); + } + + /// Creates a new inventory folder + /// + /// Folder to create + public void moveInventoryFolder(InventoryFolderBase folder) + { + string sql = + "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; + + MySqlCommand cmd = new MySqlCommand(sql, database.Connection); + cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString()); + + try + { + lock (database) + { + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + + /// + /// Append a list of all the child folders of a parent folder + /// + /// list where folders will be appended + /// ID of parent + protected void getInventoryFolders(ref List folders, LLUUID parentID) + { + List subfolderList = getInventoryFolders(parentID); + + foreach (InventoryFolderBase f in subfolderList) + folders.Add(f); + } + + // See IInventoryData + public List getFolderHierarchy(LLUUID parentID) + { + List folders = new List(); + getInventoryFolders(ref folders, parentID); + + for (int i = 0; i < folders.Count; i++) + getInventoryFolders(ref folders, folders[i].folderID); + + return folders; + } + + protected void deleteOneFolder(LLUUID folderID) + { + try + { + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + + lock (database) + { + cmd.ExecuteNonQuery(); + } + } + catch (MySqlException e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } + } + + protected void deleteItemsInFolder(LLUUID folderID) + { + try + { + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + + lock (database) + { + cmd.ExecuteNonQuery(); + } + } + catch (MySqlException e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } + } + + /// + /// Delete an inventory folder + /// + /// Id of folder to delete + public void deleteInventoryFolder(LLUUID folderID) + { + List subFolders = getFolderHierarchy(folderID); + + //Delete all sub-folders + foreach (InventoryFolderBase f in subFolders) + { + deleteOneFolder(f.folderID); + deleteItemsInFolder(f.folderID); + } + + //Delete the actual row + deleteOneFolder(folderID); + deleteItemsInFolder(folderID); + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs new file mode 100644 index 0000000..480446f --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -0,0 +1,106 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OpenSim.Framework.Data.MySQL +{ + /// + /// An interface to the log database for MySQL + /// + internal class MySQLLogData : ILogData + { + /// + /// The database manager + /// + public MySQLManager database; + + /// + /// Artificial constructor called when the plugin is loaded + /// + public void Initialise() + { + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); + string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); + string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); + string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + } + + /// + /// Saves a log item to the database + /// + /// The daemon triggering the event + /// The target of the action (region / agent UUID, etc) + /// The method call where the problem occured + /// The arguments passed to the method + /// How critical is this? + /// The message to log + public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, + string logMessage) + { + try + { + database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage); + } + catch + { + database.Reconnect(); + } + } + + /// + /// Returns the name of this DB provider + /// + /// A string containing the DB provider name + public string getName() + { + return "MySQL Logdata Interface"; + } + + /// + /// Closes the database provider + /// + public void Close() + { + // Do nothing. + } + + /// + /// Returns the version of this DB provider + /// + /// A string containing the provider version + public string getVersion() + { + return "0.1"; + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs new file mode 100644 index 0000000..579667b --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -0,0 +1,909 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.IO; +using System.Reflection; +using libsecondlife; +using MySql.Data.MySqlClient; +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Data.MySQL +{ + /// + /// A MySQL Database manager + /// + internal class MySQLManager + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// The database connection object + /// + private MySqlConnection dbcon; + + /// + /// Connection string for ADO.net + /// + private string connectionString; + + /// + /// Initialises and creates a new MySQL connection and maintains it. + /// + /// The MySQL server being connected to + /// The name of the MySQL database being used + /// The username logging into the database + /// The password for the user logging in + /// Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'. + public MySQLManager(string hostname, string database, string username, string password, string cpooling, + string port) + { + try + { + connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; + dbcon = new MySqlConnection(connectionString); + + try + { + dbcon.Open(); + } + catch(Exception e) + { + throw new Exception( "Connection error while using connection string ["+connectionString+"]", e ); + } + + m_log.Info("[MYSQL]: Connection established"); + } + catch (Exception e) + { + throw new Exception("Error initialising MySql Database: " + e.ToString()); + } + } + + /// + /// Get the connection being used + /// + public MySqlConnection Connection + { + get { return dbcon; } + } + + /// + /// Shuts down the database connection + /// + public void Close() + { + dbcon.Close(); + dbcon = null; + } + + /// + /// Reconnects to the database + /// + public void Reconnect() + { + lock (dbcon) + { + try + { + // Close the DB connection + dbcon.Close(); + // Try reopen it + dbcon = new MySqlConnection(connectionString); + dbcon.Open(); + } + catch (Exception e) + { + m_log.Error("Unable to reconnect to database " + e.ToString()); + } + } + } + + /// + /// Returns the version of this DB provider + /// + /// A string containing the DB provider + public string getVersion() + { + Module module = GetType().Module; + string dllName = module.Assembly.ManifestModule.Name; + Version dllVersion = module.Assembly.GetName().Version; + + return + string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, + dllVersion.Revision); + } + + /// + /// Extract a named string resource from the embedded resources + /// + /// name of embedded resource + /// string contained within the embedded resource + private string getResourceString(string name) + { + Assembly assem = GetType().Assembly; + string[] names = assem.GetManifestResourceNames(); + + foreach (string s in names) + { + if (s.EndsWith(name)) + { + using (Stream resource = assem.GetManifestResourceStream(s)) + { + using (StreamReader resourceReader = new StreamReader(resource)) + { + string resourceString = resourceReader.ReadToEnd(); + return resourceString; + } + } + } + } + throw new Exception(string.Format("Resource '{0}' was not found", name)); + } + + /// + /// Execute a SQL statement stored in a resource, as a string + /// + /// + public void ExecuteResourceSql(string name) + { + MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); + cmd.ExecuteNonQuery(); + } + + /// + /// Given a list of tables, return the version of the tables, as seen in the database + /// + /// + public void GetTableVersion(Dictionary tableList) + { + lock (dbcon) + { + MySqlCommand tablesCmd = + new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon); + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + { + while (tables.Read()) + { + try + { + string tableName = (string) tables["TABLE_NAME"]; + string comment = (string) tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) + { + tableList[tableName] = comment; + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + tables.Close(); + } + } + } + + // TODO: at some time this code should be cleaned up + + /// + /// Runs a query with protection against SQL Injection by using parameterised input. + /// + /// The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y + /// The parameters - index so that @y is indexed as 'y' + /// A MySQL DB Command + public IDbCommand Query(string sql, Dictionary parameters) + { + try + { + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); + dbcommand.CommandText = sql; + foreach (KeyValuePair param in parameters) + { + dbcommand.Parameters.AddWithValue(param.Key, param.Value); + } + + return (IDbCommand) dbcommand; + } + catch + { + lock (dbcon) + { + // Close the DB connection + try + { + dbcon.Close(); + } + catch + { + } + + // Try to reopen it + try + { + dbcon = new MySqlConnection(connectionString); + dbcon.Open(); + } + catch (Exception e) + { + m_log.Error("Unable to reconnect to database " + e.ToString()); + } + + // Run the query again + try + { + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); + dbcommand.CommandText = sql; + foreach (KeyValuePair param in parameters) + { + dbcommand.Parameters.AddWithValue(param.Key, param.Value); + } + + return (IDbCommand) dbcommand; + } + catch (Exception e) + { + // Return null if it fails. + m_log.Error("Failed during Query generation: " + e.ToString()); + return null; + } + } + } + } + + /// + /// Reads a region row from a database reader + /// + /// An active database reader + /// A region profile + public RegionProfileData readSimRow(IDataReader reader) + { + RegionProfileData retval = new RegionProfileData(); + + if (reader.Read()) + { + // Region Main gotta-have-or-we-return-null parts + if (!UInt64.TryParse(reader["regionHandle"].ToString(), out retval.regionHandle)) + return null; + if (!LLUUID.TryParse((string)reader["uuid"], out retval.UUID)) + return null; + + // non-critical parts + retval.regionName = (string)reader["regionName"]; + retval.originUUID = new LLUUID((string) reader["originUUID"]); + + // Secrets + retval.regionRecvKey = (string) reader["regionRecvKey"]; + retval.regionSecret = (string) reader["regionSecret"]; + retval.regionSendKey = (string) reader["regionSendKey"]; + + // Region Server + retval.regionDataURI = (string) reader["regionDataURI"]; + retval.regionOnline = false; // Needs to be pinged before this can be set. + retval.serverIP = (string) reader["serverIP"]; + retval.serverPort = (uint) reader["serverPort"]; + retval.serverURI = (string) reader["serverURI"]; + retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); + retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); + + // Location + retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); + retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); + retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); + + // Neighbours - 0 = No Override + retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); + retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); + retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); + retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); + + // Assets + retval.regionAssetURI = (string) reader["regionAssetURI"]; + retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; + retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; + + // Userserver + retval.regionUserURI = (string) reader["regionUserURI"]; + retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; + retval.regionUserSendKey = (string) reader["regionUserSendKey"]; + + // World Map Addition + LLUUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); + LLUUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); + } + else + { + return null; + } + return retval; + } + + /// + /// Reads a reservation row from a database reader + /// + /// An active database reader + /// A reservation data object + public ReservationData readReservationRow(IDataReader reader) + { + ReservationData retval = new ReservationData(); + if (reader.Read()) + { + retval.gridRecvKey = (string) reader["gridRecvKey"]; + retval.gridSendKey = (string) reader["gridSendKey"]; + retval.reservationCompany = (string) reader["resCompany"]; + retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); + retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); + retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); + retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); + retval.reservationName = (string) reader["resName"]; + retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; + LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID); + } + else + { + return null; + } + return retval; + } + + /// + /// Reads an agent row from a database reader + /// + /// An active database reader + /// A user session agent + public UserAgentData readAgentRow(IDataReader reader) + { + UserAgentData retval = new UserAgentData(); + + if (reader.Read()) + { + // Agent IDs + if (!LLUUID.TryParse((string)reader["UUID"], out retval.UUID)) + return null; + LLUUID.TryParse((string) reader["sessionID"], out retval.sessionID); + LLUUID.TryParse((string)reader["secureSessionID"], out retval.secureSessionID); + + // Agent Who? + retval.agentIP = (string) reader["agentIP"]; + retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); + retval.agentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString())); + + // Login/Logout times (UNIX Epoch) + retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); + retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); + + // Current position + retval.currentRegion = new LLUUID((string)reader["currentRegion"]); + retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); + LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); + } + else + { + return null; + } + return retval; + } + + /// + /// Reads a user profile from an active data reader + /// + /// An active database reader + /// A user profile + public UserProfileData readUserRow(IDataReader reader) + { + UserProfileData retval = new UserProfileData(); + + if (reader.Read()) + { + if (!LLUUID.TryParse((string)reader["UUID"], out retval.UUID)) + return null; + retval.username = (string) reader["username"]; + retval.surname = (string) reader["lastname"]; + + retval.passwordHash = (string) reader["passwordHash"]; + retval.passwordSalt = (string) reader["passwordSalt"]; + + retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); + retval.homeLocation = new LLVector3( + Convert.ToSingle(reader["homeLocationX"].ToString()), + Convert.ToSingle(reader["homeLocationY"].ToString()), + Convert.ToSingle(reader["homeLocationZ"].ToString())); + retval.homeLookAt = new LLVector3( + Convert.ToSingle(reader["homeLookAtX"].ToString()), + Convert.ToSingle(reader["homeLookAtY"].ToString()), + Convert.ToSingle(reader["homeLookAtZ"].ToString())); + + retval.created = Convert.ToInt32(reader["created"].ToString()); + retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); + + retval.userInventoryURI = (string) reader["userInventoryURI"]; + retval.userAssetURI = (string) reader["userAssetURI"]; + + retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); + retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); + + if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) + retval.profileAboutText = ""; + else + retval.profileAboutText = (string) reader["profileAboutText"]; + + if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) + retval.profileFirstText = ""; + else + retval.profileFirstText = (string)reader["profileFirstText"]; + + if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) + retval.profileImage = LLUUID.Zero; + else + LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); + + if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) + retval.profileFirstImage = LLUUID.Zero; + else + LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); + + if(reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) + { + retval.webLoginKey = LLUUID.Zero; + } + else + { + LLUUID.TryParse((string)reader["webLoginKey"], out retval.webLoginKey); + } + } + else + { + return null; + } + return retval; + } + + /// + /// Inserts a new row into the log database + /// + /// The daemon which triggered this event + /// Who were we operating on when this occured (region UUID, user UUID, etc) + /// The method call where the problem occured + /// The arguments passed to the method + /// How critical is this? + /// Extra message info + /// Saved successfully? + public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, + string logMessage) + { + string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; + sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; + + Dictionary parameters = new Dictionary(); + parameters["?server"] = serverDaemon; + parameters["?target"] = target; + parameters["?method"] = methodCall; + parameters["?arguments"] = arguments; + parameters["?priority"] = priority.ToString(); + parameters["?message"] = logMessage; + + bool returnval = false; + + try + { + IDbCommand result = Query(sql, parameters); + + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + return returnval; + } + + /// + /// Creates a new user and inserts it into the database + /// + /// User ID + /// First part of the login + /// Second part of the login + /// A salted hash of the users password + /// The salt used for the password hash + /// A regionHandle of the users home region + /// Home region position vector + /// Home region position vector + /// Home region position vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Account created (unix timestamp) + /// Last login (unix timestamp) + /// Users inventory URI + /// Users asset URI + /// I can do mask + /// I want to do mask + /// Profile text + /// Firstlife text + /// UUID for profile image + /// UUID for firstlife image + /// Success? + public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash, + string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, + string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, + string aboutText, string firstText, + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) + { + m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); + string sql = + "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; + sql += + "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; + sql += + "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; + sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`) VALUES "; + + sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; + sql += + "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; + sql += + "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; + sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey)"; + + Dictionary parameters = new Dictionary(); + parameters["?UUID"] = uuid.ToString(); + parameters["?username"] = username.ToString(); + parameters["?lastname"] = lastname.ToString(); + parameters["?passwordHash"] = passwordHash.ToString(); + parameters["?passwordSalt"] = passwordSalt.ToString(); + parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeLocationX"] = homeLocX.ToString(); + parameters["?homeLocationY"] = homeLocY.ToString(); + parameters["?homeLocationZ"] = homeLocZ.ToString(); + parameters["?homeLookAtX"] = homeLookAtX.ToString(); + parameters["?homeLookAtY"] = homeLookAtY.ToString(); + parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); + parameters["?created"] = created.ToString(); + parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?userInventoryURI"] = String.Empty; + parameters["?userAssetURI"] = String.Empty; + parameters["?profileCanDoMask"] = "0"; + parameters["?profileWantDoMask"] = "0"; + parameters["?profileAboutText"] = aboutText; + parameters["?profileFirstText"] = firstText; + parameters["?profileImage"] = profileImage.ToString(); + parameters["?profileFirstImage"] = firstImage.ToString(); + parameters["?webLoginKey"] = string.Empty; + + bool returnval = false; + + try + { + IDbCommand result = Query(sql, parameters); + + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString()); + return returnval; + } + + /// + /// Creates a new user and inserts it into the database + /// + /// User ID + /// First part of the login + /// Second part of the login + /// A salted hash of the users password + /// The salt used for the password hash + /// A regionHandle of the users home region + /// Home region position vector + /// Home region position vector + /// Home region position vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Account created (unix timestamp) + /// Last login (unix timestamp) + /// Users inventory URI + /// Users asset URI + /// I can do mask + /// I want to do mask + /// Profile text + /// Firstlife text + /// UUID for profile image + /// UUID for firstlife image + /// Success? + public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, + string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, + string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, + string aboutText, string firstText, + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) + { + string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; + sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; + sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , "; + sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; + sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; + sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; + sql += "`userInventoryURI` = ?userInventoryURI , `userAssetURI` = ?userAssetURI , "; + sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , "; + sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; + sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; + sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; + + Dictionary parameters = new Dictionary(); + parameters["?UUID"] = uuid.ToString(); + parameters["?username"] = username.ToString(); + parameters["?lastname"] = lastname.ToString(); + parameters["?passwordHash"] = passwordHash.ToString(); + parameters["?passwordSalt"] = passwordSalt.ToString(); + parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeLocationX"] = homeLocX.ToString(); + parameters["?homeLocationY"] = homeLocY.ToString(); + parameters["?homeLocationZ"] = homeLocZ.ToString(); + parameters["?homeLookAtX"] = homeLookAtX.ToString(); + parameters["?homeLookAtY"] = homeLookAtY.ToString(); + parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); + parameters["?created"] = created.ToString(); + parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?userInventoryURI"] = inventoryURI; + parameters["?userAssetURI"] = assetURI; + parameters["?profileCanDoMask"] = "0"; + parameters["?profileWantDoMask"] = "0"; + parameters["?profileAboutText"] = aboutText; + parameters["?profileFirstText"] = firstText; + parameters["?profileImage"] = profileImage.ToString(); + parameters["?profileFirstImage"] = firstImage.ToString(); + parameters["?webLoginKey"] = webLoginKey.ToString(); + + bool returnval = false; + try + { + IDbCommand result = Query(sql, parameters); + + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString()); + return returnval; + } + + /// + /// Inserts a new region into the database + /// + /// The region to insert + /// Success? + public bool insertRegion(RegionProfileData regiondata) + { + bool GRID_ONLY_UPDATE_NECESSARY_DATA = false; + + string sql = String.Empty; + if (GRID_ONLY_UPDATE_NECESSARY_DATA) + { + sql += "INSERT INTO "; + } + else + { + sql += "REPLACE INTO "; + } + + sql += "regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; + sql += + "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; + + // part of an initial brutish effort to provide accurate information (as per the xml region spec) + // wrt the ownership of a given region + // the (very bad) assumption is that this value is being read and handled inconsistently or + // not at all. Current strategy is to put the code in place to support the validity of this information + // and to roll forward debugging any issues from that point + // + // this particular section of the mod attempts to implement the commit of a supplied value + // server for the UUID of the region's owner (master avatar). It consists of the addition of the column and value to the relevant sql, + // as well as the related parameterization + sql += + "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID) VALUES "; + + sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; + sql += + "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; + sql += + "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid, ?originUUID)"; + + if (GRID_ONLY_UPDATE_NECESSARY_DATA) + { + sql += "ON DUPLICATE KEY UPDATE serverIP = ?serverIP, serverPort = ?serverPort, serverURI = ?serverURI, owner_uuid - ?owner_uuid;"; + } + else + { + sql += ";"; + } + + Dictionary parameters = new Dictionary(); + + parameters["?regionHandle"] = regiondata.regionHandle.ToString(); + parameters["?regionName"] = regiondata.regionName.ToString(); + parameters["?uuid"] = regiondata.UUID.ToString(); + parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString(); + parameters["?regionSecret"] = regiondata.regionSecret.ToString(); + parameters["?regionSendKey"] = regiondata.regionSendKey.ToString(); + parameters["?regionDataURI"] = regiondata.regionDataURI.ToString(); + parameters["?serverIP"] = regiondata.serverIP.ToString(); + parameters["?serverPort"] = regiondata.serverPort.ToString(); + parameters["?serverURI"] = regiondata.serverURI.ToString(); + parameters["?locX"] = regiondata.regionLocX.ToString(); + parameters["?locY"] = regiondata.regionLocY.ToString(); + parameters["?locZ"] = regiondata.regionLocZ.ToString(); + parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString(); + parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString(); + parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString(); + parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString(); + parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString(); + parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString(); + parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString(); + parameters["?regionUserURI"] = regiondata.regionUserURI.ToString(); + parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString(); + parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString(); + parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToString(); + parameters["?serverHttpPort"] = regiondata.httpPort.ToString(); + parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString(); + parameters["?owner_uuid"] = regiondata.owner_uuid.ToString(); + parameters["?originUUID"] = regiondata.originUUID.ToString(); + + bool returnval = false; + + try + { + IDbCommand result = Query(sql, parameters); + + //Console.WriteLine(result.CommandText); + int x; + if ((x = result.ExecuteNonQuery()) > 0) + { + returnval = true; + } + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + return returnval; + } + + /// + /// Delete a region from the database + /// + /// The region to insert + /// Success? + //public bool deleteRegion(RegionProfileData regiondata) + public bool deleteRegion(string uuid) + { + bool returnval = false; + + string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; + + Dictionary parameters = new Dictionary(); + + try + { + parameters["?uuid"] = uuid; + + IDbCommand result = Query(sql, parameters); + + int x; + if ((x = result.ExecuteNonQuery()) > 0) + { + returnval = true; + } + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + return returnval; + } + + /// + /// Creates a new agent and inserts it into the database + /// + /// The agent data to be inserted + /// Success? + public bool insertAgentRow(UserAgentData agentdata) + { + string sql = String.Empty; + sql += "REPLACE INTO "; + sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES "; + sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos);"; + Dictionary parameters = new Dictionary(); + + parameters["?UUID"] = agentdata.UUID.ToString(); + parameters["?sessionID"] = agentdata.sessionID.ToString(); + parameters["?secureSessionID"] = agentdata.secureSessionID.ToString(); + parameters["?agentIP"] = agentdata.agentIP.ToString(); + parameters["?agentPort"] = agentdata.agentPort.ToString(); + parameters["?agentOnline"] = (agentdata.agentOnline == true) ? "1" : "0"; + parameters["?loginTime"] = agentdata.loginTime.ToString(); + parameters["?logoutTime"] = agentdata.logoutTime.ToString(); + parameters["?currentRegion"] = agentdata.currentRegion.ToString(); + parameters["?currentHandle"] = agentdata.currentHandle.ToString(); + parameters["?currentPos"] = "<" + ((int)agentdata.currentPos.X).ToString() + "," + ((int)agentdata.currentPos.Y).ToString() + "," + ((int)agentdata.currentPos.Z).ToString() + ">"; + + bool returnval = false; + + try + { + IDbCommand result = Query(sql, parameters); + + //Console.WriteLine(result.CommandText); + int x; + if ((x = result.ExecuteNonQuery()) > 0) + { + returnval = true; + } + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + return returnval; + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs new file mode 100644 index 0000000..fd640ec --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -0,0 +1,643 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Text.RegularExpressions; +using libsecondlife; +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Data.MySQL +{ + /// + /// A database interface class to a user profile storage system + /// + internal class MySQLUserData : UserDataBase + { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Database manager for MySQL + /// + public MySQLManager database; + + private string m_agentsTableName; + private string m_usersTableName; + private string m_userFriendsTableName; + + /// + /// Loads and initialises the MySQL storage plugin + /// + override public void Initialise() + { + // Load from an INI file connection details + // TODO: move this to XML? Yes, PLEASE! + + IniFile iniFile = new IniFile("mysql_connection.ini"); + string settingHostname = iniFile.ParseFileReadValue("hostname"); + string settingDatabase = iniFile.ParseFileReadValue("database"); + string settingUsername = iniFile.ParseFileReadValue("username"); + string settingPassword = iniFile.ParseFileReadValue("password"); + string settingPooling = iniFile.ParseFileReadValue("pooling"); + string settingPort = iniFile.ParseFileReadValue("port"); + + m_usersTableName = iniFile.ParseFileReadValue("userstablename"); + if( m_usersTableName == null ) + { + m_usersTableName = "users"; + } + + m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); + if (m_userFriendsTableName == null) + { + m_userFriendsTableName = "userfriends"; + } + + m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); + if (m_agentsTableName == null) + { + m_agentsTableName = "agents"; + } + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + + TestTables(); + } + + #region Test and initialization code + + /// + /// Ensure that the user related tables exists and are at the latest version + /// + private void TestTables() + { + Dictionary tableList = new Dictionary(); + + tableList[m_agentsTableName] = null; + tableList[m_usersTableName] = null; + tableList[m_userFriendsTableName] = null; + database.GetTableVersion(tableList); + + UpgradeAgentsTable(tableList[m_agentsTableName]); + UpgradeUsersTable(tableList[m_usersTableName]); + UpgradeFriendsTable(tableList[m_userFriendsTableName]); + } + + /// + /// Create or upgrade the table if necessary + /// + /// A null indicates that the table does not + /// currently exist + private void UpgradeAgentsTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateAgentsTable.sql"); + return; + } + } + + /// + /// Create or upgrade the table if necessary + /// + /// A null indicates that the table does not + /// currently exist + private void UpgradeUsersTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateUsersTable.sql"); + return; + } + else if (oldVersion.Contains("Rev. 1")) + { + database.ExecuteResourceSql("UpgradeUsersTableToVersion2.sql"); + return; + } + //m_log.Info("[DB]: DBVers:" + oldVersion); + } + + /// + /// Create or upgrade the table if necessary + /// + /// A null indicates that the table does not + /// currently exist + private void UpgradeFriendsTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateUserFriendsTable.sql"); + return; + } + } + + #endregion + + // see IUserData + override public UserProfileData GetUserByName(string user, string last) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?first"] = user; + param["?second"] = last; + + IDbCommand result = + database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + UserProfileData row = database.readUserRow(reader); + + reader.Close(); + result.Dispose(); + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + #region User Friends List Data + + override public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + { + int dtvalue = Util.UnixTimeSinceEpoch(); + + Dictionary param = new Dictionary(); + param["?ownerID"] = friendlistowner.UUID.ToString(); + param["?friendID"] = friend.UUID.ToString(); + param["?friendPerms"] = perms.ToString(); + param["?datetimestamp"] = dtvalue.ToString(); + + try + { + lock (database) + { + IDbCommand adder = + database.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", + param); + adder.ExecuteNonQuery(); + + adder = + database.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?friendID,?ownerID,?friendPerms,?datetimestamp)", + param); + adder.ExecuteNonQuery(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return; + } + } + + override public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + { + Dictionary param = new Dictionary(); + param["?ownerID"] = friendlistowner.UUID.ToString(); + param["?friendID"] = friend.UUID.ToString(); + + try + { + lock (database) + { + IDbCommand updater = + database.Query( + "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", + param); + updater.ExecuteNonQuery(); + + updater = + database.Query( + "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", + param); + updater.ExecuteNonQuery(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return; + } + } + + override public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + { + Dictionary param = new Dictionary(); + param["?ownerID"] = friendlistowner.UUID.ToString(); + param["?friendID"] = friend.UUID.ToString(); + param["?friendPerms"] = perms.ToString(); + + try + { + lock (database) + { + IDbCommand updater = + database.Query( + "update " + m_userFriendsTableName + + " SET friendPerms = ?friendPerms " + + "where ownerID = ?ownerID and friendID = ?friendID", + param); + updater.ExecuteNonQuery(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return; + } + } + + override public List GetUserFriendList(LLUUID friendlistowner) + { + List Lfli = new List(); + + Dictionary param = new Dictionary(); + param["?ownerID"] = friendlistowner.UUID.ToString(); + + try + { + lock (database) + { + //Left Join userfriends to itself + IDbCommand result = + database.Query( + "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) + { + FriendListItem fli = new FriendListItem(); + fli.FriendListOwner = new LLUUID((string)reader["ownerID"]); + fli.Friend = new LLUUID((string)reader["friendID"]); + fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); + + // This is not a real column in the database table, it's a joined column from the opposite record + fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); + + Lfli.Add(fli); + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return Lfli; + } + + return Lfli; + } + + #endregion + + override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) + { + m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); + } + + override public List GeneratePickerResults(LLUUID queryID, string query) + { + List returnlist = new List(); + + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); + + string[] querysplit; + querysplit = query.Split(' '); + if (querysplit.Length == 2) + { + Dictionary param = new Dictionary(); + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; + param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; + try + { + lock (database) + { + IDbCommand result = + database.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first AND lastname like ?second LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) + { + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return returnlist; + } + } + else if (querysplit.Length == 1) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; + + IDbCommand result = + database.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first OR lastname like ?first LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) + { + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return returnlist; + } + } + return returnlist; + } + + // see IUserData + override public UserProfileData GetUserByUUID(LLUUID uuid) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); + + IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + UserProfileData row = database.readUserRow(reader); + + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Returns a user session searching by name + /// + /// The account name + /// The users session + override public UserAgentData GetAgentByName(string name) + { + return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]); + } + + /// + /// Returns a user session by account name + /// + /// First part of the users account name + /// Second part of the users account name + /// The users session + override public UserAgentData GetAgentByName(string user, string last) + { + UserProfileData profile = GetUserByName(user, last); + return GetAgentByUUID(profile.UUID); + } + + override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) + { + Dictionary param = new Dictionary(); + param["?UUID"] = AgentID.UUID.ToString(); + param["?webLoginKey"] = WebLoginKey.UUID.ToString(); + + try + { + lock (database) + { + IDbCommand updater = + database.Query( + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", + param); + updater.ExecuteNonQuery(); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return; + } + } + + /// + /// Returns an agent session by account UUID + /// + /// The accounts UUID + /// The users session + override public UserAgentData GetAgentByUUID(LLUUID uuid) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); + + IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + UserAgentData row = database.readAgentRow(reader); + + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + + /// + /// Creates a new users profile + /// + /// The user profile to create + override public void AddNewUserProfile(UserProfileData user) + { + try + { + lock (database) + { + database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, + user.homeRegion, user.homeLocation.X, user.homeLocation.Y, + user.homeLocation.Z, + user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, + user.lastLogin, user.userInventoryURI, user.userAssetURI, + user.profileCanDoMask, user.profileWantDoMask, + user.profileAboutText, user.profileFirstText, user.profileImage, + user.profileFirstImage, user.webLoginKey); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } + } + + /// + /// Creates a new agent + /// + /// The agent to create + override public void AddNewUserAgent(UserAgentData agent) + { + try + { + lock (database) + { + database.insertAgentRow(agent); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } + } + + /// + /// Updates a user profile stored in the DB + /// + /// The profile data to use to update the DB + override public bool UpdateUserProfile(UserProfileData user) + { + database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, + user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X, + user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, + user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText, + user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey); + return true; + } + + /// + /// Performs a money transfer request between two accounts + /// + /// The senders account ID + /// The receivers account ID + /// The amount to transfer + /// Success? + override public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) + { + return false; + } + + /// + /// Performs an inventory transfer request between two accounts + /// + /// TODO: Move to inventory server + /// The senders account ID + /// The receivers account ID + /// The item to transfer + /// Success? + override public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) + { + return false; + } + + /// + /// Database provider name + /// + /// Provider name + override public string getName() + { + return "MySQL Userdata Interface"; + } + + /// + /// Database provider version + /// + /// provider version + override public string GetVersion() + { + return "0.1"; + } + } +} diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..060e26c --- /dev/null +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly : ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql new file mode 100644 index 0000000..b638ee2 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql @@ -0,0 +1,42 @@ +-- +-- Create schema avatar_appearance +-- + +CREATE DATABASE IF NOT EXISTS avatar_appearance; +USE avatar_appearance; + +DROP TABLE IF EXISTS `avatarappearance`; +CREATE TABLE `avatarappearance` ( + `UUID` char(36) NOT NULL, + `Serial` int(10) unsigned NOT NULL, + `WearableItem0` char(36) NOT NULL, + `WearableAsset0` char(36) NOT NULL, + `WearableItem1` char(36) NOT NULL, + `WearableAsset1` char(36) NOT NULL, + `WearableItem2` char(36) NOT NULL, + `WearableAsset2` char(36) NOT NULL, + `WearableItem3` char(36) NOT NULL, + `WearableAsset3` char(36) NOT NULL, + `WearableItem4` char(36) NOT NULL, + `WearableAsset4` char(36) NOT NULL, + `WearableItem5` char(36) NOT NULL, + `WearableAsset5` char(36) NOT NULL, + `WearableItem6` char(36) NOT NULL, + `WearableAsset6` char(36) NOT NULL, + `WearableItem7` char(36) NOT NULL, + `WearableAsset7` char(36) NOT NULL, + `WearableItem8` char(36) NOT NULL, + `WearableAsset8` char(36) NOT NULL, + `WearableItem9` char(36) NOT NULL, + `WearableAsset9` char(36) NOT NULL, + `WearableItem10` char(36) NOT NULL, + `WearableAsset10` char(36) NOT NULL, + `WearableItem11` char(36) NOT NULL, + `WearableAsset11` char(36) NOT NULL, + `WearableItem12` char(36) NOT NULL, + `WearableAsset12` char(36) NOT NULL, + + + PRIMARY KEY (`UUID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + diff --git a/OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql b/OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql new file mode 100644 index 0000000..3ef7bc9 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql @@ -0,0 +1,24 @@ +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for agents +-- ---------------------------- +CREATE TABLE `agents` ( + `UUID` varchar(36) NOT NULL, + `sessionID` varchar(36) NOT NULL, + `secureSessionID` varchar(36) NOT NULL, + `agentIP` varchar(16) NOT NULL, + `agentPort` int(11) NOT NULL, + `agentOnline` tinyint(4) NOT NULL, + `loginTime` int(11) NOT NULL, + `logoutTime` int(11) NOT NULL, + `currentRegion` varchar(36) NOT NULL, + `currentHandle` bigint(20) unsigned NOT NULL, + `currentPos` varchar(64) NOT NULL, + PRIMARY KEY (`UUID`), + UNIQUE KEY `session` (`sessionID`), + UNIQUE KEY `ssession` (`secureSessionID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; + +-- ---------------------------- +-- Records +-- ---------------------------- diff --git a/OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql b/OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql new file mode 100644 index 0000000..2c750fe --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql @@ -0,0 +1,11 @@ +CREATE TABLE `assets` ( + `id` binary(16) NOT NULL, + `name` varchar(64) NOT NULL, + `description` varchar(64) NOT NULL, + `assetType` tinyint(4) NOT NULL, + `invType` tinyint(4) NOT NULL, + `local` tinyint(1) NOT NULL, + `temporary` tinyint(1) NOT NULL, + `data` longblob NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql b/OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql new file mode 100644 index 0000000..b5bddde --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql @@ -0,0 +1,11 @@ +CREATE TABLE `inventoryfolders` ( + `folderID` varchar(36) NOT NULL default '', + `agentID` varchar(36) default NULL, + `parentFolderID` varchar(36) default NULL, + `folderName` varchar(64) default NULL, + `type` smallint NOT NULL default 0, + `version` int NOT NULL default 0, + PRIMARY KEY (`folderID`), + KEY `owner` (`agentID`), + KEY `parent` (`parentFolderID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; diff --git a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql new file mode 100644 index 0000000..1723ee3 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql @@ -0,0 +1,18 @@ +CREATE TABLE `inventoryitems` ( + `inventoryID` varchar(36) NOT NULL default '', + `assetID` varchar(36) default NULL, + `assetType` int(11) default NULL, + `parentFolderID` varchar(36) default NULL, + `avatarID` varchar(36) default NULL, + `inventoryName` varchar(64) default NULL, + `inventoryDescription` varchar(128) default NULL, + `inventoryNextPermissions` int(10) unsigned default NULL, + `inventoryCurrentPermissions` int(10) unsigned default NULL, + `invType` int(11) default NULL, + `creatorID` varchar(36) default NULL, + `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, + `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, + PRIMARY KEY (`inventoryID`), + KEY `owner` (`avatarID`), + KEY `folder` (`parentFolderID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; diff --git a/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql b/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql new file mode 100644 index 0000000..64b3a80 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql @@ -0,0 +1,10 @@ +CREATE TABLE `logs` ( + `logID` int(10) unsigned NOT NULL auto_increment, + `target` varchar(36) default NULL, + `server` varchar(64) default NULL, + `method` varchar(64) default NULL, + `arguments` varchar(255) default NULL, + `priority` int(11) default NULL, + `message` text, + PRIMARY KEY (`logID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; diff --git a/OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql b/OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql new file mode 100644 index 0000000..cb0f9bd --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql @@ -0,0 +1,32 @@ +CREATE TABLE `regions` ( + `uuid` varchar(36) NOT NULL, + `regionHandle` bigint(20) unsigned NOT NULL, + `regionName` varchar(32) default NULL, + `regionRecvKey` varchar(128) default NULL, + `regionSendKey` varchar(128) default NULL, + `regionSecret` varchar(128) default NULL, + `regionDataURI` varchar(255) default NULL, + `serverIP` varchar(64) default NULL, + `serverPort` int(10) unsigned default NULL, + `serverURI` varchar(255) default NULL, + `locX` int(10) unsigned default NULL, + `locY` int(10) unsigned default NULL, + `locZ` int(10) unsigned default NULL, + `eastOverrideHandle` bigint(20) unsigned default NULL, + `westOverrideHandle` bigint(20) unsigned default NULL, + `southOverrideHandle` bigint(20) unsigned default NULL, + `northOverrideHandle` bigint(20) unsigned default NULL, + `regionAssetURI` varchar(255) default NULL, + `regionAssetRecvKey` varchar(128) default NULL, + `regionAssetSendKey` varchar(128) default NULL, + `regionUserURI` varchar(255) default NULL, + `regionUserRecvKey` varchar(128) default NULL, + `regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL, + `serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL, + `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, + `originUUID` varchar(36), + PRIMARY KEY (`uuid`), + KEY `regionName` (`regionName`), + KEY `regionHandle` (`regionHandle`), + KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql b/OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql new file mode 100644 index 0000000..8480d48 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql @@ -0,0 +1,11 @@ +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +CREATE TABLE `userfriends` ( + `ownerID` VARCHAR(37) NOT NULL, + `friendID` VARCHAR(37) NOT NULL, + `friendPerms` INT NOT NULL, + `datetimestamp` INT NOT NULL, + UNIQUE KEY (`ownerID`, `friendID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/CreateUsersTable.sql b/OpenSim/Data/MySQL/Resources/CreateUsersTable.sql new file mode 100644 index 0000000..d9e8ae2 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateUsersTable.sql @@ -0,0 +1,35 @@ +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +CREATE TABLE `users` ( + `UUID` varchar(36) NOT NULL default '', + `username` varchar(32) NOT NULL, + `lastname` varchar(32) NOT NULL, + `passwordHash` varchar(32) NOT NULL, + `passwordSalt` varchar(32) NOT NULL, + `homeRegion` bigint(20) unsigned default NULL, + `homeLocationX` float default NULL, + `homeLocationY` float default NULL, + `homeLocationZ` float default NULL, + `homeLookAtX` float default NULL, + `homeLookAtY` float default NULL, + `homeLookAtZ` float default NULL, + `created` int(11) NOT NULL, + `lastLogin` int(11) NOT NULL, + `userInventoryURI` varchar(255) default NULL, + `userAssetURI` varchar(255) default NULL, + `profileCanDoMask` int(10) unsigned default NULL, + `profileWantDoMask` int(10) unsigned default NULL, + `profileAboutText` text, + `profileFirstText` text, + `profileImage` varchar(36) default NULL, + `profileFirstImage` varchar(36) default NULL, + `webLoginKey` varchar(36) default NULL, + PRIMARY KEY (`UUID`), + UNIQUE KEY `usernames` (`username`,`lastname`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; + +-- ---------------------------- +-- Records +-- ---------------------------- diff --git a/OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql new file mode 100644 index 0000000..b5a7964 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql @@ -0,0 +1,4 @@ +ALTER TABLE `inventoryfolders` + ADD COLUMN `type` smallint NOT NULL default 0, + ADD COLUMN `version` int NOT NULL default 0, +COMMENT='Rev. 2'; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql new file mode 100644 index 0000000..d1ef504 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql @@ -0,0 +1,9 @@ +ALTER TABLE `inventoryitems` + CHANGE COLUMN `type` `assetType` int(11) default NULL, + ADD COLUMN `invType` int(11) default NULL, + ADD COLUMN `creatorID` varchar(36) default NULL, + ADD COLUMN `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, + ADD COLUMN `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, +COMMENT='Rev. 2'; + +UPDATE `inventoryitems` SET invType=assetType; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql new file mode 100644 index 0000000..034b755 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql @@ -0,0 +1,4 @@ +ALTER TABLE `regions` + ADD COLUMN `originUUID` varchar(36), +COMMENT='Rev. 2'; +UPDATE `regions` SET originUUID=uuid; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql b/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql new file mode 100644 index 0000000..b48afec --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql @@ -0,0 +1,18 @@ +DROP PROCEDURE IF EXISTS upgraderegions3; + +create procedure upgraderegions3() +BEGIN +DECLARE db_name varchar(64); +select database() into db_name; +IF ((select count(*) from information_schema.columns where table_name='regions' and column_name='owner_uuid' and table_schema=db_name) > 0) +THEN + ALTER TABLE `regions`, COMMENT='Rev. 3'; +ELSE + ALTER TABLE `regions` + ADD COLUMN `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null after serverRemotingPort, COMMENT='Rev. 3'; +END IF; +END; + +call upgraderegions3(); + + diff --git a/OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql new file mode 100644 index 0000000..dd21a66 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql @@ -0,0 +1,3 @@ +ALTER TABLE `users` + ADD COLUMN `webLoginKey` varchar(36) default '00000000-0000-0000-0000-000000000000' NOT NULL, +COMMENT='Rev. 2'; \ No newline at end of file -- cgit v1.1 From f52c8f3970c5f528aaa6edf2b1bf8acc31c52313 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 2 Apr 2008 15:36:01 +0000 Subject: attempt to fix up all refernces to new directory structure --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLDataStore.cs | 2 +- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLLogData.cs | 2 +- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 79994ae..d5f7816 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -32,7 +32,7 @@ using libsecondlife; using MySql.Data.MySqlClient; using OpenSim.Framework.Console; -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { internal class MySQLAssetData : AssetDataBase, IPlugin { diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index eaa7f14..0d9fb3b 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -36,7 +36,7 @@ using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { public class MySQLDataStore : IRegionDataStore { diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 61ab067..610dfaf 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -34,7 +34,7 @@ using System.Text.RegularExpressions; using libsecondlife; using OpenSim.Framework.Console; -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { /// /// A MySQL Interface for the Grid Server diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 4165d8f..326bf60 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -31,7 +31,7 @@ using libsecondlife; using MySql.Data.MySqlClient; using OpenSim.Framework.Console; -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { /// /// A MySQL interface for the inventory server diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 480446f..bb34d34 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { /// /// An interface to the log database for MySQL diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 579667b..3d408d0 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -35,7 +35,7 @@ using libsecondlife; using MySql.Data.MySqlClient; using OpenSim.Framework.Console; -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { /// /// A MySQL Database manager diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index fd640ec..b03d1d9 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -32,7 +32,7 @@ using System.Text.RegularExpressions; using libsecondlife; using OpenSim.Framework.Console; -namespace OpenSim.Framework.Data.MySQL +namespace OpenSim.Data.MySQL { /// /// A database interface class to a user profile storage system diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 060e26c..16b2a4f 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -32,11 +32,11 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")] +[assembly : AssemblyTitle("OpenSim.Data.MySQL")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] [assembly : AssemblyCompany("")] -[assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")] +[assembly : AssemblyProduct("OpenSim.Data.MySQL")] [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] -- cgit v1.1 From 30ea28c3b1f7e8bc6534f5353236eb59328ce999 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 2 Apr 2008 16:00:40 +0000 Subject: fix ups to include OpenSim.Framework explicit includes (they were implicitly included before). Everything builds again. Now off to testing. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 1 + OpenSim/Data/MySQL/MySQLDataStore.cs | 1 + OpenSim/Data/MySQL/MySQLInventoryData.cs | 1 + OpenSim/Data/MySQL/MySQLManager.cs | 1 + OpenSim/Data/MySQL/MySQLUserData.cs | 1 + 5 files changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index d5f7816..50f1cc5 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Data; using libsecondlife; using MySql.Data.MySqlClient; +using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 0d9fb3b..de15421 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -32,6 +32,7 @@ using System.Diagnostics; using System.IO; using libsecondlife; using MySql.Data.MySqlClient; +using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 326bf60..ceb73c5 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using libsecondlife; using MySql.Data.MySqlClient; +using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 3d408d0..0d36136 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -33,6 +33,7 @@ using System.IO; using System.Reflection; using libsecondlife; using MySql.Data.MySqlClient; +using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index b03d1d9..bd094f6 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Data; using System.Text.RegularExpressions; using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL -- cgit v1.1 From f43681510725f5b95fcb864a1f3e4b744fcaf992 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 7 Apr 2008 23:15:35 +0000 Subject: Refactor InventoryItemBase to do the following: * wrap fields as Properties * rename some fields/properties to more sensible names * set style to PropName to match more standard C# approach --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 52 ++++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index ceb73c5..6bb7a53 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -312,19 +312,19 @@ namespace OpenSim.Data.MySQL { InventoryItemBase item = new InventoryItemBase(); - item.inventoryID = new LLUUID((string) reader["inventoryID"]); - item.assetID = new LLUUID((string) reader["assetID"]); - item.assetType = (int) reader["assetType"]; - item.parentFolderID = new LLUUID((string) reader["parentFolderID"]); - item.avatarID = new LLUUID((string) reader["avatarID"]); - item.inventoryName = (string) reader["inventoryName"]; - item.inventoryDescription = (string) reader["inventoryDescription"]; - item.inventoryNextPermissions = (uint) reader["inventoryNextPermissions"]; - item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; - item.invType = (int) reader["invType"]; - item.creatorsID = new LLUUID((string) reader["creatorID"]); - item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"]; - item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + item.ID = new LLUUID((string) reader["inventoryID"]); + item.AssetID = new LLUUID((string) reader["assetID"]); + item.AssetType = (int) reader["assetType"]; + item.Folder = new LLUUID((string) reader["parentFolderID"]); + item.Owner = new LLUUID((string) reader["avatarID"]); + item.Name = (string) reader["inventoryName"]; + item.Description = (string) reader["inventoryDescription"]; + item.NextPermissions = (uint) reader["inventoryNextPermissions"]; + item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; + item.InvType = (int) reader["invType"]; + item.Creator = new LLUUID((string) reader["creatorID"]); + item.BasePermissions = (uint) reader["inventoryBasePermissions"]; + item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; return item; } catch (MySqlException e) @@ -444,20 +444,20 @@ namespace OpenSim.Data.MySQL try { MySqlCommand result = new MySqlCommand(sql, database.Connection); - result.Parameters.AddWithValue("?inventoryID", item.inventoryID.ToString()); - result.Parameters.AddWithValue("?assetID", item.assetID.ToString()); - result.Parameters.AddWithValue("?assetType", item.assetType.ToString()); - result.Parameters.AddWithValue("?parentFolderID", item.parentFolderID.ToString()); - result.Parameters.AddWithValue("?avatarID", item.avatarID.ToString()); - result.Parameters.AddWithValue("?inventoryName", item.inventoryName); - result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription); - result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); + result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); + result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); + result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); + result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); + result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); + result.Parameters.AddWithValue("?inventoryName", item.Name); + result.Parameters.AddWithValue("?inventoryDescription", item.Description); + result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); result.Parameters.AddWithValue("?inventoryCurrentPermissions", - item.inventoryCurrentPermissions.ToString()); - result.Parameters.AddWithValue("?invType", item.invType); - result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToString()); - result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions); - result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.inventoryEveryOnePermissions); + item.CurrentPermissions.ToString()); + result.Parameters.AddWithValue("?invType", item.InvType); + result.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); + result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); + result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); result.ExecuteNonQuery(); result.Dispose(); } -- cgit v1.1 From 5ee75998ce4d941efd937848d28f3a4dac6ba6cc Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 7 Apr 2008 23:27:05 +0000 Subject: more refactoring, this time on InventoryFolderBase * wrap attributes in properties * clean up names a little bit * clean up name styles --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 6bb7a53..6cc8998 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -381,12 +381,12 @@ namespace OpenSim.Data.MySQL try { InventoryFolderBase folder = new InventoryFolderBase(); - folder.agentID = new LLUUID((string) reader["agentID"]); - folder.parentID = new LLUUID((string) reader["parentFolderID"]); - folder.folderID = new LLUUID((string) reader["folderID"]); - folder.name = (string) reader["folderName"]; - folder.type = (short) reader["type"]; - folder.version = (ushort) ((int) reader["version"]); + folder.AgentID = new LLUUID((string) reader["agentID"]); + folder.ParentID = new LLUUID((string) reader["parentFolderID"]); + folder.ID = new LLUUID((string) reader["folderID"]); + folder.Name = (string) reader["folderName"]; + folder.Type = (short) reader["type"]; + folder.Version = (ushort) ((int) reader["version"]); return folder; } catch (Exception e) @@ -507,12 +507,12 @@ namespace OpenSim.Data.MySQL sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; MySqlCommand cmd = new MySqlCommand(sql, database.Connection); - cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString()); - cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToString()); - cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString()); - cmd.Parameters.AddWithValue("?folderName", folder.name); - cmd.Parameters.AddWithValue("?type", (short) folder.type); - cmd.Parameters.AddWithValue("?version", folder.version); + cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); + cmd.Parameters.AddWithValue("?agentID", folder.AgentID.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); + cmd.Parameters.AddWithValue("?folderName", folder.Name); + cmd.Parameters.AddWithValue("?type", (short) folder.Type); + cmd.Parameters.AddWithValue("?version", folder.Version); try { @@ -545,8 +545,8 @@ namespace OpenSim.Data.MySQL "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; MySqlCommand cmd = new MySqlCommand(sql, database.Connection); - cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString()); - cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString()); + cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); try { @@ -581,7 +581,7 @@ namespace OpenSim.Data.MySQL getInventoryFolders(ref folders, parentID); for (int i = 0; i < folders.Count; i++) - getInventoryFolders(ref folders, folders[i].folderID); + getInventoryFolders(ref folders, folders[i].ID); return folders; } @@ -637,8 +637,8 @@ namespace OpenSim.Data.MySQL //Delete all sub-folders foreach (InventoryFolderBase f in subFolders) { - deleteOneFolder(f.folderID); - deleteItemsInFolder(f.folderID); + deleteOneFolder(f.ID); + deleteItemsInFolder(f.ID); } //Delete the actual row -- cgit v1.1 From a6d27e09295cd0160d3439fbfa6598f08c431608 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 8 Apr 2008 23:26:31 +0000 Subject: further refactor and rename of InventoryFolderBase properties to reflect what they really are. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 6cc8998..ce9829a 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -381,7 +381,7 @@ namespace OpenSim.Data.MySQL try { InventoryFolderBase folder = new InventoryFolderBase(); - folder.AgentID = new LLUUID((string) reader["agentID"]); + folder.Owner = new LLUUID((string) reader["agentID"]); folder.ParentID = new LLUUID((string) reader["parentFolderID"]); folder.ID = new LLUUID((string) reader["folderID"]); folder.Name = (string) reader["folderName"]; @@ -508,7 +508,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(sql, database.Connection); cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); - cmd.Parameters.AddWithValue("?agentID", folder.AgentID.ToString()); + cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); cmd.Parameters.AddWithValue("?folderName", folder.Name); cmd.Parameters.AddWithValue("?type", (short) folder.Type); -- cgit v1.1 From c176caeb05c2264654b764e4d010561da60c24fc Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 13:53:06 +0000 Subject: moved fields to properties for UserDataProfile, which was actually a little more work than I expected given the copious use of out params. --- OpenSim/Data/MySQL/MySQLManager.cs | 63 ++++++++++++++++++++++--------------- OpenSim/Data/MySQL/MySQLUserData.cs | 28 ++++++++--------- 2 files changed, 51 insertions(+), 40 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 0d36136..110f192 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -427,60 +427,71 @@ namespace OpenSim.Data.MySQL if (reader.Read()) { - if (!LLUUID.TryParse((string)reader["UUID"], out retval.UUID)) + LLUUID id; + if (!LLUUID.TryParse((string)reader["UUID"], out id)) return null; - retval.username = (string) reader["username"]; - retval.surname = (string) reader["lastname"]; - retval.passwordHash = (string) reader["passwordHash"]; - retval.passwordSalt = (string) reader["passwordSalt"]; + retval.Id = id; + retval.FirstName = (string) reader["username"]; + retval.SurName = (string) reader["lastname"]; + + retval.PasswordHash = (string) reader["passwordHash"]; + retval.PasswordSalt = (string) reader["passwordSalt"]; - retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); - retval.homeLocation = new LLVector3( + retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); + retval.HomeLocation = new LLVector3( Convert.ToSingle(reader["homeLocationX"].ToString()), Convert.ToSingle(reader["homeLocationY"].ToString()), Convert.ToSingle(reader["homeLocationZ"].ToString())); - retval.homeLookAt = new LLVector3( + retval.HomeLookAt = new LLVector3( Convert.ToSingle(reader["homeLookAtX"].ToString()), Convert.ToSingle(reader["homeLookAtY"].ToString()), Convert.ToSingle(reader["homeLookAtZ"].ToString())); - retval.created = Convert.ToInt32(reader["created"].ToString()); - retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); + retval.Created = Convert.ToInt32(reader["created"].ToString()); + retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); - retval.userInventoryURI = (string) reader["userInventoryURI"]; - retval.userAssetURI = (string) reader["userAssetURI"]; + retval.UserInventoryURI = (string) reader["userInventoryURI"]; + retval.UserAssetURI = (string) reader["userAssetURI"]; - retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); - retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); + retval.ProfileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); + retval.ProfileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) - retval.profileAboutText = ""; + retval.ProfileAboutText = ""; else - retval.profileAboutText = (string) reader["profileAboutText"]; + retval.ProfileAboutText = (string) reader["profileAboutText"]; if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) - retval.profileFirstText = ""; + retval.ProfileFirstText = ""; else - retval.profileFirstText = (string)reader["profileFirstText"]; + retval.ProfileFirstText = (string)reader["profileFirstText"]; if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) - retval.profileImage = LLUUID.Zero; - else - LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); + retval.ProfileImage = LLUUID.Zero; + else { + LLUUID tmp; + LLUUID.TryParse((string)reader["profileImage"], out tmp); + retval.ProfileImage = tmp; + } if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) - retval.profileFirstImage = LLUUID.Zero; - else - LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); + retval.ProfileFirstImage = LLUUID.Zero; + else { + LLUUID tmp; + LLUUID.TryParse((string)reader["profileFirstImage"], out tmp); + retval.ProfileFirstImage = tmp; + } if(reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) { - retval.webLoginKey = LLUUID.Zero; + retval.WebLoginKey = LLUUID.Zero; } else { - LLUUID.TryParse((string)reader["webLoginKey"], out retval.webLoginKey); + LLUUID tmp; + LLUUID.TryParse((string)reader["webLoginKey"], out tmp); + retval.WebLoginKey = tmp; } } else diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index bd094f6..5654207 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -475,7 +475,7 @@ namespace OpenSim.Data.MySQL override public UserAgentData GetAgentByName(string user, string last) { UserProfileData profile = GetUserByName(user, last); - return GetAgentByUUID(profile.UUID); + return GetAgentByUUID(profile.Id); } override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) @@ -547,14 +547,14 @@ namespace OpenSim.Data.MySQL { lock (database) { - database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, - user.homeRegion, user.homeLocation.X, user.homeLocation.Y, - user.homeLocation.Z, - user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, - user.lastLogin, user.userInventoryURI, user.userAssetURI, - user.profileCanDoMask, user.profileWantDoMask, - user.profileAboutText, user.profileFirstText, user.profileImage, - user.profileFirstImage, user.webLoginKey); + database.insertUserRow(user.Id, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, + user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, + user.LastLogin, user.UserInventoryURI, user.UserAssetURI, + user.ProfileCanDoMask, user.ProfileWantDoMask, + user.ProfileAboutText, user.ProfileFirstText, user.ProfileImage, + user.ProfileFirstImage, user.WebLoginKey); } } catch (Exception e) @@ -590,11 +590,11 @@ namespace OpenSim.Data.MySQL /// The profile data to use to update the DB override public bool UpdateUserProfile(UserProfileData user) { - database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, - user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X, - user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, - user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText, - user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey); + database.updateUserRow(user.Id, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, + user.UserAssetURI, user.ProfileCanDoMask, user.ProfileWantDoMask, user.ProfileAboutText, + user.ProfileFirstText, user.ProfileImage, user.ProfileFirstImage, user.WebLoginKey); return true; } -- cgit v1.1 From 25fea01b92a7682e10f57ce979217d31fee975ef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 14:09:30 +0000 Subject: further renaming of properties for clarity --- OpenSim/Data/MySQL/MySQLManager.cs | 22 +++++++++++----------- OpenSim/Data/MySQL/MySQLUserData.cs | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 110f192..f4ef172 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -431,7 +431,7 @@ namespace OpenSim.Data.MySQL if (!LLUUID.TryParse((string)reader["UUID"], out id)) return null; - retval.Id = id; + retval.ID = id; retval.FirstName = (string) reader["username"]; retval.SurName = (string) reader["lastname"]; @@ -454,33 +454,33 @@ namespace OpenSim.Data.MySQL retval.UserInventoryURI = (string) reader["userInventoryURI"]; retval.UserAssetURI = (string) reader["userAssetURI"]; - retval.ProfileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); - retval.ProfileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); + retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); + retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) - retval.ProfileAboutText = ""; + retval.AboutText = ""; else - retval.ProfileAboutText = (string) reader["profileAboutText"]; + retval.AboutText = (string) reader["profileAboutText"]; if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) - retval.ProfileFirstText = ""; + retval.FirstLifeAboutText = ""; else - retval.ProfileFirstText = (string)reader["profileFirstText"]; + retval.FirstLifeAboutText = (string)reader["profileFirstText"]; if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) - retval.ProfileImage = LLUUID.Zero; + retval.Image = LLUUID.Zero; else { LLUUID tmp; LLUUID.TryParse((string)reader["profileImage"], out tmp); - retval.ProfileImage = tmp; + retval.Image = tmp; } if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) - retval.ProfileFirstImage = LLUUID.Zero; + retval.FirstLifeImage = LLUUID.Zero; else { LLUUID tmp; LLUUID.TryParse((string)reader["profileFirstImage"], out tmp); - retval.ProfileFirstImage = tmp; + retval.FirstLifeImage = tmp; } if(reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 5654207..5b2dc76 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -475,7 +475,7 @@ namespace OpenSim.Data.MySQL override public UserAgentData GetAgentByName(string user, string last) { UserProfileData profile = GetUserByName(user, last); - return GetAgentByUUID(profile.Id); + return GetAgentByUUID(profile.ID); } override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) @@ -547,14 +547,14 @@ namespace OpenSim.Data.MySQL { lock (database) { - database.insertUserRow(user.Id, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + database.insertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.ProfileCanDoMask, user.ProfileWantDoMask, - user.ProfileAboutText, user.ProfileFirstText, user.ProfileImage, - user.ProfileFirstImage, user.WebLoginKey); + user.CanDoMask, user.WantDoMask, + user.AboutText, user.FirstLifeAboutText, user.Image, + user.FirstLifeImage, user.WebLoginKey); } } catch (Exception e) @@ -590,11 +590,11 @@ namespace OpenSim.Data.MySQL /// The profile data to use to update the DB override public bool UpdateUserProfile(UserProfileData user) { - database.updateUserRow(user.Id, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, - user.UserAssetURI, user.ProfileCanDoMask, user.ProfileWantDoMask, user.ProfileAboutText, - user.ProfileFirstText, user.ProfileImage, user.ProfileFirstImage, user.WebLoginKey); + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); return true; } -- cgit v1.1 From ef7dfae41c728d10cfe835cb256958c354449f1b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 14:37:17 +0000 Subject: changing UserAgentData to use properties. This caused more grief than expected, as monodevelop doesn't like to refactor properties of properties. --- OpenSim/Data/MySQL/MySQLManager.cs | 74 +++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 25 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index f4ef172..f2ec6be 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -295,10 +295,24 @@ namespace OpenSim.Data.MySQL if (reader.Read()) { // Region Main gotta-have-or-we-return-null parts - if (!UInt64.TryParse(reader["regionHandle"].ToString(), out retval.regionHandle)) + UInt64 tmp64; + if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) + { return null; - if (!LLUUID.TryParse((string)reader["uuid"], out retval.UUID)) + } + else + { + retval.regionHandle = tmp64; + } + LLUUID tmp_uuid; + if (!LLUUID.TryParse((string)reader["uuid"], out tmp_uuid)) + { return null; + } + else + { + retval.UUID = tmp_uuid; + } // non-critical parts retval.regionName = (string)reader["regionName"]; @@ -369,7 +383,9 @@ namespace OpenSim.Data.MySQL retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); retval.reservationName = (string) reader["resName"]; retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; - LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID); + LLUUID tmp; + LLUUID.TryParse((string) reader["userUUID"], out tmp); + retval.userUUID = tmp; } else { @@ -390,24 +406,32 @@ namespace OpenSim.Data.MySQL if (reader.Read()) { // Agent IDs - if (!LLUUID.TryParse((string)reader["UUID"], out retval.UUID)) + LLUUID tmp; + if (!LLUUID.TryParse((string)reader["UUID"], out tmp)) return null; - LLUUID.TryParse((string) reader["sessionID"], out retval.sessionID); - LLUUID.TryParse((string)reader["secureSessionID"], out retval.secureSessionID); + retval.ProfileID = tmp; + + LLUUID.TryParse((string) reader["sessionID"], out tmp); + retval.SessionID = tmp; + + LLUUID.TryParse((string)reader["secureSessionID"], out tmp); + retval.SecureSessionID = tmp; // Agent Who? - retval.agentIP = (string) reader["agentIP"]; - retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); - retval.agentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString())); + retval.AgentIP = (string) reader["agentIP"]; + retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString()); + retval.AgentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString())); // Login/Logout times (UNIX Epoch) - retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); - retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); + retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString()); + retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); // Current position - retval.currentRegion = new LLUUID((string)reader["currentRegion"]); - retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); - LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); + retval.CurrentRegion = new LLUUID((string)reader["currentRegion"]); + retval.CurrentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); + LLVector3 tmp_v; + LLVector3.TryParse((string) reader["currentPos"], out tmp_v); + retval.CurrentPos = tmp_v; } else { @@ -883,17 +907,17 @@ namespace OpenSim.Data.MySQL sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos);"; Dictionary parameters = new Dictionary(); - parameters["?UUID"] = agentdata.UUID.ToString(); - parameters["?sessionID"] = agentdata.sessionID.ToString(); - parameters["?secureSessionID"] = agentdata.secureSessionID.ToString(); - parameters["?agentIP"] = agentdata.agentIP.ToString(); - parameters["?agentPort"] = agentdata.agentPort.ToString(); - parameters["?agentOnline"] = (agentdata.agentOnline == true) ? "1" : "0"; - parameters["?loginTime"] = agentdata.loginTime.ToString(); - parameters["?logoutTime"] = agentdata.logoutTime.ToString(); - parameters["?currentRegion"] = agentdata.currentRegion.ToString(); - parameters["?currentHandle"] = agentdata.currentHandle.ToString(); - parameters["?currentPos"] = "<" + ((int)agentdata.currentPos.X).ToString() + "," + ((int)agentdata.currentPos.Y).ToString() + "," + ((int)agentdata.currentPos.Z).ToString() + ">"; + parameters["?UUID"] = agentdata.ProfileID.ToString(); + parameters["?sessionID"] = agentdata.SessionID.ToString(); + parameters["?secureSessionID"] = agentdata.SecureSessionID.ToString(); + parameters["?agentIP"] = agentdata.AgentIP.ToString(); + parameters["?agentPort"] = agentdata.AgentPort.ToString(); + parameters["?agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0"; + parameters["?loginTime"] = agentdata.LoginTime.ToString(); + parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); + parameters["?currentRegion"] = agentdata.CurrentRegion.ToString(); + parameters["?currentHandle"] = agentdata.CurrentHandle.ToString(); + parameters["?currentPos"] = "<" + ((int)agentdata.CurrentPos.X).ToString() + "," + ((int)agentdata.CurrentPos.Y).ToString() + "," + ((int)agentdata.CurrentPos.Z).ToString() + ">"; bool returnval = false; -- cgit v1.1 From 55ac1c6dce15d768cc7240b75f903076a131c39e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 14:50:52 +0000 Subject: renaming of attributes in UserAgentData for readability --- OpenSim/Data/MySQL/MySQLManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index f2ec6be..38f56c4 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -427,11 +427,11 @@ namespace OpenSim.Data.MySQL retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); // Current position - retval.CurrentRegion = new LLUUID((string)reader["currentRegion"]); - retval.CurrentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); + retval.Region = new LLUUID((string)reader["currentRegion"]); + retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString()); LLVector3 tmp_v; LLVector3.TryParse((string) reader["currentPos"], out tmp_v); - retval.CurrentPos = tmp_v; + retval.Position = tmp_v; } else { @@ -915,9 +915,9 @@ namespace OpenSim.Data.MySQL parameters["?agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0"; parameters["?loginTime"] = agentdata.LoginTime.ToString(); parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); - parameters["?currentRegion"] = agentdata.CurrentRegion.ToString(); - parameters["?currentHandle"] = agentdata.CurrentHandle.ToString(); - parameters["?currentPos"] = "<" + ((int)agentdata.CurrentPos.X).ToString() + "," + ((int)agentdata.CurrentPos.Y).ToString() + "," + ((int)agentdata.CurrentPos.Z).ToString() + ">"; + parameters["?currentRegion"] = agentdata.Region.ToString(); + parameters["?currentHandle"] = agentdata.Handle.ToString(); + parameters["?currentPos"] = "<" + ((int)agentdata.Position.X).ToString() + "," + ((int)agentdata.Position.Y).ToString() + "," + ((int)agentdata.Position.Z).ToString() + ">"; bool returnval = false; -- cgit v1.1 From cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 11 Apr 2008 09:56:22 +0000 Subject: * Discerned between AddProfile and UpdateProfile in region registration :: Believe it or not, but INSERT/UPDATE is actually a better pattern than REPLACE, since, with INSERT/UPDATE you can catch erroneous UPDATES to non-INSERTed items as well as catch erroneous re-INSERTS. in 95% of the cases, you SHOULD have a clear INSERT context, and a clear and separate UPDATE context. If you think your case falls within the 5%, maybe you should re-evaluate your code. :: --- OpenSim/Data/MySQL/MySQLGridData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 610dfaf..639f899 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -309,6 +309,11 @@ namespace OpenSim.Data.MySQL } } + override public DataResponse UpdateProfile(RegionProfileData profile) + { + return AddProfile(profile); + } + /// /// Deletes a profile from the database /// -- cgit v1.1 From 379ac9c92ac2cdaf9ad4cc1e66de243a42ae7c42 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 15 Apr 2008 22:41:34 +0000 Subject: * Make it easier to follow logins on the user server by changing and tidying up log messages --- OpenSim/Data/MySQL/MySQLManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 38f56c4..a122954 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -660,7 +660,7 @@ namespace OpenSim.Data.MySQL return false; } - m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString()); + //m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString()); return returnval; } @@ -750,7 +750,7 @@ namespace OpenSim.Data.MySQL return false; } - m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString()); + //m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString()); return returnval; } -- cgit v1.1 From f0896c263bea162a64367e5d3c86daeb7cc91a7b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 18 Apr 2008 22:46:03 +0000 Subject: * Insert some missing database locks for inventory and user data on mysql --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 13 +++++++++++-- OpenSim/Data/MySQL/MySQLUserData.cs | 14 +++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index ce9829a..82bbf4f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -458,7 +458,12 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); - result.ExecuteNonQuery(); + + lock (database) + { + result.ExecuteNonQuery(); + } + result.Dispose(); } catch (MySqlException e) @@ -487,7 +492,11 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); - cmd.ExecuteNonQuery(); + + lock (database) + { + cmd.ExecuteNonQuery(); + } } catch (MySqlException e) { diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 5b2dc76..d04c932 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -590,11 +590,15 @@ namespace OpenSim.Data.MySQL /// The profile data to use to update the DB override public bool UpdateUserProfile(UserProfileData user) { - database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); + lock (database) + { + database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); + } + return true; } -- cgit v1.1 From fef3b3689492dea63693c964bcdbec9f5137eb5e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 21 Apr 2008 07:09:17 +0000 Subject: * Optimised using statements and namespace references across entire project (this took a while to run). --- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +++-- OpenSim/Data/MySQL/MySQLDataStore.cs | 9 +++++---- OpenSim/Data/MySQL/MySQLGridData.cs | 6 +++--- OpenSim/Data/MySQL/MySQLInventoryData.cs | 7 ++++--- OpenSim/Data/MySQL/MySQLManager.cs | 5 ++--- OpenSim/Data/MySQL/MySQLUserData.cs | 13 +++++++------ 6 files changed, 24 insertions(+), 21 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 50f1cc5..111f7d1 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -28,16 +28,17 @@ using System; using System.Collections.Generic; using System.Data; +using System.Reflection; using libsecondlife; +using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; -using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL { internal class MySQLAssetData : AssetDataBase, IPlugin { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private MySQLManager _dbConnection; diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index de15421..08e4456 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -28,12 +28,13 @@ using System; using System.Collections.Generic; using System.Data; -using System.Diagnostics; using System.IO; +using System.Reflection; +using System.Threading; using libsecondlife; +using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -41,7 +42,7 @@ namespace OpenSim.Data.MySQL { public class MySQLDataStore : IRegionDataStore { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private const string m_primSelect = "select * from prims"; private const string m_shapeSelect = "select * from primshapes"; @@ -1498,7 +1499,7 @@ namespace OpenSim.Data.MySQL { m_log.Error("[MySql]: Error connecting to MySQL server: " + ex.Message); m_log.Error("[MySql]: Application is terminating!"); - System.Threading.Thread.CurrentThread.Abort(); + Thread.CurrentThread.Abort(); } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 639f899..b6274d4 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -28,11 +28,11 @@ using System; using System.Collections.Generic; using System.Data; +using System.Reflection; using System.Security.Cryptography; using System.Text; -using System.Text.RegularExpressions; using libsecondlife; -using OpenSim.Framework.Console; +using log4net; namespace OpenSim.Data.MySQL { @@ -41,7 +41,7 @@ namespace OpenSim.Data.MySQL /// public class MySQLGridData : GridDataBase { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// MySQL Database Manager diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 82bbf4f..3aed301 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -27,10 +27,11 @@ using System; using System.Collections.Generic; +using System.Reflection; using libsecondlife; +using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; -using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL { @@ -39,8 +40,8 @@ namespace OpenSim.Data.MySQL /// public class MySQLInventoryData : IInventoryData { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The database manager diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a122954..1e7038f 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -28,13 +28,12 @@ using System; using System.Collections.Generic; using System.Data; -using System.Data.SqlClient; using System.IO; using System.Reflection; using libsecondlife; +using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; -using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL { @@ -43,7 +42,7 @@ namespace OpenSim.Data.MySQL /// internal class MySQLManager { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The database connection object diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index d04c932..66b65dc 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -28,10 +28,11 @@ using System; using System.Collections.Generic; using System.Data; +using System.Reflection; using System.Text.RegularExpressions; using libsecondlife; +using log4net; using OpenSim.Framework; -using OpenSim.Framework.Console; namespace OpenSim.Data.MySQL { @@ -40,7 +41,7 @@ namespace OpenSim.Data.MySQL /// internal class MySQLUserData : UserDataBase { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// Database manager for MySQL @@ -348,9 +349,9 @@ namespace OpenSim.Data.MySQL m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); } - override public List GeneratePickerResults(LLUUID queryID, string query) + override public List GeneratePickerResults(LLUUID queryID, string query) { - List returnlist = new List(); + List returnlist = new List(); Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); @@ -373,7 +374,7 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { - Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + AvatarPickerAvatar user = new AvatarPickerAvatar(); user.AvatarID = new LLUUID((string) reader["UUID"]); user.firstName = (string) reader["username"]; user.lastName = (string) reader["lastname"]; @@ -407,7 +408,7 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { - Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + AvatarPickerAvatar user = new AvatarPickerAvatar(); user.AvatarID = new LLUUID((string) reader["UUID"]); user.firstName = (string) reader["username"]; user.lastName = (string) reader["lastname"]; -- cgit v1.1 From 4db839c3b84bed8a775074beb1ae0b526bc05e81 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Apr 2008 17:04:15 +0000 Subject: * Implement proper emptying of trashcan on standalone * On standalone, folders (and their items) should now be persistently deleted on trash emptying, as well as immediate child items * An implementation for grid mode will follow. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 3aed301..dbcb9bd 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -637,7 +637,7 @@ namespace OpenSim.Data.MySQL } /// - /// Delete an inventory folder + /// Deletes an inventory folder /// /// Id of folder to delete public void deleteInventoryFolder(LLUUID folderID) -- cgit v1.1 From a1cc0e436ff9081f3c0a76de861ed0673cd36142 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Apr 2008 19:13:06 +0000 Subject: changes to allow asset_source to be specified in the opensim.ini this will work for sqlite and nhibernate, but will be ignored for mysql and mssql (reverting to their ini files) until someone writes that bit. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 111f7d1..b6545d7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -170,6 +170,13 @@ namespace OpenSim.Data.MySQL #region IPlugin Members + override public void Initialise(string connect) + { + // TODO: This will let you pass in the connect string in + // the config, though someone will need to write that. + Initialise(); + } + override public void Initialise() { IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); -- cgit v1.1 From 3dd98a112f4308532d768943690b13c403dff68b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Apr 2008 20:48:23 +0000 Subject: allow for Inventory database source to be specified in main configs. This works with sqlite and nhibernate backends, and stays with default seperate ini files for mysql and mssql until someone writes those. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index dbcb9bd..6261d37 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -51,6 +51,12 @@ namespace OpenSim.Data.MySQL /// /// Loads and initialises this database plugin /// + public void Initialise(string connect) + { + // TODO: actually use the provided connect string + Initialise(); + } + public void Initialise() { IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); -- cgit v1.1 From c6f6218f60db023fb4c124039fd9551bc4754b13 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 24 Apr 2008 15:23:49 +0000 Subject: in theory, let you pass the mysql connection string into the mysql manager class. This could use some testing of inventory and asset services. Once this is prooved out, I'll do it for mssql as well. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 +++++++- OpenSim/Data/MySQL/MySQLManager.cs | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index b6545d7..b4a9191 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -174,7 +174,13 @@ namespace OpenSim.Data.MySQL { // TODO: This will let you pass in the connect string in // the config, though someone will need to write that. - Initialise(); + if (connect == String.Empty) { + // This is old seperate config file + Initialise(); + } else { + _dbConnection = new MySQLManager(connect); + TestTables(); + } } override public void Initialise() diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 1e7038f..d522b78 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -65,10 +65,22 @@ namespace OpenSim.Data.MySQL public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) { + string s = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; + + Initialise(s); + } + + public MySQLManager(String connect) + { + Initialise(connect); + } + + public void Initialise(String connect) + { try { - connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + - username + ";Password=" + password + ";Pooling=" + cpooling + ";"; + connectionString = connect; dbcon = new MySqlConnection(connectionString); try -- cgit v1.1 From a9cc76e0efba7496909d613c75b81de6a9c5d979 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 30 Apr 2008 16:08:24 +0000 Subject: * Long awaited patch from A_Biondi Mantis 923. Kept alive by Melanie. Thanks A_Biondi and Melanie! * This builds but might not work. JustinCC will examine.. it may work out of the box. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 21 +++++++++++++++++---- OpenSim/Data/MySQL/Resources/CreateItemsTable.sql | 8 +++++++- .../MySQL/Resources/UpgradeItemsTableToVersion3.sql | 8 ++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 6261d37..2c781e0 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -332,6 +332,15 @@ namespace OpenSim.Data.MySQL item.Creator = new LLUUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + + // new fields + item.SalePrice = (int) reader["salePrice"]; + item.SaleType = Convert.ToByte(reader["saleType"]); + item.CreationDate = (int) reader["creationDate"]; + item.GroupID = new LLUUID(reader["groupID"].ToString()); + item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); + item.Flags = (uint) reader["flags"]; + return item; } catch (MySqlException e) @@ -353,8 +362,6 @@ namespace OpenSim.Data.MySQL { lock (database) { - Dictionary param = new Dictionary(); - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", itemID.ToString()); @@ -444,9 +451,9 @@ namespace OpenSim.Data.MySQL public void addInventoryItem(InventoryItemBase item) { string sql = - "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES "; + "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, groupID, groupOwned, flags) VALUES "; sql += - "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)"; + "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?salePrice, ?saleType, ?creationDate, ?groupID, ?groupOwned, ?flags)"; try { @@ -465,6 +472,12 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); + result.Parameters.AddWithValue("?salePrice", item.SalePrice); + result.Parameters.AddWithValue("?saleType", item.SaleType); + result.Parameters.AddWithValue("?creationDate", item.CreationDate); + result.Parameters.AddWithValue("?groupID", item.GroupID); + result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); + result.Parameters.AddWithValue("?flags", item.Flags); lock (database) { diff --git a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql index 1723ee3..c8b7481 100644 --- a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql +++ b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql @@ -12,7 +12,13 @@ CREATE TABLE `inventoryitems` ( `creatorID` varchar(36) default NULL, `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, + `salePrice` int(11) default NULL, + `saleType` tinyint(4) default NULL, + `creationDate` int(11) default NULL, + `groupID` varchar(63) default NULL, + `groupOwned` tinyint(4) default NULL, + `flags` int(11) unsigned default NULL, PRIMARY KEY (`inventoryID`), KEY `owner` (`avatarID`), KEY `folder` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql new file mode 100644 index 0000000..2b3b1f7 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql @@ -0,0 +1,8 @@ +ALTER TABLE `inventoryitems` + ADD COLUMN `salePrice` int(11) NOT NULL, + ADD COLUMN `saleType` tinyint(4) NOT NULL, + ADD COLUMN `creationDate` int(11) NOT NULL, + ADD COLUMN `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + ADD COLUMN `groupOwned` tinyint(4) NOT NULL, + ADD COLUMN `flags` int(11) unsigned NOT NULL, +COMMENT='Rev. 3'; -- cgit v1.1 From b70da6ac1955ada29e1cb4dbe9aeb915735ec686 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 30 Apr 2008 16:52:12 +0000 Subject: * Patch by Melanie. Implements proper objectflags on child objects. Thanks Melanie! RE: 0001079: r4387. touch() event does not fire when touch script is in root prim and child prims are touched --- OpenSim/Data/MySQL/MySQLDataStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 08e4456..7714fdc 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -148,7 +148,7 @@ namespace OpenSim.Data.MySQL { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) + if ((prim.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) == 0) { m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); -- cgit v1.1 From dbcd6112b9e23f45638089a528102617af57b4fc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Apr 2008 17:11:59 +0000 Subject: * Actually enable the inventory upgrade sql if appropriate --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 2c781e0..944c2f5 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -101,10 +101,11 @@ namespace OpenSim.Data.MySQL } // if the table is already at the current version, then we can exit immediately -// if (oldVersion == "Rev. 2") -// return; - -// database.ExecuteResourceSql("UpgradeItemsTableToVersion2.sql"); + if (oldVersion.StartsWith("Rev. 2;")) + { + m_log.Info("[INVENTORY DB]: Upgrading inventory items table from Rev. 2 to Rev. 3"); + database.ExecuteResourceSql("UpgradeItemsTableToVersion3.sql"); + } } private void TestTables(MySqlConnection conn) @@ -115,8 +116,8 @@ namespace OpenSim.Data.MySQL tableList["inventoryitems"] = null; database.GetTableVersion(tableList); - m_log.Info("[MYSQL]: Inventory Folder Version: " + tableList["inventoryfolders"]); - m_log.Info("[MYSQL]: Inventory Items Version: " + tableList["inventoryitems"]); + m_log.Info("[INVENTORY DB]: Inventory Folder Version: " + tableList["inventoryfolders"]); + m_log.Info("[INVENTORY DB]: Inventory Items Version: " + tableList["inventoryitems"]); UpgradeFoldersTable(tableList["inventoryfolders"]); UpgradeItemsTable(tableList["inventoryitems"]); -- cgit v1.1 From f57ff4c36bab3b9e26c55d64afde251bf07a2de3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Apr 2008 19:13:06 +0000 Subject: * Change new inventory groupID field to 36 rather than 63 * Add updated stub mssql inventory sql (only really because I was in the middle of this when I spotted the numeric transposition) --- OpenSim/Data/MySQL/Resources/CreateItemsTable.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql index c8b7481..24ebccd 100644 --- a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql +++ b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql @@ -15,7 +15,7 @@ CREATE TABLE `inventoryitems` ( `salePrice` int(11) default NULL, `saleType` tinyint(4) default NULL, `creationDate` int(11) default NULL, - `groupID` varchar(63) default NULL, + `groupID` varchar(36) default NULL, `groupOwned` tinyint(4) default NULL, `flags` int(11) unsigned default NULL, PRIMARY KEY (`inventoryID`), -- cgit v1.1 From 8ed9e578968539ff991ffa8215e715c0e4c3be5d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Apr 2008 19:28:36 +0000 Subject: * Add a scratch implementation of the new inventory fields to the mssql database adapter * I don't use mssql so this may not work, corrections (in the form of patches) are welcome. * Unlike mysql, mssql requires manual updating of existing tables here (which should mean just adding the new fields manually) --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 944c2f5..23d2ea5 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -333,8 +333,6 @@ namespace OpenSim.Data.MySQL item.Creator = new LLUUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; - - // new fields item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; @@ -452,9 +450,15 @@ namespace OpenSim.Data.MySQL public void addInventoryItem(InventoryItemBase item) { string sql = - "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, groupID, groupOwned, flags) VALUES "; + "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName" + + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType" + + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType" + + ", creationDate, groupID, groupOwned, flags) VALUES "; sql += - "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?salePrice, ?saleType, ?creationDate, ?groupID, ?groupOwned, ?flags)"; + "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription" + + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID" + + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?salePrice, ?saleType, ?creationDate" + + ", ?groupID, ?groupOwned, ?flags)"; try { -- cgit v1.1 From b3f44fbb94287d58c635cad7d75e5223ef35aedf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 30 Apr 2008 20:08:15 +0000 Subject: * Refactored the land table to be versionable in mySQL. * Added AuthbuyerID so that if someone sets a land for sale to someone and then restarts the simulator, when the simulator comes back up, the setting persists. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 139 +++++++++++++++++++-- OpenSim/Data/MySQL/Resources/CreateLandTable.sql | 39 ++++++ .../MySQL/Resources/UpgradeLandTableToVersion2.sql | 3 + 3 files changed, 170 insertions(+), 11 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/CreateLandTable.sql create mode 100644 OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 7714fdc..d438064 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -50,6 +50,12 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; + + + /// + /// We're only using this to version the table! + /// + private DataSet m_dataSet; private MySqlDataAdapter m_primDataAdapter; @@ -85,6 +91,8 @@ namespace OpenSim.Data.MySQL m_log.Info("[DATASTORE]: MySql - connecting: " + connectionstring); m_connection = new MySqlConnection(connectionstring); + TestTablesVersionable(m_connection); + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); @@ -103,6 +111,7 @@ namespace OpenSim.Data.MySQL MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); + TestTables(m_connection); lock (m_dataSet) @@ -141,7 +150,104 @@ namespace OpenSim.Data.MySQL m_landAccessListDataAdapter.Fill(m_landAccessListTable); } } + /// + /// Given a list of tables, return the version of the tables, as seen in the database + /// + /// + public void GetTableVersion(Dictionary tableList, MySqlConnection dbcon) + { + lock (dbcon) + { + MySqlCommand tablesCmd = + new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon); + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + { + while (tables.Read()) + { + try + { + string tableName = (string)tables["TABLE_NAME"]; + string comment = (string)tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) + { + tableList[tableName] = comment; + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + tables.Close(); + } + } + } + private void TestTablesVersionable(MySqlConnection dbconn) + { + Dictionary tableList = new Dictionary(); + + tableList["land"] = null; + dbconn.Open(); + GetTableVersion(tableList,dbconn); + + UpgradeLandTable(tableList["land"], dbconn); + //database.Close(); + + } + + /// + /// Execute a SQL statement stored in a resource, as a string + /// + /// + public void ExecuteResourceSql(string name, MySqlConnection dbcon) + { + MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); + cmd.ExecuteNonQuery(); + } + + /// + /// Extract a named string resource from the embedded resources + /// + /// name of embedded resource + /// string contained within the embedded resource + private string getResourceString(string name) + { + Assembly assem = GetType().Assembly; + string[] names = assem.GetManifestResourceNames(); + + foreach (string s in names) + { + if (s.EndsWith(name)) + { + using (Stream resource = assem.GetManifestResourceStream(s)) + { + using (StreamReader resourceReader = new StreamReader(resource)) + { + string resourceString = resourceReader.ReadToEnd(); + return resourceString; + } + } + } + } + throw new Exception(string.Format("Resource '{0}' was not found", name)); + } + private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + ExecuteResourceSql("CreateLandTable.sql",dbconn); + oldVersion = "Rev. 2; InnoDB free: 0 kB"; + } + if (!oldVersion.Contains("Rev.")) + { + ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); + } + } public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { lock (m_dataSet) @@ -673,6 +779,7 @@ namespace OpenSim.Data.MySQL createCol(land, "UserLookAtX", typeof (Double)); createCol(land, "UserLookAtY", typeof (Double)); createCol(land, "UserLookAtZ", typeof (Double)); + createCol(land, "AuthBuyerID", typeof (String)); land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; @@ -925,7 +1032,14 @@ namespace OpenSim.Data.MySQL newData.musicURL = (String) row["MusicURL"]; newData.passHours = Convert.ToSingle(row["PassHours"]); newData.passPrice = Convert.ToInt32(row["PassPrice"]); - newData.snapshotID = (String) row["SnapshotUUID"]; + LLUUID authedbuyer = LLUUID.Zero; + LLUUID snapshotID = LLUUID.Zero; + + Helpers.TryParse((string)row["AuthBuyerID"], out authedbuyer); + Helpers.TryParse((string)row["SnapshotUUID"], out snapshotID); + + newData.authBuyerID = authedbuyer; + newData.snapshotID = snapshotID; newData.userLocation = new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), @@ -1096,6 +1210,7 @@ namespace OpenSim.Data.MySQL row["UserLookAtX"] = land.userLookAt.X; row["UserLookAtY"] = land.userLookAt.Y; row["UserLookAtZ"] = land.userLookAt.Z; + row["AuthBuyerID"] = land.authBuyerID; } private void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) @@ -1479,14 +1594,16 @@ namespace OpenSim.Data.MySQL string createShapes = defineTable(createShapeTable()); string createItems = defineTable(createItemsTable()); string createTerrain = defineTable(createTerrainTable()); - string createLand = defineTable(createLandTable()); + + // Land table is created from the Versionable Test Table routine now. + //string createLand = defineTable(createLandTable()); string createLandAccessList = defineTable(createLandAccessListTable()); MySqlCommand pcmd = new MySqlCommand(createPrims, conn); MySqlCommand scmd = new MySqlCommand(createShapes, conn); MySqlCommand icmd = new MySqlCommand(createItems, conn); MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); - MySqlCommand lcmd = new MySqlCommand(createLand, conn); + //MySqlCommand lcmd = new MySqlCommand(createLand, conn); MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); if (conn.State != ConnectionState.Open) @@ -1539,14 +1656,14 @@ namespace OpenSim.Data.MySQL m_log.WarnFormat("[MySql]: Terrain Table Already Exists: {0}", e); } - try - { - lcmd.ExecuteNonQuery(); - } - catch (MySqlException e) - { - m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); - } + //try + //{ + //lcmd.ExecuteNonQuery(); + //} + //catch (MySqlException e) + //{ + //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); + //} try { diff --git a/OpenSim/Data/MySQL/Resources/CreateLandTable.sql b/OpenSim/Data/MySQL/Resources/CreateLandTable.sql new file mode 100644 index 0000000..8a1b626 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateLandTable.sql @@ -0,0 +1,39 @@ +CREATE TABLE `land` + ( + `UUID` varchar (255) NOT NULL, + `RegionUUID` varchar (255) DEFAULT NULL , + `LocalLandID` int (11) DEFAULT NULL , + `Bitmap` longblob, + `Name` varchar (255) DEFAULT NULL , + `Description` varchar (255) DEFAULT NULL , + `OwnerUUID` varchar (255) DEFAULT NULL , + `IsGroupOwned` int (11) DEFAULT NULL , + `Area` int (11) DEFAULT NULL , + `AuctionID` int (11) DEFAULT NULL , + `Category` int (11) DEFAULT NULL , + `ClaimDate` int (11) DEFAULT NULL , + `ClaimPrice` int (11) DEFAULT NULL , + `GroupUUID` varchar (255) DEFAULT NULL , + `SalePrice` int (11) DEFAULT NULL , + `LandStatus` int (11) DEFAULT NULL , + `LandFlags` int (11) DEFAULT NULL , + `LandingType` int (11) DEFAULT NULL , + `MediaAutoScale` int (11) DEFAULT NULL , + `MediaTextureUUID` varchar (255) DEFAULT NULL , + `MediaURL` varchar (255) DEFAULT NULL , + `MusicURL` varchar (255) DEFAULT NULL , + `PassHours` float DEFAULT NULL , + `PassPrice` int (11) DEFAULT NULL , + `SnapshotUUID` varchar (255) DEFAULT NULL , + `UserLocationX` float DEFAULT NULL , + `UserLocationY` float DEFAULT NULL , + `UserLocationZ` float DEFAULT NULL , + `UserLookAtX` float DEFAULT NULL , + `UserLookAtY` float DEFAULT NULL , + `UserLookAtZ` float DEFAULT NULL , + `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, + + PRIMARY KEY (`UUID`) + ) + ENGINE=INNODB + DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql new file mode 100644 index 0000000..eb024be --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql @@ -0,0 +1,3 @@ +ALTER TABLE `land` + ADD COLUMN `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, +COMMENT='Rev. 2'; \ No newline at end of file -- cgit v1.1 From 25a49ac4de056f43d6c5803fcd34804fcea96ae2 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 30 Apr 2008 23:11:07 +0000 Subject: * Spring cleaned a bunch of '//TODO: unused' marked functions. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 42 ------------------------------------ 1 file changed, 42 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index d438064..1f9ea70 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -586,40 +586,6 @@ namespace OpenSim.Data.MySQL return landDataForRegion; } -// TODO: unused -// private void DisplayDataSet(DataSet ds, string title) -// { -// Debug.WriteLine(title); -// //--- Loop through the DataTables -// foreach (DataTable table in ds.Tables) -// { -// Debug.WriteLine("*** DataTable: " + table.TableName + "***"); -// //--- Loop through each DataTable's DataRows -// foreach (DataRow row in table.Rows) -// { -// //--- Display the original values, if there are any. -// if (row.HasVersion(DataRowVersion.Original)) -// { -// Debug.Write("Original Row Values ===> "); -// foreach (DataColumn column in table.Columns) -// Debug.Write(column.ColumnName + " = " + -// row[column, DataRowVersion.Original] + ", "); -// Debug.WriteLine(String.Empty); -// } -// //--- Display the current values, if there are any. -// if (row.HasVersion(DataRowVersion.Current)) -// { -// Debug.Write("Current Row Values ====> "); -// foreach (DataColumn column in table.Columns) -// Debug.Write(column.ColumnName + " = " + -// row[column, DataRowVersion.Current] + ", "); -// Debug.WriteLine(String.Empty); -// } -// Debug.WriteLine(String.Empty); -// } -// } -// } - public void Commit() { if (m_connection.State != ConnectionState.Open) @@ -1515,14 +1481,6 @@ namespace OpenSim.Data.MySQL return param; } -// TODO: unused -// private MySqlParameter createParamWithValue(string name, Type type, Object o) -// { -// MySqlParameter param = createMySqlParameter(name, type); -// param.Value = o; -// return param; -// } - private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) { MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); -- cgit v1.1 From 9024fe68fc3ab5e3e4fde2a88b63ddd67c335490 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 12:08:22 +0000 Subject: * Insert temporary cast exception catching code to deal with mantis 1099 - mysql inventoryitems table problem --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 23d2ea5..991e9c7 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -333,12 +333,38 @@ namespace OpenSim.Data.MySQL item.Creator = new LLUUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; - item.SalePrice = (int) reader["salePrice"]; + + try + { + item.SalePrice = (int) reader["salePrice"]; + } + catch (InvalidCastException) + { + m_log.WarnFormat("Could not cast salePrice {0} to {1}", reader["salePrice"], "int"); + } + item.SaleType = Convert.ToByte(reader["saleType"]); - item.CreationDate = (int) reader["creationDate"]; + + try + { + item.CreationDate = (int) reader["creationDate"]; + } + catch (InvalidCastException) + { + m_log.WarnFormat("Could not cast creationDate {0} to {1}", reader["creationDate"], "int"); + } + item.GroupID = new LLUUID(reader["groupID"].ToString()); item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); - item.Flags = (uint) reader["flags"]; + + try + { + item.Flags = (uint) reader["flags"]; + } + catch (InvalidCastException) + { + m_log.WarnFormat("Could not cast flags {0} to {1}", reader["flags"], "uint"); + } return item; } -- cgit v1.1 From 6e9042c3d34f5e7169eac146b48eec8fe0b406cb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 12:33:05 +0000 Subject: * Change mysql inventory items table version 3 upgrade sql to provide explicit default values --- OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql index 2b3b1f7..5bd6994 100644 --- a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql +++ b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql @@ -1,8 +1,8 @@ ALTER TABLE `inventoryitems` - ADD COLUMN `salePrice` int(11) NOT NULL, - ADD COLUMN `saleType` tinyint(4) NOT NULL, - ADD COLUMN `creationDate` int(11) NOT NULL, + ADD COLUMN `salePrice` int(11) NOT NULL default 0, + ADD COLUMN `saleType` tinyint(4) NOT NULL default 0, + ADD COLUMN `creationDate` int(11) NOT NULL default 3000, ADD COLUMN `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - ADD COLUMN `groupOwned` tinyint(4) NOT NULL, - ADD COLUMN `flags` int(11) unsigned NOT NULL, + ADD COLUMN `groupOwned` tinyint(4) NOT NULL default 0, + ADD COLUMN `flags` int(11) unsigned NOT NULL default 0, COMMENT='Rev. 3'; -- cgit v1.1 From d72bdf432a622f237b3030c1da9d1bccca20f83c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 13:27:40 +0000 Subject: * Align new fields upgrade sql to have the same 'not null' and default settings as when an inventoryitems table is newly created * Normalize logging titles in database code, though this doesn't yet cover invoking code --- OpenSim/Data/MySQL/MySQLAssetData.cs | 6 +-- OpenSim/Data/MySQL/MySQLDataStore.cs | 46 +++++++++++----------- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Resources/CreateItemsTable.sql | 12 +++--- .../Resources/UpgradeItemsTableToVersion3.sql | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index b4a9191..efcf59e 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -49,7 +49,7 @@ namespace OpenSim.Data.MySQL // null as the version, indicates that the table didn't exist if (oldVersion == null) { - m_log.Info("[ASSETS]: Creating new database tables"); + m_log.Info("[ASSETS DB]: Creating new database tables"); _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); return; } @@ -102,7 +102,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { m_log.ErrorFormat( - "[ASSETS]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection", assetID); _dbConnection.Reconnect(); } @@ -141,7 +141,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { m_log.ErrorFormat( - "[ASSETS]: " + + "[ASSETS DB]: " + "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); _dbConnection.Reconnect(); diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 1f9ea70..33981de 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL m_dataSet = new DataSet(); this.persistPrimInventories = persistPrimInventories; - m_log.Info("[DATASTORE]: MySql - connecting: " + connectionstring); + m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring); m_connection = new MySqlConnection(connectionstring); TestTablesVersionable(m_connection); @@ -256,7 +256,7 @@ namespace OpenSim.Data.MySQL { if ((prim.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) == 0) { - m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); } else @@ -270,7 +270,7 @@ namespace OpenSim.Data.MySQL public void RemoveObject(LLUUID obj, LLUUID regionUUID) { - m_log.InfoFormat("[DATASTORE]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); DataTable prims = m_primTable; DataTable shapes = m_shapeTable; @@ -334,7 +334,7 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - m_log.Info("[DATASTORE]: " + + m_log.Info("[REGION DB]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); foreach (DataRow primRow in primsForRegion) @@ -390,11 +390,11 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error("[DATASTORE]: Failed create prim object, exception and data follows"); - m_log.Info("[DATASTORE]: " + e.ToString()); + m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); + m_log.Info("[REGION DB]: " + e.ToString()); foreach (DataColumn col in prims.Columns) { - m_log.Info("[DATASTORE]: Col: " + col.ColumnName + " => " + primRow[col]); + m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); } } } @@ -438,7 +438,7 @@ namespace OpenSim.Data.MySQL public void StoreTerrain(double[,] ter, LLUUID regionID) { int revision = Util.UnixTimeSinceEpoch(); - m_log.Info("[DATASTORE]: Storing terrain revision r" + revision.ToString()); + m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); DataTable terrain = m_dataSet.Tables["terrain"]; lock (m_dataSet) @@ -493,11 +493,11 @@ namespace OpenSim.Data.MySQL } else { - m_log.Info("[DATASTORE]: No terrain found for region"); + m_log.Info("[REGION DB]: No terrain found for region"); return null; } - m_log.Info("[DATASTORE]: Loaded terrain revision r" + rev.ToString()); + m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); } } return terret; @@ -1329,7 +1329,7 @@ namespace OpenSim.Data.MySQL if (!persistPrimInventories) return; - m_log.InfoFormat("[DATASTORE]: Persisting Prim Inventory with prim ID {0}", primID); + m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); // For now, we're just going to crudely remove all the previous inventory items // no matter whether they have changed or not, and replace them with the current set. @@ -1341,7 +1341,7 @@ namespace OpenSim.Data.MySQL foreach (TaskInventoryItem newItem in items) { // m_log.InfoFormat( -// "[DATASTORE]: " + +// "[REGION DB]: " + // "Adding item {0}, {1} to prim ID {2}", // newItem.Name, newItem.ItemID, newItem.ParentPartID); @@ -1572,8 +1572,8 @@ namespace OpenSim.Data.MySQL } catch (Exception ex) { - m_log.Error("[MySql]: Error connecting to MySQL server: " + ex.Message); - m_log.Error("[MySql]: Application is terminating!"); + m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message); + m_log.Error("[REGION DB]: Application is terminating!"); Thread.CurrentThread.Abort(); } } @@ -1584,7 +1584,7 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.WarnFormat("[MySql]: Primitives Table Already Exists: {0}", e); + m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e); } try @@ -1593,7 +1593,7 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.WarnFormat("[MySql]: Shapes Table Already Exists: {0}", e); + m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); } try @@ -1602,7 +1602,7 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.WarnFormat("[MySql]: Items Table Already Exists: {0}", e); + m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); } try @@ -1611,7 +1611,7 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.WarnFormat("[MySql]: Terrain Table Already Exists: {0}", e); + m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e); } //try @@ -1629,7 +1629,7 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.WarnFormat("[MySql]: LandAccessList Table Already Exists: {0}", e); + m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e); } conn.Close(); } @@ -1682,7 +1682,7 @@ namespace OpenSim.Data.MySQL { if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) { - m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); + m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); return false; } } @@ -1691,7 +1691,7 @@ namespace OpenSim.Data.MySQL { if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) { - m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName); + m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); return false; } } @@ -1702,7 +1702,7 @@ namespace OpenSim.Data.MySQL { if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) { - m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); return false; } } @@ -1711,7 +1711,7 @@ namespace OpenSim.Data.MySQL { if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) { - m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); return false; } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index b6274d4..df52ae0 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -284,7 +284,7 @@ namespace OpenSim.Data.MySQL } else { - m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); + m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index d522b78..c62cfa7 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -89,7 +89,7 @@ namespace OpenSim.Data.MySQL } catch(Exception e) { - throw new Exception( "Connection error while using connection string ["+connectionString+"]", e ); + throw new Exception("Connection error while using connection string ["+connectionString+"]", e); } m_log.Info("[MYSQL]: Connection established"); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 66b65dc..382d69c 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -346,7 +346,7 @@ namespace OpenSim.Data.MySQL override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) { - m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); + m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called"); } override public List GeneratePickerResults(LLUUID queryID, string query) diff --git a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql index 24ebccd..ffdbe17 100644 --- a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql +++ b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql @@ -12,12 +12,12 @@ CREATE TABLE `inventoryitems` ( `creatorID` varchar(36) default NULL, `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, - `salePrice` int(11) default NULL, - `saleType` tinyint(4) default NULL, - `creationDate` int(11) default NULL, - `groupID` varchar(36) default NULL, - `groupOwned` tinyint(4) default NULL, - `flags` int(11) unsigned default NULL, + `salePrice` int(11) NOT NULL default 0, + `saleType` tinyint(4) NOT NULL default 0, + `creationDate` int(11) NOT NULL default 0, + `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `groupOwned` tinyint(4) NOT NULL default 0, + `flags` int(11) unsigned NOT NULL default 0, PRIMARY KEY (`inventoryID`), KEY `owner` (`avatarID`), KEY `folder` (`parentFolderID`) diff --git a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql index 5bd6994..b4108ab 100644 --- a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql +++ b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql @@ -1,7 +1,7 @@ ALTER TABLE `inventoryitems` ADD COLUMN `salePrice` int(11) NOT NULL default 0, ADD COLUMN `saleType` tinyint(4) NOT NULL default 0, - ADD COLUMN `creationDate` int(11) NOT NULL default 3000, + ADD COLUMN `creationDate` int(11) NOT NULL default 0, ADD COLUMN `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', ADD COLUMN `groupOwned` tinyint(4) NOT NULL default 0, ADD COLUMN `flags` int(11) unsigned NOT NULL default 0, -- cgit v1.1 From 13e51b197cb842de916645c5e4b4d2d2898b8f00 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 13:41:36 +0000 Subject: * Add more class cast exceptions to mysql read inventory item to cover all new fields - not just those I think are initially failing. * This is more likely to allow existing mysql databases to work temporarily, if the previous revision doesn't work --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 991e9c7..592ade9 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -343,7 +343,14 @@ namespace OpenSim.Data.MySQL m_log.WarnFormat("Could not cast salePrice {0} to {1}", reader["salePrice"], "int"); } - item.SaleType = Convert.ToByte(reader["saleType"]); + try + { + item.SaleType = Convert.ToByte(reader["saleType"]); + } + catch (InvalidCastException) + { + m_log.WarnFormat("Could not convert saleType {0} to {1}", reader["saleType"], "byte"); + } try { @@ -354,8 +361,24 @@ namespace OpenSim.Data.MySQL m_log.WarnFormat("Could not cast creationDate {0} to {1}", reader["creationDate"], "int"); } - item.GroupID = new LLUUID(reader["groupID"].ToString()); - item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); + try + { + item.GroupID = new LLUUID(reader["groupID"].ToString()); + } + catch (Exception) + { + item.GroupID = LLUUID.Zero; + m_log.WarnFormat("Could not convert groupID {0} to {1}", reader["groupID"], "LLUUID"); + } + + try + { + item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); + } + catch (InvalidCastException) + { + m_log.WarnFormat("Could not cast groupOwned {0} to {1}", reader["groupOwned"], "boolean"); + } try { -- cgit v1.1 From d51ce47b2d7635b17f3dd429158e8f59b78b83aa Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 May 2008 14:31:30 +0000 Subject: Update svn properties. Minor formatting cleanup. --- OpenSim/Data/MySQL/Resources/CreateLandTable.sql | 76 +++++++++++----------- .../MySQL/Resources/UpgradeLandTableToVersion2.sql | 4 +- 2 files changed, 40 insertions(+), 40 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/CreateLandTable.sql b/OpenSim/Data/MySQL/Resources/CreateLandTable.sql index 8a1b626..6c7254a 100644 --- a/OpenSim/Data/MySQL/Resources/CreateLandTable.sql +++ b/OpenSim/Data/MySQL/Resources/CreateLandTable.sql @@ -1,39 +1,39 @@ -CREATE TABLE `land` - ( - `UUID` varchar (255) NOT NULL, - `RegionUUID` varchar (255) DEFAULT NULL , - `LocalLandID` int (11) DEFAULT NULL , - `Bitmap` longblob, - `Name` varchar (255) DEFAULT NULL , - `Description` varchar (255) DEFAULT NULL , - `OwnerUUID` varchar (255) DEFAULT NULL , - `IsGroupOwned` int (11) DEFAULT NULL , - `Area` int (11) DEFAULT NULL , - `AuctionID` int (11) DEFAULT NULL , - `Category` int (11) DEFAULT NULL , - `ClaimDate` int (11) DEFAULT NULL , - `ClaimPrice` int (11) DEFAULT NULL , - `GroupUUID` varchar (255) DEFAULT NULL , - `SalePrice` int (11) DEFAULT NULL , - `LandStatus` int (11) DEFAULT NULL , - `LandFlags` int (11) DEFAULT NULL , - `LandingType` int (11) DEFAULT NULL , - `MediaAutoScale` int (11) DEFAULT NULL , - `MediaTextureUUID` varchar (255) DEFAULT NULL , - `MediaURL` varchar (255) DEFAULT NULL , - `MusicURL` varchar (255) DEFAULT NULL , - `PassHours` float DEFAULT NULL , - `PassPrice` int (11) DEFAULT NULL , - `SnapshotUUID` varchar (255) DEFAULT NULL , - `UserLocationX` float DEFAULT NULL , - `UserLocationY` float DEFAULT NULL , - `UserLocationZ` float DEFAULT NULL , - `UserLookAtX` float DEFAULT NULL , - `UserLookAtY` float DEFAULT NULL , - `UserLookAtZ` float DEFAULT NULL , - `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, - - PRIMARY KEY (`UUID`) - ) - ENGINE=INNODB +CREATE TABLE `land` + ( + `UUID` varchar (255) NOT NULL, + `RegionUUID` varchar (255) DEFAULT NULL , + `LocalLandID` int (11) DEFAULT NULL , + `Bitmap` longblob, + `Name` varchar (255) DEFAULT NULL , + `Description` varchar (255) DEFAULT NULL , + `OwnerUUID` varchar (255) DEFAULT NULL , + `IsGroupOwned` int (11) DEFAULT NULL , + `Area` int (11) DEFAULT NULL , + `AuctionID` int (11) DEFAULT NULL , + `Category` int (11) DEFAULT NULL , + `ClaimDate` int (11) DEFAULT NULL , + `ClaimPrice` int (11) DEFAULT NULL , + `GroupUUID` varchar (255) DEFAULT NULL , + `SalePrice` int (11) DEFAULT NULL , + `LandStatus` int (11) DEFAULT NULL , + `LandFlags` int (11) DEFAULT NULL , + `LandingType` int (11) DEFAULT NULL , + `MediaAutoScale` int (11) DEFAULT NULL , + `MediaTextureUUID` varchar (255) DEFAULT NULL , + `MediaURL` varchar (255) DEFAULT NULL , + `MusicURL` varchar (255) DEFAULT NULL , + `PassHours` float DEFAULT NULL , + `PassPrice` int (11) DEFAULT NULL , + `SnapshotUUID` varchar (255) DEFAULT NULL , + `UserLocationX` float DEFAULT NULL , + `UserLocationY` float DEFAULT NULL , + `UserLocationZ` float DEFAULT NULL , + `UserLookAtX` float DEFAULT NULL , + `UserLookAtY` float DEFAULT NULL , + `UserLookAtZ` float DEFAULT NULL , + `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, + + PRIMARY KEY (`UUID`) + ) + ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql index eb024be..c5c55f1 100644 --- a/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql +++ b/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql @@ -1,3 +1,3 @@ -ALTER TABLE `land` - ADD COLUMN `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, +ALTER TABLE `land` + ADD COLUMN `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, COMMENT='Rev. 2'; \ No newline at end of file -- cgit v1.1 From 523190377861292dfecdaddebe1204301a0c7912 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 16:03:53 +0000 Subject: * In ur code. Making it static. * Converted a bunch of functions to static functions. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 44 ++++++++++++++++---------------- OpenSim/Data/MySQL/MySQLInventoryData.cs | 4 +-- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 33981de..c3fe332 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -627,24 +627,24 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ - private DataColumn createCol(DataTable dt, string name, Type type) + private static DataColumn createCol(DataTable dt, string name, Type type) { DataColumn col = new DataColumn(name, type); dt.Columns.Add(col); return col; } - private DataTable createTerrainTable() + private static DataTable createTerrainTable() { DataTable terrain = new DataTable("terrain"); createCol(terrain, "RegionUUID", typeof (String)); createCol(terrain, "Revision", typeof (Int32)); - DataColumn heightField = createCol(terrain, "Heightfield", typeof (Byte[])); + createCol(terrain, "Heightfield", typeof (Byte[])); return terrain; } - private DataTable createPrimTable() + private static DataTable createPrimTable() { DataTable prims = new DataTable("prims"); @@ -708,7 +708,7 @@ namespace OpenSim.Data.MySQL return prims; } - private DataTable createLandTable() + private static DataTable createLandTable() { DataTable land = new DataTable("land"); createCol(land, "UUID", typeof (String)); @@ -752,7 +752,7 @@ namespace OpenSim.Data.MySQL return land; } - private DataTable createLandAccessListTable() + private static DataTable createLandAccessListTable() { DataTable landaccess = new DataTable("landaccesslist"); createCol(landaccess, "LandUUID", typeof (String)); @@ -762,7 +762,7 @@ namespace OpenSim.Data.MySQL return landaccess; } - private DataTable createShapeTable() + private static DataTable createShapeTable() { DataTable shapes = new DataTable("primshapes"); createCol(shapes, "UUID", typeof (String)); @@ -802,7 +802,7 @@ namespace OpenSim.Data.MySQL return shapes; } - private DataTable createItemsTable() + private static DataTable createItemsTable() { DataTable items = new DataTable("primitems"); @@ -937,7 +937,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private TaskInventoryItem buildItem(DataRow row) + private static TaskInventoryItem buildItem(DataRow row) { TaskInventoryItem taskItem = new TaskInventoryItem(); @@ -966,7 +966,7 @@ namespace OpenSim.Data.MySQL return taskItem; } - private LandData buildLandData(DataRow row) + private static LandData buildLandData(DataRow row) { LandData newData = new LandData(); @@ -1018,7 +1018,7 @@ namespace OpenSim.Data.MySQL return newData; } - private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) + private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = new LLUUID((string) row["AccessUUID"]); @@ -1027,7 +1027,7 @@ namespace OpenSim.Data.MySQL return entry; } - private Array serializeTerrain(double[,] val) + private static Array serializeTerrain(double[,] val) { MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); @@ -1116,7 +1116,7 @@ namespace OpenSim.Data.MySQL } } - private void fillItemRow(DataRow row, TaskInventoryItem taskItem) + private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) { row["itemID"] = taskItem.ItemID; row["primID"] = taskItem.ParentPartID; @@ -1140,7 +1140,7 @@ namespace OpenSim.Data.MySQL row["groupPermissions"] = taskItem.GroupMask; } - private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) + private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) { row["UUID"] = Util.ToRawUuidString(land.globalID); row["RegionUUID"] = Util.ToRawUuidString(regionUUID); @@ -1179,7 +1179,7 @@ namespace OpenSim.Data.MySQL row["AuthBuyerID"] = land.authBuyerID; } - private void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) + private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) { row["LandUUID"] = Util.ToRawUuidString(parcelID); row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); @@ -1364,7 +1364,7 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ - private MySqlCommand createInsertCommand(string table, DataTable dt) + private static MySqlCommand createInsertCommand(string table, DataTable dt) { /** * This is subtle enough to deserve some commentary. @@ -1399,7 +1399,7 @@ namespace OpenSim.Data.MySQL return cmd; } - private MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) + private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) { string sql = "update " + table + " set "; string subsql = String.Empty; @@ -1426,7 +1426,7 @@ namespace OpenSim.Data.MySQL return cmd; } - private string defineTable(DataTable dt) + private static string defineTable(DataTable dt) { string sql = "create table " + dt.TableName + "("; string subsql = String.Empty; @@ -1471,7 +1471,7 @@ namespace OpenSim.Data.MySQL /// for us. /// ///a built MySql parameter - private MySqlParameter createMySqlParameter(string name, Type type) + private static MySqlParameter createMySqlParameter(string name, Type type) { MySqlParameter param = new MySqlParameter(); param.ParameterName = "?" + name; @@ -1546,7 +1546,7 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } - private void InitDB(MySqlConnection conn) + private static void InitDB(MySqlConnection conn) { string createPrims = defineTable(createPrimTable()); string createShapes = defineTable(createShapeTable()); @@ -1734,7 +1734,7 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ - private DbType dbtypeFromType(Type type) + private static DbType dbtypeFromType(Type type) { if (type == typeof (String)) { @@ -1768,7 +1768,7 @@ namespace OpenSim.Data.MySQL // this is something we'll need to implement for each db // slightly differently. - private string MySqlType(Type type) + private static string MySqlType(Type type) { if (type == typeof (String)) { diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 592ade9..c9765c0 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -314,7 +314,7 @@ namespace OpenSim.Data.MySQL /// /// The SQL Result /// the item read - private InventoryItemBase readInventoryItem(MySqlDataReader reader) + private static InventoryItemBase readInventoryItem(MySqlDataReader reader) { try { @@ -438,7 +438,7 @@ namespace OpenSim.Data.MySQL /// /// A MySQL Data Reader /// A List containing inventory folders - protected InventoryFolderBase readInventoryFolder(MySqlDataReader reader) + protected static InventoryFolderBase readInventoryFolder(MySqlDataReader reader) { try { -- cgit v1.1 From 76d8eaa4069d6445c47784168e274ba4253f7b9c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 18:50:44 +0000 Subject: * Thanks to Mic Bowman for inspiring me to look at that we are still using ASCIIEncoder in places we shouldn't. --- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index df52ae0..e830133 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -366,7 +366,7 @@ namespace OpenSim.Data.MySQL public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge) { SHA512Managed HashProvider = new SHA512Managed(); - ASCIIEncoding TextProvider = new ASCIIEncoding(); + Encoding TextProvider = new UTF8Encoding(); byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); byte[] hash = HashProvider.ComputeHash(stream); -- cgit v1.1 From 86d2e53d1f616eea8603533e9cba236fbae275ef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 1 May 2008 20:16:26 +0000 Subject: added stubs for appearance bits to all the db layers --- OpenSim/Data/MySQL/MySQLUserData.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 382d69c..a01bf60 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -628,6 +628,33 @@ namespace OpenSim.Data.MySQL return false; } + /// Appearance + /// TODO: stubs for now to get us to a compiling state gently + override public UserAppearance GetUserAppearance(LLUUID user) + { + return new UserAppearance(); + } + + override public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) + { + return; + } + + override public void AddAttachment(LLUUID user, LLUUID item) + { + return; + } + + override public void RemoveAttachment(LLUUID user, LLUUID item) + { + return; + } + + override public List GetAttachments(LLUUID user) + { + return new List(); + } + /// /// Database provider name /// -- cgit v1.1 From 1de6cffa28348975a2492ce1e8a85c365df4dfaf Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 20:47:33 +0000 Subject: * Refactor: Remove the unused userID parameter that was being passed into almost every inventory method * This allows lots of redundant inventory methods with only slightly different names to be eliminated. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 63 ++++---------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index c9765c0..b529d4e 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -332,62 +332,13 @@ namespace OpenSim.Data.MySQL item.InvType = (int) reader["invType"]; item.Creator = new LLUUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; - item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; - - try - { - item.SalePrice = (int) reader["salePrice"]; - } - catch (InvalidCastException) - { - m_log.WarnFormat("Could not cast salePrice {0} to {1}", reader["salePrice"], "int"); - } - - try - { - item.SaleType = Convert.ToByte(reader["saleType"]); - } - catch (InvalidCastException) - { - m_log.WarnFormat("Could not convert saleType {0} to {1}", reader["saleType"], "byte"); - } - - try - { - item.CreationDate = (int) reader["creationDate"]; - } - catch (InvalidCastException) - { - m_log.WarnFormat("Could not cast creationDate {0} to {1}", reader["creationDate"], "int"); - } - - try - { - item.GroupID = new LLUUID(reader["groupID"].ToString()); - } - catch (Exception) - { - item.GroupID = LLUUID.Zero; - m_log.WarnFormat("Could not convert groupID {0} to {1}", reader["groupID"], "LLUUID"); - } - - try - { - item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); - } - catch (InvalidCastException) - { - m_log.WarnFormat("Could not cast groupOwned {0} to {1}", reader["groupOwned"], "boolean"); - } - - try - { - item.Flags = (uint) reader["flags"]; - } - catch (InvalidCastException) - { - m_log.WarnFormat("Could not cast flags {0} to {1}", reader["flags"], "uint"); - } + item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + item.SalePrice = (int) reader["salePrice"]; + item.SaleType = Convert.ToByte(reader["saleType"]); + item.CreationDate = (int) reader["creationDate"]; + item.GroupID = new LLUUID(reader["groupID"].ToString()); + item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); + item.Flags = (uint) reader["flags"]; return item; } -- cgit v1.1 From 4a8f43244160ca9324cc43a54ba64a51e10268bf Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 2 May 2008 12:35:24 +0000 Subject: minor refactoring. Change getName and GetVersion methods (yes the had different casings) to Name and Version properties for the User stores. --- OpenSim/Data/MySQL/MySQLUserData.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index a01bf60..c374bf2 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -659,18 +659,18 @@ namespace OpenSim.Data.MySQL /// Database provider name /// /// Provider name - override public string getName() + override public string Name { - return "MySQL Userdata Interface"; + get {return "MySQL Userdata Interface";} } /// /// Database provider version /// /// provider version - override public string GetVersion() + override public string Version { - return "0.1"; + get {return "0.1";} } } } -- cgit v1.1 From 1b7f1c956c86458bc0cee341ea95ee593be76703 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 2 May 2008 18:59:12 +0000 Subject: plumb in connection string to the user database paths. mysql and mssql just ignore this for now, but it lets us get connect strings to sqlite and nhibernate. --- OpenSim/Data/MySQL/MySQLUserData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index c374bf2..b448715 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -55,10 +55,10 @@ namespace OpenSim.Data.MySQL /// /// Loads and initialises the MySQL storage plugin /// - override public void Initialise() + override public void Initialise(string connect) { - // Load from an INI file connection details - // TODO: move this to XML? Yes, PLEASE! + // TODO: actually do something with our connect string + // instead of loading the second config IniFile iniFile = new IniFile("mysql_connection.ini"); string settingHostname = iniFile.ParseFileReadValue("hostname"); -- cgit v1.1 From 7b446aba9174aac68c62ec40c2115a1e1f012191 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 4 May 2008 22:55:52 +0000 Subject: * Implemented DIE_AT_EDGE and Temporary objects don't save to the database. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index c3fe332..ac0d382 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -254,7 +254,9 @@ namespace OpenSim.Data.MySQL { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) == 0) + if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0) { m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); -- cgit v1.1 From 0ea48cf7860a83e30e4401b4bb1ff4b4eb3ae3a7 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 6 May 2008 22:41:38 +0000 Subject: De-tabify source. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index b529d4e..90664ff 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -333,7 +333,7 @@ namespace OpenSim.Data.MySQL item.Creator = new LLUUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; - item.SalePrice = (int) reader["salePrice"]; + item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; item.GroupID = new LLUUID(reader["groupID"].ToString()); -- cgit v1.1 From 4fa0cbdfbb9b8c1b60c8f23edb6301962afd8533 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 8 May 2008 05:35:01 +0000 Subject: * You can haz more spring cleaning. * Eventually this codebase will be clean. >_> --- OpenSim/Data/MySQL/MySQLManager.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index c62cfa7..1f95aad 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -253,13 +253,7 @@ namespace OpenSim.Data.MySQL lock (dbcon) { // Close the DB connection - try - { - dbcon.Close(); - } - catch - { - } + dbcon.Close(); // Try to reopen it try @@ -269,7 +263,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error("Unable to reconnect to database " + e.ToString()); + m_log.Error("Unable to reconnect to database " + e); } // Run the query again -- cgit v1.1 From c995d60d37032db3198b8496e186aa7a892dc7a8 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 14 May 2008 05:11:23 +0000 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 1f95aad..4455c3b 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -512,7 +512,7 @@ namespace OpenSim.Data.MySQL retval.FirstLifeImage = tmp; } - if(reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) + if (reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) { retval.WebLoginKey = LLUUID.Zero; } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index b448715..ab34f15 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -69,7 +69,7 @@ namespace OpenSim.Data.MySQL string settingPort = iniFile.ParseFileReadValue("port"); m_usersTableName = iniFile.ParseFileReadValue("userstablename"); - if( m_usersTableName == null ) + if (m_usersTableName == null) { m_usersTableName = "users"; } -- cgit v1.1 From 6a1b787436cc59043a26a296781e7a7b5ea0c67b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 14 May 2008 05:33:32 +0000 Subject: More formatting cleanup. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index efcf59e..7e6289b 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -174,10 +174,13 @@ namespace OpenSim.Data.MySQL { // TODO: This will let you pass in the connect string in // the config, though someone will need to write that. - if (connect == String.Empty) { + if (connect == String.Empty) + { // This is old seperate config file Initialise(); - } else { + } + else + { _dbConnection = new MySQLManager(connect); TestTables(); } -- cgit v1.1 From 4ff4475d02a26805749897bc62feddcc21b1c5da Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 15 May 2008 18:42:27 +0000 Subject: remove my UserAppearance object, switch all code to use AvatarAppearance instead. --- OpenSim/Data/MySQL/MySQLUserData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index ab34f15..622a618 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -630,12 +630,12 @@ namespace OpenSim.Data.MySQL /// Appearance /// TODO: stubs for now to get us to a compiling state gently - override public UserAppearance GetUserAppearance(LLUUID user) + override public AvatarAppearance GetUserAppearance(LLUUID user) { - return new UserAppearance(); + return new AvatarAppearance(); } - override public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) + override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { return; } -- cgit v1.1 From 4a9ee9f870b53abbc5ba8814c35d694c3fd186a1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 15 May 2008 20:25:42 +0000 Subject: testing avatar appearance as a user service --- OpenSim/Data/MySQL/MySQLUserData.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 622a618..a1e1094 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -630,15 +630,15 @@ namespace OpenSim.Data.MySQL /// Appearance /// TODO: stubs for now to get us to a compiling state gently - override public AvatarAppearance GetUserAppearance(LLUUID user) - { - return new AvatarAppearance(); - } - - override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) - { - return; - } + // override public AvatarAppearance GetUserAppearance(LLUUID user) + // { + // return new AvatarAppearance(); + // } + + // override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) + // { + // return; + // } override public void AddAttachment(LLUUID user, LLUUID item) { -- cgit v1.1 From 65c5efe43b68700bad94076d4cd421160203c5de Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 16 May 2008 01:22:11 +0000 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 10 +- OpenSim/Data/MySQL/MySQLDataStore.cs | 184 +++++++++++++------------- OpenSim/Data/MySQL/MySQLInventoryData.cs | 24 ++-- OpenSim/Data/MySQL/MySQLManager.cs | 16 +-- OpenSim/Data/MySQL/MySQLUserData.cs | 20 +-- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 10 +- 6 files changed, 132 insertions(+), 132 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 7e6289b..e556352 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -79,7 +79,7 @@ namespace OpenSim.Data.MySQL _dbConnection.Connection); MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); p.Value = assetID.GetBytes(); - + try { using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) @@ -111,7 +111,7 @@ namespace OpenSim.Data.MySQL } override public void CreateAsset(AssetBase asset) - { + { lock (_dbConnection) { MySqlCommand cmd = @@ -119,10 +119,10 @@ namespace OpenSim.Data.MySQL "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection); - + // need to ensure we dispose try - { + { using (cmd) { MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); @@ -145,7 +145,7 @@ namespace OpenSim.Data.MySQL "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); _dbConnection.Reconnect(); - } + } } } diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index ac0d382..3c39a5e 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -50,12 +50,12 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; - - + + /// /// We're only using this to version the table! /// - + private DataSet m_dataSet; private MySqlDataAdapter m_primDataAdapter; @@ -65,16 +65,16 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_terrainDataAdapter; private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; - + private DataTable m_primTable; private DataTable m_shapeTable; private DataTable m_itemsTable; private DataTable m_terrainTable; private DataTable m_landTable; private DataTable m_landAccessListTable; - + // Temporary attribute while this is experimental - private bool persistPrimInventories; + private bool persistPrimInventories; /*********************************************************************** * @@ -98,9 +98,9 @@ namespace OpenSim.Data.MySQL MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, m_connection); m_shapeDataAdapter = new MySqlDataAdapter(shapeSelectCmd); - + MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, m_connection); - m_itemsDataAdapter = new MySqlDataAdapter(itemsSelectCmd); + m_itemsDataAdapter = new MySqlDataAdapter(itemsSelectCmd); MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, m_connection); m_terrainDataAdapter = new MySqlDataAdapter(terrainSelectCmd); @@ -111,7 +111,7 @@ namespace OpenSim.Data.MySQL MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); - + TestTables(m_connection); lock (m_dataSet) @@ -125,13 +125,13 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_shapeTable); SetupShapeCommands(m_shapeDataAdapter, m_connection); m_shapeDataAdapter.Fill(m_shapeTable); - + if (persistPrimInventories) { m_itemsTable = createItemsTable(); m_dataSet.Tables.Add(m_itemsTable); SetupItemsCommands(m_itemsDataAdapter, m_connection); - m_itemsDataAdapter.Fill(m_itemsTable); + m_itemsDataAdapter.Fill(m_itemsTable); } m_terrainTable = createTerrainTable(); @@ -195,7 +195,7 @@ namespace OpenSim.Data.MySQL UpgradeLandTable(tableList["land"], dbconn); //database.Close(); - + } /// @@ -290,12 +290,12 @@ namespace OpenSim.Data.MySQL { shapeRow.Delete(); } - + if (persistPrimInventories) - { + { RemoveItems(uuid); } - + // Remove prim row row.Delete(); } @@ -309,18 +309,18 @@ namespace OpenSim.Data.MySQL /// private void RemoveItems(LLUUID uuid) { - String sql = String.Format("primID = '{0}'", uuid); + String sql = String.Format("primID = '{0}'", uuid); DataRow[] itemRows = m_itemsTable.Select(sql); - + foreach (DataRow itemRow in itemRows) { itemRow.Delete(); } } - + /// /// Load persisted objects from region storage. - /// + /// public List LoadObjects(LLUUID regionUUID) { Dictionary createdObjects = new Dictionary(); @@ -341,17 +341,17 @@ namespace OpenSim.Data.MySQL foreach (DataRow primRow in primsForRegion) { - try + try { string uuid = (string) primRow["UUID"]; string objID = (string) primRow["SceneGroupID"]; - + SceneObjectPart prim = buildPrim(primRow); - + if (uuid == objID) //is new SceneObjectGroup ? { SceneObjectGroup group = new SceneObjectGroup(); - + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); if (shapeRow != null) { @@ -384,11 +384,11 @@ namespace OpenSim.Data.MySQL } createdObjects[new LLUUID(objID)].AddPart(prim); } - + if (persistPrimInventories) { LoadItems(prim); - } + } } catch (Exception e) { @@ -403,7 +403,7 @@ namespace OpenSim.Data.MySQL } return retvals; } - + /// /// Load in a prim's persisted inventory. /// @@ -411,31 +411,31 @@ namespace OpenSim.Data.MySQL private void LoadItems(SceneObjectPart prim) { //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); - + DataTable dbItems = m_itemsTable; - - String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); + + String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); DataRow[] dbItemRows = dbItems.Select(sql); - + IList inventory = new List(); - + foreach (DataRow row in dbItemRows) { TaskInventoryItem item = buildItem(row); inventory.Add(item); - - //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); + + //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); } - + prim.RestoreInventoryItems(inventory); - - // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in + + // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in // every item). This data should really be stored in the prim table itself. if (dbItemRows.Length > 0) { prim.FolderID = inventory[0].ParentID; } - } + } public void StoreTerrain(double[,] ter, LLUUID regionID) { @@ -474,8 +474,8 @@ namespace OpenSim.Data.MySQL { m_connection.Open(); } - - lock (m_dataSet) + + lock (m_dataSet) { using (MySqlDataReader row = cmd.ExecuteReader()) { @@ -498,7 +498,7 @@ namespace OpenSim.Data.MySQL m_log.Info("[REGION DB]: No terrain found for region"); return null; } - + m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); } } @@ -558,7 +558,7 @@ namespace OpenSim.Data.MySQL fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID); landaccesslist.Rows.Add(newAccessRow); } - + Commit(); } } @@ -624,7 +624,7 @@ namespace OpenSim.Data.MySQL /*********************************************************************** * * Database Definition Functions - * + * * This should be db agnostic as we define them in ADO.NET terms * **********************************************************************/ @@ -803,7 +803,7 @@ namespace OpenSim.Data.MySQL return shapes; } - + private static DataTable createItemsTable() { DataTable items = new DataTable("primitems"); @@ -812,8 +812,8 @@ namespace OpenSim.Data.MySQL createCol(items, "primID", typeof (String)); createCol(items, "assetID", typeof (String)); createCol(items, "parentFolderID", typeof (String)); - - createCol(items, "invType", typeof (Int32)); + + createCol(items, "invType", typeof (Int32)); createCol(items, "assetType", typeof (Int32)); createCol(items, "name", typeof (String)); @@ -834,10 +834,10 @@ namespace OpenSim.Data.MySQL items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; return items; - } + } /*********************************************************************** - * + * * Convert between ADO.NET <=> OpenSim Objects * * These should be database independant @@ -932,8 +932,8 @@ namespace OpenSim.Data.MySQL } return prim; } - - + + /// /// Build a prim inventory item from the persisted data. /// @@ -942,15 +942,15 @@ namespace OpenSim.Data.MySQL private static TaskInventoryItem buildItem(DataRow row) { TaskInventoryItem taskItem = new TaskInventoryItem(); - - taskItem.ItemID = new LLUUID((String)row["itemID"]); + + taskItem.ItemID = new LLUUID((String)row["itemID"]); taskItem.ParentPartID = new LLUUID((String)row["primID"]); taskItem.AssetID = new LLUUID((String)row["assetID"]); taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); - + taskItem.InvType = Convert.ToInt32(row["invType"]); taskItem.Type = Convert.ToInt32(row["assetType"]); - + taskItem.Name = (String)row["name"]; taskItem.Description = (String)row["description"]; taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); @@ -958,15 +958,15 @@ namespace OpenSim.Data.MySQL taskItem.OwnerID = new LLUUID((String)row["ownerID"]); taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); taskItem.GroupID = new LLUUID((String)row["groupID"]); - + taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]); taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]); taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); - + return taskItem; - } + } private static LandData buildLandData(DataRow row) { @@ -1117,17 +1117,17 @@ namespace OpenSim.Data.MySQL } } } - + private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) { row["itemID"] = taskItem.ItemID; row["primID"] = taskItem.ParentPartID; row["assetID"] = taskItem.AssetID; row["parentFolderID"] = taskItem.ParentID; - + row["invType"] = taskItem.InvType; row["assetType"] = taskItem.Type; - + row["name"] = taskItem.Name; row["description"] = taskItem.Description; row["creationDate"] = taskItem.CreationDate; @@ -1140,7 +1140,7 @@ namespace OpenSim.Data.MySQL row["basePermissions"] = taskItem.BaseMask; row["everyonePermissions"] = taskItem.EveryoneMask; row["groupPermissions"] = taskItem.GroupMask; - } + } private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) { @@ -1322,39 +1322,39 @@ namespace OpenSim.Data.MySQL else { fillShapeRow(shapeRow, prim); - } + } } - + // see IRegionDatastore public void StorePrimInventory(LLUUID primID, ICollection items) { if (!persistPrimInventories) return; - + m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); - - // For now, we're just going to crudely remove all the previous inventory items + + // For now, we're just going to crudely remove all the previous inventory items // no matter whether they have changed or not, and replace them with the current set. lock (m_dataSet) - { - RemoveItems(primID); - + { + RemoveItems(primID); + // repalce with current inventory details foreach (TaskInventoryItem newItem in items) { // m_log.InfoFormat( // "[REGION DB]: " + -// "Adding item {0}, {1} to prim ID {2}", +// "Adding item {0}, {1} to prim ID {2}", // newItem.Name, newItem.ItemID, newItem.ParentPartID); - + DataRow newItemRow = m_itemsTable.NewRow(); fillItemRow(newItemRow, newItem); - m_itemsTable.Rows.Add(newItemRow); + m_itemsTable.Rows.Add(newItemRow); } } - + Commit(); - } + } /*********************************************************************** * @@ -1447,9 +1447,9 @@ namespace OpenSim.Data.MySQL } sql += subsql; sql += ")"; - + //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); - + return sql; } @@ -1466,7 +1466,7 @@ namespace OpenSim.Data.MySQL /// This is a convenience function that collapses 5 repetitive /// lines for defining MySqlParameters to 2 parameters: /// column name and database type. - /// + /// /// It assumes certain conventions like ?param as the param /// name to replace in parametrized queries, and that source /// version is always current version, both of which are fine @@ -1498,7 +1498,7 @@ namespace OpenSim.Data.MySQL delete.Connection = conn; da.DeleteCommand = delete; } - + private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("primitems", m_itemsTable); @@ -1511,7 +1511,7 @@ namespace OpenSim.Data.MySQL delete.Parameters.Add(createMySqlParameter("itemID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; - } + } private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) { @@ -1597,7 +1597,7 @@ namespace OpenSim.Data.MySQL { m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); } - + try { icmd.ExecuteNonQuery(); @@ -1605,7 +1605,7 @@ namespace OpenSim.Data.MySQL catch (MySqlException e) { m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); - } + } try { @@ -1643,7 +1643,7 @@ namespace OpenSim.Data.MySQL MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); MySqlDataAdapter sDa = new MySqlDataAdapter(shapeSelectCmd); MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, conn); - MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd); + MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd); MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, conn); MySqlDataAdapter tDa = new MySqlDataAdapter(terrainSelectCmd); MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, conn); @@ -1656,10 +1656,10 @@ namespace OpenSim.Data.MySQL { pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - + if (persistPrimInventories) iDa.Fill(tmpDS, "primitems"); - + tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); lalDa.Fill(tmpDS, "landaccesslist"); @@ -1672,10 +1672,10 @@ namespace OpenSim.Data.MySQL pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - + if (persistPrimInventories) iDa.Fill(tmpDS, "primitems"); - + tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); lalDa.Fill(tmpDS, "landaccesslist"); @@ -1688,7 +1688,7 @@ namespace OpenSim.Data.MySQL return false; } } - + foreach (DataColumn col in createShapeTable().Columns) { if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) @@ -1697,9 +1697,9 @@ namespace OpenSim.Data.MySQL return false; } } - + // XXX primitems should probably go here eventually - + foreach (DataColumn col in createTerrainTable().Columns) { if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) @@ -1708,7 +1708,7 @@ namespace OpenSim.Data.MySQL return false; } } - + foreach (DataColumn col in createLandTable().Columns) { if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) @@ -1717,7 +1717,7 @@ namespace OpenSim.Data.MySQL return false; } } - + foreach (DataColumn col in createLandAccessListTable().Columns) { if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) @@ -1726,7 +1726,7 @@ namespace OpenSim.Data.MySQL return false; } } - + return true; } @@ -1783,7 +1783,7 @@ namespace OpenSim.Data.MySQL else if (type == typeof (Int64)) { return "bigint"; - } + } else if (type == typeof (Double)) { return "float"; diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 90664ff..92b005d 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -40,7 +40,7 @@ namespace OpenSim.Data.MySQL /// public class MySQLInventoryData : IInventoryData { - private static readonly ILog m_log + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// @@ -249,7 +249,7 @@ namespace OpenSim.Data.MySQL // There should only ever be one root folder for a user. However, if there's more // than one we'll simply use the first one rather than failing. It would be even - // nicer to print some message to this effect, but this feels like it's too low a + // nicer to print some message to this effect, but this feels like it's too low a // to put such a message out, and it's too minor right now to spare the time to // suitably refactor. if (items.Count > 0) @@ -332,13 +332,13 @@ namespace OpenSim.Data.MySQL item.InvType = (int) reader["invType"]; item.Creator = new LLUUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; - item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; item.GroupID = new LLUUID(reader["groupID"].ToString()); item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); - item.Flags = (uint) reader["flags"]; + item.Flags = (uint) reader["flags"]; return item; } @@ -483,12 +483,12 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?groupID", item.GroupID); result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); result.Parameters.AddWithValue("?flags", item.Flags); - + lock (database) { result.ExecuteNonQuery(); } - + result.Dispose(); } catch (MySqlException e) @@ -507,7 +507,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// public void deleteInventoryItem(LLUUID itemID) @@ -517,7 +517,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); - + lock (database) { cmd.ExecuteNonQuery(); @@ -596,7 +596,7 @@ namespace OpenSim.Data.MySQL } /// - /// Append a list of all the child folders of a parent folder + /// Append a list of all the child folders of a parent folder /// /// list where folders will be appended /// ID of parent @@ -623,11 +623,11 @@ namespace OpenSim.Data.MySQL protected void deleteOneFolder(LLUUID folderID) { try - { + { MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - + lock (database) { cmd.ExecuteNonQuery(); @@ -647,7 +647,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - + lock (database) { cmd.ExecuteNonQuery(); diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 4455c3b..f7baadc 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -302,7 +302,7 @@ namespace OpenSim.Data.MySQL // Region Main gotta-have-or-we-return-null parts UInt64 tmp64; if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) - { + { return null; } else @@ -310,7 +310,7 @@ namespace OpenSim.Data.MySQL retval.regionHandle = tmp64; } LLUUID tmp_uuid; - if (!LLUUID.TryParse((string)reader["uuid"], out tmp_uuid)) + if (!LLUUID.TryParse((string)reader["uuid"], out tmp_uuid)) { return null; } @@ -321,7 +321,7 @@ namespace OpenSim.Data.MySQL // non-critical parts retval.regionName = (string)reader["regionName"]; - retval.originUUID = new LLUUID((string) reader["originUUID"]); + retval.originUUID = new LLUUID((string) reader["originUUID"]); // Secrets retval.regionRecvKey = (string) reader["regionRecvKey"]; @@ -360,8 +360,8 @@ namespace OpenSim.Data.MySQL // World Map Addition LLUUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); - LLUUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); - } + LLUUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); + } else { return null; @@ -418,7 +418,7 @@ namespace OpenSim.Data.MySQL LLUUID.TryParse((string) reader["sessionID"], out tmp); retval.SessionID = tmp; - + LLUUID.TryParse((string)reader["secureSessionID"], out tmp); retval.SecureSessionID = tmp; @@ -488,7 +488,7 @@ namespace OpenSim.Data.MySQL if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) retval.AboutText = ""; - else + else retval.AboutText = (string) reader["profileAboutText"]; if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) @@ -511,7 +511,7 @@ namespace OpenSim.Data.MySQL LLUUID.TryParse((string)reader["profileFirstImage"], out tmp); retval.FirstLifeImage = tmp; } - + if (reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) { retval.WebLoginKey = LLUUID.Zero; diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index a1e1094..0acf47b 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -59,7 +59,7 @@ namespace OpenSim.Data.MySQL { // TODO: actually do something with our connect string // instead of loading the second config - + IniFile iniFile = new IniFile("mysql_connection.ini"); string settingHostname = iniFile.ParseFileReadValue("hostname"); string settingDatabase = iniFile.ParseFileReadValue("database"); @@ -67,7 +67,7 @@ namespace OpenSim.Data.MySQL string settingPassword = iniFile.ParseFileReadValue("password"); string settingPooling = iniFile.ParseFileReadValue("pooling"); string settingPort = iniFile.ParseFileReadValue("port"); - + m_usersTableName = iniFile.ParseFileReadValue("userstablename"); if (m_usersTableName == null) { @@ -206,15 +206,15 @@ namespace OpenSim.Data.MySQL param["?friendID"] = friend.UUID.ToString(); param["?friendPerms"] = perms.ToString(); param["?datetimestamp"] = dtvalue.ToString(); - - try + + try { lock (database) { IDbCommand adder = database.Query( "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + "VALUES " + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", param); @@ -325,7 +325,7 @@ namespace OpenSim.Data.MySQL // This is not a real column in the database table, it's a joined column from the opposite record fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); - + Lfli.Add(fli); } reader.Close(); @@ -599,7 +599,7 @@ namespace OpenSim.Data.MySQL user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); } - + return true; } @@ -630,7 +630,7 @@ namespace OpenSim.Data.MySQL /// Appearance /// TODO: stubs for now to get us to a compiling state gently - // override public AvatarAppearance GetUserAppearance(LLUUID user) + // override public AvatarAppearance GetUserAppearance(LLUUID user) // { // return new AvatarAppearance(); // } @@ -644,12 +644,12 @@ namespace OpenSim.Data.MySQL { return; } - + override public void RemoveAttachment(LLUUID user, LLUUID item) { return; } - + override public List GetAttachments(LLUUID user) { return new List(); diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 16b2a4f..b3e08a3 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -28,7 +28,7 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. @@ -41,8 +41,8 @@ using System.Runtime.InteropServices; [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly : ComVisible(false)] @@ -54,11 +54,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -- cgit v1.1 From 0076ed40ffd971f361244ffc894f0c78b2ae6d79 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 16 May 2008 14:30:25 +0000 Subject: in theory, this moves the appearance mapper to live under the MySQLUserData. There is a lot of in theory here so testing would be appreciated. --- OpenSim/Data/MySQL/MySQLUserData.cs | 107 +++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 37 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 0acf47b..cab1608 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -33,6 +33,9 @@ using System.Text.RegularExpressions; using libsecondlife; using log4net; using OpenSim.Framework; +using OpenSim.Data.Base; +using OpenSim.Data.MapperFactory; +using OpenSim.Data.MySQLMapper; namespace OpenSim.Data.MySQL { @@ -51,44 +54,65 @@ namespace OpenSim.Data.MySQL private string m_agentsTableName; private string m_usersTableName; private string m_userFriendsTableName; + private string m_connectString; + private BaseDatabaseConnector m_databaseMapper; + private AppearanceTableMapper m_appearanceMapper; /// /// Loads and initialises the MySQL storage plugin /// override public void Initialise(string connect) { - // TODO: actually do something with our connect string - // instead of loading the second config - - IniFile iniFile = new IniFile("mysql_connection.ini"); - string settingHostname = iniFile.ParseFileReadValue("hostname"); - string settingDatabase = iniFile.ParseFileReadValue("database"); - string settingUsername = iniFile.ParseFileReadValue("username"); - string settingPassword = iniFile.ParseFileReadValue("password"); - string settingPooling = iniFile.ParseFileReadValue("pooling"); - string settingPort = iniFile.ParseFileReadValue("port"); - - m_usersTableName = iniFile.ParseFileReadValue("userstablename"); - if (m_usersTableName == null) - { - m_usersTableName = "users"; - } + if (connect == String.Empty) { + // TODO: actually do something with our connect string + // instead of loading the second config + + m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead"); + IniFile iniFile = new IniFile("mysql_connection.ini"); + string settingHostname = iniFile.ParseFileReadValue("hostname"); + string settingDatabase = iniFile.ParseFileReadValue("database"); + string settingUsername = iniFile.ParseFileReadValue("username"); + string settingPassword = iniFile.ParseFileReadValue("password"); + string settingPooling = iniFile.ParseFileReadValue("pooling"); + string settingPort = iniFile.ParseFileReadValue("port"); + + m_usersTableName = iniFile.ParseFileReadValue("userstablename"); + if (m_usersTableName == null) + { + m_usersTableName = "users"; + } - m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); - if (m_userFriendsTableName == null) - { - m_userFriendsTableName = "userfriends"; - } + m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); + if (m_userFriendsTableName == null) + { + m_userFriendsTableName = "userfriends"; + } + + m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); + if (m_agentsTableName == null) + { + m_agentsTableName = "agents"; + } - m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); - if (m_agentsTableName == null) - { + m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" + + settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; + + database = new MySQLManager(m_connectString); + } else { + m_connectString = connect; m_agentsTableName = "agents"; + m_usersTableName = "users"; + m_userFriendsTableName = "userfriends"; } - - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); + + string mapperTypeStr = "MySQL"; + DataMapperFactory.MAPPER_TYPE mapperType = + (DataMapperFactory.MAPPER_TYPE) + Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr); + + m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString); + + m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance"); TestTables(); } @@ -630,15 +654,24 @@ namespace OpenSim.Data.MySQL /// Appearance /// TODO: stubs for now to get us to a compiling state gently - // override public AvatarAppearance GetUserAppearance(LLUUID user) - // { - // return new AvatarAppearance(); - // } - - // override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) - // { - // return; - // } + // override + public AvatarAppearance GetUserAppearance(LLUUID user) + { + AvatarAppearance appearance = null; + if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) + { + appearance = new AvatarAppearance(); + appearance.Owner = user; + UpdateUserAppearance(user, appearance); + } + return appearance; + } + + // override + public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) + { + m_appearanceMapper.Update(user.UUID, appearance); + } override public void AddAttachment(LLUUID user, LLUUID item) { -- cgit v1.1 From 8a7ae313bedf316e42d88b4cc65e5ddf5a589d26 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 16 May 2008 18:43:53 +0000 Subject: it helps to actually create the database if the connect string is provided. My bad. --- OpenSim/Data/MySQL/MySQLUserData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index cab1608..a1c989b 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -103,6 +103,7 @@ namespace OpenSim.Data.MySQL m_agentsTableName = "agents"; m_usersTableName = "users"; m_userFriendsTableName = "userfriends"; + database = new MySQLManager(m_connectString); } string mapperTypeStr = "MySQL"; -- cgit v1.1 From a5f08b430d644c7a4274db9fff3db0c63a6a7857 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 17 May 2008 00:06:35 +0000 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLUserData.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index a1c989b..677d287 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -75,7 +75,7 @@ namespace OpenSim.Data.MySQL string settingPassword = iniFile.ParseFileReadValue("password"); string settingPooling = iniFile.ParseFileReadValue("pooling"); string settingPort = iniFile.ParseFileReadValue("port"); - + m_usersTableName = iniFile.ParseFileReadValue("userstablename"); if (m_usersTableName == null) { @@ -87,7 +87,7 @@ namespace OpenSim.Data.MySQL { m_userFriendsTableName = "userfriends"; } - + m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); if (m_agentsTableName == null) { @@ -96,7 +96,7 @@ namespace OpenSim.Data.MySQL m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" + settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; - + database = new MySQLManager(m_connectString); } else { m_connectString = connect; @@ -105,14 +105,14 @@ namespace OpenSim.Data.MySQL m_userFriendsTableName = "userfriends"; database = new MySQLManager(m_connectString); } - + string mapperTypeStr = "MySQL"; DataMapperFactory.MAPPER_TYPE mapperType = (DataMapperFactory.MAPPER_TYPE) Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr); - + m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString); - + m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance"); TestTables(); @@ -655,7 +655,7 @@ namespace OpenSim.Data.MySQL /// Appearance /// TODO: stubs for now to get us to a compiling state gently - // override + // override public AvatarAppearance GetUserAppearance(LLUUID user) { AvatarAppearance appearance = null; @@ -668,7 +668,7 @@ namespace OpenSim.Data.MySQL return appearance; } - // override + // override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { m_appearanceMapper.Update(user.UUID, appearance); -- cgit v1.1 From 9808f39b6f21c26ac0e8cf9c8a04cc8ab2bfa7e9 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 19 May 2008 19:08:59 +0000 Subject: i can haz pantz? You sure can. This change set restores pants (and the rest of the default appearance) in grid mode. The root issue had to do with serializing multi-faced textures to the grid server. This also restores the lookup path through the avatar factory module, as that seems the reasonable place to have it live. Some clean up patches are coming later as well, plus testing on standalone, but this should be in a good kicking around state for grid users. --- OpenSim/Data/MySQL/MySQLUserData.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 677d287..cd5ac39 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -661,9 +661,7 @@ namespace OpenSim.Data.MySQL AvatarAppearance appearance = null; if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) { - appearance = new AvatarAppearance(); - appearance.Owner = user; - UpdateUserAppearance(user, appearance); + appearance = null; } return appearance; } -- cgit v1.1 From d1c4fc94e7cdec807558dd692c249c90519d1af1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 19 May 2008 20:49:57 +0000 Subject: make the super class conveniance appearance stuff virtual so they can be overrided correctly by subclasses --- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index cd5ac39..f7d5659 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -656,7 +656,7 @@ namespace OpenSim.Data.MySQL /// Appearance /// TODO: stubs for now to get us to a compiling state gently // override - public AvatarAppearance GetUserAppearance(LLUUID user) + override public AvatarAppearance GetUserAppearance(LLUUID user) { AvatarAppearance appearance = null; if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) @@ -667,7 +667,7 @@ namespace OpenSim.Data.MySQL } // override - public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) + override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { m_appearanceMapper.Update(user.UUID, appearance); } -- cgit v1.1 From 419adadc465cd534e500397191e69027199c3268 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 19 May 2008 21:39:02 +0000 Subject: prep for changes need to create the appearance tables by default --- OpenSim/Data/MySQL/Resources/AvatarAppearance.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql index b638ee2..0deb099 100644 --- a/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql +++ b/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql @@ -2,9 +2,6 @@ -- Create schema avatar_appearance -- -CREATE DATABASE IF NOT EXISTS avatar_appearance; -USE avatar_appearance; - DROP TABLE IF EXISTS `avatarappearance`; CREATE TABLE `avatarappearance` ( `UUID` char(36) NOT NULL, @@ -38,5 +35,5 @@ CREATE TABLE `avatarappearance` ( PRIMARY KEY (`UUID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; -- cgit v1.1 From 6d2f6be82b82c96a7457c5b25ed0ca73e6039893 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 19 May 2008 21:47:31 +0000 Subject: autocreate appearance table if it isn't there --- OpenSim/Data/MySQL/MySQLUserData.cs | 18 ++++++++++ OpenSim/Data/MySQL/Resources/AvatarAppearance.sql | 39 ---------------------- .../MySQL/Resources/CreateAvatarAppearance.sql | 39 ++++++++++++++++++++++ 3 files changed, 57 insertions(+), 39 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/AvatarAppearance.sql create mode 100644 OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index f7d5659..56bdcbf 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -54,6 +54,7 @@ namespace OpenSim.Data.MySQL private string m_agentsTableName; private string m_usersTableName; private string m_userFriendsTableName; + private string m_appearanceTableName = "avatarappearance"; private string m_connectString; private BaseDatabaseConnector m_databaseMapper; private AppearanceTableMapper m_appearanceMapper; @@ -130,11 +131,13 @@ namespace OpenSim.Data.MySQL tableList[m_agentsTableName] = null; tableList[m_usersTableName] = null; tableList[m_userFriendsTableName] = null; + tableList[m_appearanceTableName] = null; database.GetTableVersion(tableList); UpgradeAgentsTable(tableList[m_agentsTableName]); UpgradeUsersTable(tableList[m_usersTableName]); UpgradeFriendsTable(tableList[m_userFriendsTableName]); + UpgradeAppearanceTable(tableList[m_appearanceTableName]); } /// @@ -188,6 +191,21 @@ namespace OpenSim.Data.MySQL } } + /// + /// Create or upgrade the table if necessary + /// + /// A null indicates that the table does not + /// currently exist + private void UpgradeAppearanceTable(string oldVersion) + { + // null as the version, indicates that the table didn't exist + if (oldVersion == null) + { + database.ExecuteResourceSql("CreateAvatarAppearance.sql"); + return; + } + } + #endregion // see IUserData diff --git a/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql deleted file mode 100644 index 0deb099..0000000 --- a/OpenSim/Data/MySQL/Resources/AvatarAppearance.sql +++ /dev/null @@ -1,39 +0,0 @@ --- --- Create schema avatar_appearance --- - -DROP TABLE IF EXISTS `avatarappearance`; -CREATE TABLE `avatarappearance` ( - `UUID` char(36) NOT NULL, - `Serial` int(10) unsigned NOT NULL, - `WearableItem0` char(36) NOT NULL, - `WearableAsset0` char(36) NOT NULL, - `WearableItem1` char(36) NOT NULL, - `WearableAsset1` char(36) NOT NULL, - `WearableItem2` char(36) NOT NULL, - `WearableAsset2` char(36) NOT NULL, - `WearableItem3` char(36) NOT NULL, - `WearableAsset3` char(36) NOT NULL, - `WearableItem4` char(36) NOT NULL, - `WearableAsset4` char(36) NOT NULL, - `WearableItem5` char(36) NOT NULL, - `WearableAsset5` char(36) NOT NULL, - `WearableItem6` char(36) NOT NULL, - `WearableAsset6` char(36) NOT NULL, - `WearableItem7` char(36) NOT NULL, - `WearableAsset7` char(36) NOT NULL, - `WearableItem8` char(36) NOT NULL, - `WearableAsset8` char(36) NOT NULL, - `WearableItem9` char(36) NOT NULL, - `WearableAsset9` char(36) NOT NULL, - `WearableItem10` char(36) NOT NULL, - `WearableAsset10` char(36) NOT NULL, - `WearableItem11` char(36) NOT NULL, - `WearableAsset11` char(36) NOT NULL, - `WearableItem12` char(36) NOT NULL, - `WearableAsset12` char(36) NOT NULL, - - - PRIMARY KEY (`UUID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; - diff --git a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql new file mode 100644 index 0000000..0deb099 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql @@ -0,0 +1,39 @@ +-- +-- Create schema avatar_appearance +-- + +DROP TABLE IF EXISTS `avatarappearance`; +CREATE TABLE `avatarappearance` ( + `UUID` char(36) NOT NULL, + `Serial` int(10) unsigned NOT NULL, + `WearableItem0` char(36) NOT NULL, + `WearableAsset0` char(36) NOT NULL, + `WearableItem1` char(36) NOT NULL, + `WearableAsset1` char(36) NOT NULL, + `WearableItem2` char(36) NOT NULL, + `WearableAsset2` char(36) NOT NULL, + `WearableItem3` char(36) NOT NULL, + `WearableAsset3` char(36) NOT NULL, + `WearableItem4` char(36) NOT NULL, + `WearableAsset4` char(36) NOT NULL, + `WearableItem5` char(36) NOT NULL, + `WearableAsset5` char(36) NOT NULL, + `WearableItem6` char(36) NOT NULL, + `WearableAsset6` char(36) NOT NULL, + `WearableItem7` char(36) NOT NULL, + `WearableAsset7` char(36) NOT NULL, + `WearableItem8` char(36) NOT NULL, + `WearableAsset8` char(36) NOT NULL, + `WearableItem9` char(36) NOT NULL, + `WearableAsset9` char(36) NOT NULL, + `WearableItem10` char(36) NOT NULL, + `WearableAsset10` char(36) NOT NULL, + `WearableItem11` char(36) NOT NULL, + `WearableAsset11` char(36) NOT NULL, + `WearableItem12` char(36) NOT NULL, + `WearableAsset12` char(36) NOT NULL, + + + PRIMARY KEY (`UUID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; + -- cgit v1.1 From 0e39250506f3dd3f2f66dfc87a808ea8eb5867ba Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 21 May 2008 14:34:52 +0000 Subject: create some direct sql calls for appearance --- OpenSim/Data/MySQL/MySQLManager.cs | 109 +++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index f7baadc..7e1b405 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -530,6 +530,44 @@ namespace OpenSim.Data.MySQL return retval; } + public AvatarAppearance readAppearanceRow(IDataReader reader) + { + AvatarAppearance appearance = new AvatarAppearance(); + appearance.Owner = new LLUUID((string)reader["owner"]); + appearance.Serial = Convert.ToInt32(reader["serial"]); + appearance.VisualParams = (byte[])reader["visual_params"]; + appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); + appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); + appearance.BodyItem = new LLUUID((string)reader["body_item"]); + appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); + appearance.SkinItem = new LLUUID((string)reader["skin_item"]); + appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); + appearance.HairItem = new LLUUID((string)reader["hair_item"]); + appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); + appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); + appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); + appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); + appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); + appearance.PantsItem = new LLUUID((string)reader["pants_item"]); + appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); + appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); + appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); + appearance.SocksItem = new LLUUID((string)reader["socks_item"]); + appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); + appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); + appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); + appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); + appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); + appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); + appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); + appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); + appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); + appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); + appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]); + return appearance; + } + + /// /// Inserts a new row into the log database /// @@ -946,5 +984,76 @@ namespace OpenSim.Data.MySQL return returnval; } + + public bool insertAppearanceRow(AvatarAppearance appearance) + { + string sql = String.Empty; + sql += "REPLACE INTO "; + sql += "avatarappearance (owner, serial, visual_params, texture, avatar_height, "; + sql += "body_item, body_asset, skin_item, skin_asset, hair_item, hair_asset, eyes_item, eyes_asset, "; + sql += "shirt_item, shirt_asset, pants_item, pants_asset, shoes_item, shoes_asset, socks_item, socks_asset, "; + sql += "jacket_item, jacket_asset, gloves_item, gloves_asset, undershirt_item, undershirt_asset, underpants_item, underpants_asset, "; + sql += "skirt_item, skirt_asset) values ("; + sql += "?owner, ?serial, ?visual_params, ?texture, ?avatar_height, "; + sql += "?body_item, ?body_asset, ?skin_item, ?skin_asset, ?hair_item, ?hair_asset, ?eyes_item, ?eyes_asset, "; + sql += "?shirt_item, ?shirt_asset, ?pants_item, ?pants_asset, ?shoes_item, ?shoes_asset, ?socks_item, ?socks_asset, "; + sql += "?jacket_item, ?jacket_asset, ?gloves_item, ?gloves_asset, ?undershirt_item, ?undershirt_asset, ?underpants_item, ?underpants_asset, "; + sql += "?skirt_item, ?skirt_asset)"; + + bool returnval = false; + + // we want to send in byte data, which means we can't just pass down strings + try { + MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); + cmd.Parameters.AddWithValue("?serial", appearance.Serial.ToString()); + cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); + cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes()); + cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight.ToString()); + cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); + cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); + cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); + cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); + cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); + cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); + cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); + cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); + cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); + cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); + cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); + cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); + cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); + cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); + cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); + cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); + cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); + cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); + cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); + cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); + cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); + cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); + cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); + cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); + cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); + cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); + + int x; + if ((x = cmd.ExecuteNonQuery()) > 0) + { + returnval = true; + } + cmd.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + return returnval; + + } + } } -- cgit v1.1 From 53bcf2139e7c8c9da2fbbcafc45704eae3bc5daa Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 21 May 2008 18:02:09 +0000 Subject: this removes use of the mapper for wearables, and I can confirm things get saved to the database. There are still issues on wearing things after a cleared cache that I'm looking at now. --- OpenSim/Data/MySQL/MySQLManager.cs | 86 ++++++++++++---------- OpenSim/Data/MySQL/MySQLUserData.cs | 48 +++++++----- .../MySQL/Resources/CreateAvatarAppearance.sql | 63 ++++++++-------- 3 files changed, 109 insertions(+), 88 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 7e1b405..4b11739 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -191,6 +191,12 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + public void ExecuteSql(string sql) + { + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); + } + /// /// Given a list of tables, return the version of the tables, as seen in the database /// @@ -532,38 +538,42 @@ namespace OpenSim.Data.MySQL public AvatarAppearance readAppearanceRow(IDataReader reader) { - AvatarAppearance appearance = new AvatarAppearance(); - appearance.Owner = new LLUUID((string)reader["owner"]); - appearance.Serial = Convert.ToInt32(reader["serial"]); - appearance.VisualParams = (byte[])reader["visual_params"]; - appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); - appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); - appearance.BodyItem = new LLUUID((string)reader["body_item"]); - appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); - appearance.SkinItem = new LLUUID((string)reader["skin_item"]); - appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); - appearance.HairItem = new LLUUID((string)reader["hair_item"]); - appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); - appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); - appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); - appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); - appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); - appearance.PantsItem = new LLUUID((string)reader["pants_item"]); - appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); - appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); - appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); - appearance.SocksItem = new LLUUID((string)reader["socks_item"]); - appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); - appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); - appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); - appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); - appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); - appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); - appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); - appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); - appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); - appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); - appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]); + AvatarAppearance appearance = null; + if (reader.Read()) + { + appearance = new AvatarAppearance(); + appearance.Owner = new LLUUID((string)reader["owner"]); + appearance.Serial = Convert.ToInt32(reader["serial"]); + appearance.VisualParams = (byte[])reader["visual_params"]; + appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); + appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); + appearance.BodyItem = new LLUUID((string)reader["body_item"]); + appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); + appearance.SkinItem = new LLUUID((string)reader["skin_item"]); + appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); + appearance.HairItem = new LLUUID((string)reader["hair_item"]); + appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); + appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); + appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); + appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); + appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); + appearance.PantsItem = new LLUUID((string)reader["pants_item"]); + appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); + appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); + appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); + appearance.SocksItem = new LLUUID((string)reader["socks_item"]); + appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); + appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); + appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); + appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); + appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); + appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); + appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); + appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); + appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); + appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); + appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]); + } return appearance; } @@ -1007,10 +1017,10 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); cmd.CommandText = sql; cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); - cmd.Parameters.AddWithValue("?serial", appearance.Serial.ToString()); + cmd.Parameters.AddWithValue("?serial", appearance.Serial); cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes()); - cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight.ToString()); + cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); @@ -1037,12 +1047,10 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); - - int x; - if ((x = cmd.ExecuteNonQuery()) > 0) - { + + if (cmd.ExecuteNonQuery() > 0) returnval = true; - } + cmd.Dispose(); } catch (Exception e) diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 56bdcbf..35bcb1d 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -34,8 +34,6 @@ using libsecondlife; using log4net; using OpenSim.Framework; using OpenSim.Data.Base; -using OpenSim.Data.MapperFactory; -using OpenSim.Data.MySQLMapper; namespace OpenSim.Data.MySQL { @@ -56,8 +54,6 @@ namespace OpenSim.Data.MySQL private string m_userFriendsTableName; private string m_appearanceTableName = "avatarappearance"; private string m_connectString; - private BaseDatabaseConnector m_databaseMapper; - private AppearanceTableMapper m_appearanceMapper; /// /// Loads and initialises the MySQL storage plugin @@ -107,15 +103,6 @@ namespace OpenSim.Data.MySQL database = new MySQLManager(m_connectString); } - string mapperTypeStr = "MySQL"; - DataMapperFactory.MAPPER_TYPE mapperType = - (DataMapperFactory.MAPPER_TYPE) - Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr); - - m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString); - - m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance"); - TestTables(); } @@ -203,6 +190,12 @@ namespace OpenSim.Data.MySQL { database.ExecuteResourceSql("CreateAvatarAppearance.sql"); return; + } + else if (oldVersion.Contains("Rev.1")) + { + database.ExecuteSql("drop table avatarappearance"); + database.ExecuteResourceSql("CreateAvatarAppearance.sql"); + return; } } @@ -676,18 +669,35 @@ namespace OpenSim.Data.MySQL // override override public AvatarAppearance GetUserAppearance(LLUUID user) { - AvatarAppearance appearance = null; - if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) + try { + lock (database) + { + Dictionary param = new Dictionary(); + param["?owner"] = user.ToString(); + + IDbCommand result = database.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); + IDataReader reader = result.ExecuteReader(); + + AvatarAppearance appearance = database.readAppearanceRow(reader); + + reader.Close(); + result.Dispose(); + + return appearance; + } + } + catch (Exception e) { - appearance = null; + database.Reconnect(); + m_log.Error(e.ToString()); + return null; } - return appearance; } - // override override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { - m_appearanceMapper.Update(user.UUID, appearance); + appearance.Owner = user; + database.insertAppearanceRow(appearance); } override public void AddAttachment(LLUUID user, LLUUID item) diff --git a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql index 0deb099..475c933 100644 --- a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql +++ b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql @@ -4,36 +4,39 @@ DROP TABLE IF EXISTS `avatarappearance`; CREATE TABLE `avatarappearance` ( - `UUID` char(36) NOT NULL, - `Serial` int(10) unsigned NOT NULL, - `WearableItem0` char(36) NOT NULL, - `WearableAsset0` char(36) NOT NULL, - `WearableItem1` char(36) NOT NULL, - `WearableAsset1` char(36) NOT NULL, - `WearableItem2` char(36) NOT NULL, - `WearableAsset2` char(36) NOT NULL, - `WearableItem3` char(36) NOT NULL, - `WearableAsset3` char(36) NOT NULL, - `WearableItem4` char(36) NOT NULL, - `WearableAsset4` char(36) NOT NULL, - `WearableItem5` char(36) NOT NULL, - `WearableAsset5` char(36) NOT NULL, - `WearableItem6` char(36) NOT NULL, - `WearableAsset6` char(36) NOT NULL, - `WearableItem7` char(36) NOT NULL, - `WearableAsset7` char(36) NOT NULL, - `WearableItem8` char(36) NOT NULL, - `WearableAsset8` char(36) NOT NULL, - `WearableItem9` char(36) NOT NULL, - `WearableAsset9` char(36) NOT NULL, - `WearableItem10` char(36) NOT NULL, - `WearableAsset10` char(36) NOT NULL, - `WearableItem11` char(36) NOT NULL, - `WearableAsset11` char(36) NOT NULL, - `WearableItem12` char(36) NOT NULL, - `WearableAsset12` char(36) NOT NULL, + Owner char(36) NOT NULL, + Serial int(10) unsigned NOT NULL, + Visual_Params blob NOT NULL, + Texture blob NOT NULL, + Avatar_Height float NOT NULL, + Body_Item char(36) NOT NULL, + Body_Asset char(36) NOT NULL, + Skin_Item char(36) NOT NULL, + Skin_Asset char(36) NOT NULL, + Hair_Item char(36) NOT NULL, + Hair_Asset char(36) NOT NULL, + Eyes_Item char(36) NOT NULL, + Eyes_Asset char(36) NOT NULL, + Shirt_Item char(36) NOT NULL, + Shirt_Asset char(36) NOT NULL, + Pants_Item char(36) NOT NULL, + Pants_Asset char(36) NOT NULL, + Shoes_Item char(36) NOT NULL, + Shoes_Asset char(36) NOT NULL, + Socks_Item char(36) NOT NULL, + Socks_Asset char(36) NOT NULL, + Jacket_Item char(36) NOT NULL, + Jacket_Asset char(36) NOT NULL, + Gloves_Item char(36) NOT NULL, + Gloves_Asset char(36) NOT NULL, + Undershirt_Item char(36) NOT NULL, + Undershirt_Asset char(36) NOT NULL, + Underpants_Item char(36) NOT NULL, + Underpants_Asset char(36) NOT NULL, + Skirt_Item char(36) NOT NULL, + Skirt_Asset char(36) NOT NULL, - PRIMARY KEY (`UUID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; + PRIMARY KEY (`Owner`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2'; -- cgit v1.1 From 1ebc6bfd0a949980b0c4a61ac0f9b851633fc4f3 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 22 May 2008 18:31:47 +0000 Subject: add a lock on the update, this should have been there before. still not convinced this will help, but it was wrong. --- OpenSim/Data/MySQL/MySQLUserData.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 35bcb1d..745583f 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -696,8 +696,19 @@ namespace OpenSim.Data.MySQL // override override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { - appearance.Owner = user; - database.insertAppearanceRow(appearance); + try + { + lock (database) + { + appearance.Owner = user; + database.insertAppearanceRow(appearance); + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + } } override public void AddAttachment(LLUUID user, LLUUID item) -- cgit v1.1 From 5d77625e9ac4ce1fc7b8fd67aabf563678ef0d5d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 25 May 2008 23:27:38 +0000 Subject: Update svn properties. Formatting cleanup. --- OpenSim/Data/MySQL/MySQLUserData.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 745583f..bcfd7c3 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -95,7 +95,9 @@ namespace OpenSim.Data.MySQL settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; database = new MySQLManager(m_connectString); - } else { + } + else + { m_connectString = connect; m_agentsTableName = "agents"; m_usersTableName = "users"; @@ -190,7 +192,7 @@ namespace OpenSim.Data.MySQL { database.ExecuteResourceSql("CreateAvatarAppearance.sql"); return; - } + } else if (oldVersion.Contains("Rev.1")) { database.ExecuteSql("drop table avatarappearance"); @@ -674,15 +676,15 @@ namespace OpenSim.Data.MySQL { Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); - + IDbCommand result = database.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); IDataReader reader = result.ExecuteReader(); - + AvatarAppearance appearance = database.readAppearanceRow(reader); - + reader.Close(); result.Dispose(); - + return appearance; } } -- cgit v1.1 From 77281ed85cabb7e278d179ea7ab5ca12b9a0b984 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 26 May 2008 21:53:32 +0000 Subject: * Potential fix for Mantis#167, 332 - MySQL Thread collision. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 137 +++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 61 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 3c39a5e..1cd76a8 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -410,30 +410,33 @@ namespace OpenSim.Data.MySQL /// private void LoadItems(SceneObjectPart prim) { - //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); + lock (m_dataSet) + { + //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); - DataTable dbItems = m_itemsTable; + DataTable dbItems = m_itemsTable; - String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); - DataRow[] dbItemRows = dbItems.Select(sql); + String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); + DataRow[] dbItemRows = dbItems.Select(sql); - IList inventory = new List(); + IList inventory = new List(); - foreach (DataRow row in dbItemRows) - { - TaskInventoryItem item = buildItem(row); - inventory.Add(item); + foreach (DataRow row in dbItemRows) + { + TaskInventoryItem item = buildItem(row); + inventory.Add(item); - //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); - } + //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); + } - prim.RestoreInventoryItems(inventory); + prim.RestoreInventoryItems(inventory); - // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in - // every item). This data should really be stored in the prim table itself. - if (dbItemRows.Length > 0) - { - prim.FolderID = inventory[0].ParentID; + // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in + // every item). This data should really be stored in the prim table itself. + if (dbItemRows.Length > 0) + { + prim.FolderID = inventory[0].ParentID; + } } } @@ -442,9 +445,10 @@ namespace OpenSim.Data.MySQL int revision = Util.UnixTimeSinceEpoch(); m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); - DataTable terrain = m_dataSet.Tables["terrain"]; lock (m_dataSet) { + DataTable terrain = m_dataSet.Tables["terrain"]; + MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); using (cmd) @@ -921,13 +925,16 @@ namespace OpenSim.Data.MySQL { // Database table was created before we got here and needs to be created! :P - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", - m_connection)) + lock (m_dataSet) { - cmd.ExecuteNonQuery(); + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } } } return prim; @@ -1230,14 +1237,16 @@ namespace OpenSim.Data.MySQL catch (InvalidCastException) { // Database table was created before we got here and needs to be created! :P - - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", - m_connection)) + lock (m_dataSet) { - cmd.ExecuteNonQuery(); + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } } } @@ -1283,45 +1292,51 @@ namespace OpenSim.Data.MySQL } catch (MySqlException) { - // Database table was created before we got here and needs to be created! :P - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", - m_connection)) + lock (m_dataSet) { - cmd.ExecuteNonQuery(); + // Database table was created before we got here and needs to be created! :P + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } } } } private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) { - DataTable prims = m_dataSet.Tables["prims"]; - DataTable shapes = m_dataSet.Tables["primshapes"]; - - DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (primRow == null) - { - primRow = prims.NewRow(); - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - prims.Rows.Add(primRow); - } - else + lock (m_dataSet) { - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - } + DataTable prims = m_dataSet.Tables["prims"]; + DataTable shapes = m_dataSet.Tables["primshapes"]; - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow == null) - { - shapeRow = shapes.NewRow(); - fillShapeRow(shapeRow, prim); - shapes.Rows.Add(shapeRow); - } - else - { - fillShapeRow(shapeRow, prim); + DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (primRow == null) + { + primRow = prims.NewRow(); + fillPrimRow(primRow, prim, sceneGroupID, regionUUID); + prims.Rows.Add(primRow); + } + else + { + fillPrimRow(primRow, prim, sceneGroupID, regionUUID); + } + + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow == null) + { + shapeRow = shapes.NewRow(); + fillShapeRow(shapeRow, prim); + shapes.Rows.Add(shapeRow); + } + else + { + fillShapeRow(shapeRow, prim); + } } } -- cgit v1.1 From a28a6e9aaa8d0563fa98e13a9ec586ccfa236fcb Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 28 May 2008 14:57:24 +0000 Subject: remove an erroneous line to fetch the terrain table in a way that isn't actually used. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 1cd76a8..7ee625d 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -447,8 +447,6 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { - DataTable terrain = m_dataSet.Tables["terrain"]; - MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); using (cmd) -- cgit v1.1 From 7ddf183da4854a4c9f56906b0cdc64badf97660f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 28 May 2008 15:02:04 +0000 Subject: remove terrain bloat, only keep last terrain revision for mysql. For active terraformers this should return a lot of database space. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 7ee625d..9a44fbd 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -442,15 +442,19 @@ namespace OpenSim.Data.MySQL public void StoreTerrain(double[,] ter, LLUUID regionID) { - int revision = Util.UnixTimeSinceEpoch(); + int revision = 1; m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); lock (m_dataSet) { + MySqlCommand delete = new MySqlCommand("delete from terrain where RegionUUID=?RegionUUID", m_connection); MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); using (cmd) { + delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + delete.ExecuteNonQuery(); + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); -- cgit v1.1 From 89c164fbc18e082bf2d036bd2167b824e90aebc1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 28 May 2008 17:59:46 +0000 Subject: let Grid Servers specify a connect string in their configuration. --- OpenSim/Data/MySQL/MySQLGridData.cs | 29 +++++++++++++++++------------ OpenSim/Data/MySQL/MySQLLogData.cs | 34 ++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 24 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index e830133..421c283 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -51,19 +51,24 @@ namespace OpenSim.Data.MySQL /// /// Initialises the Grid Interface /// - override public void Initialise() + override public void Initialise(string connect) { - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); - string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); - string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); + if (connect != String.Empty) { + database = new MySQLManager(connect); + } else { + m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); + string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); + string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); + string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + } TestTables(); } diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index bb34d34..0873066 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -24,6 +24,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Reflection; +using log4net; namespace OpenSim.Data.MySQL { @@ -31,7 +34,8 @@ namespace OpenSim.Data.MySQL /// An interface to the log database for MySQL /// internal class MySQLLogData : ILogData - { + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The database manager /// @@ -40,19 +44,25 @@ namespace OpenSim.Data.MySQL /// /// Artificial constructor called when the plugin is loaded /// - public void Initialise() + public void Initialise(string connect) { - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); - string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); - string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + if (connect != String.Empty) { + database = new MySQLManager(connect); + } else { + m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); + string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); + string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); + string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + } } /// -- cgit v1.1 From 11d83cb737ebb12a3e6ae6c63551a0d010b90211 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 28 May 2008 18:12:32 +0000 Subject: actually user the database_connect string for mysql. This means you can run all the OpenSim grid services without needing a mysql_connection.ini --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 39 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 92b005d..74afe4f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -48,28 +48,27 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; - /// - /// Loads and initialises this database plugin - /// public void Initialise(string connect) { - // TODO: actually use the provided connect string - Initialise(); - } - - public void Initialise() - { - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); - string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); - string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); + if(connect != String.Empty) + { + database = new MySQLManager(connect); + } + else + { + m_log.Warn("Reverting to deprecated mysql_connection.ini file for connection info"); + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); + string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); + string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); + string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); + } TestTables(database.Connection); } -- cgit v1.1 From 04625109560fb54d613b1fc9c81a8a9f387720c9 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 30 May 2008 08:35:57 +0000 Subject: Update svn properties. Formatting cleanup. --- OpenSim/Data/MySQL/MySQLGridData.cs | 12 +++++++----- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLLogData.cs | 14 ++++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 421c283..86ceffc 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -53,9 +53,12 @@ namespace OpenSim.Data.MySQL /// override public void Initialise(string connect) { - if (connect != String.Empty) { + if (connect != String.Empty) + { database = new MySQLManager(connect); - } else { + } + else + { m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); @@ -65,9 +68,8 @@ namespace OpenSim.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); + database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, + settingPooling, settingPort); } TestTables(); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 74afe4f..8e160b7 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -50,7 +50,7 @@ namespace OpenSim.Data.MySQL public void Initialise(string connect) { - if(connect != String.Empty) + if (connect != String.Empty) { database = new MySQLManager(connect); } diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 0873066..2bd246a 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -34,7 +34,7 @@ namespace OpenSim.Data.MySQL /// An interface to the log database for MySQL /// internal class MySQLLogData : ILogData - { + { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The database manager @@ -46,9 +46,12 @@ namespace OpenSim.Data.MySQL /// public void Initialise(string connect) { - if (connect != String.Empty) { + if (connect != String.Empty) + { database = new MySQLManager(connect); - } else { + } + else + { m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); @@ -59,9 +62,8 @@ namespace OpenSim.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); + database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, + settingPooling, settingPort); } } -- cgit v1.1 From febe78d06249cd4d36a86e97610dd45ab518a757 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 31 May 2008 12:18:29 +0000 Subject: * Implements UserServer logoff in a few situations * User tries to log-in but is already logged in. Userserver will send message to simulator user was in to log the user out there. * From the UserServer, admin types 'logoff-user firstname lastname message'. * Some regions may not get the message because they're not updated yet. --- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index bcfd7c3..f717609 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -382,9 +382,9 @@ namespace OpenSim.Data.MySQL #endregion - override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid) + override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) { - m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called"); + //m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called"); } override public List GeneratePickerResults(LLUUID queryID, string query) -- cgit v1.1 From d703e2004fb39ede3cb166db02fb8ccd790b5835 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 31 May 2008 21:44:57 +0000 Subject: * Change MySQL to check whether an asset already exists before inserting it into the database --- OpenSim/Data/MySQL/MySQLAssetData.cs | 41 +++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index e556352..76f6307 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -114,6 +114,12 @@ namespace OpenSim.Data.MySQL { lock (_dbConnection) { + m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); + if (ExistsAsset(asset.FullID)) + { + m_log.Info("[ASSET DB]: Asset exists already, ignoring."); + } + MySqlCommand cmd = new MySqlCommand( "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + @@ -156,7 +162,40 @@ namespace OpenSim.Data.MySQL override public bool ExistsAsset(LLUUID uuid) { - throw new Exception("The method or operation is not implemented."); + bool assetExists = false; + + lock (_dbConnection) + { + MySqlCommand cmd = + new MySqlCommand( + "SELECT id FROM assets WHERE id=?id", + _dbConnection.Connection); + MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); + p.Value = uuid.GetBytes(); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + assetExists = true; + } + + dbReader.Close(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", uuid); + _dbConnection.Reconnect(); + } + } + + return assetExists; } /// -- cgit v1.1 From 775221137631648903509620588e7d775390ab67 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 31 May 2008 21:53:17 +0000 Subject: * Remove the mysql logging noise I accidentally left in a few commits ago --- OpenSim/Data/MySQL/MySQLAssetData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 76f6307..abe3ff3 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -114,10 +114,10 @@ namespace OpenSim.Data.MySQL { lock (_dbConnection) { - m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); + //m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); if (ExistsAsset(asset.FullID)) { - m_log.Info("[ASSET DB]: Asset exists already, ignoring."); + //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); } MySqlCommand cmd = -- cgit v1.1 From 0c21f90ba72f00ebea3ac598d000e8f6603e3718 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 31 May 2008 21:54:13 +0000 Subject: * Duh, actually returning from the CreateAsset method once we know the asset exists would be better than carrying on --- OpenSim/Data/MySQL/MySQLAssetData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index abe3ff3..7ebc806 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -118,6 +118,7 @@ namespace OpenSim.Data.MySQL if (ExistsAsset(asset.FullID)) { //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); + return; } MySqlCommand cmd = -- cgit v1.1 From 4453c8bc5c68affa7ebafcdeab47340203186017 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 2 Jun 2008 17:23:13 +0000 Subject: * experimental: Make OpenSim archiver save and reload all prim textures when not all faces have the same texture --- OpenSim/Data/MySQL/MySQLDataStore.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 9a44fbd..9b7771c 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1288,6 +1288,7 @@ namespace OpenSim.Data.MySQL row["ProfileHollow"] = s.ProfileHollow; row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; + try { row["State"] = s.State; -- cgit v1.1 From 4ec4e16c809cf86a63b736d2b7b6ad7291595a5f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 4 Jun 2008 09:59:27 +0000 Subject: Formatting cleanup, minor refactoring, svn properties. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 7ebc806..a2215ef 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -120,7 +120,7 @@ namespace OpenSim.Data.MySQL //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); return; } - + MySqlCommand cmd = new MySqlCommand( "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + @@ -164,7 +164,7 @@ namespace OpenSim.Data.MySQL override public bool ExistsAsset(LLUUID uuid) { bool assetExists = false; - + lock (_dbConnection) { MySqlCommand cmd = @@ -182,7 +182,7 @@ namespace OpenSim.Data.MySQL { assetExists = true; } - + dbReader.Close(); cmd.Dispose(); } @@ -195,8 +195,8 @@ namespace OpenSim.Data.MySQL _dbConnection.Reconnect(); } } - - return assetExists; + + return assetExists; } /// -- cgit v1.1 From 53cc63e243b33b45779b6c891e0ea40430b187df Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 10 Jun 2008 16:02:18 +0000 Subject: Mantis#1501. Thank you kindly, Nebadon, for a patch that addresses the 'terrain fill 0' error. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 9b7771c..a38a8b2 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1046,7 +1046,13 @@ namespace OpenSim.Data.MySQL // TODO: COMPATIBILITY - Add byte-order conversions for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) - bw.Write(val[x, y]); + { + double height = val[x, y]; + if (height == 0.0) + height = double.Epsilon; + + bw.Write(height); + } return str.ToArray(); } -- cgit v1.1 From 4387744a78ec9ce098a818dbf9b04cc3704a13f6 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 Jun 2008 14:44:52 +0000 Subject: check in migration files for mysql --- OpenSim/Data/MySQL/Resources/001_AssetStore.sql | 11 +++ .../Data/MySQL/Resources/001_InventoryStore.sql | 35 +++++++ OpenSim/Data/MySQL/Resources/001_UserStore.sql | 106 +++++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_AssetStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/001_InventoryStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/001_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_AssetStore.sql b/OpenSim/Data/MySQL/Resources/001_AssetStore.sql new file mode 100644 index 0000000..2c750fe --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_AssetStore.sql @@ -0,0 +1,11 @@ +CREATE TABLE `assets` ( + `id` binary(16) NOT NULL, + `name` varchar(64) NOT NULL, + `description` varchar(64) NOT NULL, + `assetType` tinyint(4) NOT NULL, + `invType` tinyint(4) NOT NULL, + `local` tinyint(1) NOT NULL, + `temporary` tinyint(1) NOT NULL, + `data` longblob NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql new file mode 100644 index 0000000..84701db --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql @@ -0,0 +1,35 @@ +CREATE TABLE `inventoryfolders` ( + `folderID` varchar(36) NOT NULL default '', + `agentID` varchar(36) default NULL, + `parentFolderID` varchar(36) default NULL, + `folderName` varchar(64) default NULL, + `type` smallint NOT NULL default 0, + `version` int NOT NULL default 0, + PRIMARY KEY (`folderID`), + KEY `owner` (`agentID`), + KEY `parent` (`parentFolderID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; +CREATE TABLE `inventoryitems` ( + `inventoryID` varchar(36) NOT NULL default '', + `assetID` varchar(36) default NULL, + `assetType` int(11) default NULL, + `parentFolderID` varchar(36) default NULL, + `avatarID` varchar(36) default NULL, + `inventoryName` varchar(64) default NULL, + `inventoryDescription` varchar(128) default NULL, + `inventoryNextPermissions` int(10) unsigned default NULL, + `inventoryCurrentPermissions` int(10) unsigned default NULL, + `invType` int(11) default NULL, + `creatorID` varchar(36) default NULL, + `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, + `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, + `salePrice` int(11) NOT NULL default 0, + `saleType` tinyint(4) NOT NULL default 0, + `creationDate` int(11) NOT NULL default 0, + `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `groupOwned` tinyint(4) NOT NULL default 0, + `flags` int(11) unsigned NOT NULL default 0, + PRIMARY KEY (`inventoryID`), + KEY `owner` (`avatarID`), + KEY `folder` (`parentFolderID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/001_UserStore.sql b/OpenSim/Data/MySQL/Resources/001_UserStore.sql new file mode 100644 index 0000000..7ab628f --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_UserStore.sql @@ -0,0 +1,106 @@ +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for agents +-- ---------------------------- +CREATE TABLE `agents` ( + `UUID` varchar(36) NOT NULL, + `sessionID` varchar(36) NOT NULL, + `secureSessionID` varchar(36) NOT NULL, + `agentIP` varchar(16) NOT NULL, + `agentPort` int(11) NOT NULL, + `agentOnline` tinyint(4) NOT NULL, + `loginTime` int(11) NOT NULL, + `logoutTime` int(11) NOT NULL, + `currentRegion` varchar(36) NOT NULL, + `currentHandle` bigint(20) unsigned NOT NULL, + `currentPos` varchar(64) NOT NULL, + PRIMARY KEY (`UUID`), + UNIQUE KEY `session` (`sessionID`), + UNIQUE KEY `ssession` (`secureSessionID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; + +-- Create schema avatar_appearance +-- + +CREATE TABLE `avatarappearance` ( + Owner char(36) NOT NULL, + Serial int(10) unsigned NOT NULL, + Visual_Params blob NOT NULL, + Texture blob NOT NULL, + Avatar_Height float NOT NULL, + Body_Item char(36) NOT NULL, + Body_Asset char(36) NOT NULL, + Skin_Item char(36) NOT NULL, + Skin_Asset char(36) NOT NULL, + Hair_Item char(36) NOT NULL, + Hair_Asset char(36) NOT NULL, + Eyes_Item char(36) NOT NULL, + Eyes_Asset char(36) NOT NULL, + Shirt_Item char(36) NOT NULL, + Shirt_Asset char(36) NOT NULL, + Pants_Item char(36) NOT NULL, + Pants_Asset char(36) NOT NULL, + Shoes_Item char(36) NOT NULL, + Shoes_Asset char(36) NOT NULL, + Socks_Item char(36) NOT NULL, + Socks_Asset char(36) NOT NULL, + Jacket_Item char(36) NOT NULL, + Jacket_Asset char(36) NOT NULL, + Gloves_Item char(36) NOT NULL, + Gloves_Asset char(36) NOT NULL, + Undershirt_Item char(36) NOT NULL, + Undershirt_Asset char(36) NOT NULL, + Underpants_Item char(36) NOT NULL, + Underpants_Asset char(36) NOT NULL, + Skirt_Item char(36) NOT NULL, + Skirt_Asset char(36) NOT NULL, + + + PRIMARY KEY (`Owner`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2'; + +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +CREATE TABLE `userfriends` ( + `ownerID` VARCHAR(37) NOT NULL, + `friendID` VARCHAR(37) NOT NULL, + `friendPerms` INT NOT NULL, + `datetimestamp` INT NOT NULL, + UNIQUE KEY (`ownerID`, `friendID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1';SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +CREATE TABLE `users` ( + `UUID` varchar(36) NOT NULL default '', + `username` varchar(32) NOT NULL, + `lastname` varchar(32) NOT NULL, + `passwordHash` varchar(32) NOT NULL, + `passwordSalt` varchar(32) NOT NULL, + `homeRegion` bigint(20) unsigned default NULL, + `homeLocationX` float default NULL, + `homeLocationY` float default NULL, + `homeLocationZ` float default NULL, + `homeLookAtX` float default NULL, + `homeLookAtY` float default NULL, + `homeLookAtZ` float default NULL, + `created` int(11) NOT NULL, + `lastLogin` int(11) NOT NULL, + `userInventoryURI` varchar(255) default NULL, + `userAssetURI` varchar(255) default NULL, + `profileCanDoMask` int(10) unsigned default NULL, + `profileWantDoMask` int(10) unsigned default NULL, + `profileAboutText` text, + `profileFirstText` text, + `profileImage` varchar(36) default NULL, + `profileFirstImage` varchar(36) default NULL, + `webLoginKey` varchar(36) default NULL, + PRIMARY KEY (`UUID`), + UNIQUE KEY `usernames` (`username`,`lastname`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; + +-- ---------------------------- +-- Records +-- ---------------------------- -- cgit v1.1 From cee071ea6080ae2c5beb495a5dee636662073734 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 Jun 2008 15:21:34 +0000 Subject: check in region store initial migration definition, now on to integrating this approach into the mysql driver. Beware the next couple of checkins. --- OpenSim/Data/MySQL/Resources/001_RegionStore.sql | 150 +++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_RegionStore.sql b/OpenSim/Data/MySQL/Resources/001_RegionStore.sql new file mode 100644 index 0000000..6604c3b --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_RegionStore.sql @@ -0,0 +1,150 @@ +CREATE TABLE `prims` ( + `UUID` varchar(255) NOT NULL, + `RegionUUID` varchar(255) default NULL, + `ParentID` int(11) default NULL, + `CreationDate` int(11) default NULL, + `Name` varchar(255) default NULL, + `SceneGroupID` varchar(255) default NULL, + `Text` varchar(255) default NULL, + `Description` varchar(255) default NULL, + `SitName` varchar(255) default NULL, + `TouchName` varchar(255) default NULL, + `ObjectFlags` int(11) default NULL, + `CreatorID` varchar(255) default NULL, + `OwnerID` varchar(255) default NULL, + `GroupID` varchar(255) default NULL, + `LastOwnerID` varchar(255) default NULL, + `OwnerMask` int(11) default NULL, + `NextOwnerMask` int(11) default NULL, + `GroupMask` int(11) default NULL, + `EveryoneMask` int(11) default NULL, + `BaseMask` int(11) default NULL, + `PositionX` float default NULL, + `PositionY` float default NULL, + `PositionZ` float default NULL, + `GroupPositionX` float default NULL, + `GroupPositionY` float default NULL, + `GroupPositionZ` float default NULL, + `VelocityX` float default NULL, + `VelocityY` float default NULL, + `VelocityZ` float default NULL, + `AngularVelocityX` float default NULL, + `AngularVelocityY` float default NULL, + `AngularVelocityZ` float default NULL, + `AccelerationX` float default NULL, + `AccelerationY` float default NULL, + `AccelerationZ` float default NULL, + `RotationX` float default NULL, + `RotationY` float default NULL, + `RotationZ` float default NULL, + `RotationW` float default NULL, + `SitTargetOffsetX` float default NULL, + `SitTargetOffsetY` float default NULL, + `SitTargetOffsetZ` float default NULL, + `SitTargetOrientW` float default NULL, + `SitTargetOrientX` float default NULL, + `SitTargetOrientY` float default NULL, + `SitTargetOrientZ` float default NULL, + PRIMARY KEY (`UUID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + +CREATE TABLE `primshapes` ( + `UUID` varchar(255) NOT NULL, + `Shape` int(11) default NULL, + `ScaleX` float default NULL, + `ScaleY` float default NULL, + `ScaleZ` float default NULL, + `PCode` int(11) default NULL, + `PathBegin` int(11) default NULL, + `PathEnd` int(11) default NULL, + `PathScaleX` int(11) default NULL, + `PathScaleY` int(11) default NULL, + `PathShearX` int(11) default NULL, + `PathShearY` int(11) default NULL, + `PathSkew` int(11) default NULL, + `PathCurve` int(11) default NULL, + `PathRadiusOffset` int(11) default NULL, + `PathRevolutions` int(11) default NULL, + `PathTaperX` int(11) default NULL, + `PathTaperY` int(11) default NULL, + `PathTwist` int(11) default NULL, + `PathTwistBegin` int(11) default NULL, + `ProfileBegin` int(11) default NULL, + `ProfileEnd` int(11) default NULL, + `ProfileCurve` int(11) default NULL, + `ProfileHollow` int(11) default NULL, + `State` int(11) default NULL, + `Texture` longblob, + `ExtraParams` longblob, + PRIMARY KEY (`UUID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + +CREATE TABLE `primitems` ( + `itemID` varchar(255) NOT NULL, + `primID` varchar(255) default NULL, + `assetID` varchar(255) default NULL, + `parentFolderID` varchar(255) default NULL, + `invType` int(11) default NULL, + `assetType` int(11) default NULL, + `name` varchar(255) default NULL, + `description` varchar(255) default NULL, + `creationDate` bigint(20) default NULL, + `creatorID` varchar(255) default NULL, + `ownerID` varchar(255) default NULL, + `lastOwnerID` varchar(255) default NULL, + `groupID` varchar(255) default NULL, + `nextPermissions` int(11) default NULL, + `currentPermissions` int(11) default NULL, + `basePermissions` int(11) default NULL, + `everyonePermissions` int(11) default NULL, + `groupPermissions` int(11) default NULL, + PRIMARY KEY (`itemID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + +CREATE TABLE `terrain` ( + `RegionUUID` varchar(255) default NULL, + `Revision` int(11) default NULL, + `Heightfield` longblob +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + +CREATE TABLE `land` ( + `UUID` varchar(255) NOT NULL, + `RegionUUID` varchar(255) default NULL, + `LocalLandID` int(11) default NULL, + `Bitmap` longblob, + `Name` varchar(255) default NULL, + `Description` varchar(255) default NULL, + `OwnerUUID` varchar(255) default NULL, + `IsGroupOwned` int(11) default NULL, + `Area` int(11) default NULL, + `AuctionID` int(11) default NULL, + `Category` int(11) default NULL, + `ClaimDate` int(11) default NULL, + `ClaimPrice` int(11) default NULL, + `GroupUUID` varchar(255) default NULL, + `SalePrice` int(11) default NULL, + `LandStatus` int(11) default NULL, + `LandFlags` int(11) default NULL, + `LandingType` int(11) default NULL, + `MediaAutoScale` int(11) default NULL, + `MediaTextureUUID` varchar(255) default NULL, + `MediaURL` varchar(255) default NULL, + `MusicURL` varchar(255) default NULL, + `PassHours` float default NULL, + `PassPrice` int(11) default NULL, + `SnapshotUUID` varchar(255) default NULL, + `UserLocationX` float default NULL, + `UserLocationY` float default NULL, + `UserLocationZ` float default NULL, + `UserLookAtX` float default NULL, + `UserLookAtY` float default NULL, + `UserLookAtZ` float default NULL, + `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`UUID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2' + +CREATE TABLE `landaccesslist` ( + `LandUUID` varchar(255) default NULL, + `AccessUUID` varchar(255) default NULL, + `Flags` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 \ No newline at end of file -- cgit v1.1 From e1140a4f9ba4b0d6b62002927dcde27d85a22ff0 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 Jun 2008 15:47:33 +0000 Subject: this, in theory, adds migration support to mysql for all data sources besides the grid store. It is only lightly tested so the less adventurous should wait a couple of checkins before upgrading. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 84 ++++++++++------- OpenSim/Data/MySQL/MySQLDataStore.cs | 156 +++++++++++++++++-------------- OpenSim/Data/MySQL/MySQLInventoryData.cs | 34 ++++++- OpenSim/Data/MySQL/MySQLUserData.cs | 32 ++++++- 4 files changed, 194 insertions(+), 112 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a2215ef..f51eee2 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -42,6 +42,48 @@ namespace OpenSim.Data.MySQL private MySQLManager _dbConnection; + #region IPlugin Members + + override public void Initialise(string connect) + { + // TODO: This will let you pass in the connect string in + // the config, though someone will need to write that. + if (connect == String.Empty) + { + // This is old seperate config file + m_log.Warn("no connect string, using old mysql_connection.ini instead"); + Initialise(); + } + else + { + _dbConnection = new MySQLManager(connect); + } + + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m); + + m.Update(); + } + + override public void Initialise() + { + IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); + string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); + string database = GridDataMySqlFile.ParseFileReadValue("database"); + string username = GridDataMySqlFile.ParseFileReadValue("username"); + string password = GridDataMySqlFile.ParseFileReadValue("password"); + string pooling = GridDataMySqlFile.ParseFileReadValue("pooling"); + string port = GridDataMySqlFile.ParseFileReadValue("port"); + + _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port); + + } + #region IAssetProvider Members private void UpgradeAssetsTable(string oldVersion) @@ -58,14 +100,20 @@ namespace OpenSim.Data.MySQL /// /// Ensure that the assets related tables exists and are at the latest version /// - private void TestTables() + private void TestTables(Migration m) { Dictionary tableList = new Dictionary(); tableList["assets"] = null; _dbConnection.GetTableVersion(tableList); - UpgradeAssetsTable(tableList["assets"]); + // if there is no table, return, migrations will handle it. + if (tableList["assets"] == null) + return; + + // if there is a table, and we don't have a migration, set it to 1 + if (m.Version == 0) + m.Version = 1; } override public AssetBase FetchAsset(LLUUID assetID) @@ -208,38 +256,6 @@ namespace OpenSim.Data.MySQL #endregion - #region IPlugin Members - - override public void Initialise(string connect) - { - // TODO: This will let you pass in the connect string in - // the config, though someone will need to write that. - if (connect == String.Empty) - { - // This is old seperate config file - Initialise(); - } - else - { - _dbConnection = new MySQLManager(connect); - TestTables(); - } - } - - override public void Initialise() - { - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string database = GridDataMySqlFile.ParseFileReadValue("database"); - string username = GridDataMySqlFile.ParseFileReadValue("username"); - string password = GridDataMySqlFile.ParseFileReadValue("password"); - string pooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string port = GridDataMySqlFile.ParseFileReadValue("port"); - - _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port); - - TestTables(); - } override public string Version { diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index a38a8b2..60aca7a 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -91,7 +91,16 @@ namespace OpenSim.Data.MySQL m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring); m_connection = new MySqlConnection(connectionstring); - TestTablesVersionable(m_connection); + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_connection, assem, "RegionStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m_connection, m); + + m.Update(); + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); @@ -112,8 +121,6 @@ namespace OpenSim.Data.MySQL m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); - TestTables(m_connection); - lock (m_dataSet) { m_primTable = createPrimTable(); @@ -185,18 +192,18 @@ namespace OpenSim.Data.MySQL } } } - private void TestTablesVersionable(MySqlConnection dbconn) - { - Dictionary tableList = new Dictionary(); + // private void TestTablesVersionable(MySqlConnection dbconn) + // { + // Dictionary tableList = new Dictionary(); - tableList["land"] = null; - dbconn.Open(); - GetTableVersion(tableList,dbconn); + // tableList["land"] = null; + // dbconn.Open(); + // GetTableVersion(tableList,dbconn); - UpgradeLandTable(tableList["land"], dbconn); - //database.Close(); + // UpgradeLandTable(tableList["land"], dbconn); + // //database.Close(); - } + // } /// /// Execute a SQL statement stored in a resource, as a string @@ -1660,7 +1667,7 @@ namespace OpenSim.Data.MySQL conn.Close(); } - private bool TestTables(MySqlConnection conn) + private bool TestTables(MySqlConnection conn, Migration m) { MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); @@ -1681,8 +1688,7 @@ namespace OpenSim.Data.MySQL pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - if (persistPrimInventories) - iDa.Fill(tmpDS, "primitems"); + iDa.Fill(tmpDS, "primitems"); tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); @@ -1691,67 +1697,73 @@ namespace OpenSim.Data.MySQL catch (MySqlException) { m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); - InitDB(conn); + return false; } - pDa.Fill(tmpDS, "prims"); - sDa.Fill(tmpDS, "primshapes"); - - if (persistPrimInventories) - iDa.Fill(tmpDS, "primitems"); - - tDa.Fill(tmpDS, "terrain"); - lDa.Fill(tmpDS, "land"); - lalDa.Fill(tmpDS, "landaccesslist"); - - foreach (DataColumn col in createPrimTable().Columns) - { - if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) - { - m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); - return false; - } - } - - foreach (DataColumn col in createShapeTable().Columns) - { - if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) - { - m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); - return false; - } - } - - // XXX primitems should probably go here eventually - - foreach (DataColumn col in createTerrainTable().Columns) - { - if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) - { - m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); - return false; - } - } - - foreach (DataColumn col in createLandTable().Columns) - { - if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) - { - m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); - return false; - } - } - - foreach (DataColumn col in createLandAccessListTable().Columns) - { - if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) - { - m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); - return false; - } - } + // we have tables, but not a migration model yet + if (m.Version == 0) + m.Version = 1; return true; + + // pDa.Fill(tmpDS, "prims"); + // sDa.Fill(tmpDS, "primshapes"); + + // if (persistPrimInventories) + // iDa.Fill(tmpDS, "primitems"); + + // tDa.Fill(tmpDS, "terrain"); + // lDa.Fill(tmpDS, "land"); + // lalDa.Fill(tmpDS, "landaccesslist"); + + // foreach (DataColumn col in createPrimTable().Columns) + // { + // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); + // return false; + // } + // } + + // foreach (DataColumn col in createShapeTable().Columns) + // { + // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); + // return false; + // } + // } + + // // XXX primitems should probably go here eventually + + // foreach (DataColumn col in createTerrainTable().Columns) + // { + // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); + // return false; + // } + // } + + // foreach (DataColumn col in createLandTable().Columns) + // { + // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); + // return false; + // } + // } + + // foreach (DataColumn col in createLandAccessListTable().Columns) + // { + // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + // return false; + // } + // } + + // return true; } /*********************************************************************** diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 8e160b7..1b86abf 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -69,7 +69,16 @@ namespace OpenSim.Data.MySQL new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); } - TestTables(database.Connection); + + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(database.Connection, assem, "AssetStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(database.Connection, m); + + m.Update(); } #region Test and initialization code @@ -107,7 +116,7 @@ namespace OpenSim.Data.MySQL } } - private void TestTables(MySqlConnection conn) + private void TestTables(MySqlConnection conn, Migration m) { Dictionary tableList = new Dictionary(); @@ -115,11 +124,28 @@ namespace OpenSim.Data.MySQL tableList["inventoryitems"] = null; database.GetTableVersion(tableList); - m_log.Info("[INVENTORY DB]: Inventory Folder Version: " + tableList["inventoryfolders"]); - m_log.Info("[INVENTORY DB]: Inventory Items Version: " + tableList["inventoryitems"]); + // if we've already started using migrations, get out of + // here, we've got this under control + if (m.Version > 0) + return; + + // if there are no tables, get out of here and let + // migrations do their job + if( + tableList["inventoryfolders"] == null && + tableList["inventoryitems"] == null + ) + return; + + // otherwise, let the upgrade on legacy proceed... UpgradeFoldersTable(tableList["inventoryfolders"]); UpgradeItemsTable(tableList["inventoryitems"]); + + // ... and set the version + if (m.Version == 0) + m.Version = 1; + } #endregion diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index f717609..7d2da3a 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -105,7 +105,15 @@ namespace OpenSim.Data.MySQL database = new MySQLManager(m_connectString); } - TestTables(); + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(database.Connection, assem, "AssetStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m); + + m.Update(); } #region Test and initialization code @@ -113,7 +121,7 @@ namespace OpenSim.Data.MySQL /// /// Ensure that the user related tables exists and are at the latest version /// - private void TestTables() + private void TestTables(Migration m) { Dictionary tableList = new Dictionary(); @@ -123,10 +131,30 @@ namespace OpenSim.Data.MySQL tableList[m_appearanceTableName] = null; database.GetTableVersion(tableList); + // if we've already started using migrations, get out of + // here, we've got this under control + if (m.Version > 0) + return; + + // if there are no tables, get out of here and let + // migrations do their job + if( + tableList[m_agentsTableName] == null && + tableList[m_usersTableName] == null && + tableList[m_userFriendsTableName] == null && + tableList[m_appearanceTableName] == null + ) + return; + + // otherwise, let the upgrade on legacy proceed... UpgradeAgentsTable(tableList[m_agentsTableName]); UpgradeUsersTable(tableList[m_usersTableName]); UpgradeFriendsTable(tableList[m_userFriendsTableName]); UpgradeAppearanceTable(tableList[m_appearanceTableName]); + + // ... and set the version + if (m.Version == 0) + m.Version = 1; } /// -- cgit v1.1 From 7cdedcaf0e1c69266d6c1d4648d00b76bcb329d4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 12 Jun 2008 18:18:59 +0000 Subject: * minor: Remove and tidy duplicate 'storing object to scene' messages in log --- OpenSim/Data/MySQL/MySQLDataStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 60aca7a..e9bc365 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -265,7 +265,7 @@ namespace OpenSim.Data.MySQL && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0 && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0) { - m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); } else -- cgit v1.1 From 202a4bec13a37d8a2f702f879a5e2b0d2e74085a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 Jun 2008 18:44:58 +0000 Subject: Fix mysql migrations. This is tested with an existing up to date schema, and no schema. It should also work with a non up to date schema as well. Btw, meetings in which I can get code done are the right kind of meetings. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 1 + OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Resources/001_AssetStore.sql | 6 +++++- OpenSim/Data/MySQL/Resources/001_InventoryStore.sql | 9 +++++++-- OpenSim/Data/MySQL/Resources/001_RegionStore.sql | 16 ++++++++++------ OpenSim/Data/MySQL/Resources/001_UserStore.sql | 13 +++++++------ 7 files changed, 32 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index e9bc365..01cd605 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -90,6 +90,7 @@ namespace OpenSim.Data.MySQL m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring); m_connection = new MySqlConnection(connectionstring); + m_connection.Open(); // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 1b86abf..780b96f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -72,7 +72,7 @@ namespace OpenSim.Data.MySQL // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "AssetStore"); + Migration m = new Migration(database.Connection, assem, "InventoryStore"); // TODO: After rev 6000, remove this. People should have // been rolled onto the new migration code by then. diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 7d2da3a..279ff71 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -107,7 +107,7 @@ namespace OpenSim.Data.MySQL // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "AssetStore"); + Migration m = new Migration(database.Connection, assem, "UserStore"); // TODO: After rev 6000, remove this. People should have // been rolled onto the new migration code by then. diff --git a/OpenSim/Data/MySQL/Resources/001_AssetStore.sql b/OpenSim/Data/MySQL/Resources/001_AssetStore.sql index 2c750fe..6a9a127 100644 --- a/OpenSim/Data/MySQL/Resources/001_AssetStore.sql +++ b/OpenSim/Data/MySQL/Resources/001_AssetStore.sql @@ -1,3 +1,5 @@ +BEGIN; + CREATE TABLE `assets` ( `id` binary(16) NOT NULL, `name` varchar(64) NOT NULL, @@ -8,4 +10,6 @@ CREATE TABLE `assets` ( `temporary` tinyint(1) NOT NULL, `data` longblob NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql index 84701db..40dc91c 100644 --- a/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql +++ b/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql @@ -1,3 +1,5 @@ +BEGIN; + CREATE TABLE `inventoryfolders` ( `folderID` varchar(36) NOT NULL default '', `agentID` varchar(36) default NULL, @@ -8,7 +10,8 @@ CREATE TABLE `inventoryfolders` ( PRIMARY KEY (`folderID`), KEY `owner` (`agentID`), KEY `parent` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE `inventoryitems` ( `inventoryID` varchar(36) NOT NULL default '', `assetID` varchar(36) default NULL, @@ -32,4 +35,6 @@ CREATE TABLE `inventoryitems` ( PRIMARY KEY (`inventoryID`), KEY `owner` (`avatarID`), KEY `folder` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 3'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_RegionStore.sql b/OpenSim/Data/MySQL/Resources/001_RegionStore.sql index 6604c3b..31164b3 100644 --- a/OpenSim/Data/MySQL/Resources/001_RegionStore.sql +++ b/OpenSim/Data/MySQL/Resources/001_RegionStore.sql @@ -1,3 +1,5 @@ +BEGIN; + CREATE TABLE `prims` ( `UUID` varchar(255) NOT NULL, `RegionUUID` varchar(255) default NULL, @@ -46,7 +48,7 @@ CREATE TABLE `prims` ( `SitTargetOrientY` float default NULL, `SitTargetOrientZ` float default NULL, PRIMARY KEY (`UUID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `primshapes` ( `UUID` varchar(255) NOT NULL, @@ -77,7 +79,7 @@ CREATE TABLE `primshapes` ( `Texture` longblob, `ExtraParams` longblob, PRIMARY KEY (`UUID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `primitems` ( `itemID` varchar(255) NOT NULL, @@ -99,13 +101,13 @@ CREATE TABLE `primitems` ( `everyonePermissions` int(11) default NULL, `groupPermissions` int(11) default NULL, PRIMARY KEY (`itemID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `terrain` ( `RegionUUID` varchar(255) default NULL, `Revision` int(11) default NULL, `Heightfield` longblob -) ENGINE=MyISAM DEFAULT CHARSET=latin1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `land` ( `UUID` varchar(255) NOT NULL, @@ -141,10 +143,12 @@ CREATE TABLE `land` ( `UserLookAtZ` float default NULL, `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', PRIMARY KEY (`UUID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `landaccesslist` ( `LandUUID` varchar(255) default NULL, `AccessUUID` varchar(255) default NULL, `Flags` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 \ No newline at end of file +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_UserStore.sql b/OpenSim/Data/MySQL/Resources/001_UserStore.sql index 7ab628f..29ebc7d 100644 --- a/OpenSim/Data/MySQL/Resources/001_UserStore.sql +++ b/OpenSim/Data/MySQL/Resources/001_UserStore.sql @@ -1,3 +1,5 @@ +BEGIN; + SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for agents @@ -17,7 +19,7 @@ CREATE TABLE `agents` ( PRIMARY KEY (`UUID`), UNIQUE KEY `session` (`sessionID`), UNIQUE KEY `ssession` (`secureSessionID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- Create schema avatar_appearance -- @@ -54,10 +56,8 @@ CREATE TABLE `avatarappearance` ( Underpants_Asset char(36) NOT NULL, Skirt_Item char(36) NOT NULL, Skirt_Asset char(36) NOT NULL, - - PRIMARY KEY (`Owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- @@ -69,7 +69,7 @@ CREATE TABLE `userfriends` ( `friendPerms` INT NOT NULL, `datetimestamp` INT NOT NULL, UNIQUE KEY (`ownerID`, `friendID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1';SET FOREIGN_KEY_CHECKS=0; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for users -- ---------------------------- @@ -99,8 +99,9 @@ CREATE TABLE `users` ( `webLoginKey` varchar(36) default NULL, PRIMARY KEY (`UUID`), UNIQUE KEY `usernames` (`username`,`lastname`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records -- ---------------------------- +COMMIT; \ No newline at end of file -- cgit v1.1 From 1451d6fb9a4976e5846d17524e1b43affeba0863 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 Jun 2008 20:48:06 +0000 Subject: look mom, migrations in action. This adds a couple of indexes to mysql regions that should help on performance of some of the selects. We should start capturing more data on performance bits to figure out where else we are missing indexes and add them via migrations as well. --- OpenSim/Data/MySQL/Resources/002_RegionStore.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/002_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_RegionStore.sql b/OpenSim/Data/MySQL/Resources/002_RegionStore.sql new file mode 100644 index 0000000..45bf959 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_RegionStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +CREATE index prims_regionuuid on prims(RegionUUID); +CREATE index primitems_primid on primitems(primID); + +COMMIT; \ No newline at end of file -- cgit v1.1 From 64f01ade04863dbe7b392ea8f0fc4dcc8e32bd94 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 13 Jun 2008 00:21:53 +0000 Subject: Update svn properties, clean up formatting, refactor out duplicate hard-coded port numbers. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 780b96f..de0826f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -132,7 +132,7 @@ namespace OpenSim.Data.MySQL // if there are no tables, get out of here and let // migrations do their job - if( + if ( tableList["inventoryfolders"] == null && tableList["inventoryitems"] == null ) diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 279ff71..05874f8 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -138,7 +138,7 @@ namespace OpenSim.Data.MySQL // if there are no tables, get out of here and let // migrations do their job - if( + if ( tableList[m_agentsTableName] == null && tableList[m_usersTableName] == null && tableList[m_userFriendsTableName] == null && -- cgit v1.1 From ec78a2871bedd951844be01490fcb85e22dac178 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 16 Jun 2008 14:10:51 +0000 Subject: the beginning of the great id format migration. This makes asset uuids no longer binary. I've tested this migration a few times, and it seems working in all the scenarios I've found but it wouldn't hurt to backup your asset db before running this as it does touch a very sensitive part of our content system. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 10 ++++------ OpenSim/Data/MySQL/Resources/002_AssetStore.sql | 9 +++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/002_AssetStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index f51eee2..3cda5b8 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -125,8 +125,7 @@ namespace OpenSim.Data.MySQL new MySqlCommand( "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); - MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); - p.Value = assetID.GetBytes(); + cmd.Parameters.AddWithValue("?id", assetID.ToString()); try { @@ -180,8 +179,7 @@ namespace OpenSim.Data.MySQL { using (cmd) { - MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); - p.Value = asset.FullID.GetBytes(); + cmd.Parameters.AddWithValue("?id", asset.FullID.ToString()); cmd.Parameters.AddWithValue("?name", asset.Name); cmd.Parameters.AddWithValue("?description", asset.Description); cmd.Parameters.AddWithValue("?assetType", asset.Type); @@ -219,8 +217,8 @@ namespace OpenSim.Data.MySQL new MySqlCommand( "SELECT id FROM assets WHERE id=?id", _dbConnection.Connection); - MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); - p.Value = uuid.GetBytes(); + + cmd.Parameters.AddWithValue("?id", uuid.ToString()); try { diff --git a/OpenSim/Data/MySQL/Resources/002_AssetStore.sql b/OpenSim/Data/MySQL/Resources/002_AssetStore.sql new file mode 100644 index 0000000..a7d7fca --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_AssetStore.sql @@ -0,0 +1,9 @@ +BEGIN; + +ALTER TABLE assets change id oldid binary(16); +ALTER TABLE assets add id varchar(36) not null default ''; +UPDATE assets set id = concat(substr(hex(oldid),1,8),"-",substr(hex(oldid),9,4),"-",substr(hex(oldid),13,4),"-",substr(hex(oldid),17,4),"-",substr(hex(oldid),21,12)); +ALTER TABLE assets drop oldid; +ALTER TABLE assets add constraint primary key(id); + +COMMIT; \ No newline at end of file -- cgit v1.1 From fcd7cf5e4a7ef0a998e3d05236f8cb161e5c1bef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 19 Jun 2008 15:03:00 +0000 Subject: fix an edge case with migrations in the region store. Add migration support to gridstore. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 4 ++++ OpenSim/Data/MySQL/MySQLGridData.cs | 20 ++++++++++++++-- OpenSim/Data/MySQL/Resources/001_GridStore.sql | 32 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/001_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 01cd605..ff1b583 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1670,6 +1670,10 @@ namespace OpenSim.Data.MySQL private bool TestTables(MySqlConnection conn, Migration m) { + // we already have migrations, get out of here + if (m.Version > 0) + return false; + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 86ceffc..e5940e2 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -72,7 +72,15 @@ namespace OpenSim.Data.MySQL settingPooling, settingPort); } - TestTables(); + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(database.Connection, assem, "GridStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m); + + m.Update(); } #region Test and initialization code @@ -80,14 +88,22 @@ namespace OpenSim.Data.MySQL /// /// Ensure that the user related tables exists and are at the latest version /// - private void TestTables() + private void TestTables(Migration m) { + // we already have migrations, get out of here + if (m.Version > 0) + return; + Dictionary tableList = new Dictionary(); tableList["regions"] = null; database.GetTableVersion(tableList); UpgradeRegionsTable(tableList["regions"]); + + // we have tables, but not a migration model yet + if (m.Version == 0) + m.Version = 1; } /// diff --git a/OpenSim/Data/MySQL/Resources/001_GridStore.sql b/OpenSim/Data/MySQL/Resources/001_GridStore.sql new file mode 100644 index 0000000..cb0f9bd --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_GridStore.sql @@ -0,0 +1,32 @@ +CREATE TABLE `regions` ( + `uuid` varchar(36) NOT NULL, + `regionHandle` bigint(20) unsigned NOT NULL, + `regionName` varchar(32) default NULL, + `regionRecvKey` varchar(128) default NULL, + `regionSendKey` varchar(128) default NULL, + `regionSecret` varchar(128) default NULL, + `regionDataURI` varchar(255) default NULL, + `serverIP` varchar(64) default NULL, + `serverPort` int(10) unsigned default NULL, + `serverURI` varchar(255) default NULL, + `locX` int(10) unsigned default NULL, + `locY` int(10) unsigned default NULL, + `locZ` int(10) unsigned default NULL, + `eastOverrideHandle` bigint(20) unsigned default NULL, + `westOverrideHandle` bigint(20) unsigned default NULL, + `southOverrideHandle` bigint(20) unsigned default NULL, + `northOverrideHandle` bigint(20) unsigned default NULL, + `regionAssetURI` varchar(255) default NULL, + `regionAssetRecvKey` varchar(128) default NULL, + `regionAssetSendKey` varchar(128) default NULL, + `regionUserURI` varchar(255) default NULL, + `regionUserRecvKey` varchar(128) default NULL, + `regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL, + `serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL, + `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, + `originUUID` varchar(36), + PRIMARY KEY (`uuid`), + KEY `regionName` (`regionName`), + KEY `regionHandle` (`regionHandle`), + KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; -- cgit v1.1 From d28a5a4de78f79d2730d09d20a8284caef5339bf Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 19 Jun 2008 15:42:57 +0000 Subject: add migrations support for mysql log store. This should complete all the mysql bits for migration. --- OpenSim/Data/MySQL/MySQLLogData.cs | 30 ++++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/001_LogStore.sql | 10 ++++++++ OpenSim/Data/MySQL/Resources/CreateLogsTable.sql | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Data/MySQL/Resources/001_LogStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 2bd246a..2e6de7c 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -65,6 +65,36 @@ namespace OpenSim.Data.MySQL database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); } + + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(database.Connection, assem, "LogStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m); + + m.Update(); + + } + + private void TestTables(Migration m) + { + // under migrations, bail + if (m.Version > 0) + return; + + Dictionary tableList = new Dictionary(); + tableList["logs"] = null; + database.GetTableVersion(tableList); + + // migrations will handle it + if (tableList["logs"] == null) + return; + + // we have the table, so pretend like we did the first migration in the past + if (m.Version == 0) + m.Version = 1; } /// diff --git a/OpenSim/Data/MySQL/Resources/001_LogStore.sql b/OpenSim/Data/MySQL/Resources/001_LogStore.sql new file mode 100644 index 0000000..b4c29fb --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_LogStore.sql @@ -0,0 +1,10 @@ +CREATE TABLE `logs` ( + `logID` int(10) unsigned NOT NULL auto_increment, + `target` varchar(36) default NULL, + `server` varchar(64) default NULL, + `method` varchar(64) default NULL, + `arguments` varchar(255) default NULL, + `priority` int(11) default NULL, + `message` text, + PRIMARY KEY (`logID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql b/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql index 64b3a80..53dcd31 100644 --- a/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql +++ b/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql @@ -7,4 +7,4 @@ CREATE TABLE `logs` ( `priority` int(11) default NULL, `message` text, PRIMARY KEY (`logID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 -- cgit v1.1 From 40f32a9271d70675798e6ab820cbc5cec2fe0d12 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 19 Jun 2008 15:44:33 +0000 Subject: oops, build break. needed to include another reference. --- OpenSim/Data/MySQL/MySQLLogData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 2e6de7c..2ca5bb2 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -26,6 +26,7 @@ */ using System; using System.Reflection; +using System.Collections.Generic; using log4net; namespace OpenSim.Data.MySQL -- cgit v1.1 From 4448fd4b2f3fb85cd9262e8d8428bdf4c9ca8b2c Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 20 Jun 2008 18:46:43 +0000 Subject: * Handle parcel telehub location corruption gracefully. DBNull * mySQL this time. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index ff1b583..b0f02f0 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1025,13 +1025,22 @@ namespace OpenSim.Data.MySQL newData.authBuyerID = authedbuyer; newData.snapshotID = snapshotID; - - newData.userLocation = - new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), - Convert.ToSingle(row["UserLocationZ"])); - newData.userLookAt = - new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), - Convert.ToSingle(row["UserLookAtZ"])); + try + { + newData.userLocation = + new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.userLookAt = + new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); + } + catch (InvalidCastException) + { + newData.userLocation = LLVector3.Zero; + newData.userLookAt = LLVector3.Zero; + m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.landName); + } + newData.parcelAccessList = new List(); return newData; -- cgit v1.1 From a5860ad438885cbf76a36dc7958947355522b8cf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 21 Jun 2008 03:29:08 +0000 Subject: * Adds Region ban capability to Regions. You access this by going to World->Region/Estate. Then on the Estate tab, at the lower right hand corner, clicking the 'Add' button and picking an avatar. * It only persists across reboots for the mySQL datastore currently. * Currently have stubs in the other datastores. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 117 +++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/003_RegionStore.sql | 5 + 2 files changed, 122 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index b0f02f0..d3e7a90 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -50,6 +50,7 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; + private const string m_regionBanListSelect = "select * from regionban"; /// @@ -65,6 +66,7 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_terrainDataAdapter; private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; + private MySqlDataAdapter m_regionBanListDataAdapter; private DataTable m_primTable; private DataTable m_shapeTable; @@ -72,6 +74,7 @@ namespace OpenSim.Data.MySQL private DataTable m_terrainTable; private DataTable m_landTable; private DataTable m_landAccessListTable; + private DataTable m_regionBanListTable; // Temporary attribute while this is experimental private bool persistPrimInventories; @@ -121,6 +124,9 @@ namespace OpenSim.Data.MySQL MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); + MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection); + m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd); + lock (m_dataSet) { @@ -133,6 +139,7 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_shapeTable); SetupShapeCommands(m_shapeDataAdapter, m_connection); m_shapeDataAdapter.Fill(m_shapeTable); + if (persistPrimInventories) { @@ -156,6 +163,11 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_landAccessListTable); setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); m_landAccessListDataAdapter.Fill(m_landAccessListTable); + + m_regionBanListTable = createRegionBanTable(); + m_dataSet.Tables.Add(m_regionBanListTable); + SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection); + m_regionBanListDataAdapter.Fill(m_regionBanListTable); } } /// @@ -577,6 +589,86 @@ namespace OpenSim.Data.MySQL } } + public List LoadRegionBanList(LLUUID regionUUID) + { + List regionbanlist = new List(); + lock (m_dataSet) + { + DataTable regionban = m_regionBanListTable; + string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; + DataRow[] rawbanlist = regionban.Select(searchExp); + foreach (DataRow rawbanrow in rawbanlist) + { + RegionBanListItem rbli = new RegionBanListItem(); + LLUUID tmpvalue = LLUUID.Zero; + + rbli.regionUUID = regionUUID; + + if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue)) + rbli.bannedUUID = tmpvalue; + + rbli.bannedIP = (string)rawbanrow["bannedIp"]; + rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"]; + regionbanlist.Add(rbli); + } + return regionbanlist; + } + } + + public void AddToRegionBanlist(RegionBanListItem item) + { + lock (m_dataSet) + { + DataTable regionban = m_regionBanListTable; + string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; + DataRow[] rawbanlist = regionban.Select(searchExp); + if (rawbanlist.Length == 0) + { + DataRow regionbanrow = regionban.NewRow(); + regionbanrow["regionUUID"] = item.regionUUID.ToString(); + regionbanrow["bannedUUID"] = item.bannedUUID.ToString(); + regionbanrow["bannedIp"] = item.bannedIP.ToString(); + regionbanrow["bannedIpHostMask"] = item.bannedIPHostMask.ToString(); + regionban.Rows.Add(regionbanrow); + } + Commit(); + } + } + + public void RemoveFromRegionBanlist(RegionBanListItem item) + { + lock (m_dataSet) + { + DataTable regionban = m_regionBanListTable; + string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; + DataRow[] rawbanlist = regionban.Select(searchExp); + if (rawbanlist.Length > 0) + { + foreach (DataRow rbli in rawbanlist) + { + regionban.Rows.Remove(rbli); + } + } + Commit(); + } + if (m_connection.State != ConnectionState.Open) + { + m_connection.Open(); + } + + using + ( + MySqlCommand cmd = + new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_connection) + ) + { + cmd.Parameters.Add(new MySqlParameter("?regionUUID", item.regionUUID.ToString())); + cmd.Parameters.Add(new MySqlParameter("?bannedUUID", item.bannedUUID.ToString())); + cmd.ExecuteNonQuery(); + } + + } + public List LoadLandObjects(LLUUID regionUUID) { List landDataForRegion = new List(); @@ -624,6 +716,7 @@ namespace OpenSim.Data.MySQL m_terrainDataAdapter.Update(m_terrainTable); m_landDataAdapter.Update(m_landTable); m_landAccessListDataAdapter.Update(m_landAccessListTable); + m_regionBanListDataAdapter.Update(m_regionBanListTable); m_dataSet.AcceptChanges(); } @@ -660,6 +753,17 @@ namespace OpenSim.Data.MySQL return terrain; } + private static DataTable createRegionBanTable() + { + DataTable regionban = new DataTable("regionban"); + createCol(regionban, "regionUUID", typeof(String)); + createCol(regionban, "bannedUUID", typeof(String)); + createCol(regionban, "bannedIp", typeof(String)); + createCol(regionban, "bannedIpHostMask", typeof(String)); + return regionban; + + } + private static DataTable createPrimTable() { DataTable prims = new DataTable("prims"); @@ -1553,7 +1657,20 @@ namespace OpenSim.Data.MySQL delete.Connection = conn; da.DeleteCommand = delete; } + private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("regionban", "regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_regionBanListTable); + da.UpdateCommand.Connection = conn; + MySqlCommand delete = new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID"); + delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); + delete.Parameters.Add(createMySqlParameter("bannedUUID", typeof(String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); diff --git a/OpenSim/Data/MySQL/Resources/003_RegionStore.sql b/OpenSim/Data/MySQL/Resources/003_RegionStore.sql new file mode 100644 index 0000000..cb0a614 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + + CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 8b6bd93d68226f468cb20ecfe4e932ca91d15c21 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 23 Jun 2008 16:00:18 +0000 Subject: add migration to go from varchar -> char for uuid. Tested on my machine, and works, but backing up before migrations is always a good idea. --- OpenSim/Data/MySQL/Resources/003_AssetStore.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_AssetStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/003_AssetStore.sql b/OpenSim/Data/MySQL/Resources/003_AssetStore.sql new file mode 100644 index 0000000..d489278 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_AssetStore.sql @@ -0,0 +1,9 @@ +BEGIN; + +ALTER TABLE assets change id oldid varchar(36); +ALTER TABLE assets add id char(36) not null default '00000000-0000-0000-0000-000000000000'; +UPDATE assets set id = oldid; +ALTER TABLE assets drop oldid; +ALTER TABLE assets add constraint primary key(id); + +COMMIT; \ No newline at end of file -- cgit v1.1 From c0a083ad38743ac5fb09e9c3a42ba17a75b42447 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 24 Jun 2008 18:01:28 +0000 Subject: based on positive feedback on performance of making keys fixed length for assets, make all the indexed columns in the inventory fixed length via migration. --- .../Data/MySQL/Resources/002_InventoryStore.sql | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/002_InventoryStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/002_InventoryStore.sql new file mode 100644 index 0000000..c161a68 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_InventoryStore.sql @@ -0,0 +1,31 @@ +BEGIN; + +ALTER TABLE inventoryfolders change folderID folderIDold varchar(36); +ALTER TABLE inventoryfolders change agentID agentIDold varchar(36); +ALTER TABLE inventoryfolders change parentFolderID parentFolderIDold varchar(36); +ALTER TABLE inventoryfolders add folderID char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE inventoryfolders add agentID char(36) default NULL; +ALTER TABLE inventoryfolders add parentFolderID char(36) default NULL; +UPDATE inventoryfolders set folderID = folderIDold, agentID = agentIDold, parentFolderID = parentFolderIDold; +ALTER TABLE inventoryfolders drop folderIDold; +ALTER TABLE inventoryfolders drop agentIDold; +ALTER TABLE inventoryfolders drop parentFolderIDold; +ALTER TABLE inventoryfolders add constraint primary key(folderID); +ALTER TABLE inventoryfolders add index inventoryfolders_agentid(agentID); +ALTER TABLE inventoryfolders add index inventoryfolders_parentFolderid(parentFolderID); + +ALTER TABLE inventoryitems change inventoryID inventoryIDold varchar(36); +ALTER TABLE inventoryitems change avatarID avatarIDold varchar(36); +ALTER TABLE inventoryitems change parentFolderID parentFolderIDold varchar(36); +ALTER TABLE inventoryitems add inventoryID char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE inventoryitems add avatarID char(36) default NULL; +ALTER TABLE inventoryitems add parentFolderID char(36) default NULL; +UPDATE inventoryitems set inventoryID = inventoryIDold, avatarID = avatarIDold, parentFolderID = parentFolderIDold; +ALTER TABLE inventoryitems drop inventoryIDold; +ALTER TABLE inventoryitems drop avatarIDold; +ALTER TABLE inventoryitems drop parentFolderIDold; +ALTER TABLE inventoryitems add constraint primary key(inventoryID); +ALTER TABLE inventoryitems add index inventoryitems_avatarid(avatarID); +ALTER TABLE inventoryitems add index inventoryitems_parentFolderid(parentFolderID); + +COMMIT; \ No newline at end of file -- cgit v1.1 From ce9c58434104f8dcb87eea20b5eb70333b4934fe Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 25 Jun 2008 18:57:21 +0000 Subject: add migrations to mysql and sqlite for flags on embedded inventory --- OpenSim/Data/MySQL/Resources/004_RegionStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/004_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/004_RegionStore.sql b/OpenSim/Data/MySQL/Resources/004_RegionStore.sql new file mode 100644 index 0000000..4db2f75 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE primitems add flags integer not null default 0; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 8a0a0f9bb563f2cb7ec823587e13e3f4483d3a68 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 26 Jun 2008 01:12:28 +0000 Subject: Add patch from bug #1596 - adds Doxygen documentation in OpenSim.Data.MySQL files. Thanks kerunix_Flan! --- OpenSim/Data/MySQL/MySQLAssetData.cs | 37 ++++++++++++++++- OpenSim/Data/MySQL/MySQLDataStore.cs | 68 ++++++++++++++++++++++++++++++-- OpenSim/Data/MySQL/MySQLGridData.cs | 24 +++++++++-- OpenSim/Data/MySQL/MySQLInventoryData.cs | 31 ++++++++++++++- OpenSim/Data/MySQL/MySQLLogData.cs | 5 +++ OpenSim/Data/MySQL/MySQLManager.cs | 34 ++++++++++++++-- OpenSim/Data/MySQL/MySQLUserData.cs | 42 ++++++++++++++++++-- 7 files changed, 224 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 3cda5b8..a29e11b 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -44,6 +44,13 @@ namespace OpenSim.Data.MySQL #region IPlugin Members + /// + /// Initialises Asset interface + /// Loads and initialises the MySQL storage plugin + /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration + /// + /// connect string. override public void Initialise(string connect) { // TODO: This will let you pass in the connect string in @@ -70,6 +77,11 @@ namespace OpenSim.Data.MySQL m.Update(); } + /// + /// uses the obsolete mysql_connection.ini + /// + /// connect string. + /// Probably deprecated and shouldn't be used override public void Initialise() { IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); @@ -116,6 +128,11 @@ namespace OpenSim.Data.MySQL m.Version = 1; } + /// + /// + /// + /// + /// override public AssetBase FetchAsset(LLUUID assetID) { AssetBase asset = null; @@ -157,6 +174,10 @@ namespace OpenSim.Data.MySQL return asset; } + /// + /// + /// + /// override public void CreateAsset(AssetBase asset) { lock (_dbConnection) @@ -202,11 +223,20 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// override public void UpdateAsset(AssetBase asset) { CreateAsset(asset); } + /// + /// + /// + /// + /// override public bool ExistsAsset(LLUUID uuid) { bool assetExists = false; @@ -254,12 +284,17 @@ namespace OpenSim.Data.MySQL #endregion - + /// + /// database provider version + /// override public string Version { get { return _dbConnection.getVersion(); } } + /// + /// The name of this DB provider + /// override public string Name { get { return "MySQL Asset storage engine"; } diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index d3e7a90..def875f 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -85,7 +85,11 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ - // see IRegionDataStore + /// + /// see IRegionDataStore + /// + /// + /// public void Initialise(string connectionstring, bool persistPrimInventories) { m_dataSet = new DataSet(); @@ -221,7 +225,7 @@ namespace OpenSim.Data.MySQL /// /// Execute a SQL statement stored in a resource, as a string /// - /// + /// the ressource name public void ExecuteResourceSql(string name, MySqlConnection dbcon) { MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); @@ -255,6 +259,10 @@ namespace OpenSim.Data.MySQL throw new Exception(string.Format("Resource '{0}' was not found", name)); } + /// + /// + /// + /// private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) { // null as the version, indicates that the table didn't exist @@ -268,6 +276,12 @@ namespace OpenSim.Data.MySQL ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); } } + + /// + /// Adds an object into region storage + /// + /// + /// public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { lock (m_dataSet) @@ -290,6 +304,11 @@ namespace OpenSim.Data.MySQL } } + /// + /// removes an object from region storage + /// + /// + /// public void RemoveObject(LLUUID obj, LLUUID regionUUID) { m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); @@ -327,6 +346,7 @@ namespace OpenSim.Data.MySQL /// Remove all persisted items of the given prim. /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. /// + /// the Item UUID private void RemoveItems(LLUUID uuid) { String sql = String.Format("primID = '{0}'", uuid); @@ -341,6 +361,7 @@ namespace OpenSim.Data.MySQL /// /// Load persisted objects from region storage. /// + /// the Region UUID public List LoadObjects(LLUUID regionUUID) { Dictionary createdObjects = new Dictionary(); @@ -460,6 +481,11 @@ namespace OpenSim.Data.MySQL } } + /// + /// Store a terrain revision in region storage + /// + /// terrain data + /// region UUID public void StoreTerrain(double[,] ter, LLUUID regionID) { int revision = 1; @@ -483,6 +509,11 @@ namespace OpenSim.Data.MySQL } } + /// + /// Load the latest terrain revision from region storage + /// + /// the region UUID + /// public double[,] LoadTerrain(LLUUID regionID) { double[,] terret = new double[256,256]; @@ -531,6 +562,11 @@ namespace OpenSim.Data.MySQL return terret; } + /// + /// delete from land where UUID=globalID + /// delete from landaccesslist where LandUUID=globalID + /// + /// public void RemoveLandObject(LLUUID globalID) { lock (m_dataSet) @@ -551,6 +587,9 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// public void StoreLandObject(ILandObject parcel) { lock (m_dataSet) @@ -589,6 +628,11 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// + /// public List LoadRegionBanList(LLUUID regionUUID) { List regionbanlist = new List(); @@ -615,6 +659,10 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// public void AddToRegionBanlist(RegionBanListItem item) { lock (m_dataSet) @@ -635,6 +683,10 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// public void RemoveFromRegionBanlist(RegionBanListItem item) { lock (m_dataSet) @@ -669,6 +721,11 @@ namespace OpenSim.Data.MySQL } + /// + /// + /// + /// + /// public List LoadLandObjects(LLUUID regionUUID) { List landDataForRegion = new List(); @@ -694,6 +751,9 @@ namespace OpenSim.Data.MySQL return landDataForRegion; } + /// + /// + /// public void Commit() { if (m_connection.State != ConnectionState.Open) @@ -722,7 +782,9 @@ namespace OpenSim.Data.MySQL } } - + /// + /// + /// public void Shutdown() { Commit(); diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index e5940e2..394dbbd 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -49,8 +49,12 @@ namespace OpenSim.Data.MySQL private MySQLManager database; /// - /// Initialises the Grid Interface + /// Initialises Grid interface + /// Loads and initialises the MySQL storage plugin + /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration /// + /// connect string. override public void Initialise(string connect) { if (connect != String.Empty) @@ -166,7 +170,7 @@ namespace OpenSim.Data.MySQL /// Minimum Y coordinate /// Maximum X coordinate /// Maximum Y coordinate - /// + /// Array of sim profiles override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) { try @@ -332,15 +336,21 @@ namespace OpenSim.Data.MySQL } } + /// + /// Update a sim profile + /// + /// The profile to update + /// Sucessful? + /// Same as AddProfile override public DataResponse UpdateProfile(RegionProfileData profile) { return AddProfile(profile); } /// - /// Deletes a profile from the database + /// Deletes a sim profile from the database /// - /// The profile to delete + /// the sim UUID /// Successful? //public DataResponse DeleteProfile(RegionProfileData profile) public DataResponse DeleteProfile(string uuid) @@ -397,6 +407,12 @@ namespace OpenSim.Data.MySQL return false; } + /// + /// Adds a location reservation + /// + /// + /// + /// override public ReservationData GetReservationAtPoint(uint x, uint y) { try diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index de0826f..2d93df3 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -48,6 +48,13 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + /// + /// Initialises User interface + /// Loads and initialises the MySQL storage plugin + /// warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration + /// + /// connect string. public void Initialise(string connect) { if (connect != String.Empty) @@ -162,6 +169,7 @@ namespace OpenSim.Data.MySQL /// /// Closes this DB provider /// + /// do nothing public void Close() { // Do nothing. @@ -250,7 +258,12 @@ namespace OpenSim.Data.MySQL } } - // see InventoryItemBase.getUserRootFolder + + /// + /// see InventoryItemBase.getUserRootFolder + /// + /// + /// public InventoryFolderBase getUserRootFolder(LLUUID user) { try @@ -595,6 +608,7 @@ namespace OpenSim.Data.MySQL addInventoryFolder(folder); } + /// /// Creates a new inventory folder /// /// Folder to create @@ -633,7 +647,12 @@ namespace OpenSim.Data.MySQL folders.Add(f); } - // See IInventoryData + + /// + /// See IInventoryData + /// + /// + /// public List getFolderHierarchy(LLUUID parentID) { List folders = new List(); @@ -645,6 +664,10 @@ namespace OpenSim.Data.MySQL return folders; } + /// + /// Delete a folder from database + /// + /// the folder UUID protected void deleteOneFolder(LLUUID folderID) { try @@ -665,6 +688,10 @@ namespace OpenSim.Data.MySQL } } + /// + /// Delete all item in a folder + /// + /// the folder UUID protected void deleteItemsInFolder(LLUUID folderID) { try diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 2ca5bb2..fee7f2f 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -44,7 +44,9 @@ namespace OpenSim.Data.MySQL /// /// Artificial constructor called when the plugin is loaded + /// Uses the obsolete mysql_connection.ini if connect string is empty. /// + /// connect string public void Initialise(string connect) { if (connect != String.Empty) @@ -79,6 +81,8 @@ namespace OpenSim.Data.MySQL } + /// + /// private void TestTables(Migration m) { // under migrations, bail @@ -132,6 +136,7 @@ namespace OpenSim.Data.MySQL /// /// Closes the database provider /// + /// do nothing public void Close() { // Do nothing. diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 4b11739..7c3ed28 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -62,6 +62,7 @@ namespace OpenSim.Data.MySQL /// The username logging into the database /// The password for the user logging in /// Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'. + /// The MySQL server port public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) { @@ -71,11 +72,19 @@ namespace OpenSim.Data.MySQL Initialise(s); } + /// + /// Initialises and creates a new MySQL connection and maintains it. + /// + /// connectionString public MySQLManager(String connect) { Initialise(connect); } + /// + /// Initialises and creates a new MySQL connection and maintains it. + /// + /// connectionString public void Initialise(String connect) { try @@ -103,6 +112,7 @@ namespace OpenSim.Data.MySQL /// /// Get the connection being used /// + /// MySqlConnection Object public MySqlConnection Connection { get { return dbcon; } @@ -184,13 +194,17 @@ namespace OpenSim.Data.MySQL /// /// Execute a SQL statement stored in a resource, as a string /// - /// + /// name of embedded resource public void ExecuteResourceSql(string name) { MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); cmd.ExecuteNonQuery(); } + /// + /// Execute a MySqlCommand + /// + /// sql string to execute public void ExecuteSql(string sql) { MySqlCommand cmd = new MySqlCommand(sql, dbcon); @@ -536,6 +550,11 @@ namespace OpenSim.Data.MySQL return retval; } + /// + /// Reads an avatar appearence from an active data reader + /// + /// An active database reader + /// An avatar appearence public AvatarAppearance readAppearanceRow(IDataReader reader) { AvatarAppearance appearance = null; @@ -647,6 +666,7 @@ namespace OpenSim.Data.MySQL /// Firstlife text /// UUID for profile image /// UUID for firstlife image + /// Ignored /// Success? public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, @@ -718,7 +738,7 @@ namespace OpenSim.Data.MySQL } /// - /// Creates a new user and inserts it into the database + /// Update user data into the database where User ID = uuid /// /// User ID /// First part of the login @@ -742,6 +762,7 @@ namespace OpenSim.Data.MySQL /// Firstlife text /// UUID for profile image /// UUID for firstlife image + /// UUID for weblogin Key /// Success? public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, @@ -810,7 +831,7 @@ namespace OpenSim.Data.MySQL /// /// Inserts a new region into the database /// - /// The region to insert + /// The region to insert /// Success? public bool insertRegion(RegionProfileData regiondata) { @@ -914,7 +935,7 @@ namespace OpenSim.Data.MySQL /// /// Delete a region from the database /// - /// The region to insert + /// The region to delete /// Success? //public bool deleteRegion(RegionProfileData regiondata) public bool deleteRegion(string uuid) @@ -995,6 +1016,11 @@ namespace OpenSim.Data.MySQL return returnval; } + /// + /// Create (or replace if existing) an avatar appearence + /// + /// + /// Succes? public bool insertAppearanceRow(AvatarAppearance appearance) { string sql = String.Empty; diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 05874f8..11d9c26 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -56,8 +56,12 @@ namespace OpenSim.Data.MySQL private string m_connectString; /// + /// Initialise User Interface /// Loads and initialises the MySQL storage plugin + /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Checks for migration /// + /// connect string. override public void Initialise(string connect) { if (connect == String.Empty) { @@ -494,7 +498,11 @@ namespace OpenSim.Data.MySQL return returnlist; } - // see IUserData + /// + /// See IUserData + /// + /// User UUID + /// User profile data override public UserProfileData GetUserByUUID(LLUUID uuid) { try @@ -526,7 +534,7 @@ namespace OpenSim.Data.MySQL /// /// Returns a user session searching by name /// - /// The account name + /// The account name : "Username Lastname" /// The users session override public UserAgentData GetAgentByName(string name) { @@ -545,6 +553,11 @@ namespace OpenSim.Data.MySQL return GetAgentByUUID(profile.ID); } + /// + /// + /// + /// + /// is it still used ? override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) { Dictionary param = new Dictionary(); @@ -694,9 +707,11 @@ namespace OpenSim.Data.MySQL return false; } + /// /// Appearance /// TODO: stubs for now to get us to a compiling state gently - // override + /// override + /// override public AvatarAppearance GetUserAppearance(LLUUID user) { try { @@ -723,6 +738,12 @@ namespace OpenSim.Data.MySQL return null; } } + + /// + /// Updates an avatar appearence + /// + /// The user UUID + /// The avatar appearance // override override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { @@ -741,16 +762,31 @@ namespace OpenSim.Data.MySQL } } + /// + /// Adds an attachment item to a user + /// + /// the user UUID + /// the item UUID override public void AddAttachment(LLUUID user, LLUUID item) { return; } + /// + /// Removes an attachment from a user + /// + /// the user UUID + /// the item UUID override public void RemoveAttachment(LLUUID user, LLUUID item) { return; } + /// + /// Get the list of item attached to a user + /// + /// the user UUID + /// UUID list of attached item override public List GetAttachments(LLUUID user) { return new List(); -- cgit v1.1 From 1c6bf4fe774b5f04e9616dc46b11f54fdf6ab41e Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 26 Jun 2008 02:51:59 +0000 Subject: Mantis#1595. Thank you, Melanie for a patch that: Adds pipes for the prim item flags field --- OpenSim/Data/MySQL/MySQLDataStore.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index def875f..2b4702b 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1010,6 +1010,7 @@ namespace OpenSim.Data.MySQL createCol(items, "basePermissions", typeof (Int32)); createCol(items, "everyonePermissions", typeof (Int32)); createCol(items, "groupPermissions", typeof (Int32)); + createCol(items, "flags", typeof (Int32)); items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; @@ -1147,6 +1148,7 @@ namespace OpenSim.Data.MySQL taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); + taskItem.Flags = Convert.ToUInt32(row["flags"]); return taskItem; } @@ -1338,6 +1340,7 @@ namespace OpenSim.Data.MySQL row["basePermissions"] = taskItem.BaseMask; row["everyonePermissions"] = taskItem.EveryoneMask; row["groupPermissions"] = taskItem.GroupMask; + row["flags"] = taskItem.Flags; } private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) -- cgit v1.1 From ca724636d4615c6c58d3830fa8ccd620250886ea Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 26 Jun 2008 12:38:03 +0000 Subject: Apply patch from bug #1601 -- more documentation for Data/MySQL. Thanks kerunix_Flan! --- OpenSim/Data/MySQL/MySQLAssetData.cs | 61 +++++--- OpenSim/Data/MySQL/MySQLDataStore.cs | 259 ++++++++++++++++++++++++++----- OpenSim/Data/MySQL/MySQLGridData.cs | 16 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 57 +++++-- 4 files changed, 315 insertions(+), 78 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a29e11b..a64a256 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -36,6 +36,9 @@ using OpenSim.Framework; namespace OpenSim.Data.MySQL { + /// + /// A MySQL Interface for the Asset Server + /// internal class MySQLAssetData : AssetDataBase, IPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -45,12 +48,16 @@ namespace OpenSim.Data.MySQL #region IPlugin Members /// - /// Initialises Asset interface - /// Loads and initialises the MySQL storage plugin - /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. - /// Check for migration + /// Initialises Asset interface + /// + /// + /// Loads and initialises the MySQL storage plugin. + /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration + /// + /// /// - /// connect string. + /// connect string override public void Initialise(string connect) { // TODO: This will let you pass in the connect string in @@ -78,10 +85,16 @@ namespace OpenSim.Data.MySQL } /// - /// uses the obsolete mysql_connection.ini + /// Initialises Asset interface + /// + /// + /// Loads and initialises the MySQL storage plugin + /// uses the obsolete mysql_connection.ini + /// + /// /// - /// connect string. - /// Probably deprecated and shouldn't be used + /// connect string + /// Probably DEPRECATED and shouldn't be used override public void Initialise() { IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); @@ -98,6 +111,13 @@ namespace OpenSim.Data.MySQL #region IAssetProvider Members + /// + /// + /// Execute CreateAssetsTable.sql if oldVersion == null + /// do nothing if oldVersion != null + /// + /// + /// private void UpgradeAssetsTable(string oldVersion) { // null as the version, indicates that the table didn't exist @@ -112,6 +132,7 @@ namespace OpenSim.Data.MySQL /// /// Ensure that the assets related tables exists and are at the latest version /// + /// private void TestTables(Migration m) { Dictionary tableList = new Dictionary(); @@ -129,10 +150,11 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Fetch Asset from database /// - /// - /// + /// Asset UUID to fetch + /// Return the asset + /// On failure : throw an exception and attempt to reconnect to database override public AssetBase FetchAsset(LLUUID assetID) { AssetBase asset = null; @@ -175,9 +197,10 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Create an asset in database, or update it if existing. /// - /// + /// Asset UUID to create + /// On failure : Throw an exception and attempt to reconnect to database override public void CreateAsset(AssetBase asset) { lock (_dbConnection) @@ -224,19 +247,19 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Update a asset in database, see /// - /// + /// Asset UUID to update override public void UpdateAsset(AssetBase asset) { CreateAsset(asset); } /// - /// + /// check if the asset UUID exist in database /// - /// - /// + /// The asset UUID + /// true if exist. override public bool ExistsAsset(LLUUID uuid) { bool assetExists = false; @@ -285,7 +308,7 @@ namespace OpenSim.Data.MySQL #endregion /// - /// database provider version + /// Database provider version /// override public string Version { 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; namespace OpenSim.Data.MySQL { + /// + /// A MySQL Interface for the Region Server + /// public class MySQLDataStore : IRegionDataStore { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -76,7 +79,7 @@ namespace OpenSim.Data.MySQL private DataTable m_landAccessListTable; private DataTable m_regionBanListTable; - // Temporary attribute while this is experimental + /// Temporary attribute while this is experimental private bool persistPrimInventories; /*********************************************************************** @@ -177,7 +180,8 @@ namespace OpenSim.Data.MySQL /// /// Given a list of tables, return the version of the tables, as seen in the database /// - /// + /// The list of table + /// The database connection handler public void GetTableVersion(Dictionary tableList, MySqlConnection dbcon) { lock (dbcon) @@ -226,6 +230,7 @@ namespace OpenSim.Data.MySQL /// Execute a SQL statement stored in a resource, as a string /// /// the ressource name + /// The database connection handler public void ExecuteResourceSql(string name, MySqlConnection dbcon) { MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); @@ -260,9 +265,13 @@ namespace OpenSim.Data.MySQL } /// + /// + /// Execute CreateLandTable.sql if oldVersion == null + /// Execute UpgradeLandTable.sqm if oldVersion contain "Rev." + /// /// /// - /// + /// The database connection handler private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) { // null as the version, indicates that the table didn't exist @@ -280,8 +289,8 @@ namespace OpenSim.Data.MySQL /// /// Adds an object into region storage /// - /// - /// + /// The object + /// The region UUID public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { lock (m_dataSet) @@ -307,8 +316,8 @@ namespace OpenSim.Data.MySQL /// /// removes an object from region storage /// - /// - /// + /// The object + /// The Region UUID public void RemoveObject(LLUUID obj, LLUUID regionUUID) { m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); @@ -362,6 +371,7 @@ namespace OpenSim.Data.MySQL /// Load persisted objects from region storage. /// /// the Region UUID + /// List of loaded groups public List LoadObjects(LLUUID regionUUID) { Dictionary createdObjects = new Dictionary(); @@ -448,7 +458,7 @@ namespace OpenSim.Data.MySQL /// /// Load in a prim's persisted inventory. /// - /// + /// The prim private void LoadItems(SceneObjectPart prim) { lock (m_dataSet) @@ -484,7 +494,7 @@ namespace OpenSim.Data.MySQL /// /// Store a terrain revision in region storage /// - /// terrain data + /// HeightField data /// region UUID public void StoreTerrain(double[,] ter, LLUUID regionID) { @@ -513,7 +523,7 @@ namespace OpenSim.Data.MySQL /// Load the latest terrain revision from region storage /// /// the region UUID - /// + /// Heightfield data public double[,] LoadTerrain(LLUUID regionID) { double[,] terret = new double[256,256]; @@ -563,8 +573,10 @@ namespace OpenSim.Data.MySQL } /// - /// delete from land where UUID=globalID - /// delete from landaccesslist where LandUUID=globalID + /// + /// delete from land where UUID=globalID + /// delete from landaccesslist where LandUUID=globalID + /// /// /// public void RemoveLandObject(LLUUID globalID) @@ -629,10 +641,10 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Load (fetch?) a region banlist /// - /// - /// + /// The region UUID + /// The Region banlist public List LoadRegionBanList(LLUUID regionUUID) { List regionbanlist = new List(); @@ -660,9 +672,9 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Add an item to region banlist /// - /// + /// The item public void AddToRegionBanlist(RegionBanListItem item) { lock (m_dataSet) @@ -684,9 +696,9 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Remove an item from region banlist /// - /// + /// The item public void RemoveFromRegionBanlist(RegionBanListItem item) { lock (m_dataSet) @@ -783,7 +795,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// See /// public void Shutdown() { @@ -798,6 +810,13 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ + /// + /// + /// + /// + /// + /// + /// private static DataColumn createCol(DataTable dt, string name, Type type) { DataColumn col = new DataColumn(name, type); @@ -805,6 +824,10 @@ namespace OpenSim.Data.MySQL return col; } + /// + /// Create the "terrain" table + /// + /// private static DataTable createTerrainTable() { DataTable terrain = new DataTable("terrain"); @@ -815,6 +838,10 @@ namespace OpenSim.Data.MySQL return terrain; } + /// + /// Create the "regionban" table + /// + /// private static DataTable createRegionBanTable() { DataTable regionban = new DataTable("regionban"); @@ -826,6 +853,10 @@ namespace OpenSim.Data.MySQL } + /// + /// Create the "prims" table + /// + /// private static DataTable createPrimTable() { DataTable prims = new DataTable("prims"); @@ -890,6 +921,10 @@ namespace OpenSim.Data.MySQL return prims; } + /// + /// Create the "land" table + /// + /// private static DataTable createLandTable() { DataTable land = new DataTable("land"); @@ -934,6 +969,10 @@ namespace OpenSim.Data.MySQL return land; } + /// + /// Create the "landaccesslist" table + /// + /// private static DataTable createLandAccessListTable() { DataTable landaccess = new DataTable("landaccesslist"); @@ -944,6 +983,10 @@ namespace OpenSim.Data.MySQL return landaccess; } + /// + /// Create the "primshapes" table + /// + /// private static DataTable createShapeTable() { DataTable shapes = new DataTable("primshapes"); @@ -984,6 +1027,10 @@ namespace OpenSim.Data.MySQL return shapes; } + /// + /// Create the "primitems" table + /// + /// private static DataTable createItemsTable() { DataTable items = new DataTable("primitems"); @@ -1025,6 +1072,11 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ + /// + /// + /// + /// + /// private SceneObjectPart buildPrim(DataRow row) { SceneObjectPart prim = new SceneObjectPart(); @@ -1153,6 +1205,11 @@ namespace OpenSim.Data.MySQL return taskItem; } + /// + /// + /// + /// + /// private static LandData buildLandData(DataRow row) { LandData newData = new LandData(); @@ -1214,6 +1271,11 @@ namespace OpenSim.Data.MySQL return newData; } + /// + /// + /// + /// + /// private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); @@ -1223,6 +1285,11 @@ namespace OpenSim.Data.MySQL return entry; } + /// + /// + /// + /// + /// private static Array serializeTerrain(double[,] val) { MemoryStream str = new MemoryStream(65536*sizeof (double)); @@ -1242,6 +1309,13 @@ namespace OpenSim.Data.MySQL return str.ToArray(); } + /// + /// + /// + /// + /// + /// + /// private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) { row["UUID"] = Util.ToRawUuidString(prim.UUID); @@ -1318,6 +1392,11 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// + /// private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) { row["itemID"] = taskItem.ItemID; @@ -1343,6 +1422,12 @@ namespace OpenSim.Data.MySQL row["flags"] = taskItem.Flags; } + /// + /// + /// + /// + /// + /// private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) { row["UUID"] = Util.ToRawUuidString(land.globalID); @@ -1382,6 +1467,12 @@ namespace OpenSim.Data.MySQL row["AuthBuyerID"] = land.authBuyerID; } + /// + /// + /// + /// + /// + /// private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) { row["LandUUID"] = Util.ToRawUuidString(parcelID); @@ -1389,6 +1480,11 @@ namespace OpenSim.Data.MySQL row["Flags"] = entry.Flags; } + /// + /// + /// + /// + /// private PrimitiveBaseShape buildShape(DataRow row) { PrimitiveBaseShape s = new PrimitiveBaseShape(); @@ -1447,6 +1543,11 @@ namespace OpenSim.Data.MySQL return s; } + /// + /// + /// + /// + /// private void fillShapeRow(DataRow row, SceneObjectPart prim) { PrimitiveBaseShape s = prim.Shape; @@ -1502,6 +1603,12 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// + /// + /// private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) { lock (m_dataSet) @@ -1535,7 +1642,11 @@ namespace OpenSim.Data.MySQL } } - // see IRegionDatastore + /// + /// see IRegionDatastore + /// + /// + /// public void StorePrimInventory(LLUUID primID, ICollection items) { if (!persistPrimInventories) @@ -1576,17 +1687,24 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ + /// + /// Create a MySQL insert command + /// + /// + /// + /// + /// + /// This is subtle enough to deserve some commentary. + /// Instead of doing *lots* and *lots of hardcoded strings + /// for database definitions we'll use the fact that + /// realistically all insert statements look like "insert + /// into A(b, c) values(:b, :c) on the parameterized query + /// front. If we just have a list of b, c, etc... we can + /// generate these strings instead of typing them out. + /// private static MySqlCommand createInsertCommand(string table, DataTable dt) { - /** - * This is subtle enough to deserve some commentary. - * Instead of doing *lots* and *lots of hardcoded strings - * for database definitions we'll use the fact that - * realistically all insert statements look like "insert - * into A(b, c) values(:b, :c) on the parameterized query - * front. If we just have a list of b, c, etc... we can - * generate these strings instead of typing them out. - */ + string[] cols = new string[dt.Columns.Count]; for (int i = 0; i < dt.Columns.Count; i++) { @@ -1611,6 +1729,13 @@ namespace OpenSim.Data.MySQL return cmd; } + /// + /// Create a MySQL update command + /// + /// + /// + /// + /// private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) { string sql = "update " + table + " set "; @@ -1638,6 +1763,11 @@ namespace OpenSim.Data.MySQL return cmd; } + /// + /// + /// + /// + /// private static string defineTable(DataTable dt) { string sql = "create table " + dt.TableName + "("; @@ -1673,16 +1803,18 @@ namespace OpenSim.Data.MySQL **********************************************************************/ /// - /// This is a convenience function that collapses 5 repetitive + /// This is a convenience function that collapses 5 repetitive /// lines for defining MySqlParameters to 2 parameters: /// column name and database type. - /// + /// + /// /// It assumes certain conventions like ?param as the param /// name to replace in parametrized queries, and that source /// version is always current version, both of which are fine /// for us. - /// - ///a built MySql parameter + /// + /// + /// a built MySql parameter private static MySqlParameter createMySqlParameter(string name, Type type) { MySqlParameter param = new MySqlParameter(); @@ -1693,6 +1825,11 @@ namespace OpenSim.Data.MySQL return param; } + /// + /// + /// + /// + /// private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) { MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); @@ -1709,6 +1846,11 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } + /// + /// + /// + /// + /// private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("primitems", m_itemsTable); @@ -1722,6 +1864,12 @@ namespace OpenSim.Data.MySQL delete.Connection = conn; da.DeleteCommand = delete; } + + /// + /// + /// + /// + /// private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable); @@ -1736,12 +1884,23 @@ namespace OpenSim.Data.MySQL delete.Connection = conn; da.DeleteCommand = delete; } + + /// + /// + /// + /// + /// private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); da.InsertCommand.Connection = conn; } + /// + /// + /// + /// + /// private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); @@ -1751,12 +1910,22 @@ namespace OpenSim.Data.MySQL da.UpdateCommand.Connection = conn; } + /// + /// + /// + /// + /// private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); da.InsertCommand.Connection = conn; } + /// + /// + /// + /// + /// private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); @@ -1771,6 +1940,10 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } + /// + /// + /// + /// MySQL connection handler private static void InitDB(MySqlConnection conn) { string createPrims = defineTable(createPrimTable()); @@ -1859,6 +2032,12 @@ namespace OpenSim.Data.MySQL conn.Close(); } + /// + /// + /// + /// + /// + /// private bool TestTables(MySqlConnection conn, Migration m) { // we already have migrations, get out of here @@ -1968,6 +2147,11 @@ namespace OpenSim.Data.MySQL * **********************************************************************/ + /// + /// Type conversion functions + /// + /// + /// private static DbType dbtypeFromType(Type type) { if (type == typeof (String)) @@ -2000,8 +2184,11 @@ namespace OpenSim.Data.MySQL } } - // this is something we'll need to implement for each db - // slightly differently. + /// + /// + /// + /// + /// this is something we'll need to implement for each db slightly differently. private static string MySqlType(Type type) { if (type == typeof (String)) diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 394dbbd..7abc85a 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -49,10 +49,14 @@ namespace OpenSim.Data.MySQL private MySQLManager database; /// - /// Initialises Grid interface - /// Loads and initialises the MySQL storage plugin - /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. - /// Check for migration + /// Initialises Grid interface + /// + /// + /// Loads and initialises the MySQL storage plugin + /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration + /// + /// /// /// connect string. override public void Initialise(string connect) @@ -410,8 +414,8 @@ namespace OpenSim.Data.MySQL /// /// Adds a location reservation /// - /// - /// + /// x coordinate + /// y coordinate /// override public ReservationData GetReservationAtPoint(uint x, uint y) { diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 2d93df3..911958c 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -49,12 +49,16 @@ namespace OpenSim.Data.MySQL private MySQLManager database; /// - /// Initialises User interface - /// Loads and initialises the MySQL storage plugin - /// warns and uses the obsolete mysql_connection.ini if connect string is empty. - /// Check for migration + /// Initialises Inventory interface + /// + /// + /// Loads and initialises the MySQL storage plugin + /// warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration + /// + /// /// - /// connect string. + /// connect string public void Initialise(string connect) { if (connect != String.Empty) @@ -90,6 +94,13 @@ namespace OpenSim.Data.MySQL #region Test and initialization code + /// + /// + /// Execute CreateFoldersTable.sql if oldVersion == null + /// do nothing if oldVersion != null + /// + /// + /// private void UpgradeFoldersTable(string oldVersion) { // null as the version, indicates that the table didn't exist @@ -99,13 +110,19 @@ namespace OpenSim.Data.MySQL return; } - // if the table is already at the current version, then we can exit immediately -// if (oldVersion == "Rev. 2") -// return; - -// database.ExecuteResourceSql("UpgradeFoldersTableToVersion2.sql"); + //// if the table is already at the current version, then we can exit immediately + // if (oldVersion == "Rev. 2") + // return; + // database.ExecuteResourceSql("UpgradeFoldersTableToVersion2.sql"); } + /// + /// + /// Execute CreateItemsTable.sql if oldVersion == null + /// Execute "UpgradeItemsTableToVersion3.sql" if oldVersion start with "Rev. 2;" + /// + /// + /// private void UpgradeItemsTable(string oldVersion) { // null as the version, indicates that the table didn't exist @@ -123,6 +140,11 @@ namespace OpenSim.Data.MySQL } } + /// + /// + /// + /// MySQL connection handler + /// private void TestTables(MySqlConnection conn, Migration m) { Dictionary tableList = new Dictionary(); @@ -178,7 +200,7 @@ namespace OpenSim.Data.MySQL /// /// Returns the version of this DB provider /// - /// A string containing the DB provider + /// A string containing the DB provider version public string getVersion() { return database.getVersion(); @@ -260,9 +282,9 @@ namespace OpenSim.Data.MySQL /// - /// see InventoryItemBase.getUserRootFolder + /// see /// - /// + /// The user UUID /// public InventoryFolderBase getUserRootFolder(LLUUID user) { @@ -545,9 +567,9 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Detele the specified inventory item /// - /// + /// The inventory item UUID to delete public void deleteInventoryItem(LLUUID itemID) { try @@ -609,9 +631,10 @@ namespace OpenSim.Data.MySQL } /// - /// Creates a new inventory folder + /// Move an inventory folder /// - /// Folder to create + /// Folder to move + /// UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID public void moveInventoryFolder(InventoryFolderBase folder) { string sql = -- cgit v1.1 From ca8d1d57e1bbf49cb52abe81b3a7246dacbe9b03 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 27 Jun 2008 02:15:57 +0000 Subject: Mantis#1591. Thank you graciously, Sempuki for a patch that: Currently module loading is done ad-hoc. I propose creating a simple loader class that leverages Mono.Addins (and perhaps the new .NET addins when they become available in mono). Attached is a basic patch for review that compiles into HEAD, but doesn't yet replace any existing ad-hoc loaders. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a64a256..ac7fa1d 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL /// /// A MySQL Interface for the Asset Server /// - internal class MySQLAssetData : AssetDataBase, IPlugin + internal class MySQLAssetData : AssetDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -109,6 +109,8 @@ namespace OpenSim.Data.MySQL } + override public void Dispose() { } + #region IAssetProvider Members /// -- cgit v1.1 From 748f72326d9a295958bc9ba63bbb1a5d39030ef7 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 27 Jun 2008 23:03:39 +0000 Subject: last round of warning squashing. calling it a day now. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 20 +-- OpenSim/Data/MySQL/MySQLDataStore.cs | 304 +++++++++++++++++------------------ OpenSim/Data/MySQL/MySQLGridData.cs | 8 +- OpenSim/Data/MySQL/MySQLManager.cs | 26 ++- 4 files changed, 185 insertions(+), 173 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index ac7fa1d..fc331cd 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -120,16 +120,16 @@ namespace OpenSim.Data.MySQL /// /// /// - private void UpgradeAssetsTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - m_log.Info("[ASSETS DB]: Creating new database tables"); - _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); - return; - } - } + // private void UpgradeAssetsTable(string oldVersion) + // { + // // null as the version, indicates that the table didn't exist + // if (oldVersion == null) + // { + // m_log.Info("[ASSETS DB]: Creating new database tables"); + // _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); + // return; + // } + // } /// /// Ensure that the assets related tables exists and are at the latest version diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index aa4c111..87bce10 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -272,19 +272,19 @@ namespace OpenSim.Data.MySQL /// /// /// The database connection handler - private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - ExecuteResourceSql("CreateLandTable.sql",dbconn); - oldVersion = "Rev. 2; InnoDB free: 0 kB"; - } - if (!oldVersion.Contains("Rev.")) - { - ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); - } - } + // private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) + // { + // // null as the version, indicates that the table didn't exist + // if (oldVersion == null) + // { + // ExecuteResourceSql("CreateLandTable.sql",dbconn); + // oldVersion = "Rev. 2; InnoDB free: 0 kB"; + // } + // if (!oldVersion.Contains("Rev.")) + // { + // ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); + // } + // } /// /// Adds an object into region storage @@ -534,7 +534,7 @@ namespace OpenSim.Data.MySQL where RegionUUID=?RegionUUID order by Revision desc limit 1" , m_connection); - MySqlParameter param = new MySqlParameter(); + // MySqlParameter param = new MySqlParameter(); cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); if (m_connection.State != ConnectionState.Open) @@ -1768,30 +1768,30 @@ namespace OpenSim.Data.MySQL /// /// /// - private static string defineTable(DataTable dt) - { - string sql = "create table " + dt.TableName + "("; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ",\n"; - } - subsql += col.ColumnName + " " + MySqlType(col.DataType); - if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) - { - subsql += " primary key"; - } - } - sql += subsql; - sql += ")"; - - //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); - - return sql; - } + // private static string defineTable(DataTable dt) + // { + // string sql = "create table " + dt.TableName + "("; + // string subsql = String.Empty; + // foreach (DataColumn col in dt.Columns) + // { + // if (subsql.Length > 0) + // { + // // a map function would rock so much here + // subsql += ",\n"; + // } + // subsql += col.ColumnName + " " + MySqlType(col.DataType); + // if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) + // { + // subsql += " primary key"; + // } + // } + // sql += subsql; + // sql += ")"; + + // //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); + + // return sql; + // } /*********************************************************************** * @@ -1944,93 +1944,93 @@ namespace OpenSim.Data.MySQL /// /// /// MySQL connection handler - private static void InitDB(MySqlConnection conn) - { - string createPrims = defineTable(createPrimTable()); - string createShapes = defineTable(createShapeTable()); - string createItems = defineTable(createItemsTable()); - string createTerrain = defineTable(createTerrainTable()); - - // Land table is created from the Versionable Test Table routine now. - //string createLand = defineTable(createLandTable()); - string createLandAccessList = defineTable(createLandAccessListTable()); - - MySqlCommand pcmd = new MySqlCommand(createPrims, conn); - MySqlCommand scmd = new MySqlCommand(createShapes, conn); - MySqlCommand icmd = new MySqlCommand(createItems, conn); - MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); - //MySqlCommand lcmd = new MySqlCommand(createLand, conn); - MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); - - if (conn.State != ConnectionState.Open) - { - try - { - conn.Open(); - } - catch (Exception ex) - { - m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message); - m_log.Error("[REGION DB]: Application is terminating!"); - Thread.CurrentThread.Abort(); - } - } - - try - { - pcmd.ExecuteNonQuery(); - } - catch (MySqlException e) - { - m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e); - } - - try - { - scmd.ExecuteNonQuery(); - } - catch (MySqlException e) - { - m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); - } - - try - { - icmd.ExecuteNonQuery(); - } - catch (MySqlException e) - { - m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); - } - - try - { - tcmd.ExecuteNonQuery(); - } - catch (MySqlException e) - { - m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e); - } - - //try - //{ - //lcmd.ExecuteNonQuery(); - //} - //catch (MySqlException e) - //{ - //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); - //} - - try - { - lalcmd.ExecuteNonQuery(); - } - catch (MySqlException e) - { - m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e); - } - conn.Close(); - } + // private static void InitDB(MySqlConnection conn) + // { + // string createPrims = defineTable(createPrimTable()); + // string createShapes = defineTable(createShapeTable()); + // string createItems = defineTable(createItemsTable()); + // string createTerrain = defineTable(createTerrainTable()); + + // // Land table is created from the Versionable Test Table routine now. + // //string createLand = defineTable(createLandTable()); + // string createLandAccessList = defineTable(createLandAccessListTable()); + + // MySqlCommand pcmd = new MySqlCommand(createPrims, conn); + // MySqlCommand scmd = new MySqlCommand(createShapes, conn); + // MySqlCommand icmd = new MySqlCommand(createItems, conn); + // MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); + // //MySqlCommand lcmd = new MySqlCommand(createLand, conn); + // MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); + + // if (conn.State != ConnectionState.Open) + // { + // try + // { + // conn.Open(); + // } + // catch (Exception ex) + // { + // m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message); + // m_log.Error("[REGION DB]: Application is terminating!"); + // Thread.CurrentThread.Abort(); + // } + // } + + // try + // { + // pcmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e); + // } + + // try + // { + // scmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); + // } + + // try + // { + // icmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); + // } + + // try + // { + // tcmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e); + // } + + // //try + // //{ + // //lcmd.ExecuteNonQuery(); + // //} + // //catch (MySqlException e) + // //{ + // //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); + // //} + + // try + // { + // lalcmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e); + // } + // conn.Close(); + // } /// /// @@ -2189,32 +2189,32 @@ namespace OpenSim.Data.MySQL /// /// /// this is something we'll need to implement for each db slightly differently. - private static string MySqlType(Type type) - { - if (type == typeof (String)) - { - return "varchar(255)"; - } - else if (type == typeof (Int32)) - { - return "integer"; - } - else if (type == typeof (Int64)) - { - return "bigint"; - } - else if (type == typeof (Double)) - { - return "float"; - } - else if (type == typeof (Byte[])) - { - return "longblob"; - } - else - { - return "string"; - } - } + // private static string MySqlType(Type type) + // { + // if (type == typeof (String)) + // { + // return "varchar(255)"; + // } + // else if (type == typeof (Int32)) + // { + // return "integer"; + // } + // else if (type == typeof (Int64)) + // { + // return "bigint"; + // } + // else if (type == typeof (Double)) + // { + // return "float"; + // } + // else if (type == typeof (Byte[])) + // { + // return "longblob"; + // } + // else + // { + // return "string"; + // } + // } } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 7abc85a..bb71c99 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -402,11 +402,11 @@ namespace OpenSim.Data.MySQL /// public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge) { - SHA512Managed HashProvider = new SHA512Managed(); - Encoding TextProvider = new UTF8Encoding(); + // SHA512Managed HashProvider = new SHA512Managed(); + // Encoding TextProvider = new UTF8Encoding(); - byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); - byte[] hash = HashProvider.ComputeHash(stream); + // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); + // byte[] hash = HashProvider.ComputeHash(stream); return false; } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 7c3ed28..61fd039 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -156,7 +156,7 @@ namespace OpenSim.Data.MySQL public string getVersion() { Module module = GetType().Module; - string dllName = module.Assembly.ManifestModule.Name; + // string dllName = module.Assembly.ManifestModule.Name; Version dllVersion = module.Assembly.GetName().Version; return @@ -916,8 +916,12 @@ namespace OpenSim.Data.MySQL IDbCommand result = Query(sql, parameters); //Console.WriteLine(result.CommandText); - int x; - if ((x = result.ExecuteNonQuery()) > 0) + // int x; + // if ((x = result.ExecuteNonQuery()) > 0) + // { + // returnval = true; + // } + if (result.ExecuteNonQuery() > 0) { returnval = true; } @@ -952,8 +956,12 @@ namespace OpenSim.Data.MySQL IDbCommand result = Query(sql, parameters); - int x; - if ((x = result.ExecuteNonQuery()) > 0) + // int x; + // if ((x = result.ExecuteNonQuery()) > 0) + // { + // returnval = true; + // } + if (result.ExecuteNonQuery() > 0) { returnval = true; } @@ -1000,8 +1008,12 @@ namespace OpenSim.Data.MySQL IDbCommand result = Query(sql, parameters); //Console.WriteLine(result.CommandText); - int x; - if ((x = result.ExecuteNonQuery()) > 0) + // int x; + // if ((x = result.ExecuteNonQuery()) > 0) + // { + // returnval = true; + // } + if (result.ExecuteNonQuery() > 0) { returnval = true; } -- cgit v1.1 From f3f31744abaf8a9df952a0d547faa59035b46ff3 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 29 Jun 2008 11:48:58 +0000 Subject: patch and files from mantis #1630, Thanks Melanie --- OpenSim/Data/MySQL/MySQLDataStore.cs | 183 +++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/005_RegionStore.sql | 40 +++++ 2 files changed, 223 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/005_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 87bce10..35e0ab7 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -54,6 +54,7 @@ namespace OpenSim.Data.MySQL private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; private const string m_regionBanListSelect = "select * from regionban"; + private const string m_regionSettingsSelect = "select * from regionsettings"; /// @@ -70,6 +71,7 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; private MySqlDataAdapter m_regionBanListDataAdapter; + private MySqlDataAdapter m_regionSettingsDataAdapter; private DataTable m_primTable; private DataTable m_shapeTable; @@ -78,6 +80,7 @@ namespace OpenSim.Data.MySQL private DataTable m_landTable; private DataTable m_landAccessListTable; private DataTable m_regionBanListTable; + private DataTable m_regionSettingsTable; /// Temporary attribute while this is experimental private bool persistPrimInventories; @@ -134,6 +137,8 @@ namespace OpenSim.Data.MySQL MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection); m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd); + MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); + m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); lock (m_dataSet) { @@ -175,6 +180,11 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_regionBanListTable); SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection); m_regionBanListDataAdapter.Fill(m_regionBanListTable); + + m_regionSettingsTable = createRegionSettingsTable(); + m_dataSet.Tables.Add(m_regionSettingsTable); + SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection); + m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); } } /// @@ -640,6 +650,41 @@ namespace OpenSim.Data.MySQL } } + public RegionSettings LoadRegionSettings(LLUUID regionUUID) + { + lock(m_dataSet) + { + DataTable regionsettings = m_regionSettingsTable; + string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; + DataRow[] rawsettings = regionsettings.Select(searchExp); + if(rawsettings.Length == 0) + return null; + DataRow row = rawsettings[0]; + + return buildRegionSettings(row); + } + } + + public void StoreRegionSettings(RegionSettings rs) + { + lock (m_dataSet) + { + DataTable regionsettings = m_dataSet.Tables["regionsettings"]; + + DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); + if (settingsRow == null) + { + settingsRow = regionsettings.NewRow(); + fillRegionSettingsRow(settingsRow, rs); + regionsettings.Rows.Add(settingsRow); + } + else + { + fillRegionSettingsRow(settingsRow, rs); + } + } + } + /// /// Load (fetch?) a region banlist /// @@ -839,6 +884,49 @@ namespace OpenSim.Data.MySQL } /// + /// Create the "regionsettings" table + /// + /// + private static DataTable createRegionSettingsTable() + { + DataTable regionsettings = new DataTable("regionsettings"); + createCol(regionsettings, "regionUUID", typeof(String)); + createCol(regionsettings, "block_terraform", typeof (Int32)); + createCol(regionsettings, "block_fly", typeof (Int32)); + createCol(regionsettings, "allow_damage", typeof (Int32)); + createCol(regionsettings, "restrict_pushing", typeof (Int32)); + createCol(regionsettings, "allow_land_resell", typeof (Int32)); + createCol(regionsettings, "allow_land_join_divide", typeof (Int32)); + createCol(regionsettings, "block_show_in_search", typeof (Int32)); + createCol(regionsettings, "agent_limit", typeof (Int32)); + createCol(regionsettings, "object_bonus", typeof (Double)); + createCol(regionsettings, "maturity", typeof (Int32)); + createCol(regionsettings, "disable_scripts", typeof (Int32)); + createCol(regionsettings, "disable_collisions", typeof (Int32)); + createCol(regionsettings, "disable_physics", typeof (Int32)); + createCol(regionsettings, "terrain_texture_1", typeof(String)); + createCol(regionsettings, "terrain_texture_2", typeof(String)); + createCol(regionsettings, "terrain_texture_3", typeof(String)); + createCol(regionsettings, "terrain_texture_4", typeof(String)); + createCol(regionsettings, "elevation_1_nw", typeof (Double)); + createCol(regionsettings, "elevation_2_nw", typeof (Double)); + createCol(regionsettings, "elevation_1_ne", typeof (Double)); + createCol(regionsettings, "elevation_2_ne", typeof (Double)); + createCol(regionsettings, "elevation_1_se", typeof (Double)); + createCol(regionsettings, "elevation_2_se", typeof (Double)); + createCol(regionsettings, "elevation_1_sw", typeof (Double)); + createCol(regionsettings, "elevation_2_sw", typeof (Double)); + createCol(regionsettings, "water_height", typeof (Double)); + createCol(regionsettings, "terrain_raise_limit", typeof (Double)); + createCol(regionsettings, "terrain_lower_limit", typeof (Double)); + createCol(regionsettings, "use_estate_sun", typeof (Int32)); + createCol(regionsettings, "fixed_sun", typeof (Int32)); + createCol(regionsettings, "sun_position", typeof (Double)); + createCol(regionsettings, "covenant", typeof(String)); + return regionsettings; + } + + /// /// Create the "regionban" table /// /// @@ -1205,6 +1293,47 @@ namespace OpenSim.Data.MySQL return taskItem; } + private static RegionSettings buildRegionSettings(DataRow row) + { + RegionSettings newSettings = new RegionSettings(); + + newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); + newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); + newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); + newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); + newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); + newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); + newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); + newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); + newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); + newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); + newSettings.Maturity = Convert.ToInt32(row["maturity"]); + newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); + newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); + newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); + newSettings.TerrainTexture1 = new LLUUID((String) row["terrain_texture_1"]); + newSettings.TerrainTexture2 = new LLUUID((String) row["terrain_texture_2"]); + newSettings.TerrainTexture3 = new LLUUID((String) row["terrain_texture_3"]); + newSettings.TerrainTexture4 = new LLUUID((String) row["terrain_texture_4"]); + newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); + newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); + newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); + newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); + newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); + newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); + newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); + newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); + newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); + newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); + newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); + newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); + newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); + newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); + newSettings.Covenant = new LLUUID((String) row["covenant"]); + + return newSettings; + } + /// /// /// @@ -1425,6 +1554,46 @@ namespace OpenSim.Data.MySQL /// /// /// + private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) + { + row["regionUUID"] = settings.RegionUUID.ToString(); + row["block_terraform"] = settings.BlockTerraform; + row["block_fly"] = settings.BlockFly; + row["allow_damage"] = settings.AllowDamage; + row["restrict_pushing"] = settings.RestrictPushing; + row["allow_land_resell"] = settings.AllowLandResell; + row["allow_land_join_divide"] = settings.AllowLandJoinDivide; + row["block_show_in_search"] = settings.BlockShowInSearch; + row["agent_limit"] = settings.AgentLimit; + row["object_bonus"] = settings.ObjectBonus; + row["maturity"] = settings.Maturity; + row["disable_scripts"] = settings.DisableScripts; + row["disable_collisions"] = settings.DisableCollisions; + row["disable_physics"] = settings.DisablePhysics; + row["terrain_texture_1"] = settings.TerrainTexture1.ToString(); + row["terrain_texture_2"] = settings.TerrainTexture2.ToString(); + row["terrain_texture_3"] = settings.TerrainTexture3.ToString(); + row["terrain_texture_4"] = settings.TerrainTexture4.ToString(); + row["elevation_1_nw"] = settings.Elevation1NW; + row["elevation_2_nw"] = settings.Elevation2NW; + row["elevation_1_ne"] = settings.Elevation1NE; + row["elevation_2_ne"] = settings.Elevation2NE; + row["elevation_1_se"] = settings.Elevation1SE; + row["elevation_2_se"] = settings.Elevation2SE; + row["elevation_1_sw"] = settings.Elevation1SW; + row["elevation_2_sw"] = settings.Elevation2SW; + row["water_height"] = settings.WaterHeight; + row["terrain_raise_limit"] = settings.TerrainRaiseLimit; + row["terrain_lower_limit"] = settings.TerrainLowerLimit; + row["use_estate_sun"] = settings.UseEstateSun; + row["fixed_sun"] = settings.FixedSun; + row["sun_position"] = settings.SunPosition; + row["covenant"] = settings.Covenant.ToString(); + } + + /// + /// + /// /// /// /// @@ -1865,6 +2034,20 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } + private void SetupRegionSettingsCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("regionsettings", m_regionSettingsTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID = ?regionUUID", m_regionSettingsTable); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from regionsettings where regionUUID = ?regionUUID"); + delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + /// /// /// diff --git a/OpenSim/Data/MySQL/Resources/005_RegionStore.sql b/OpenSim/Data/MySQL/Resources/005_RegionStore.sql new file mode 100644 index 0000000..c4a9527 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_RegionStore.sql @@ -0,0 +1,40 @@ +BEGIN; + +create table regionsettings ( + regionUUID char(36) not null, + block_terraform integer not null, + block_fly integer not null, + allow_damage integer not null, + restrict_pushing integer not null, + allow_land_resell integer not null, + allow_land_join_divide integer not null, + block_show_in_search integer not null, + agent_limit integer not null, + object_bonus float not null, + maturity integer not null, + disable_scripts integer not null, + disable_collisions integer not null, + disable_physics integer not null, + terrain_texture_1 char(36) not null, + terrain_texture_2 char(36) not null, + terrain_texture_3 char(36) not null, + terrain_texture_4 char(36) not null, + elevation_1_nw float not null, + elevation_2_nw float not null, + elevation_1_ne float not null, + elevation_2_ne float not null, + elevation_1_se float not null, + elevation_2_se float not null, + elevation_1_sw float not null, + elevation_2_sw float not null, + water_height float not null, + terrain_raise_limit float not null, + terrain_lower_limit float not null, + use_estate_sun integer not null, + fixed_sun integer not null, + sun_position float not null, + covenant char(36), + primary key(regionUUID) +); + +COMMIT; -- cgit v1.1 From 31c63558c89b617fa46b86a9c2c8a14529a5b8ba Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 29 Jun 2008 18:10:38 +0000 Subject: * Fix for http://opensimulator.org/mantis/view.php?id=1512 * Introduce experimental wait timeout checking to mysql region datastore code * This should mean that if the mysql connection has timed out, we should automatically reconnect and not fail or drop queries on region database manipulations --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLDataStore.cs | 112 +++++++++++++++++++++++++++++------ 2 files changed, 95 insertions(+), 19 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index fc331cd..d66a5c2 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -191,7 +191,7 @@ namespace OpenSim.Data.MySQL { m_log.ErrorFormat( "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", assetID); + + Environment.NewLine + "Reconnecting", assetID); _dbConnection.Reconnect(); } } diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 35e0ab7..97aaf6a 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -54,19 +54,32 @@ namespace OpenSim.Data.MySQL private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; private const string m_regionBanListSelect = "select * from regionban"; - private const string m_regionSettingsSelect = "select * from regionsettings"; - + private const string m_regionSettingsSelect = "select * from regionsettings"; + private const string m_waitTimeoutSelect = "select @@wait_timeout"; + private MySqlConnection m_connection; + private string m_connectionString; + /// - /// We're only using this to version the table! + /// Wait timeout for our connection in ticks. /// - + private long m_waitTimeout; + + /// + /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long + /// running database operations. + /// + private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; + + /// + /// Holds the last tick time that the connection was used. + /// + private long m_lastConnectionUse; private DataSet m_dataSet; private MySqlDataAdapter m_primDataAdapter; private MySqlDataAdapter m_shapeDataAdapter; private MySqlDataAdapter m_itemsDataAdapter; - private MySqlConnection m_connection; private MySqlDataAdapter m_terrainDataAdapter; private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; @@ -96,14 +109,18 @@ namespace OpenSim.Data.MySQL /// /// /// - public void Initialise(string connectionstring, bool persistPrimInventories) + public void Initialise(string connectionString, bool persistPrimInventories) { + m_connectionString = connectionString; + m_dataSet = new DataSet(); this.persistPrimInventories = persistPrimInventories; - m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring); - m_connection = new MySqlConnection(connectionstring); + m_log.Info("[REGION DB]: MySql - connecting: " + m_connectionString); + m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); + + GetWaitTimeout(); // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; @@ -115,7 +132,6 @@ namespace OpenSim.Data.MySQL m.Update(); - MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); @@ -187,6 +203,58 @@ namespace OpenSim.Data.MySQL m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); } } + + /// + /// Get the wait_timeout value for our connection + /// + protected void GetWaitTimeout() + { + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); + + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + + dbReader.Close(); + cmd.Dispose(); + } + + m_lastConnectionUse = System.DateTime.Now.Ticks; + + m_log.DebugFormat( + "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); + } + + /// + /// Should be called before any db operation. This checks to see if the connection has not timed out + /// + protected void CheckConnection() + { + //m_log.Debug("[REGION DB]: Checking connection"); + + long timeNow = System.DateTime.Now.Ticks; + if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) + { + m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); + + lock (m_connection) + { + m_connection.Close(); + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + } + } + + // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather + // than require the code to call another method - the timeout leeway should be large enough to cover the + // inaccuracy. + m_lastConnectionUse = timeNow; + } + /// /// Given a list of tables, return the version of the tables, as seen in the database /// @@ -201,6 +269,8 @@ namespace OpenSim.Data.MySQL "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + + CheckConnection(); using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { while (tables.Read()) @@ -396,6 +466,7 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { + CheckConnection(); DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); m_log.Info("[REGION DB]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); @@ -473,6 +544,7 @@ namespace OpenSim.Data.MySQL { lock (m_dataSet) { + CheckConnection(); //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); DataTable dbItems = m_itemsTable; @@ -519,6 +591,8 @@ namespace OpenSim.Data.MySQL using (cmd) { delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + + CheckConnection(); delete.ExecuteNonQuery(); cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); @@ -554,6 +628,7 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { + CheckConnection(); using (MySqlDataReader row = cmd.ExecuteReader()) { int rev = 0; @@ -593,6 +668,7 @@ namespace OpenSim.Data.MySQL { lock (m_dataSet) { + CheckConnection(); using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection)) { cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); @@ -616,6 +692,7 @@ namespace OpenSim.Data.MySQL { lock (m_dataSet) { + CheckConnection(); DataTable land = m_landTable; DataTable landaccesslist = m_landAccessListTable; @@ -654,6 +731,7 @@ namespace OpenSim.Data.MySQL { lock(m_dataSet) { + CheckConnection(); DataTable regionsettings = m_regionSettingsTable; string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; DataRow[] rawsettings = regionsettings.Select(searchExp); @@ -669,6 +747,7 @@ namespace OpenSim.Data.MySQL { lock (m_dataSet) { + CheckConnection(); DataTable regionsettings = m_dataSet.Tables["regionsettings"]; DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); @@ -695,6 +774,7 @@ namespace OpenSim.Data.MySQL List regionbanlist = new List(); lock (m_dataSet) { + CheckConnection(); DataTable regionban = m_regionBanListTable; string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; DataRow[] rawbanlist = regionban.Select(searchExp); @@ -724,6 +804,7 @@ namespace OpenSim.Data.MySQL { lock (m_dataSet) { + CheckConnection(); DataTable regionban = m_regionBanListTable; string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; DataRow[] rawbanlist = regionban.Select(searchExp); @@ -748,6 +829,7 @@ namespace OpenSim.Data.MySQL { lock (m_dataSet) { + CheckConnection(); DataTable regionban = m_regionBanListTable; string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; DataRow[] rawbanlist = regionban.Select(searchExp); @@ -760,10 +842,6 @@ namespace OpenSim.Data.MySQL } Commit(); } - if (m_connection.State != ConnectionState.Open) - { - m_connection.Open(); - } using ( @@ -773,6 +851,7 @@ namespace OpenSim.Data.MySQL { cmd.Parameters.Add(new MySqlParameter("?regionUUID", item.regionUUID.ToString())); cmd.Parameters.Add(new MySqlParameter("?bannedUUID", item.bannedUUID.ToString())); + CheckConnection(); cmd.ExecuteNonQuery(); } @@ -788,6 +867,7 @@ namespace OpenSim.Data.MySQL List landDataForRegion = new List(); lock (m_dataSet) { + CheckConnection(); DataTable land = m_landTable; DataTable landaccesslist = m_landAccessListTable; string searchExp = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; @@ -813,13 +893,9 @@ namespace OpenSim.Data.MySQL /// public void Commit() { - if (m_connection.State != ConnectionState.Open) - { - m_connection.Open(); - } - lock (m_dataSet) { + CheckConnection(); // DisplayDataSet(m_dataSet, "Region DataSet"); m_primDataAdapter.Update(m_primTable); -- cgit v1.1 From 4cb42d4c3596845ab8afd076c5e742de4685df91 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 30 Jun 2008 14:09:19 +0000 Subject: Mantis#1637. Thank you kindly, Melanie for a patch that: Make each region load it's settings from the database on startup. No user functionality yet. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 97aaf6a..f1a252d 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -761,6 +761,8 @@ namespace OpenSim.Data.MySQL { fillRegionSettingsRow(settingsRow, rs); } + + Commit(); } } @@ -910,6 +912,7 @@ namespace OpenSim.Data.MySQL m_landDataAdapter.Update(m_landTable); m_landAccessListDataAdapter.Update(m_landAccessListTable); m_regionBanListDataAdapter.Update(m_regionBanListTable); + m_regionSettingsDataAdapter.Update(m_regionSettingsTable); m_dataSet.AcceptChanges(); } @@ -999,6 +1002,9 @@ namespace OpenSim.Data.MySQL createCol(regionsettings, "fixed_sun", typeof (Int32)); createCol(regionsettings, "sun_position", typeof (Double)); createCol(regionsettings, "covenant", typeof(String)); + + regionsettings.PrimaryKey = new DataColumn[] {regionsettings.Columns["RegionUUID"]}; + return regionsettings; } -- cgit v1.1 From bf34f65125b7af6fc44b9eea85cf3c6c7333f1c9 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 1 Jul 2008 02:16:58 +0000 Subject: Mantis#1639. Thank you, Melanie for a patch that: Reads estate_settings.xml and populates the database from it. If there is no record, just passes the defaults to the application. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index f1a252d..69f9a16 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -736,7 +736,14 @@ namespace OpenSim.Data.MySQL string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; DataRow[] rawsettings = regionsettings.Select(searchExp); if(rawsettings.Length == 0) - return null; + { + RegionSettings rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + + StoreRegionSettings(rs); + + return rs; + } DataRow row = rawsettings[0]; return buildRegionSettings(row); -- cgit v1.1 From 9052c43319ab69f57b80e363d965780be625b0e2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 2 Jul 2008 16:20:54 +0000 Subject: * Drop InvType from the assets table since it is no longer used * Migration should be automatic on sqlite and mysql * Migration is not automatic on mssql, you will need to drop the invType column manually * Migration should be fine, but as for any db change, I would recommend making sure you have backups before moving past this revision --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 +++----- OpenSim/Data/MySQL/Resources/004_AssetStore.sql | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/004_AssetStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index d66a5c2..21d730d 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -164,7 +164,7 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", + "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -178,7 +178,6 @@ namespace OpenSim.Data.MySQL asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; asset.FullID = assetID; - asset.InvType = (sbyte) dbReader["invType"]; asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false; asset.Name = (string) dbReader["name"]; asset.Type = (sbyte) dbReader["assetType"]; @@ -216,8 +215,8 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand( - "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", + "REPLACE INTO assets(id, name, description, assetType, local, temporary, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?data)", _dbConnection.Connection); // need to ensure we dispose @@ -229,7 +228,6 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?name", asset.Name); cmd.Parameters.AddWithValue("?description", asset.Description); cmd.Parameters.AddWithValue("?assetType", asset.Type); - cmd.Parameters.AddWithValue("?invType", asset.InvType); cmd.Parameters.AddWithValue("?local", asset.Local); cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?data", asset.Data); diff --git a/OpenSim/Data/MySQL/Resources/004_AssetStore.sql b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql new file mode 100644 index 0000000..9e9b9fe --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE assets drop InvType; + +COMMIT; -- cgit v1.1 From fde6983cce7a6501facba9a3f6d9b86f4dcac8e5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 3 Jul 2008 03:01:02 +0000 Subject: Update svn properties. --- OpenSim/Data/MySQL/Resources/004_AssetStore.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/004_AssetStore.sql b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql index 9e9b9fe..ae1951d 100644 --- a/OpenSim/Data/MySQL/Resources/004_AssetStore.sql +++ b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql @@ -1,5 +1,5 @@ -BEGIN; - -ALTER TABLE assets drop InvType; - -COMMIT; +BEGIN; + +ALTER TABLE assets drop InvType; + +COMMIT; -- cgit v1.1 From 8eb57b68f37d303b17ccf61c96145e895ff34800 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 3 Jul 2008 18:45:32 +0000 Subject: migrate the myisam mysql regions to innodb --- OpenSim/Data/MySQL/Resources/006_RegionStore.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/006_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/006_RegionStore.sql b/OpenSim/Data/MySQL/Resources/006_RegionStore.sql new file mode 100644 index 0000000..c1ba5b8 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/006_RegionStore.sql @@ -0,0 +1,12 @@ +BEGIN; + +alter table landaccesslist ENGINE = InnoDB; +alter table migrations ENGINE = InnoDB; +alter table primitems ENGINE = InnoDB; +alter table prims ENGINE = InnoDB; +alter table primshapes ENGINE = InnoDB; +alter table regionsettings ENGINE = InnoDB; +alter table terrain ENGINE = InnoDB; + +COMMIT; + -- cgit v1.1 From a9b3c2582a5a31464c0ab94fe88494fd75b4db29 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 3 Jul 2008 19:41:01 +0000 Subject: add 3 migrations, 1 each for prims, primshapes, and primitems to move all their UUID stores from varchar(255) -> char(36). Based on past evidence, this should help with performance. --- OpenSim/Data/MySQL/Resources/007_RegionStore.sql | 25 +++++++++++++++++++ OpenSim/Data/MySQL/Resources/008_RegionStore.sql | 9 +++++++ OpenSim/Data/MySQL/Resources/009_RegionStore.sql | 31 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/007_RegionStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/008_RegionStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/009_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/007_RegionStore.sql b/OpenSim/Data/MySQL/Resources/007_RegionStore.sql new file mode 100644 index 0000000..404d248 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_RegionStore.sql @@ -0,0 +1,25 @@ +BEGIN; + +ALTER TABLE prims change UUID UUIDold varchar(255); +ALTER TABLE prims change RegionUUID RegionUUIDold varchar(255); +ALTER TABLE prims change CreatorID CreatorIDold varchar(255); +ALTER TABLE prims change OwnerID OwnerIDold varchar(255); +ALTER TABLE prims change GroupID GroupIDold varchar(255); +ALTER TABLE prims change LastOwnerID LastOwnerIDold varchar(255); +ALTER TABLE prims add UUID char(36); +ALTER TABLE prims add RegionUUID char(36); +ALTER TABLE prims add CreatorID char(36); +ALTER TABLE prims add OwnerID char(36); +ALTER TABLE prims add GroupID char(36); +ALTER TABLE prims add LastOwnerID char(36); +UPDATE prims set UUID = UUIDold, RegionUUID = RegionUUIDold, CreatorID = CreatorIDold, OwnerID = OwnerIDold, GroupID = GroupIDold, LastOwnerID = LastOwnerIDold; +ALTER TABLE prims drop UUIDold; +ALTER TABLE prims drop RegionUUIDold; +ALTER TABLE prims drop CreatorIDold; +ALTER TABLE prims drop OwnerIDold; +ALTER TABLE prims drop GroupIDold; +ALTER TABLE prims drop LastOwnerIDold; +ALTER TABLE prims add constraint primary key(UUID); +ALTER TABLE prims add index prims_regionuuid(RegionUUID); + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/008_RegionStore.sql b/OpenSim/Data/MySQL/Resources/008_RegionStore.sql new file mode 100644 index 0000000..7bc61c0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/008_RegionStore.sql @@ -0,0 +1,9 @@ +BEGIN; + +ALTER TABLE primshapes change UUID UUIDold varchar(255); +ALTER TABLE primshapes add UUID char(36); +UPDATE primshapes set UUID = UUIDold; +ALTER TABLE primshapes drop UUIDold; +ALTER TABLE primshapes add constraint primary key(UUID); + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/009_RegionStore.sql b/OpenSim/Data/MySQL/Resources/009_RegionStore.sql new file mode 100644 index 0000000..284732a --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/009_RegionStore.sql @@ -0,0 +1,31 @@ +BEGIN; + +ALTER TABLE primitems change itemID itemIDold varchar(255); +ALTER TABLE primitems change primID primIDold varchar(255); +ALTER TABLE primitems change assetID assetIDold varchar(255); +ALTER TABLE primitems change parentFolderID parentFolderIDold varchar(255); +ALTER TABLE primitems change creatorID creatorIDold varchar(255); +ALTER TABLE primitems change ownerID ownerIDold varchar(255); +ALTER TABLE primitems change groupID groupIDold varchar(255); +ALTER TABLE primitems change lastOwnerID lastOwnerIDold varchar(255); +ALTER TABLE primitems add itemID char(36); +ALTER TABLE primitems add primID char(36); +ALTER TABLE primitems add assetID char(36); +ALTER TABLE primitems add parentFolderID char(36); +ALTER TABLE primitems add creatorID char(36); +ALTER TABLE primitems add ownerID char(36); +ALTER TABLE primitems add groupID char(36); +ALTER TABLE primitems add lastOwnerID char(36); +UPDATE primitems set itemID = itemIDold, primID = primIDold, assetID = assetIDold, parentFolderID = parentFolderIDold, creatorID = creatorIDold, ownerID = ownerIDold, groupID = groupIDold, lastOwnerID = lastOwnerIDold; +ALTER TABLE primitems drop itemIDold; +ALTER TABLE primitems drop primIDold; +ALTER TABLE primitems drop assetIDold; +ALTER TABLE primitems drop parentFolderIDold; +ALTER TABLE primitems drop creatorIDold; +ALTER TABLE primitems drop ownerIDold; +ALTER TABLE primitems drop groupIDold; +ALTER TABLE primitems drop lastOwnerIDold; +ALTER TABLE primitems add constraint primary key(itemID); +ALTER TABLE primitems add index primitems_primid(primID); + +COMMIT; \ No newline at end of file -- cgit v1.1 From 7fea52be3542c1eea884f92ea14285560923e57d Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 3 Jul 2008 22:30:16 +0000 Subject: Mantis#1661. Thank you kindly, CMickeyb for a patch that: patch attached to check for timeouts on mysql connections *before* operations occur that are likely to timeout. if timeout occurs or the connections is down, it is reconnected before the operation fails. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 6 ++ OpenSim/Data/MySQL/MySQLInventoryData.cs | 24 +++++++ OpenSim/Data/MySQL/MySQLManager.cs | 113 +++++++++++++++++++++---------- 3 files changed, 107 insertions(+), 36 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 21d730d..3557243 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -162,6 +162,8 @@ namespace OpenSim.Data.MySQL AssetBase asset = null; lock (_dbConnection) { + _dbConnection.CheckConnection(); + MySqlCommand cmd = new MySqlCommand( "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", @@ -213,6 +215,8 @@ namespace OpenSim.Data.MySQL return; } + _dbConnection.CheckConnection(); + MySqlCommand cmd = new MySqlCommand( "REPLACE INTO assets(id, name, description, assetType, local, temporary, data)" + @@ -266,6 +270,8 @@ namespace OpenSim.Data.MySQL lock (_dbConnection) { + _dbConnection.CheckConnection(); + MySqlCommand cmd = new MySqlCommand( "SELECT id FROM assets WHERE id=?id", diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 911958c..5bde40a 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -219,6 +219,8 @@ namespace OpenSim.Data.MySQL { List items = new List(); + database.CheckConnection(); + MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection); @@ -253,6 +255,8 @@ namespace OpenSim.Data.MySQL { lock (database) { + database.CheckConnection(); + MySqlCommand result = new MySqlCommand( "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", @@ -292,6 +296,8 @@ namespace OpenSim.Data.MySQL { lock (database) { + database.CheckConnection(); + MySqlCommand result = new MySqlCommand( "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", @@ -344,6 +350,8 @@ namespace OpenSim.Data.MySQL { lock (database) { + database.CheckConnection(); + MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection); @@ -421,6 +429,8 @@ namespace OpenSim.Data.MySQL { lock (database) { + database.CheckConnection(); + MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", itemID.ToString()); @@ -482,6 +492,8 @@ namespace OpenSim.Data.MySQL { lock (database) { + database.CheckConnection(); + MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", folderID.ToString()); @@ -522,6 +534,8 @@ namespace OpenSim.Data.MySQL try { + database.CheckConnection(); + MySqlCommand result = new MySqlCommand(sql, database.Connection); result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); @@ -574,6 +588,8 @@ namespace OpenSim.Data.MySQL { try { + database.CheckConnection(); + MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); @@ -600,6 +616,8 @@ namespace OpenSim.Data.MySQL "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; + database.CheckConnection(); + MySqlCommand cmd = new MySqlCommand(sql, database.Connection); cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); @@ -640,6 +658,8 @@ namespace OpenSim.Data.MySQL string sql = "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; + database.CheckConnection(); + MySqlCommand cmd = new MySqlCommand(sql, database.Connection); cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); @@ -695,6 +715,8 @@ namespace OpenSim.Data.MySQL { try { + database.CheckConnection(); + MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); @@ -719,6 +741,8 @@ namespace OpenSim.Data.MySQL { try { + database.CheckConnection(); + MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 61fd039..cf4bce3 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -54,6 +54,24 @@ namespace OpenSim.Data.MySQL /// private string connectionString; + private const string m_waitTimeoutSelect = "select @@wait_timeout"; + + /// + /// Wait timeout for our connection in ticks. + /// + private long m_waitTimeout; + + /// + /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long + /// running database operations. + /// + private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; + + /// + /// Holds the last tick time that the connection was used. + /// + private long m_lastConnectionUse; + /// /// Initialises and creates a new MySQL connection and maintains it. /// @@ -102,6 +120,7 @@ namespace OpenSim.Data.MySQL } m_log.Info("[MYSQL]: Connection established"); + GetWaitTimeout(); } catch (Exception e) { @@ -110,6 +129,51 @@ namespace OpenSim.Data.MySQL } /// + /// Get the wait_timeout value for our connection + /// + protected void GetWaitTimeout() + { + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); + + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + + dbReader.Close(); + cmd.Dispose(); + } + + m_lastConnectionUse = System.DateTime.Now.Ticks; + + m_log.DebugFormat( + "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); + } + + /// + /// Should be called before any db operation. This checks to see if the connection has not timed out + /// + public void CheckConnection() + { + //m_log.Debug("[REGION DB]: Checking connection"); + + long timeNow = System.DateTime.Now.Ticks; + if (timeNow - m_lastConnectionUse > m_waitTimeout || dbcon.State != ConnectionState.Open) + { + m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); + Reconnect(); + } + + // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather + // than require the code to call another method - the timeout leeway should be large enough to cover the + // inaccuracy. + m_lastConnectionUse = timeNow; + } + + /// /// Get the connection being used /// /// MySqlConnection Object @@ -132,6 +196,8 @@ namespace OpenSim.Data.MySQL /// public void Reconnect() { + m_log.Info("[REGION DB] Reconnecting database"); + lock (dbcon) { try @@ -197,6 +263,7 @@ namespace OpenSim.Data.MySQL /// name of embedded resource public void ExecuteResourceSql(string name) { + CheckConnection(); MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); cmd.ExecuteNonQuery(); } @@ -207,6 +274,7 @@ namespace OpenSim.Data.MySQL /// sql string to execute public void ExecuteSql(string sql) { + CheckConnection(); MySqlCommand cmd = new MySqlCommand(sql, dbcon); cmd.ExecuteNonQuery(); } @@ -219,11 +287,14 @@ namespace OpenSim.Data.MySQL { lock (dbcon) { + CheckConnection(); + MySqlCommand tablesCmd = new MySqlCommand( "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { while (tables.Read()) @@ -259,6 +330,8 @@ namespace OpenSim.Data.MySQL { try { + CheckConnection(); // Not sure if this one is necessary + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) @@ -268,43 +341,11 @@ namespace OpenSim.Data.MySQL return (IDbCommand) dbcommand; } - catch + catch (Exception e) { - lock (dbcon) - { - // Close the DB connection - dbcon.Close(); - - // Try to reopen it - try - { - dbcon = new MySqlConnection(connectionString); - dbcon.Open(); - } - catch (Exception e) - { - m_log.Error("Unable to reconnect to database " + e); - } - - // Run the query again - try - { - MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); - dbcommand.CommandText = sql; - foreach (KeyValuePair param in parameters) - { - dbcommand.Parameters.AddWithValue(param.Key, param.Value); - } - - return (IDbCommand) dbcommand; - } - catch (Exception e) - { - // Return null if it fails. - m_log.Error("Failed during Query generation: " + e.ToString()); - return null; - } - } + // Return null if it fails. + m_log.Error("Failed during Query generation: " + e.ToString()); + return null; } } -- cgit v1.1 From d470d30c09fde202f708a9c8af763f5d16e18bfb Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 6 Jul 2008 14:02:22 +0000 Subject: Copyright notices and formatting cleanup. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 69f9a16..7dc5b0c 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -729,13 +729,13 @@ namespace OpenSim.Data.MySQL public RegionSettings LoadRegionSettings(LLUUID regionUUID) { - lock(m_dataSet) + lock (m_dataSet) { CheckConnection(); DataTable regionsettings = m_regionSettingsTable; string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; DataRow[] rawsettings = regionsettings.Select(searchExp); - if(rawsettings.Length == 0) + if (rawsettings.Length == 0) { RegionSettings rs = new RegionSettings(); rs.RegionUUID = regionUUID; -- cgit v1.1 From 1813946937267edde79cb471c357f6cd85efd8ec Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 7 Jul 2008 19:18:44 +0000 Subject: * remove unused CommitAssets() hook for now --- OpenSim/Data/MySQL/MySQLAssetData.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 3557243..6cb0b4c 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -304,13 +304,6 @@ namespace OpenSim.Data.MySQL return assetExists; } - /// - /// All writes are immediately commited to the database, so this is a no-op - /// - override public void CommitAssets() - { - } - #endregion /// -- cgit v1.1 From 867d72c9569e672d99dc5f50aca6b1a4f2ddf906 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 7 Jul 2008 20:12:14 +0000 Subject: change SitTarget calls from functions to properties --- OpenSim/Data/MySQL/MySQLDataStore.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 7dc5b0c..254e526 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1314,18 +1314,19 @@ namespace OpenSim.Data.MySQL ); try { - prim.SetSitTargetLL(new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( - Convert.ToSingle( - row["SitTargetOrientX"]), - Convert.ToSingle( - row["SitTargetOrientY"]), - Convert.ToSingle( - row["SitTargetOrientZ"]), - Convert.ToSingle( - row["SitTargetOrientW"]))); + prim.SitTargetPositionLL = new LLVector3( + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])); + prim.SitTargetOrientationLL = new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"])); } catch (InvalidCastException) { @@ -1584,12 +1585,12 @@ namespace OpenSim.Data.MySQL try { // Sit target - LLVector3 sitTargetPos = prim.GetSitTargetPositionLL(); + LLVector3 sitTargetPos = prim.SitTargetPositionLL; row["SitTargetOffsetX"] = sitTargetPos.X; row["SitTargetOffsetY"] = sitTargetPos.Y; row["SitTargetOffsetZ"] = sitTargetPos.Z; - LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL(); + LLQuaternion sitTargetOrient = prim.SitTargetOrientationLL; row["SitTargetOrientW"] = sitTargetOrient.W; row["SitTargetOrientX"] = sitTargetOrient.X; row["SitTargetOrientY"] = sitTargetOrient.Y; -- cgit v1.1 From 12173034d94e7deb245bb7e3d1bf8099432ec3b8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 14 Jul 2008 01:29:48 +0000 Subject: Patch #9148 Patch 5 in the region settings series. Adds a migration to ensure corrupted data is purged and re-read from defaults. Some changes. Still no full functionality --- OpenSim/Data/MySQL/Resources/010_RegionStore.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/010_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/010_RegionStore.sql b/OpenSim/Data/MySQL/Resources/010_RegionStore.sql new file mode 100644 index 0000000..031a746 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/010_RegionStore.sql @@ -0,0 +1,9 @@ +# 1 "010_RegionStore.sql" +# 1 "" +# 1 "" +# 1 "010_RegionStore.sql" +BEGIN; + +DELETE FROM regionsettings; + +COMMIT; -- cgit v1.1 From 2f46ab50969a1541417944952c9bb5a948ec7ec1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 15 Jul 2008 20:06:58 +0000 Subject: add migration for SceneGroupID to char(36) plus add an index. This should actually speed up deletes substantially, especially for large regions, as this was a table scan before. --- OpenSim/Data/MySQL/Resources/011_RegionStore.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/011_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/011_RegionStore.sql b/OpenSim/Data/MySQL/Resources/011_RegionStore.sql new file mode 100644 index 0000000..ab01969 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/011_RegionStore.sql @@ -0,0 +1,9 @@ +BEGIN; + +ALTER TABLE prims change SceneGroupID SceneGroupIDold varchar(255); +ALTER TABLE prims add SceneGroupID char(36); +UPDATE prims set SceneGroupID = SceneGroupIDold; +ALTER TABLE prims drop SceneGroupIDold; +ALTER TABLE prims add index prims_scenegroupid(SceneGroupID); + +COMMIT; \ No newline at end of file -- cgit v1.1 From 2a30e85c97097794328b59c1c9691cd44e20b7b4 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 16 Jul 2008 22:16:46 +0000 Subject: added index to ParentID on prims, as this is sorted on for prim loading. This should speed up initial load of prims, especially on primy regions. --- OpenSim/Data/MySQL/Resources/012_RegionStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/012_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/012_RegionStore.sql b/OpenSim/Data/MySQL/Resources/012_RegionStore.sql new file mode 100644 index 0000000..95c2757 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/012_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE prims add index prims_parentid(ParentID); + +COMMIT; \ No newline at end of file -- cgit v1.1 From 263633e274082135b21b8183b92280b768d18883 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 18 Jul 2008 02:40:47 +0000 Subject: Patch #9151 Makes the estate dialog fully functional. Implements all client facing functionality. Moves estate data from estate_settings.xml, which is used to provide defaults, to the region data store. Creates one estate for each region, and places the region in it. Converts all region bans to estate bans. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 143 +-------- OpenSim/Data/MySQL/MySQLEstateData.cs | 386 +++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/013_RegionStore.sql | 103 ++++++ 3 files changed, 492 insertions(+), 140 deletions(-) create mode 100644 OpenSim/Data/MySQL/MySQLEstateData.cs create mode 100644 OpenSim/Data/MySQL/Resources/013_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 254e526..25956d5 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -53,7 +53,6 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; - private const string m_regionBanListSelect = "select * from regionban"; private const string m_regionSettingsSelect = "select * from regionsettings"; private const string m_waitTimeoutSelect = "select @@wait_timeout"; @@ -83,7 +82,6 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_terrainDataAdapter; private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; - private MySqlDataAdapter m_regionBanListDataAdapter; private MySqlDataAdapter m_regionSettingsDataAdapter; private DataTable m_primTable; @@ -92,7 +90,6 @@ namespace OpenSim.Data.MySQL private DataTable m_terrainTable; private DataTable m_landTable; private DataTable m_landAccessListTable; - private DataTable m_regionBanListTable; private DataTable m_regionSettingsTable; /// Temporary attribute while this is experimental @@ -150,9 +147,6 @@ namespace OpenSim.Data.MySQL MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); - MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection); - m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd); - MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); @@ -192,11 +186,6 @@ namespace OpenSim.Data.MySQL setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); m_landAccessListDataAdapter.Fill(m_landAccessListTable); - m_regionBanListTable = createRegionBanTable(); - m_dataSet.Tables.Add(m_regionBanListTable); - SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection); - m_regionBanListDataAdapter.Fill(m_regionBanListTable); - m_regionSettingsTable = createRegionSettingsTable(); m_dataSet.Tables.Add(m_regionSettingsTable); SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection); @@ -774,99 +763,6 @@ namespace OpenSim.Data.MySQL } /// - /// Load (fetch?) a region banlist - /// - /// The region UUID - /// The Region banlist - public List LoadRegionBanList(LLUUID regionUUID) - { - List regionbanlist = new List(); - lock (m_dataSet) - { - CheckConnection(); - DataTable regionban = m_regionBanListTable; - string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - foreach (DataRow rawbanrow in rawbanlist) - { - RegionBanListItem rbli = new RegionBanListItem(); - LLUUID tmpvalue = LLUUID.Zero; - - rbli.regionUUID = regionUUID; - - if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue)) - rbli.bannedUUID = tmpvalue; - - rbli.bannedIP = (string)rawbanrow["bannedIp"]; - rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"]; - regionbanlist.Add(rbli); - } - return regionbanlist; - } - } - - /// - /// Add an item to region banlist - /// - /// The item - public void AddToRegionBanlist(RegionBanListItem item) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionban = m_regionBanListTable; - string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - if (rawbanlist.Length == 0) - { - DataRow regionbanrow = regionban.NewRow(); - regionbanrow["regionUUID"] = item.regionUUID.ToString(); - regionbanrow["bannedUUID"] = item.bannedUUID.ToString(); - regionbanrow["bannedIp"] = item.bannedIP.ToString(); - regionbanrow["bannedIpHostMask"] = item.bannedIPHostMask.ToString(); - regionban.Rows.Add(regionbanrow); - } - Commit(); - } - } - - /// - /// Remove an item from region banlist - /// - /// The item - public void RemoveFromRegionBanlist(RegionBanListItem item) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionban = m_regionBanListTable; - string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - if (rawbanlist.Length > 0) - { - foreach (DataRow rbli in rawbanlist) - { - regionban.Rows.Remove(rbli); - } - } - Commit(); - } - - using - ( - MySqlCommand cmd = - new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_connection) - ) - { - cmd.Parameters.Add(new MySqlParameter("?regionUUID", item.regionUUID.ToString())); - cmd.Parameters.Add(new MySqlParameter("?bannedUUID", item.bannedUUID.ToString())); - CheckConnection(); - cmd.ExecuteNonQuery(); - } - - } - - /// /// /// /// @@ -918,7 +814,6 @@ namespace OpenSim.Data.MySQL m_terrainDataAdapter.Update(m_terrainTable); m_landDataAdapter.Update(m_landTable); m_landAccessListDataAdapter.Update(m_landAccessListTable); - m_regionBanListDataAdapter.Update(m_regionBanListTable); m_regionSettingsDataAdapter.Update(m_regionSettingsTable); m_dataSet.AcceptChanges(); @@ -1006,6 +901,7 @@ namespace OpenSim.Data.MySQL createCol(regionsettings, "terrain_raise_limit", typeof (Double)); createCol(regionsettings, "terrain_lower_limit", typeof (Double)); createCol(regionsettings, "use_estate_sun", typeof (Int32)); + createCol(regionsettings, "sandbox", typeof (Int32)); createCol(regionsettings, "fixed_sun", typeof (Int32)); createCol(regionsettings, "sun_position", typeof (Double)); createCol(regionsettings, "covenant", typeof(String)); @@ -1016,21 +912,6 @@ namespace OpenSim.Data.MySQL } /// - /// Create the "regionban" table - /// - /// - private static DataTable createRegionBanTable() - { - DataTable regionban = new DataTable("regionban"); - createCol(regionban, "regionUUID", typeof(String)); - createCol(regionban, "bannedUUID", typeof(String)); - createCol(regionban, "bannedIp", typeof(String)); - createCol(regionban, "bannedIpHostMask", typeof(String)); - return regionban; - - } - - /// /// Create the "prims" table /// /// @@ -1417,6 +1298,7 @@ namespace OpenSim.Data.MySQL newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); + newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new LLUUID((String) row["covenant"]); @@ -1676,6 +1558,7 @@ namespace OpenSim.Data.MySQL row["terrain_raise_limit"] = settings.TerrainRaiseLimit; row["terrain_lower_limit"] = settings.TerrainLowerLimit; row["use_estate_sun"] = settings.UseEstateSun; + row["sandbox"] = settings.Sandbox; row["fixed_sun"] = settings.FixedSun; row["sun_position"] = settings.SunPosition; row["covenant"] = settings.Covenant.ToString(); @@ -2143,26 +2026,6 @@ namespace OpenSim.Data.MySQL /// /// /// - private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("regionban", "regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_regionBanListTable); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID"); - delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); - delete.Parameters.Add(createMySqlParameter("bannedUUID", typeof(String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs new file mode 100644 index 0000000..eeff31b --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -0,0 +1,386 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Reflection; +using System.Threading; +using libsecondlife; +using log4net; +using MySql.Data.MySqlClient; +using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Data.MySQL +{ + public class MySQLEstateStore : IEstateDataStore + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private const string m_waitTimeoutSelect = "select @@wait_timeout"; + + private MySqlConnection m_connection; + private string m_connectionString; + private long m_waitTimeout; + private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; + private long m_lastConnectionUse; + + private FieldInfo[] m_Fields; + private Dictionary m_FieldMap = + new Dictionary(); + + public void Initialise(string connectionString) + { + m_connectionString = connectionString; + + m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); + + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + + GetWaitTimeout(); + + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_connection, assem, "EstateStore"); + m.Update(); + + Type t = typeof(EstateSettings); + m_Fields = t.GetFields(BindingFlags.NonPublic | + BindingFlags.Instance | + BindingFlags.DeclaredOnly); + + foreach (FieldInfo f in m_Fields) + if(f.Name.Substring(0, 2) == "m_") + m_FieldMap[f.Name.Substring(2)] = f; + } + + private string[] FieldList + { + get { return new List(m_FieldMap.Keys).ToArray(); } + } + + protected void GetWaitTimeout() + { + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, + m_connection); + + using (MySqlDataReader dbReader = + cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * + TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + + dbReader.Close(); + cmd.Dispose(); + } + + m_lastConnectionUse = System.DateTime.Now.Ticks; + + m_log.DebugFormat( + "[REGION DB]: Connection wait timeout {0} seconds", + m_waitTimeout / TimeSpan.TicksPerSecond); + } + + protected void CheckConnection() + { + long timeNow = System.DateTime.Now.Ticks; + if (timeNow - m_lastConnectionUse > m_waitTimeout || + m_connection.State != ConnectionState.Open) + { + m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); + + lock (m_connection) + { + m_connection.Close(); + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + } + } + + m_lastConnectionUse = timeNow; + } + + public EstateSettings LoadEstateSettings(LLUUID regionID) + { + EstateSettings es = new EstateSettings(); + + string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = sql; + cmd.Parameters.Add("?RegionID", regionID.ToString()); + + IDataReader r = cmd.ExecuteReader(); + + if(r.Read()) + { + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + int v = Convert.ToInt32(r[name]); + if(v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); + } + } + r.Close(); + } + else + { + // Migration case + // + r.Close(); + + List names = new List(FieldList); + + names.Remove("EstateID"); + + sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")"; + + cmd.CommandText = sql; + cmd.Parameters.Clear(); + + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + if((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.Add("?"+name, "1"); + else + cmd.Parameters.Add("?"+name, "0"); + } + else + { + cmd.Parameters.Add("?"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "select LAST_INSERT_ID() as id"; + cmd.Parameters.Clear(); + + r = cmd.ExecuteReader(); + + r.Read(); + + es.EstateID = Convert.ToUInt32(r["id"]); + + r.Close(); + + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.Add("?RegionID", regionID.ToString()); + cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + + // This will throw on dupe key + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } + + // Munge and transfer the ban list + // + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.Parameters.Add("?UUID", regionID.ToString()); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } + } + + LoadBanList(es); + + es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); + es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); + es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); + return es; + } + + public void StoreEstateSettings(EstateSettings es) + { + string sql = "replace into estate_settings ("+String.Join(",", FieldList)+") values ( ?"+String.Join(", ?", FieldList)+")"; + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = sql; + + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + if((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.Add("?"+name, "1"); + else + cmd.Parameters.Add("?"+name, "0"); + } + else + { + cmd.Parameters.Add("?"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + SaveBanList(es); + SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); + SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); + SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); + } + + private void LoadBanList(EstateSettings es) + { + es.ClearBans(); + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", es.EstateID); + + IDataReader r = cmd.ExecuteReader(); + + while(r.Read()) + { + EstateBan eb = new EstateBan(); + + LLUUID uuid = new LLUUID(); + LLUUID.TryParse(r["bannedUUID"].ToString(), out uuid); + + eb.bannedUUID = uuid; + eb.bannedIP = "0.0.0.0"; + eb.bannedIPHostMask = "0.0.0.0"; + es.AddBan(eb); + } + r.Close(); + } + + private void SaveBanList(EstateSettings es) + { + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )"; + + foreach(EstateBan b in es.EstateBans) + { + cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + cmd.Parameters.Add("?bannedUUID", b.bannedUUID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + + void SaveUUIDList(uint EstateID, string table, LLUUID[] data) + { + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; + + foreach(LLUUID uuid in data) + { + cmd.Parameters.Add("?EstateID", EstateID.ToString()); + cmd.Parameters.Add("?uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + + LLUUID[] LoadUUIDList(uint EstateID, string table) + { + List uuids = new List(); + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", EstateID); + + IDataReader r = cmd.ExecuteReader(); + + while(r.Read()) + { + EstateBan eb = new EstateBan(); + + LLUUID uuid = new LLUUID(); + LLUUID.TryParse(r["uuid"].ToString(), out uuid); + + uuids.Add(uuid); + } + r.Close(); + + return uuids.ToArray(); + } + } +} diff --git a/OpenSim/Data/MySQL/Resources/013_RegionStore.sql b/OpenSim/Data/MySQL/Resources/013_RegionStore.sql new file mode 100644 index 0000000..a6bd30d --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/013_RegionStore.sql @@ -0,0 +1,103 @@ +begin; + +drop table regionsettings; + +CREATE TABLE `regionsettings` ( + `regionUUID` char(36) NOT NULL, + `block_terraform` int(11) NOT NULL, + `block_fly` int(11) NOT NULL, + `allow_damage` int(11) NOT NULL, + `restrict_pushing` int(11) NOT NULL, + `allow_land_resell` int(11) NOT NULL, + `allow_land_join_divide` int(11) NOT NULL, + `block_show_in_search` int(11) NOT NULL, + `agent_limit` int(11) NOT NULL, + `object_bonus` float NOT NULL, + `maturity` int(11) NOT NULL, + `disable_scripts` int(11) NOT NULL, + `disable_collisions` int(11) NOT NULL, + `disable_physics` int(11) NOT NULL, + `terrain_texture_1` char(36) NOT NULL, + `terrain_texture_2` char(36) NOT NULL, + `terrain_texture_3` char(36) NOT NULL, + `terrain_texture_4` char(36) NOT NULL, + `elevation_1_nw` float NOT NULL, + `elevation_2_nw` float NOT NULL, + `elevation_1_ne` float NOT NULL, + `elevation_2_ne` float NOT NULL, + `elevation_1_se` float NOT NULL, + `elevation_2_se` float NOT NULL, + `elevation_1_sw` float NOT NULL, + `elevation_2_sw` float NOT NULL, + `water_height` float NOT NULL, + `terrain_raise_limit` float NOT NULL, + `terrain_lower_limit` float NOT NULL, + `use_estate_sun` int(11) NOT NULL, + `fixed_sun` int(11) NOT NULL, + `sun_position` float NOT NULL, + `covenant` char(36) default NULL, + `Sandbox` tinyint(4) NOT NULL, + PRIMARY KEY (`regionUUID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_managers` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_groups` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_users` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estateban` ( + `EstateID` int(10) unsigned NOT NULL, + `bannedUUID` varchar(36) NOT NULL, + `bannedIp` varchar(16) NOT NULL, + `bannedIpHostMask` varchar(16) NOT NULL, + `bannedNameMask` varchar(64) default NULL, + KEY `estateban_EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_settings` ( + `EstateID` int(10) unsigned NOT NULL auto_increment, + `EstateName` varchar(64) default NULL, + `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, + `DenyAnonymous` tinyint(4) NOT NULL, + `ResetHomeOnTeleport` tinyint(4) NOT NULL, + `FixedSun` tinyint(4) NOT NULL, + `DenyTransacted` tinyint(4) NOT NULL, + `BlockDwell` tinyint(4) NOT NULL, + `DenyIdentified` tinyint(4) NOT NULL, + `AllowVoice` tinyint(4) NOT NULL, + `UseGlobalTime` tinyint(4) NOT NULL, + `PricePerMeter` int(11) NOT NULL, + `TaxFree` tinyint(4) NOT NULL, + `AllowDirectTeleport` tinyint(4) NOT NULL, + `RedirectGridX` int(11) NOT NULL, + `RedirectGridY` int(11) NOT NULL, + `ParentEstateID` int(10) unsigned NOT NULL, + `SunPosition` double NOT NULL, + `EstateSkipScripts` tinyint(4) NOT NULL, + `BillableFactor` float NOT NULL, + `PublicAccess` tinyint(4) NOT NULL, + PRIMARY KEY (`EstateID`) +) ENGINE=InnoDB AUTO_INCREMENT=100; + +CREATE TABLE `estate_map` ( + `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `EstateID` int(11) NOT NULL, + PRIMARY KEY (`RegionID`), + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +commit; + -- cgit v1.1 From 230a7ecaec47f5891f39a8893f7587e86a2efb41 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Fri, 18 Jul 2008 03:23:40 +0000 Subject: masks MySQL password from console startup messages --- OpenSim/Data/MySQL/MySQLDataStore.cs | 23 ++++++++++++++++++++++- OpenSim/Data/MySQL/MySQLEstateData.cs | 27 +++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 25956d5..d1db064 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -113,7 +113,28 @@ namespace OpenSim.Data.MySQL m_dataSet = new DataSet(); this.persistPrimInventories = persistPrimInventories; - m_log.Info("[REGION DB]: MySql - connecting: " + m_connectionString); + int passPosition = 0; + int passEndPosition = 0; + string displayConnectionString = null; + + try + { // hide the password in the connection string + passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); + passPosition = m_connectionString.IndexOf("=", passPosition); + if (passPosition < m_connectionString.Length) + passPosition += 1; + passEndPosition = m_connectionString.IndexOf(";", passPosition); + + displayConnectionString = m_connectionString.Substring(0, passPosition); + displayConnectionString += "***"; + displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); + } + catch (Exception e ) + { + m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); + } + + m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index eeff31b..052c404 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -59,9 +59,32 @@ namespace OpenSim.Data.MySQL public void Initialise(string connectionString) { - m_connectionString = connectionString; + m_connectionString = connectionString; + + int passPosition = 0; + int passEndPosition = 0; + string displayConnectionString = null; + + try + { // hide the password in the connection string + passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); + passPosition = m_connectionString.IndexOf("=", passPosition); + if (passPosition < m_connectionString.Length) + passPosition += 1; + passEndPosition = m_connectionString.IndexOf(";", passPosition); + + displayConnectionString = m_connectionString.Substring(0, passPosition); + displayConnectionString += "***"; + displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); + } + catch (Exception e) + { + m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); + } + + m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); - m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); + //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); -- cgit v1.1 From e0e0db366061eae148364e3d5670f275b1ab25b7 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Fri, 18 Jul 2008 04:51:41 +0000 Subject: Thanks, sempuki, for a patch that moves all grid plugins to new PluginLoader (issue 1763). --- OpenSim/Data/MySQL/MySQLAssetData.cs | 1 + OpenSim/Data/MySQL/MySQLGridData.cs | 22 +++++++++++++++++----- OpenSim/Data/MySQL/MySQLLogData.cs | 26 ++++++++++++++++++++------ OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 4 files changed, 39 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 6cb0b4c..9284ba9 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -34,6 +34,7 @@ using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; + namespace OpenSim.Data.MySQL { /// diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index bb71c99..8142c74 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -33,12 +33,18 @@ using System.Security.Cryptography; using System.Text; using libsecondlife; using log4net; +using Mono.Addins; +using OpenSim.Framework; + +[assembly : Addin] +[assembly : AddinDependency("OpenSim.Data", "0.5")] namespace OpenSim.Data.MySQL { /// /// A MySQL Interface for the Grid Server /// + [Extension("/OpenSim/GridDataStore")] public class MySQLGridData : GridDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -48,6 +54,12 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + override public void Initialise() + { + m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialises Grid interface /// @@ -144,7 +156,7 @@ namespace OpenSim.Data.MySQL /// /// Shuts down the grid interface /// - override public void Close() + override public void Dispose() { database.Close(); } @@ -153,18 +165,18 @@ namespace OpenSim.Data.MySQL /// Returns the plugin name /// /// Plugin name - override public string getName() + override public string Name { - return "MySql OpenGridData"; + get { return "MySql OpenGridData"; } } /// /// Returns the plugin version /// /// Plugin version - override public string getVersion() + override public string Version { - return "0.1"; + get { return "0.1"; } } /// diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index fee7f2f..f11aec5 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -28,20 +28,34 @@ using System; using System.Reflection; using System.Collections.Generic; using log4net; +using Mono.Addins; +using OpenSim.Framework; + +// Only one attribute per assembly. See: *GridData.cs +// [assembly : Addin] +// [assembly : AddinDependency("OpenSim.Data", "0.5")] namespace OpenSim.Data.MySQL { /// /// An interface to the log database for MySQL /// - internal class MySQLLogData : ILogData + [Extension("/OpenSim/GridLogData")] + internal class MySQLLogData : ILogDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// The database manager /// public MySQLManager database; + public void Initialise() + { + m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Artificial constructor called when the plugin is loaded /// Uses the obsolete mysql_connection.ini if connect string is empty. @@ -128,16 +142,16 @@ namespace OpenSim.Data.MySQL /// Returns the name of this DB provider /// /// A string containing the DB provider name - public string getName() + public string Name { - return "MySQL Logdata Interface"; + get { return "MySQL Logdata Interface";} } /// /// Closes the database provider /// /// do nothing - public void Close() + public void Dispose() { // Do nothing. } @@ -146,9 +160,9 @@ namespace OpenSim.Data.MySQL /// Returns the version of this DB provider /// /// A string containing the provider version - public string getVersion() + public string Version { - return "0.1"; + get { return "0.1"; } } } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index cf4bce3..89d0672 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -227,7 +227,7 @@ namespace OpenSim.Data.MySQL return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); + dllVersion.Revision); } /// -- cgit v1.1 From 0171e76246b2e889966b33fc1700a331d8f532db Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 18 Jul 2008 10:57:18 +0000 Subject: squashing further warnings. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 052c404..17cd6a1 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -166,7 +166,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = sql; - cmd.Parameters.Add("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); IDataReader r = cmd.ExecuteReader(); @@ -209,13 +209,13 @@ namespace OpenSim.Data.MySQL if(m_FieldMap[name].GetValue(es) is bool) { if((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.Add("?"+name, "1"); + cmd.Parameters.AddWithValue("?"+name, "1"); else - cmd.Parameters.Add("?"+name, "0"); + cmd.Parameters.AddWithValue("?"+name, "0"); } else { - cmd.Parameters.Add("?"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.AddWithValue("?"+name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -233,8 +233,8 @@ namespace OpenSim.Data.MySQL r.Close(); cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.Add("?RegionID", regionID.ToString()); - cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); // This will throw on dupe key try @@ -249,7 +249,7 @@ namespace OpenSim.Data.MySQL // cmd.Parameters.Clear(); cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.Add("?UUID", regionID.ToString()); + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); try { @@ -283,13 +283,13 @@ namespace OpenSim.Data.MySQL if(m_FieldMap[name].GetValue(es) is bool) { if((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.Add("?"+name, "1"); + cmd.Parameters.AddWithValue("?"+name, "1"); else - cmd.Parameters.Add("?"+name, "0"); + cmd.Parameters.AddWithValue("?"+name, "0"); } else { - cmd.Parameters.Add("?"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.AddWithValue("?"+name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -310,7 +310,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; - cmd.Parameters.Add("?EstateID", es.EstateID); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); IDataReader r = cmd.ExecuteReader(); @@ -336,7 +336,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; - cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); cmd.ExecuteNonQuery(); @@ -346,8 +346,8 @@ namespace OpenSim.Data.MySQL foreach(EstateBan b in es.EstateBans) { - cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); - cmd.Parameters.Add("?bannedUUID", b.bannedUUID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?bannedUUID", b.bannedUUID.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); @@ -361,7 +361,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; - cmd.Parameters.Add("?EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); cmd.ExecuteNonQuery(); @@ -371,8 +371,8 @@ namespace OpenSim.Data.MySQL foreach(LLUUID uuid in data) { - cmd.Parameters.Add("?EstateID", EstateID.ToString()); - cmd.Parameters.Add("?uuid", uuid.ToString()); + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); @@ -388,13 +388,13 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; - cmd.Parameters.Add("?EstateID", EstateID); + cmd.Parameters.AddWithValue("?EstateID", EstateID); IDataReader r = cmd.ExecuteReader(); while(r.Read()) { - EstateBan eb = new EstateBan(); + // EstateBan eb = new EstateBan(); LLUUID uuid = new LLUUID(); LLUUID.TryParse(r["uuid"].ToString(), out uuid); -- cgit v1.1 From bbd076544d18961af02ee43b5e0b3f2c3e3c1133 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 18 Jul 2008 19:32:05 +0000 Subject: Patch to fix saving of estate managers list loaded during migration. No longer teleports an agent home unless their root agent is being banned. Visual blocking is still in effect. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 17cd6a1..c0395a9 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -158,6 +158,7 @@ namespace OpenSim.Data.MySQL public EstateSettings LoadEstateSettings(LLUUID regionID) { EstateSettings es = new EstateSettings(); + es.OnSave += StoreEstateSettings; string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; @@ -258,6 +259,8 @@ namespace OpenSim.Data.MySQL catch (Exception) { } + + es.Save(); } LoadBanList(es); -- cgit v1.1 From a73d87ef1651ac1e935e0cfebed99282a69c3941 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 18 Jul 2008 20:50:47 +0000 Subject: Introduce a separate connection string for estates, which defaults to the one gi ven for the region datastore. Removes the flag to store prim inventories, which are now always stored. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index d1db064..74f15cb 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -92,9 +92,6 @@ namespace OpenSim.Data.MySQL private DataTable m_landAccessListTable; private DataTable m_regionSettingsTable; - /// Temporary attribute while this is experimental - private bool persistPrimInventories; - /*********************************************************************** * * Public Interface Functions @@ -105,13 +102,11 @@ namespace OpenSim.Data.MySQL /// see IRegionDataStore /// /// - /// - public void Initialise(string connectionString, bool persistPrimInventories) + public void Initialise(string connectionString) { m_connectionString = connectionString; m_dataSet = new DataSet(); - this.persistPrimInventories = persistPrimInventories; int passPosition = 0; int passEndPosition = 0; @@ -184,13 +179,10 @@ namespace OpenSim.Data.MySQL m_shapeDataAdapter.Fill(m_shapeTable); - if (persistPrimInventories) - { m_itemsTable = createItemsTable(); m_dataSet.Tables.Add(m_itemsTable); SetupItemsCommands(m_itemsDataAdapter, m_connection); m_itemsDataAdapter.Fill(m_itemsTable); - } m_terrainTable = createTerrainTable(); m_dataSet.Tables.Add(m_terrainTable); @@ -429,10 +421,7 @@ namespace OpenSim.Data.MySQL shapeRow.Delete(); } - if (persistPrimInventories) - { RemoveItems(uuid); - } // Remove prim row row.Delete(); @@ -527,11 +516,8 @@ namespace OpenSim.Data.MySQL createdObjects[new LLUUID(objID)].AddPart(prim); } - if (persistPrimInventories) - { LoadItems(prim); } - } catch (Exception e) { m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); @@ -827,10 +813,7 @@ namespace OpenSim.Data.MySQL m_primDataAdapter.Update(m_primTable); m_shapeDataAdapter.Update(m_shapeTable); - if (persistPrimInventories) - { m_itemsDataAdapter.Update(m_itemsTable); - } m_terrainDataAdapter.Update(m_terrainTable); m_landDataAdapter.Update(m_landTable); @@ -1812,9 +1795,6 @@ namespace OpenSim.Data.MySQL /// public void StorePrimInventory(LLUUID primID, ICollection items) { - if (!persistPrimInventories) - return; - m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); // For now, we're just going to crudely remove all the previous inventory items @@ -2241,7 +2221,6 @@ namespace OpenSim.Data.MySQL // pDa.Fill(tmpDS, "prims"); // sDa.Fill(tmpDS, "primshapes"); - // if (persistPrimInventories) // iDa.Fill(tmpDS, "primitems"); // tDa.Fill(tmpDS, "terrain"); -- cgit v1.1 From 19fd2230bfda7ff3419e97157be07adc49e933f5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 19 Jul 2008 09:35:48 +0000 Subject: Update svn properties. Fix some inconsistent newlines. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 46 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index c0395a9..f8641bc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -59,29 +59,29 @@ namespace OpenSim.Data.MySQL public void Initialise(string connectionString) { - m_connectionString = connectionString; - - int passPosition = 0; - int passEndPosition = 0; - string displayConnectionString = null; - - try - { // hide the password in the connection string - passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); - passPosition = m_connectionString.IndexOf("=", passPosition); - if (passPosition < m_connectionString.Length) - passPosition += 1; - passEndPosition = m_connectionString.IndexOf(";", passPosition); - - displayConnectionString = m_connectionString.Substring(0, passPosition); - displayConnectionString += "***"; - displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); - } - catch (Exception e) - { - m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); - } - + m_connectionString = connectionString; + + int passPosition = 0; + int passEndPosition = 0; + string displayConnectionString = null; + + try + { // hide the password in the connection string + passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); + passPosition = m_connectionString.IndexOf("=", passPosition); + if (passPosition < m_connectionString.Length) + passPosition += 1; + passEndPosition = m_connectionString.IndexOf(";", passPosition); + + displayConnectionString = m_connectionString.Substring(0, passPosition); + displayConnectionString += "***"; + displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); + } + catch (Exception e) + { + m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); + } + m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); -- cgit v1.1 From a0930aa80d6f43d1dc1b4de0ee5708888cc45a5a Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 23 Jul 2008 03:08:31 +0000 Subject: Thanks, sempuki, for a patch that moves control of Mono.Addins from source attributes to external XML files. Fix issues 1682 and 1786. --- OpenSim/Data/MySQL/MySQLGridData.cs | 5 ----- OpenSim/Data/MySQL/MySQLLogData.cs | 6 ------ 2 files changed, 11 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 8142c74..fee457a 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -33,18 +33,13 @@ using System.Security.Cryptography; using System.Text; using libsecondlife; using log4net; -using Mono.Addins; using OpenSim.Framework; -[assembly : Addin] -[assembly : AddinDependency("OpenSim.Data", "0.5")] - namespace OpenSim.Data.MySQL { /// /// A MySQL Interface for the Grid Server /// - [Extension("/OpenSim/GridDataStore")] public class MySQLGridData : GridDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index f11aec5..456cfd2 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -28,19 +28,13 @@ using System; using System.Reflection; using System.Collections.Generic; using log4net; -using Mono.Addins; using OpenSim.Framework; -// Only one attribute per assembly. See: *GridData.cs -// [assembly : Addin] -// [assembly : AddinDependency("OpenSim.Data", "0.5")] - namespace OpenSim.Data.MySQL { /// /// An interface to the log database for MySQL /// - [Extension("/OpenSim/GridLogData")] internal class MySQLLogData : ILogDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 80d8e2889e62d8900837d37a800a4eeaae5ffc5a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 23 Jul 2008 13:24:25 +0000 Subject: Update svn properties. Formatting cleanup. Remove a compiler warning. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index f8641bc..78d4446 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -101,8 +101,10 @@ namespace OpenSim.Data.MySQL BindingFlags.DeclaredOnly); foreach (FieldInfo f in m_Fields) - if(f.Name.Substring(0, 2) == "m_") + { + if (f.Name.Substring(0, 2) == "m_") m_FieldMap[f.Name.Substring(2)] = f; + } } private string[] FieldList @@ -171,14 +173,14 @@ namespace OpenSim.Data.MySQL IDataReader r = cmd.ExecuteReader(); - if(r.Read()) + if (r.Read()) { foreach (string name in FieldList) { - if(m_FieldMap[name].GetValue(es) is bool) + if (m_FieldMap[name].GetValue(es) is bool) { int v = Convert.ToInt32(r[name]); - if(v != 0) + if (v != 0) m_FieldMap[name].SetValue(es, true); else m_FieldMap[name].SetValue(es, false); @@ -207,9 +209,9 @@ namespace OpenSim.Data.MySQL foreach (string name in FieldList) { - if(m_FieldMap[name].GetValue(es) is bool) + if (m_FieldMap[name].GetValue(es) is bool) { - if((bool)m_FieldMap[name].GetValue(es)) + if ((bool)m_FieldMap[name].GetValue(es)) cmd.Parameters.AddWithValue("?"+name, "1"); else cmd.Parameters.AddWithValue("?"+name, "0"); @@ -283,9 +285,9 @@ namespace OpenSim.Data.MySQL foreach (string name in FieldList) { - if(m_FieldMap[name].GetValue(es) is bool) + if (m_FieldMap[name].GetValue(es) is bool) { - if((bool)m_FieldMap[name].GetValue(es)) + if ((bool)m_FieldMap[name].GetValue(es)) cmd.Parameters.AddWithValue("?"+name, "1"); else cmd.Parameters.AddWithValue("?"+name, "0"); @@ -317,7 +319,7 @@ namespace OpenSim.Data.MySQL IDataReader r = cmd.ExecuteReader(); - while(r.Read()) + while (r.Read()) { EstateBan eb = new EstateBan(); @@ -347,7 +349,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )"; - foreach(EstateBan b in es.EstateBans) + foreach (EstateBan b in es.EstateBans) { cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); cmd.Parameters.AddWithValue("?bannedUUID", b.bannedUUID.ToString()); @@ -372,7 +374,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; - foreach(LLUUID uuid in data) + foreach (LLUUID uuid in data) { cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); @@ -395,7 +397,7 @@ namespace OpenSim.Data.MySQL IDataReader r = cmd.ExecuteReader(); - while(r.Read()) + while (r.Read()) { // EstateBan eb = new EstateBan(); -- cgit v1.1 From 090159defc731fca252b2b3520364712760f0f4e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Jul 2008 15:50:32 +0000 Subject: refactored LandData to use properties, and cleaned up the naming on the properties a bit to be more consistant with other objects (having things like .Name .Description, etc). --- OpenSim/Data/MySQL/MySQLDataStore.cs | 140 +++++++++++++++++------------------ 1 file changed, 70 insertions(+), 70 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 74f15cb..2ace4b1 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -692,7 +692,7 @@ namespace OpenSim.Data.MySQL DataTable land = m_landTable; DataTable landaccesslist = m_landAccessListTable; - DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.globalID)); + DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.GlobalID)); if (landRow == null) { landRow = land.NewRow(); @@ -708,14 +708,14 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) { - cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); + cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.GlobalID))); cmd.ExecuteNonQuery(); } - foreach (ParcelManager.ParcelAccessEntry entry in parcel.landData.parcelAccessList) + foreach (ParcelManager.ParcelAccessEntry entry in parcel.landData.ParcelAccessList) { DataRow newAccessRow = landaccesslist.NewRow(); - fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID); + fillLandAccessRow(newAccessRow, entry, parcel.landData.GlobalID); landaccesslist.Rows.Add(newAccessRow); } @@ -787,11 +787,11 @@ namespace OpenSim.Data.MySQL foreach (DataRow rawDataLand in rawDataForRegion) { LandData newLand = buildLandData(rawDataLand); - string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.globalID) + "'"; + string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.GlobalID) + "'"; DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) { - newLand.parcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); + newLand.ParcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); } landDataForRegion.Add(newLand); @@ -1319,59 +1319,59 @@ namespace OpenSim.Data.MySQL { LandData newData = new LandData(); - newData.globalID = new LLUUID((String) row["UUID"]); - newData.localID = Convert.ToInt32(row["LocalLandID"]); + newData.GlobalID = new LLUUID((String) row["UUID"]); + newData.LocalID = Convert.ToInt32(row["LocalLandID"]); // Bitmap is a byte[512] - newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; - - newData.landName = (String) row["Name"]; - newData.landDesc = (String) row["Description"]; - newData.ownerID = (String) row["OwnerUUID"]; - newData.isGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); - newData.area = Convert.ToInt32(row["Area"]); - newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented - newData.category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + newData.Bitmap = (Byte[]) row["Bitmap"]; + + newData.Name = (String) row["Name"]; + newData.Description = (String) row["Description"]; + newData.OwnerID = (String) row["OwnerUUID"]; + newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); + newData.Area = Convert.ToInt32(row["Area"]); + newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented + newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory - newData.claimDate = Convert.ToInt32(row["ClaimDate"]); - newData.claimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.groupID = new LLUUID((String) row["GroupUUID"]); - newData.salePrice = Convert.ToInt32(row["SalePrice"]); - newData.landStatus = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); + newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.GroupID = new LLUUID((String) row["GroupUUID"]); + newData.SalePrice = Convert.ToInt32(row["SalePrice"]); + newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus - newData.landFlags = Convert.ToUInt32(row["LandFlags"]); - newData.landingType = Convert.ToByte(row["LandingType"]); - newData.mediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.mediaID = new LLUUID((String) row["MediaTextureUUID"]); - newData.mediaURL = (String) row["MediaURL"]; - newData.musicURL = (String) row["MusicURL"]; - newData.passHours = Convert.ToSingle(row["PassHours"]); - newData.passPrice = Convert.ToInt32(row["PassPrice"]); + newData.Flags = Convert.ToUInt32(row["LandFlags"]); + newData.LandingType = Convert.ToByte(row["LandingType"]); + newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); + newData.MediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.MediaURL = (String) row["MediaURL"]; + newData.MusicURL = (String) row["MusicURL"]; + newData.PassHours = Convert.ToSingle(row["PassHours"]); + newData.PassPrice = Convert.ToInt32(row["PassPrice"]); LLUUID authedbuyer = LLUUID.Zero; LLUUID snapshotID = LLUUID.Zero; Helpers.TryParse((string)row["AuthBuyerID"], out authedbuyer); Helpers.TryParse((string)row["SnapshotUUID"], out snapshotID); - newData.authBuyerID = authedbuyer; - newData.snapshotID = snapshotID; + newData.AuthBuyerID = authedbuyer; + newData.SnapshotID = snapshotID; try { - newData.userLocation = + newData.UserLocation = new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); - newData.userLookAt = + newData.UserLookAt = new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), Convert.ToSingle(row["UserLookAtZ"])); } catch (InvalidCastException) { - newData.userLocation = LLVector3.Zero; - newData.userLookAt = LLVector3.Zero; - m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.landName); + newData.UserLocation = LLVector3.Zero; + newData.UserLookAt = LLVector3.Zero; + m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); } - newData.parcelAccessList = new List(); + newData.ParcelAccessList = new List(); return newData; } @@ -1576,41 +1576,41 @@ namespace OpenSim.Data.MySQL /// private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) { - row["UUID"] = Util.ToRawUuidString(land.globalID); + row["UUID"] = Util.ToRawUuidString(land.GlobalID); row["RegionUUID"] = Util.ToRawUuidString(regionUUID); - row["LocalLandID"] = land.localID; + row["LocalLandID"] = land.LocalID; // Bitmap is a byte[512] - row["Bitmap"] = land.landBitmapByteArray; - - row["Name"] = land.landName; - row["Description"] = land.landDesc; - row["OwnerUUID"] = Util.ToRawUuidString(land.ownerID); - row["IsGroupOwned"] = land.isGroupOwned; - row["Area"] = land.area; - row["AuctionID"] = land.auctionID; //Unemplemented - row["Category"] = land.category; //Enum libsecondlife.Parcel.ParcelCategory - row["ClaimDate"] = land.claimDate; - row["ClaimPrice"] = land.claimPrice; - row["GroupUUID"] = Util.ToRawUuidString(land.groupID); - row["SalePrice"] = land.salePrice; - row["LandStatus"] = land.landStatus; //Enum. libsecondlife.Parcel.ParcelStatus - row["LandFlags"] = land.landFlags; - row["LandingType"] = land.landingType; - row["MediaAutoScale"] = land.mediaAutoScale; - row["MediaTextureUUID"] = Util.ToRawUuidString(land.mediaID); - row["MediaURL"] = land.mediaURL; - row["MusicURL"] = land.musicURL; - row["PassHours"] = land.passHours; - row["PassPrice"] = land.passPrice; - row["SnapshotUUID"] = Util.ToRawUuidString(land.snapshotID); - row["UserLocationX"] = land.userLocation.X; - row["UserLocationY"] = land.userLocation.Y; - row["UserLocationZ"] = land.userLocation.Z; - row["UserLookAtX"] = land.userLookAt.X; - row["UserLookAtY"] = land.userLookAt.Y; - row["UserLookAtZ"] = land.userLookAt.Z; - row["AuthBuyerID"] = land.authBuyerID; + row["Bitmap"] = land.Bitmap; + + row["Name"] = land.Name; + row["Description"] = land.Description; + row["OwnerUUID"] = Util.ToRawUuidString(land.OwnerID); + row["IsGroupOwned"] = land.IsGroupOwned; + row["Area"] = land.Area; + row["AuctionID"] = land.AuctionID; //Unemplemented + row["Category"] = land.Category; //Enum libsecondlife.Parcel.ParcelCategory + row["ClaimDate"] = land.ClaimDate; + row["ClaimPrice"] = land.ClaimPrice; + row["GroupUUID"] = Util.ToRawUuidString(land.GroupID); + row["SalePrice"] = land.SalePrice; + row["LandStatus"] = land.Status; //Enum. libsecondlife.Parcel.ParcelStatus + row["LandFlags"] = land.Flags; + row["LandingType"] = land.LandingType; + row["MediaAutoScale"] = land.MediaAutoScale; + row["MediaTextureUUID"] = Util.ToRawUuidString(land.MediaID); + row["MediaURL"] = land.MediaURL; + row["MusicURL"] = land.MusicURL; + row["PassHours"] = land.PassHours; + row["PassPrice"] = land.PassPrice; + row["SnapshotUUID"] = Util.ToRawUuidString(land.SnapshotID); + row["UserLocationX"] = land.UserLocation.X; + row["UserLocationY"] = land.UserLocation.Y; + row["UserLocationZ"] = land.UserLocation.Z; + row["UserLookAtX"] = land.UserLookAt.X; + row["UserLookAtY"] = land.UserLookAt.Y; + row["UserLookAtZ"] = land.UserLookAt.Z; + row["AuthBuyerID"] = land.AuthBuyerID; } /// -- cgit v1.1 From cf317f5c3352f066fd61a0fa5de19c93947be22c Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Jul 2008 22:14:29 +0000 Subject: refactor TaskInventoryItem Mask -> Permissions to be consistant with how things are stored in the db. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 2ace4b1..7482df3 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1258,11 +1258,11 @@ namespace OpenSim.Data.MySQL taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); taskItem.GroupID = new LLUUID((String)row["groupID"]); - taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]); - taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]); - taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); - taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); + taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); + taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); taskItem.Flags = Convert.ToUInt32(row["flags"]); return taskItem; @@ -1519,11 +1519,11 @@ namespace OpenSim.Data.MySQL row["ownerID"] = taskItem.OwnerID; row["lastOwnerID"] = taskItem.LastOwnerID; row["groupID"] = taskItem.GroupID; - row["nextPermissions"] = taskItem.NextOwnerMask; - row["currentPermissions"] = taskItem.OwnerMask; - row["basePermissions"] = taskItem.BaseMask; - row["everyonePermissions"] = taskItem.EveryoneMask; - row["groupPermissions"] = taskItem.GroupMask; + row["nextPermissions"] = taskItem.NextPermissions; + row["currentPermissions"] = taskItem.CurrentPermissions; + row["basePermissions"] = taskItem.BasePermissions; + row["everyonePermissions"] = taskItem.EveryonePermissions; + row["groupPermissions"] = taskItem.GroupPermissions; row["flags"] = taskItem.Flags; } -- cgit v1.1 From 5998fb712a7079c5ebd12223d43a91f18925372e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 25 Jul 2008 06:17:43 +0000 Subject: Patch #9155 (Mantis #1793) Fix a regression that caused the region settings not to save. Still no SQLite support for region settings. MySQL now functional. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 7482df3..8f3d904 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -735,6 +735,7 @@ namespace OpenSim.Data.MySQL { RegionSettings rs = new RegionSettings(); rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; StoreRegionSettings(rs); -- cgit v1.1 From 1321bd25b8590d3a6fc9750a2275df100db2e532 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 26 Jul 2008 18:03:50 +0000 Subject: Fix Mantis #1830 Makes region settings save on second and subsequent sim restarts after upgrading. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 8f3d904..5bb8f72 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1272,6 +1272,7 @@ namespace OpenSim.Data.MySQL private static RegionSettings buildRegionSettings(DataRow row) { RegionSettings newSettings = new RegionSettings(); + rs.OnSave += StoreRegionSettings; newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); -- cgit v1.1 From 3b1efa4348088a55819c34dd6356ef3c948f6432 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 26 Jul 2008 18:46:04 +0000 Subject: Re-Fix the fix --- OpenSim/Data/MySQL/MySQLDataStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 5bb8f72..af3f02a 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -1272,7 +1272,7 @@ namespace OpenSim.Data.MySQL private static RegionSettings buildRegionSettings(DataRow row) { RegionSettings newSettings = new RegionSettings(); - rs.OnSave += StoreRegionSettings; + newSettings.OnSave += StoreRegionSettings; newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); -- cgit v1.1 From 2a1bc318b0db431f88a45735e58f15aad7316962 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 26 Jul 2008 18:54:59 +0000 Subject: The hazards if unclean sourc trees. Yours truly got bitten this time. Re-fix the re-fix from a clean build. This makes the region based settings work as advertised --- OpenSim/Data/MySQL/MySQLDataStore.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index af3f02a..07f4c10 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -743,7 +743,10 @@ namespace OpenSim.Data.MySQL } DataRow row = rawsettings[0]; - return buildRegionSettings(row); + RegionSettings newSettings = buildRegionSettings(row); + newSettings.OnSave += StoreRegionSettings; + + return newSettings; } } @@ -1272,7 +1275,6 @@ namespace OpenSim.Data.MySQL private static RegionSettings buildRegionSettings(DataRow row) { RegionSettings newSettings = new RegionSettings(); - newSettings.OnSave += StoreRegionSettings; newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); -- cgit v1.1 From 2270b252656146d9d74b84665a7ace6c3139db30 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 31 Jul 2008 09:24:28 +0000 Subject: Thanks, sempuki, for a patch that moves all Grid Server's plugins to PluginLoader. Fix issue 1871. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 20 +++++++++++++------- OpenSim/Data/MySQL/MySQLUserData.cs | 23 ++++++++++++++++------- 4 files changed, 31 insertions(+), 16 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 9284ba9..cec736a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL override public void Dispose() { } - #region IAssetProvider Members + #region IAssetProviderPlugin Members /// /// diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index fee457a..4cddbe5 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -51,7 +51,7 @@ namespace OpenSim.Data.MySQL override public void Initialise() { - m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); + m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException (Name); } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 5bde40a..0fb49c1 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL /// /// A MySQL interface for the inventory server /// - public class MySQLInventoryData : IInventoryData + public class MySQLInventoryData : IInventoryDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -48,6 +48,12 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + public void Initialise() + { + m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialises Inventory interface /// @@ -183,16 +189,16 @@ namespace OpenSim.Data.MySQL /// The name of this DB provider /// /// Name of DB provider - public string getName() + public string Name { - return "MySQL Inventory Data Interface"; + get { return "MySQL Inventory Data Interface"; } } /// /// Closes this DB provider /// /// do nothing - public void Close() + public void Dispose() { // Do nothing. } @@ -201,9 +207,9 @@ namespace OpenSim.Data.MySQL /// Returns the version of this DB provider /// /// A string containing the DB provider version - public string getVersion() + public string Version { - return database.getVersion(); + get { return database.getVersion(); } } /// @@ -692,7 +698,7 @@ namespace OpenSim.Data.MySQL /// - /// See IInventoryData + /// See IInventoryDataPlugin /// /// /// diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 11d9c26..d8830de 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -55,6 +55,12 @@ namespace OpenSim.Data.MySQL private string m_appearanceTableName = "avatarappearance"; private string m_connectString; + public override void Initialise() + { + m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!"); + throw new PluginNotInitialisedException (Name); + } + /// /// Initialise User Interface /// Loads and initialises the MySQL storage plugin @@ -120,6 +126,9 @@ namespace OpenSim.Data.MySQL m.Update(); } + public override void Dispose () { } + + #region Test and initialization code /// @@ -252,7 +261,7 @@ namespace OpenSim.Data.MySQL UserProfileData row = database.readUserRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return row; } @@ -398,7 +407,7 @@ namespace OpenSim.Data.MySQL Lfli.Add(fli); } - reader.Close(); + reader.Dispose(); result.Dispose(); } } @@ -450,7 +459,7 @@ namespace OpenSim.Data.MySQL user.lastName = (string) reader["lastname"]; returnlist.Add(user); } - reader.Close(); + reader.Dispose(); result.Dispose(); } } @@ -484,7 +493,7 @@ namespace OpenSim.Data.MySQL user.lastName = (string) reader["lastname"]; returnlist.Add(user); } - reader.Close(); + reader.Dispose(); result.Dispose(); } } @@ -517,7 +526,7 @@ namespace OpenSim.Data.MySQL UserProfileData row = database.readUserRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return row; @@ -603,7 +612,7 @@ namespace OpenSim.Data.MySQL UserAgentData row = database.readAgentRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return row; @@ -725,7 +734,7 @@ namespace OpenSim.Data.MySQL AvatarAppearance appearance = database.readAppearanceRow(reader); - reader.Close(); + reader.Dispose(); result.Dispose(); return appearance; -- cgit v1.1 From 15669281faab727cdf79ec1cee24d9b20fae8cbd Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 31 Jul 2008 23:53:24 +0000 Subject: Apply updated patch from issue 1871. Thanks sempuki. --- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index d8830de..131823a 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -244,7 +244,7 @@ namespace OpenSim.Data.MySQL #endregion - // see IUserData + // see IUserDataPlugin override public UserProfileData GetUserByName(string user, string last) { try @@ -508,7 +508,7 @@ namespace OpenSim.Data.MySQL } /// - /// See IUserData + /// See IUserDataPlugin /// /// User UUID /// User profile data -- cgit v1.1 From 43f3b9ad7b24cbd4c020c36e1cf5133e09a66c8f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 1 Aug 2008 02:14:34 +0000 Subject: Patch #8 in the estate series. Introduces the concept of an estate owner (alongside the master avatar) and provides storage fo the abuse email address. No user functionality yet. This patch includes a migration. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 78d4446..e843457 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -185,6 +185,13 @@ namespace OpenSim.Data.MySQL else m_FieldMap[name].SetValue(es, false); } + else if(m_FieldMap[name].GetValue(es) is libsecondlife.LLUUID) + { + LLUUID uuid = LLUUID.Zero; + + LLUUID.TryParse(r[name].ToString(), out uuid); + m_FieldMap[name].SetValue(es, uuid); + } else { m_FieldMap[name].SetValue(es, r[name]); -- cgit v1.1 From c9b39972cadd23ccaf526bd28ce38abc6ed0c5de Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 1 Aug 2008 02:54:28 +0000 Subject: Add the missing migration files :/ --- OpenSim/Data/MySQL/Resources/014_RegionStore.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/014_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/014_RegionStore.sql b/OpenSim/Data/MySQL/Resources/014_RegionStore.sql new file mode 100644 index 0000000..788fd63 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/014_RegionStore.sql @@ -0,0 +1,8 @@ +begin; + +alter table estate_settings add column AbuseEmail varchar(255) not null; + +alter table estate_settings add column EstateOwner varchar(36) not null; + +commit; + -- cgit v1.1 From 12c5bfa3e0f42232035d74b3768ea98211dc5e18 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 1 Aug 2008 21:08:00 +0000 Subject: Estate series, patch 9 (#9157) Adds the new access semantics and the new flag (allow only age verified) Plumbs in the abuse email address from sim to viewer. The other way around, libomv appears to be lacking support for the data field in the packet. Includes a migration, run prebuild! --- OpenSim/Data/MySQL/Resources/015_RegionStore.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/015_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/015_RegionStore.sql b/OpenSim/Data/MySQL/Resources/015_RegionStore.sql new file mode 100644 index 0000000..6d4f9f3 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/015_RegionStore.sql @@ -0,0 +1,6 @@ +begin; + +alter table estate_settings add column DenyMinors tinyint not null; + +commit; + -- cgit v1.1 From d367f0bf0ccd3ea83c727a6459171b34170ed5f6 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 6 Aug 2008 01:20:31 +0000 Subject: Thanks, zaki, for a patch that embeds plugin manifest files into plugin dlls. Fix issue 1876. --- .../MySQL/Resources/OpenSim.Data.MySQL.addin.xml | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml new file mode 100644 index 0000000..9e99547 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1 From 0718aa0b7fd7cb3bb42d36b37f79d8d6cfc725bc Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 7 Aug 2008 12:55:46 +0000 Subject: Minor formatting cleanup. --- OpenSim/Data/MySQL/MySQLDataStore.cs | 4 ++-- OpenSim/Data/MySQL/MySQLEstateData.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 07f4c10..70b6d3c 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -744,9 +744,9 @@ namespace OpenSim.Data.MySQL DataRow row = rawsettings[0]; RegionSettings newSettings = buildRegionSettings(row); - newSettings.OnSave += StoreRegionSettings; + newSettings.OnSave += StoreRegionSettings; - return newSettings; + return newSettings; } } diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e843457..8991e02 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -185,7 +185,7 @@ namespace OpenSim.Data.MySQL else m_FieldMap[name].SetValue(es, false); } - else if(m_FieldMap[name].GetValue(es) is libsecondlife.LLUUID) + else if (m_FieldMap[name].GetValue(es) is libsecondlife.LLUUID) { LLUUID uuid = LLUUID.Zero; -- cgit v1.1 From 54af3b4f4dd8a2885dcc57904f04d603bb444f24 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 10 Aug 2008 16:44:25 +0000 Subject: Mantis#1903. Thank you kindly, CMickeyb for a patch that: patch attached replaces the tree walk algorithm used to build the folder hierarchy with a single database query. That is, we replace 1 database query per folder with 1 query for the root folder's properties and 1 query to retrieve the entire collection of folders for a user. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 113 +++++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 0fb49c1..59d7858 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -704,13 +704,116 @@ namespace OpenSim.Data.MySQL /// public List getFolderHierarchy(LLUUID parentID) { - List folders = new List(); - getInventoryFolders(ref folders, parentID); + /* Note: There are subtle changes between this implementation of getFolderHierarchy and the previous one + * - We will only need to hit the database twice instead of n times. + * - We assume the database is well-formed - no stranded/dangling folders, all folders in heirarchy owned + * by the same person, each user only has 1 inventory heirarchy + * - The returned list is not ordered, instead of breadth-first ordered + There are basically 2 usage cases for getFolderHeirarchy: + 1) Getting the user's entire inventory heirarchy when they log in + 2) Finding a subfolder heirarchy to delete when emptying the trash. + This implementation will pull all inventory folders from the database, and then prune away any folder that + is not part of the requested sub-heirarchy. The theory is that it is cheaper to make 1 request from the + database than to make n requests. This pays off only if requested heirarchy is large. + By making this choice, we are making the worst case better at the cost of making the best case worse. + This way is generally better because we don't have to rebuild the connection/sql query per subfolder, + even if we end up getting more data from the SQL server than we need. + - Francis + */ + try + { + List folders = new List(); + Dictionary> hashtable + = new Dictionary>(); ; + List parentFolder = new List(); + lock (database) + { + MySqlCommand result; + MySqlDataReader reader; + bool buildResultsFromHashTable = false; + + database.CheckConnection(); - for (int i = 0; i < folders.Count; i++) - getInventoryFolders(ref folders, folders[i].ID); + /* Fetch the parent folder from the database to determine the agent ID, and if + * we're querying the root of the inventory folder tree */ + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) // Should be at most 1 result + parentFolder.Add(readInventoryFolder(reader)); + reader.Close(); + result.Dispose(); - return folders; + if (parentFolder.Count >= 1) // No result means parent folder does not exist + { + if (parentFolder[0].ParentID == LLUUID.Zero) // We are querying the root folder + { + /* Get all of the agent's folders from the database, put them in a list and return it */ + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) + { + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list + folders.Add(curFolder); + } + reader.Close(); + result.Dispose(); + } // if we are querying the root folder + else // else we are querying a subtree of the inventory folder tree + { + /* Get all of the agent's folders from the database, put them all in a hash table + * indexed by their parent ID */ + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) + { + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling + hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list + else // else current folder has no known (yet) siblings + { + List siblingList = new List(); + siblingList.Add(curFolder); + // Current folder has no known (yet) siblings + hashtable.Add(curFolder.ParentID, siblingList); + } + } // while more items to read from the database + reader.Close(); + result.Dispose(); + + // Set flag so we know we need to build the results from the hash table after + // we unlock the database + buildResultsFromHashTable = true; + + } // else we are querying a subtree of the inventory folder tree + } // if folder parentID exists + + if (buildResultsFromHashTable) + { + /* We have all of the user's folders stored in a hash table indexed by their parent ID + * and we need to return the requested subtree. We will build the requested subtree + * by performing a breadth-first-search on the hash table */ + if (hashtable.ContainsKey(parentID)) + folders.AddRange(hashtable[parentID]); + for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static + if (hashtable.ContainsKey(folders[i].ID)) + folders.AddRange(hashtable[folders[i].ID]); + } + } // lock(database) + return folders; + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } } /// -- cgit v1.1 From f894f5d87b7f267e56436e687d0285f890a15b60 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 12 Aug 2008 00:08:41 +0000 Subject: Minor formatting cleanup. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 59d7858..dd4d804 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -805,7 +805,7 @@ namespace OpenSim.Data.MySQL if (hashtable.ContainsKey(folders[i].ID)) folders.AddRange(hashtable[folders[i].ID]); } - } // lock(database) + } // lock (database) return folders; } catch (Exception e) -- cgit v1.1 From e3157e61aa50d057b4345cb9d49c973afeb26b15 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 14 Aug 2008 00:04:37 +0000 Subject: Mantis #1946 Thank you, HomerHorwitz, for a patch that corrects and improves TP to landmark and home position handling. --- OpenSim/Data/MySQL/MySQLManager.cs | 10 ++++++++-- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 89d0672..297b1a7 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -538,6 +538,10 @@ namespace OpenSim.Data.MySQL Convert.ToSingle(reader["homeLookAtY"].ToString()), Convert.ToSingle(reader["homeLookAtZ"].ToString())); + LLUUID regionID = LLUUID.Zero; + LLUUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero + retval.HomeRegionID = regionID; + retval.Created = Convert.ToInt32(reader["created"].ToString()); retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); @@ -583,6 +587,7 @@ namespace OpenSim.Data.MySQL LLUUID.TryParse((string)reader["webLoginKey"], out tmp); retval.WebLoginKey = tmp; } + } else { @@ -806,7 +811,7 @@ namespace OpenSim.Data.MySQL /// UUID for weblogin Key /// Success? public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, - string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + string passwordSalt, UInt64 homeRegion, LLUUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, @@ -814,7 +819,7 @@ namespace OpenSim.Data.MySQL { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; - sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , "; + sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , "; sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; @@ -831,6 +836,7 @@ namespace OpenSim.Data.MySQL parameters["?passwordHash"] = passwordHash.ToString(); parameters["?passwordSalt"] = passwordSalt.ToString(); parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegionID"] = homeRegionID.ToString(); parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationY"] = homeLocY.ToString(); parameters["?homeLocationZ"] = homeLocZ.ToString(); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 131823a..d7bf2a8 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -682,7 +682,7 @@ namespace OpenSim.Data.MySQL lock (database) { database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); -- cgit v1.1 From 17715da311797d9c538756c996c8add9403a99c5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 14 Aug 2008 11:15:11 +0000 Subject: Add the UserStore migrations to the TP fixes patch --- OpenSim/Data/MySQL/Resources/002_UserStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/002_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_UserStore.sql b/OpenSim/Data/MySQL/Resources/002_UserStore.sql new file mode 100644 index 0000000..393cea0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE users add homeRegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; -- cgit v1.1 From 7161689a97edcdeceee3d3eeeaee7eadc4e06a89 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 14 Aug 2008 19:59:32 +0000 Subject: Adds UserFlags and GodLevel to the user data store and plumbs then in. This will have no effect unless both the UGAI and the region are this revision or later --- OpenSim/Data/MySQL/MySQLManager.cs | 15 ++++++++++++--- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Resources/003_UserStore.sql | 6 ++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/003_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 297b1a7..5e9e259 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -587,6 +587,9 @@ namespace OpenSim.Data.MySQL LLUUID.TryParse((string)reader["webLoginKey"], out tmp); retval.WebLoginKey = tmp; } + + retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); + retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); } else @@ -728,14 +731,14 @@ namespace OpenSim.Data.MySQL "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; - sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`) VALUES "; + sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`) VALUES "; sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; - sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey)"; + sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel)"; Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); @@ -761,6 +764,9 @@ namespace OpenSim.Data.MySQL parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = string.Empty; + parameters["?userFlags"] = "0"; + parameters["?godLevel"] = "0"; + bool returnval = false; @@ -815,7 +821,7 @@ namespace OpenSim.Data.MySQL float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel) { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; @@ -827,6 +833,7 @@ namespace OpenSim.Data.MySQL sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , "; sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; + sql += "`userFlags` = ?userFlags , `godLevel` = ?godLevel , "; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; Dictionary parameters = new Dictionary(); @@ -854,6 +861,8 @@ namespace OpenSim.Data.MySQL parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); + parameters["?userFlags"] = userFlags.ToString(); + parameters["?godLevel"] = userFlags.ToString(); bool returnval = false; try diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index d7bf2a8..b7f4cbd 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -685,7 +685,7 @@ namespace OpenSim.Data.MySQL user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel); } return true; diff --git a/OpenSim/Data/MySQL/Resources/003_UserStore.sql b/OpenSim/Data/MySQL/Resources/003_UserStore.sql new file mode 100644 index 0000000..6f890ee --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_UserStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users add userFlags integer NOT NULL default 0; +ALTER TABLE users add godLevel integer NOT NULL default 0; + +COMMIT; -- cgit v1.1 From 3e7e0c8ced8967e7044ffdcaf32325835b6aa6c6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 15 Aug 2008 14:33:43 +0000 Subject: Small fox in the database, god level was being overwritten with the user flags value --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 5e9e259..d2b436c 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -862,7 +862,7 @@ namespace OpenSim.Data.MySQL parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); parameters["?userFlags"] = userFlags.ToString(); - parameters["?godLevel"] = userFlags.ToString(); + parameters["?godLevel"] = godLevel.ToString(); bool returnval = false; try -- cgit v1.1 From 04488d9d3819fd16502a095771d1513af02b7a93 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 15 Aug 2008 22:49:26 +0000 Subject: Plumb in the partner and the account title fields for profile info. --- OpenSim/Data/MySQL/MySQLManager.cs | 27 ++++++++++++++++++++++---- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Resources/004_UserStore.sql | 6 ++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/004_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index d2b436c..58599a8 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -590,7 +590,21 @@ namespace OpenSim.Data.MySQL retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); - + if (reader.IsDBNull(reader.GetOrdinal("customType"))) + retval.CustomType = ""; + else + retval.CustomType = reader["customType"].ToString(); + + if (reader.IsDBNull(reader.GetOrdinal("partner"))) + { + retval.Partner = LLUUID.Zero; + } + else + { + LLUUID tmp; + LLUUID.TryParse((string)reader["partner"], out tmp); + retval.Partner = tmp; + } } else { @@ -731,14 +745,14 @@ namespace OpenSim.Data.MySQL "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; - sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`) VALUES "; + sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES "; sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; - sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel)"; + sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); @@ -766,6 +780,8 @@ namespace OpenSim.Data.MySQL parameters["?webLoginKey"] = string.Empty; parameters["?userFlags"] = "0"; parameters["?godLevel"] = "0"; + parameters["?customType"] = ""; + parameters["?partner"] = ""; bool returnval = false; @@ -821,7 +837,7 @@ namespace OpenSim.Data.MySQL float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel) + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel, string customType, LLUUID partner) { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; @@ -834,6 +850,7 @@ namespace OpenSim.Data.MySQL sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; sql += "`userFlags` = ?userFlags , `godLevel` = ?godLevel , "; + sql += "`customType` = ?customType , `partner` = ?partner , "; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; Dictionary parameters = new Dictionary(); @@ -863,6 +880,8 @@ namespace OpenSim.Data.MySQL parameters["?webLoginKey"] = webLoginKey.ToString(); parameters["?userFlags"] = userFlags.ToString(); parameters["?godLevel"] = godLevel.ToString(); + parameters["?customType"] = customType.ToString(); + parameters["?partner"] = partner.ToString(); bool returnval = false; try diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index b7f4cbd..f77d947 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -685,7 +685,7 @@ namespace OpenSim.Data.MySQL user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel); + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } return true; diff --git a/OpenSim/Data/MySQL/Resources/004_UserStore.sql b/OpenSim/Data/MySQL/Resources/004_UserStore.sql new file mode 100644 index 0000000..03142af --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_UserStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE users add customType varchar(32) not null default ''; +ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; -- cgit v1.1 From d7f2c454f1f00f3d3d98b880a9c7cd18181112ae Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 16 Aug 2008 20:50:43 +0000 Subject: * Rename *DataStore classes to *RegionData to align with SQLite --- OpenSim/Data/MySQL/MySQLDataStore.cs | 2360 --------------------------------- OpenSim/Data/MySQL/MySQLRegionData.cs | 2360 +++++++++++++++++++++++++++++++++ 2 files changed, 2360 insertions(+), 2360 deletions(-) delete mode 100644 OpenSim/Data/MySQL/MySQLDataStore.cs create mode 100644 OpenSim/Data/MySQL/MySQLRegionData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs deleted file mode 100644 index 70b6d3c..0000000 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ /dev/null @@ -1,2360 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Reflection; -using System.Threading; -using libsecondlife; -using log4net; -using MySql.Data.MySqlClient; -using OpenSim.Framework; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Data.MySQL -{ - /// - /// A MySQL Interface for the Region Server - /// - public class MySQLDataStore : IRegionDataStore - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private const string m_primSelect = "select * from prims"; - private const string m_shapeSelect = "select * from primshapes"; - private const string m_itemsSelect = "select * from primitems"; - private const string m_terrainSelect = "select * from terrain limit 1"; - private const string m_landSelect = "select * from land"; - private const string m_landAccessListSelect = "select * from landaccesslist"; - private const string m_regionSettingsSelect = "select * from regionsettings"; - private const string m_waitTimeoutSelect = "select @@wait_timeout"; - - private MySqlConnection m_connection; - private string m_connectionString; - - /// - /// Wait timeout for our connection in ticks. - /// - private long m_waitTimeout; - - /// - /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long - /// running database operations. - /// - private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; - - /// - /// Holds the last tick time that the connection was used. - /// - private long m_lastConnectionUse; - - private DataSet m_dataSet; - private MySqlDataAdapter m_primDataAdapter; - private MySqlDataAdapter m_shapeDataAdapter; - private MySqlDataAdapter m_itemsDataAdapter; - private MySqlDataAdapter m_terrainDataAdapter; - private MySqlDataAdapter m_landDataAdapter; - private MySqlDataAdapter m_landAccessListDataAdapter; - private MySqlDataAdapter m_regionSettingsDataAdapter; - - private DataTable m_primTable; - private DataTable m_shapeTable; - private DataTable m_itemsTable; - private DataTable m_terrainTable; - private DataTable m_landTable; - private DataTable m_landAccessListTable; - private DataTable m_regionSettingsTable; - - /*********************************************************************** - * - * Public Interface Functions - * - **********************************************************************/ - - /// - /// see IRegionDataStore - /// - /// - public void Initialise(string connectionString) - { - m_connectionString = connectionString; - - m_dataSet = new DataSet(); - - int passPosition = 0; - int passEndPosition = 0; - string displayConnectionString = null; - - try - { // hide the password in the connection string - passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); - passPosition = m_connectionString.IndexOf("=", passPosition); - if (passPosition < m_connectionString.Length) - passPosition += 1; - passEndPosition = m_connectionString.IndexOf(";", passPosition); - - displayConnectionString = m_connectionString.Substring(0, passPosition); - displayConnectionString += "***"; - displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); - } - catch (Exception e ) - { - m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); - } - - m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); - - GetWaitTimeout(); - - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_connection, assem, "RegionStore"); - - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m_connection, m); - - m.Update(); - - MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); - m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); - - MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, m_connection); - m_shapeDataAdapter = new MySqlDataAdapter(shapeSelectCmd); - - MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, m_connection); - m_itemsDataAdapter = new MySqlDataAdapter(itemsSelectCmd); - - MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, m_connection); - m_terrainDataAdapter = new MySqlDataAdapter(terrainSelectCmd); - - MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, m_connection); - m_landDataAdapter = new MySqlDataAdapter(landSelectCmd); - - MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); - m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); - - MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); - m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); - - lock (m_dataSet) - { - m_primTable = createPrimTable(); - m_dataSet.Tables.Add(m_primTable); - SetupPrimCommands(m_primDataAdapter, m_connection); - m_primDataAdapter.Fill(m_primTable); - - m_shapeTable = createShapeTable(); - m_dataSet.Tables.Add(m_shapeTable); - SetupShapeCommands(m_shapeDataAdapter, m_connection); - m_shapeDataAdapter.Fill(m_shapeTable); - - - m_itemsTable = createItemsTable(); - m_dataSet.Tables.Add(m_itemsTable); - SetupItemsCommands(m_itemsDataAdapter, m_connection); - m_itemsDataAdapter.Fill(m_itemsTable); - - m_terrainTable = createTerrainTable(); - m_dataSet.Tables.Add(m_terrainTable); - SetupTerrainCommands(m_terrainDataAdapter, m_connection); - m_terrainDataAdapter.Fill(m_terrainTable); - - m_landTable = createLandTable(); - m_dataSet.Tables.Add(m_landTable); - setupLandCommands(m_landDataAdapter, m_connection); - m_landDataAdapter.Fill(m_landTable); - - m_landAccessListTable = createLandAccessListTable(); - m_dataSet.Tables.Add(m_landAccessListTable); - setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); - m_landAccessListDataAdapter.Fill(m_landAccessListTable); - - m_regionSettingsTable = createRegionSettingsTable(); - m_dataSet.Tables.Add(m_regionSettingsTable); - SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection); - m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); - } - } - - /// - /// Get the wait_timeout value for our connection - /// - protected void GetWaitTimeout() - { - MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); - - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } - - dbReader.Close(); - cmd.Dispose(); - } - - m_lastConnectionUse = System.DateTime.Now.Ticks; - - m_log.DebugFormat( - "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); - } - - /// - /// Should be called before any db operation. This checks to see if the connection has not timed out - /// - protected void CheckConnection() - { - //m_log.Debug("[REGION DB]: Checking connection"); - - long timeNow = System.DateTime.Now.Ticks; - if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) - { - m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); - - lock (m_connection) - { - m_connection.Close(); - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); - } - } - - // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather - // than require the code to call another method - the timeout leeway should be large enough to cover the - // inaccuracy. - m_lastConnectionUse = timeNow; - } - - /// - /// Given a list of tables, return the version of the tables, as seen in the database - /// - /// The list of table - /// The database connection handler - public void GetTableVersion(Dictionary tableList, MySqlConnection dbcon) - { - lock (dbcon) - { - MySqlCommand tablesCmd = - new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", - dbcon); - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - - CheckConnection(); - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) - { - while (tables.Read()) - { - try - { - string tableName = (string)tables["TABLE_NAME"]; - string comment = (string)tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) - { - tableList[tableName] = comment; - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - } - } - tables.Close(); - } - } - } - // private void TestTablesVersionable(MySqlConnection dbconn) - // { - // Dictionary tableList = new Dictionary(); - - // tableList["land"] = null; - // dbconn.Open(); - // GetTableVersion(tableList,dbconn); - - // UpgradeLandTable(tableList["land"], dbconn); - // //database.Close(); - - // } - - /// - /// Execute a SQL statement stored in a resource, as a string - /// - /// the ressource name - /// The database connection handler - public void ExecuteResourceSql(string name, MySqlConnection dbcon) - { - MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); - cmd.ExecuteNonQuery(); - } - - /// - /// Extract a named string resource from the embedded resources - /// - /// name of embedded resource - /// string contained within the embedded resource - private string getResourceString(string name) - { - Assembly assem = GetType().Assembly; - string[] names = assem.GetManifestResourceNames(); - - foreach (string s in names) - { - if (s.EndsWith(name)) - { - using (Stream resource = assem.GetManifestResourceStream(s)) - { - using (StreamReader resourceReader = new StreamReader(resource)) - { - string resourceString = resourceReader.ReadToEnd(); - return resourceString; - } - } - } - } - throw new Exception(string.Format("Resource '{0}' was not found", name)); - } - - /// - /// - /// Execute CreateLandTable.sql if oldVersion == null - /// Execute UpgradeLandTable.sqm if oldVersion contain "Rev." - /// - /// - /// - /// The database connection handler - // private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) - // { - // // null as the version, indicates that the table didn't exist - // if (oldVersion == null) - // { - // ExecuteResourceSql("CreateLandTable.sql",dbconn); - // oldVersion = "Rev. 2; InnoDB free: 0 kB"; - // } - // if (!oldVersion.Contains("Rev.")) - // { - // ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); - // } - // } - - /// - /// Adds an object into region storage - /// - /// The object - /// The region UUID - public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) - { - lock (m_dataSet) - { - foreach (SceneObjectPart prim in obj.Children.Values) - { - if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0) - { - //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } - else - { - // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); - } - } - Commit(); - } - } - - /// - /// removes an object from region storage - /// - /// The object - /// The Region UUID - public void RemoveObject(LLUUID obj, LLUUID regionUUID) - { - m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); - - DataTable prims = m_primTable; - DataTable shapes = m_shapeTable; - - string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'"; - lock (m_dataSet) - { - DataRow[] primRows = prims.Select(selectExp); - foreach (DataRow row in primRows) - { - // Remove shapes row - LLUUID uuid = new LLUUID((string) row["UUID"]); - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); - if (shapeRow != null) - { - shapeRow.Delete(); - } - - RemoveItems(uuid); - - // Remove prim row - row.Delete(); - } - Commit(); - } - } - - /// - /// Remove all persisted items of the given prim. - /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. - /// - /// the Item UUID - private void RemoveItems(LLUUID uuid) - { - String sql = String.Format("primID = '{0}'", uuid); - DataRow[] itemRows = m_itemsTable.Select(sql); - - foreach (DataRow itemRow in itemRows) - { - itemRow.Delete(); - } - } - - /// - /// Load persisted objects from region storage. - /// - /// the Region UUID - /// List of loaded groups - public List LoadObjects(LLUUID regionUUID) - { - Dictionary createdObjects = new Dictionary(); - - List retvals = new List(); - - DataTable prims = m_primTable; - DataTable shapes = m_shapeTable; - - string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; - string orderByParent = "ParentID ASC"; - - lock (m_dataSet) - { - CheckConnection(); - DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - m_log.Info("[REGION DB]: " + - "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); - - foreach (DataRow primRow in primsForRegion) - { - try - { - string uuid = (string) primRow["UUID"]; - string objID = (string) primRow["SceneGroupID"]; - - SceneObjectPart prim = buildPrim(primRow); - - if (uuid == objID) //is new SceneObjectGroup ? - { - SceneObjectGroup group = new SceneObjectGroup(); - - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - m_log.Info( - "No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } - group.AddPart(prim); - group.RootPart = prim; - - createdObjects.Add(group.UUID, group); - retvals.Add(group); - } - else - { - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - m_log.Info( - "No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } - createdObjects[new LLUUID(objID)].AddPart(prim); - } - - LoadItems(prim); - } - catch (Exception e) - { - m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); - m_log.Info("[REGION DB]: " + e.ToString()); - foreach (DataColumn col in prims.Columns) - { - m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); - } - } - } - } - return retvals; - } - - /// - /// Load in a prim's persisted inventory. - /// - /// The prim - private void LoadItems(SceneObjectPart prim) - { - lock (m_dataSet) - { - CheckConnection(); - //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); - - DataTable dbItems = m_itemsTable; - - String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); - DataRow[] dbItemRows = dbItems.Select(sql); - - IList inventory = new List(); - - foreach (DataRow row in dbItemRows) - { - TaskInventoryItem item = buildItem(row); - inventory.Add(item); - - //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); - } - - prim.RestoreInventoryItems(inventory); - - // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in - // every item). This data should really be stored in the prim table itself. - if (dbItemRows.Length > 0) - { - prim.FolderID = inventory[0].ParentID; - } - } - } - - /// - /// Store a terrain revision in region storage - /// - /// HeightField data - /// region UUID - public void StoreTerrain(double[,] ter, LLUUID regionID) - { - int revision = 1; - m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); - - lock (m_dataSet) - { - MySqlCommand delete = new MySqlCommand("delete from terrain where RegionUUID=?RegionUUID", m_connection); - MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + - " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); - using (cmd) - { - delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); - - CheckConnection(); - delete.ExecuteNonQuery(); - - cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); - cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); - cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); - cmd.ExecuteNonQuery(); - } - } - } - - /// - /// Load the latest terrain revision from region storage - /// - /// the region UUID - /// Heightfield data - public double[,] LoadTerrain(LLUUID regionID) - { - double[,] terret = new double[256,256]; - terret.Initialize(); - - MySqlCommand cmd = new MySqlCommand( - @"select RegionUUID, Revision, Heightfield from terrain - where RegionUUID=?RegionUUID order by Revision desc limit 1" - , m_connection); - - // MySqlParameter param = new MySqlParameter(); - cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); - - if (m_connection.State != ConnectionState.Open) - { - m_connection.Open(); - } - - lock (m_dataSet) - { - CheckConnection(); - using (MySqlDataReader row = cmd.ExecuteReader()) - { - int rev = 0; - if (row.Read()) - { - MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); - BinaryReader br = new BinaryReader(str); - for (int x = 0; x < 256; x++) - { - for (int y = 0; y < 256; y++) - { - terret[x, y] = br.ReadDouble(); - } - } - rev = (int) row["Revision"]; - } - else - { - m_log.Info("[REGION DB]: No terrain found for region"); - return null; - } - - m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); - } - } - return terret; - } - - /// - /// - /// delete from land where UUID=globalID - /// delete from landaccesslist where LandUUID=globalID - /// - /// - /// - public void RemoveLandObject(LLUUID globalID) - { - lock (m_dataSet) - { - CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection)) - { - cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); - cmd.ExecuteNonQuery(); - } - - using ( - MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?UUID", m_connection) - ) - { - cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); - cmd.ExecuteNonQuery(); - } - } - } - - /// - /// - /// - public void StoreLandObject(ILandObject parcel) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable land = m_landTable; - DataTable landaccesslist = m_landAccessListTable; - - DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.GlobalID)); - if (landRow == null) - { - landRow = land.NewRow(); - fillLandRow(landRow, parcel.landData, parcel.regionUUID); - land.Rows.Add(landRow); - } - else - { - fillLandRow(landRow, parcel.landData, parcel.regionUUID); - } - - using ( - MySqlCommand cmd = - new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) - { - cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.GlobalID))); - cmd.ExecuteNonQuery(); - } - - foreach (ParcelManager.ParcelAccessEntry entry in parcel.landData.ParcelAccessList) - { - DataRow newAccessRow = landaccesslist.NewRow(); - fillLandAccessRow(newAccessRow, entry, parcel.landData.GlobalID); - landaccesslist.Rows.Add(newAccessRow); - } - - Commit(); - } - } - - public RegionSettings LoadRegionSettings(LLUUID regionUUID) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionsettings = m_regionSettingsTable; - string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; - DataRow[] rawsettings = regionsettings.Select(searchExp); - if (rawsettings.Length == 0) - { - RegionSettings rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; - - StoreRegionSettings(rs); - - return rs; - } - DataRow row = rawsettings[0]; - - RegionSettings newSettings = buildRegionSettings(row); - newSettings.OnSave += StoreRegionSettings; - - return newSettings; - } - } - - public void StoreRegionSettings(RegionSettings rs) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionsettings = m_dataSet.Tables["regionsettings"]; - - DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); - if (settingsRow == null) - { - settingsRow = regionsettings.NewRow(); - fillRegionSettingsRow(settingsRow, rs); - regionsettings.Rows.Add(settingsRow); - } - else - { - fillRegionSettingsRow(settingsRow, rs); - } - - Commit(); - } - } - - /// - /// - /// - /// - /// - public List LoadLandObjects(LLUUID regionUUID) - { - List landDataForRegion = new List(); - lock (m_dataSet) - { - CheckConnection(); - DataTable land = m_landTable; - DataTable landaccesslist = m_landAccessListTable; - string searchExp = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; - DataRow[] rawDataForRegion = land.Select(searchExp); - foreach (DataRow rawDataLand in rawDataForRegion) - { - LandData newLand = buildLandData(rawDataLand); - string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.GlobalID) + "'"; - DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); - foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) - { - newLand.ParcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); - } - - landDataForRegion.Add(newLand); - } - } - return landDataForRegion; - } - - /// - /// - /// - public void Commit() - { - lock (m_dataSet) - { - CheckConnection(); - // DisplayDataSet(m_dataSet, "Region DataSet"); - - m_primDataAdapter.Update(m_primTable); - m_shapeDataAdapter.Update(m_shapeTable); - - m_itemsDataAdapter.Update(m_itemsTable); - - m_terrainDataAdapter.Update(m_terrainTable); - m_landDataAdapter.Update(m_landTable); - m_landAccessListDataAdapter.Update(m_landAccessListTable); - m_regionSettingsDataAdapter.Update(m_regionSettingsTable); - - m_dataSet.AcceptChanges(); - } - } - - /// - /// See - /// - public void Shutdown() - { - Commit(); - } - - /*********************************************************************** - * - * Database Definition Functions - * - * This should be db agnostic as we define them in ADO.NET terms - * - **********************************************************************/ - - /// - /// - /// - /// - /// - /// - /// - private static DataColumn createCol(DataTable dt, string name, Type type) - { - DataColumn col = new DataColumn(name, type); - dt.Columns.Add(col); - return col; - } - - /// - /// Create the "terrain" table - /// - /// - private static DataTable createTerrainTable() - { - DataTable terrain = new DataTable("terrain"); - - createCol(terrain, "RegionUUID", typeof (String)); - createCol(terrain, "Revision", typeof (Int32)); - createCol(terrain, "Heightfield", typeof (Byte[])); - return terrain; - } - - /// - /// Create the "regionsettings" table - /// - /// - private static DataTable createRegionSettingsTable() - { - DataTable regionsettings = new DataTable("regionsettings"); - createCol(regionsettings, "regionUUID", typeof(String)); - createCol(regionsettings, "block_terraform", typeof (Int32)); - createCol(regionsettings, "block_fly", typeof (Int32)); - createCol(regionsettings, "allow_damage", typeof (Int32)); - createCol(regionsettings, "restrict_pushing", typeof (Int32)); - createCol(regionsettings, "allow_land_resell", typeof (Int32)); - createCol(regionsettings, "allow_land_join_divide", typeof (Int32)); - createCol(regionsettings, "block_show_in_search", typeof (Int32)); - createCol(regionsettings, "agent_limit", typeof (Int32)); - createCol(regionsettings, "object_bonus", typeof (Double)); - createCol(regionsettings, "maturity", typeof (Int32)); - createCol(regionsettings, "disable_scripts", typeof (Int32)); - createCol(regionsettings, "disable_collisions", typeof (Int32)); - createCol(regionsettings, "disable_physics", typeof (Int32)); - createCol(regionsettings, "terrain_texture_1", typeof(String)); - createCol(regionsettings, "terrain_texture_2", typeof(String)); - createCol(regionsettings, "terrain_texture_3", typeof(String)); - createCol(regionsettings, "terrain_texture_4", typeof(String)); - createCol(regionsettings, "elevation_1_nw", typeof (Double)); - createCol(regionsettings, "elevation_2_nw", typeof (Double)); - createCol(regionsettings, "elevation_1_ne", typeof (Double)); - createCol(regionsettings, "elevation_2_ne", typeof (Double)); - createCol(regionsettings, "elevation_1_se", typeof (Double)); - createCol(regionsettings, "elevation_2_se", typeof (Double)); - createCol(regionsettings, "elevation_1_sw", typeof (Double)); - createCol(regionsettings, "elevation_2_sw", typeof (Double)); - createCol(regionsettings, "water_height", typeof (Double)); - createCol(regionsettings, "terrain_raise_limit", typeof (Double)); - createCol(regionsettings, "terrain_lower_limit", typeof (Double)); - createCol(regionsettings, "use_estate_sun", typeof (Int32)); - createCol(regionsettings, "sandbox", typeof (Int32)); - createCol(regionsettings, "fixed_sun", typeof (Int32)); - createCol(regionsettings, "sun_position", typeof (Double)); - createCol(regionsettings, "covenant", typeof(String)); - - regionsettings.PrimaryKey = new DataColumn[] {regionsettings.Columns["RegionUUID"]}; - - return regionsettings; - } - - /// - /// Create the "prims" table - /// - /// - private static DataTable createPrimTable() - { - DataTable prims = new DataTable("prims"); - - createCol(prims, "UUID", typeof (String)); - createCol(prims, "RegionUUID", typeof (String)); - createCol(prims, "ParentID", typeof (Int32)); - createCol(prims, "CreationDate", typeof (Int32)); - createCol(prims, "Name", typeof (String)); - createCol(prims, "SceneGroupID", typeof (String)); - // various text fields - createCol(prims, "Text", typeof (String)); - createCol(prims, "Description", typeof (String)); - createCol(prims, "SitName", typeof (String)); - createCol(prims, "TouchName", typeof (String)); - // permissions - createCol(prims, "ObjectFlags", typeof (Int32)); - createCol(prims, "CreatorID", typeof (String)); - createCol(prims, "OwnerID", typeof (String)); - createCol(prims, "GroupID", typeof (String)); - createCol(prims, "LastOwnerID", typeof (String)); - createCol(prims, "OwnerMask", typeof (Int32)); - createCol(prims, "NextOwnerMask", typeof (Int32)); - createCol(prims, "GroupMask", typeof (Int32)); - createCol(prims, "EveryoneMask", typeof (Int32)); - createCol(prims, "BaseMask", typeof (Int32)); - // vectors - createCol(prims, "PositionX", typeof (Double)); - createCol(prims, "PositionY", typeof (Double)); - createCol(prims, "PositionZ", typeof (Double)); - createCol(prims, "GroupPositionX", typeof (Double)); - createCol(prims, "GroupPositionY", typeof (Double)); - createCol(prims, "GroupPositionZ", typeof (Double)); - createCol(prims, "VelocityX", typeof (Double)); - createCol(prims, "VelocityY", typeof (Double)); - createCol(prims, "VelocityZ", typeof (Double)); - createCol(prims, "AngularVelocityX", typeof (Double)); - createCol(prims, "AngularVelocityY", typeof (Double)); - createCol(prims, "AngularVelocityZ", typeof (Double)); - createCol(prims, "AccelerationX", typeof (Double)); - createCol(prims, "AccelerationY", typeof (Double)); - createCol(prims, "AccelerationZ", typeof (Double)); - // quaternions - createCol(prims, "RotationX", typeof (Double)); - createCol(prims, "RotationY", typeof (Double)); - createCol(prims, "RotationZ", typeof (Double)); - createCol(prims, "RotationW", typeof (Double)); - // sit target - createCol(prims, "SitTargetOffsetX", typeof (Double)); - createCol(prims, "SitTargetOffsetY", typeof (Double)); - createCol(prims, "SitTargetOffsetZ", typeof (Double)); - - createCol(prims, "SitTargetOrientW", typeof (Double)); - createCol(prims, "SitTargetOrientX", typeof (Double)); - createCol(prims, "SitTargetOrientY", typeof (Double)); - createCol(prims, "SitTargetOrientZ", typeof (Double)); - - - // Add in contraints - prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; - - return prims; - } - - /// - /// Create the "land" table - /// - /// - private static DataTable createLandTable() - { - DataTable land = new DataTable("land"); - createCol(land, "UUID", typeof (String)); - createCol(land, "RegionUUID", typeof (String)); - createCol(land, "LocalLandID", typeof (Int32)); - - // Bitmap is a byte[512] - createCol(land, "Bitmap", typeof (Byte[])); - - createCol(land, "Name", typeof (String)); - createCol(land, "Description", typeof (String)); - createCol(land, "OwnerUUID", typeof (String)); - createCol(land, "IsGroupOwned", typeof (Int32)); - createCol(land, "Area", typeof (Int32)); - createCol(land, "AuctionID", typeof (Int32)); //Unemplemented - createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory - createCol(land, "ClaimDate", typeof (Int32)); - createCol(land, "ClaimPrice", typeof (Int32)); - createCol(land, "GroupUUID", typeof (String)); - createCol(land, "SalePrice", typeof (Int32)); - createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof (Int32)); - createCol(land, "LandingType", typeof (Int32)); - createCol(land, "MediaAutoScale", typeof (Int32)); - createCol(land, "MediaTextureUUID", typeof (String)); - createCol(land, "MediaURL", typeof (String)); - createCol(land, "MusicURL", typeof (String)); - createCol(land, "PassHours", typeof (Double)); - createCol(land, "PassPrice", typeof (Int32)); - createCol(land, "SnapshotUUID", typeof (String)); - createCol(land, "UserLocationX", typeof (Double)); - createCol(land, "UserLocationY", typeof (Double)); - createCol(land, "UserLocationZ", typeof (Double)); - createCol(land, "UserLookAtX", typeof (Double)); - createCol(land, "UserLookAtY", typeof (Double)); - createCol(land, "UserLookAtZ", typeof (Double)); - createCol(land, "AuthBuyerID", typeof (String)); - - land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; - - return land; - } - - /// - /// Create the "landaccesslist" table - /// - /// - private static DataTable createLandAccessListTable() - { - DataTable landaccess = new DataTable("landaccesslist"); - createCol(landaccess, "LandUUID", typeof (String)); - createCol(landaccess, "AccessUUID", typeof (String)); - createCol(landaccess, "Flags", typeof (Int32)); - - return landaccess; - } - - /// - /// Create the "primshapes" table - /// - /// - private static DataTable createShapeTable() - { - DataTable shapes = new DataTable("primshapes"); - createCol(shapes, "UUID", typeof (String)); - // shape is an enum - createCol(shapes, "Shape", typeof (Int32)); - // vectors - createCol(shapes, "ScaleX", typeof (Double)); - createCol(shapes, "ScaleY", typeof (Double)); - createCol(shapes, "ScaleZ", typeof (Double)); - // paths - createCol(shapes, "PCode", typeof (Int32)); - createCol(shapes, "PathBegin", typeof (Int32)); - createCol(shapes, "PathEnd", typeof (Int32)); - createCol(shapes, "PathScaleX", typeof (Int32)); - createCol(shapes, "PathScaleY", typeof (Int32)); - createCol(shapes, "PathShearX", typeof (Int32)); - createCol(shapes, "PathShearY", typeof (Int32)); - createCol(shapes, "PathSkew", typeof (Int32)); - createCol(shapes, "PathCurve", typeof (Int32)); - createCol(shapes, "PathRadiusOffset", typeof (Int32)); - createCol(shapes, "PathRevolutions", typeof (Int32)); - createCol(shapes, "PathTaperX", typeof (Int32)); - createCol(shapes, "PathTaperY", typeof (Int32)); - createCol(shapes, "PathTwist", typeof (Int32)); - createCol(shapes, "PathTwistBegin", typeof (Int32)); - // profile - createCol(shapes, "ProfileBegin", typeof (Int32)); - createCol(shapes, "ProfileEnd", typeof (Int32)); - createCol(shapes, "ProfileCurve", typeof (Int32)); - createCol(shapes, "ProfileHollow", typeof (Int32)); - createCol(shapes, "State", typeof(Int32)); - createCol(shapes, "Texture", typeof (Byte[])); - createCol(shapes, "ExtraParams", typeof (Byte[])); - - shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; - - return shapes; - } - - /// - /// Create the "primitems" table - /// - /// - private static DataTable createItemsTable() - { - DataTable items = new DataTable("primitems"); - - createCol(items, "itemID", typeof (String)); - createCol(items, "primID", typeof (String)); - createCol(items, "assetID", typeof (String)); - createCol(items, "parentFolderID", typeof (String)); - - createCol(items, "invType", typeof (Int32)); - createCol(items, "assetType", typeof (Int32)); - - createCol(items, "name", typeof (String)); - createCol(items, "description", typeof (String)); - - createCol(items, "creationDate", typeof (Int64)); - createCol(items, "creatorID", typeof (String)); - createCol(items, "ownerID", typeof (String)); - createCol(items, "lastOwnerID", typeof (String)); - createCol(items, "groupID", typeof (String)); - - createCol(items, "nextPermissions", typeof (Int32)); - createCol(items, "currentPermissions", typeof (Int32)); - createCol(items, "basePermissions", typeof (Int32)); - createCol(items, "everyonePermissions", typeof (Int32)); - createCol(items, "groupPermissions", typeof (Int32)); - createCol(items, "flags", typeof (Int32)); - - items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; - - return items; - } - - /*********************************************************************** - * - * Convert between ADO.NET <=> OpenSim Objects - * - * These should be database independant - * - **********************************************************************/ - - /// - /// - /// - /// - /// - private SceneObjectPart buildPrim(DataRow row) - { - SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new LLUUID((String) row["UUID"]); - // explicit conversion of integers is required, which sort - // of sucks. No idea if there is a shortcut here or not. - prim.ParentID = Convert.ToUInt32(row["ParentID"]); - prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - prim.Name = (String) row["Name"]; - // various text fields - prim.Text = (String) row["Text"]; - prim.Description = (String) row["Description"]; - prim.SitName = (String) row["SitName"]; - prim.TouchName = (String) row["TouchName"]; - // permissions - prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new LLUUID((String) row["CreatorID"]); - prim.OwnerID = new LLUUID((String) row["OwnerID"]); - prim.GroupID = new LLUUID((String) row["GroupID"]); - prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); - prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); - prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); - prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); - prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); - prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); - // vectors - prim.OffsetPosition = new LLVector3( - Convert.ToSingle(row["PositionX"]), - Convert.ToSingle(row["PositionY"]), - Convert.ToSingle(row["PositionZ"]) - ); - prim.GroupPosition = new LLVector3( - Convert.ToSingle(row["GroupPositionX"]), - Convert.ToSingle(row["GroupPositionY"]), - Convert.ToSingle(row["GroupPositionZ"]) - ); - prim.Velocity = new LLVector3( - Convert.ToSingle(row["VelocityX"]), - Convert.ToSingle(row["VelocityY"]), - Convert.ToSingle(row["VelocityZ"]) - ); - prim.AngularVelocity = new LLVector3( - Convert.ToSingle(row["AngularVelocityX"]), - Convert.ToSingle(row["AngularVelocityY"]), - Convert.ToSingle(row["AngularVelocityZ"]) - ); - prim.Acceleration = new LLVector3( - Convert.ToSingle(row["AccelerationX"]), - Convert.ToSingle(row["AccelerationY"]), - Convert.ToSingle(row["AccelerationZ"]) - ); - // quaternions - prim.RotationOffset = new LLQuaternion( - Convert.ToSingle(row["RotationX"]), - Convert.ToSingle(row["RotationY"]), - Convert.ToSingle(row["RotationZ"]), - Convert.ToSingle(row["RotationW"]) - ); - try - { - prim.SitTargetPositionLL = new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])); - prim.SitTargetOrientationLL = new LLQuaternion( - Convert.ToSingle( - row["SitTargetOrientX"]), - Convert.ToSingle( - row["SitTargetOrientY"]), - Convert.ToSingle( - row["SitTargetOrientZ"]), - Convert.ToSingle( - row["SitTargetOrientW"])); - } - catch (InvalidCastException) - { - // Database table was created before we got here and needs to be created! :P - - lock (m_dataSet) - { - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } - return prim; - } - - - /// - /// Build a prim inventory item from the persisted data. - /// - /// - /// - private static TaskInventoryItem buildItem(DataRow row) - { - TaskInventoryItem taskItem = new TaskInventoryItem(); - - taskItem.ItemID = new LLUUID((String)row["itemID"]); - taskItem.ParentPartID = new LLUUID((String)row["primID"]); - taskItem.AssetID = new LLUUID((String)row["assetID"]); - taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); - - taskItem.InvType = Convert.ToInt32(row["invType"]); - taskItem.Type = Convert.ToInt32(row["assetType"]); - - taskItem.Name = (String)row["name"]; - taskItem.Description = (String)row["description"]; - taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorID = new LLUUID((String)row["creatorID"]); - taskItem.OwnerID = new LLUUID((String)row["ownerID"]); - taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); - taskItem.GroupID = new LLUUID((String)row["groupID"]); - - taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); - taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); - taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); - taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); - taskItem.Flags = Convert.ToUInt32(row["flags"]); - - return taskItem; - } - - private static RegionSettings buildRegionSettings(DataRow row) - { - RegionSettings newSettings = new RegionSettings(); - - newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); - newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); - newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); - newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); - newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); - newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); - newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); - newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); - newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); - newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); - newSettings.Maturity = Convert.ToInt32(row["maturity"]); - newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); - newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); - newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); - newSettings.TerrainTexture1 = new LLUUID((String) row["terrain_texture_1"]); - newSettings.TerrainTexture2 = new LLUUID((String) row["terrain_texture_2"]); - newSettings.TerrainTexture3 = new LLUUID((String) row["terrain_texture_3"]); - newSettings.TerrainTexture4 = new LLUUID((String) row["terrain_texture_4"]); - newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); - newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); - newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); - newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); - newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); - newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); - newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); - newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); - newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); - newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); - newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); - newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); - newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); - newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); - newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); - newSettings.Covenant = new LLUUID((String) row["covenant"]); - - return newSettings; - } - - /// - /// - /// - /// - /// - private static LandData buildLandData(DataRow row) - { - LandData newData = new LandData(); - - newData.GlobalID = new LLUUID((String) row["UUID"]); - newData.LocalID = Convert.ToInt32(row["LocalLandID"]); - - // Bitmap is a byte[512] - newData.Bitmap = (Byte[]) row["Bitmap"]; - - newData.Name = (String) row["Name"]; - newData.Description = (String) row["Description"]; - newData.OwnerID = (String) row["OwnerUUID"]; - newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); - newData.Area = Convert.ToInt32(row["Area"]); - newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented - newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); - //Enum libsecondlife.Parcel.ParcelCategory - newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); - newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.GroupID = new LLUUID((String) row["GroupUUID"]); - newData.SalePrice = Convert.ToInt32(row["SalePrice"]); - newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); - //Enum. libsecondlife.Parcel.ParcelStatus - newData.Flags = Convert.ToUInt32(row["LandFlags"]); - newData.LandingType = Convert.ToByte(row["LandingType"]); - newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.MediaID = new LLUUID((String) row["MediaTextureUUID"]); - newData.MediaURL = (String) row["MediaURL"]; - newData.MusicURL = (String) row["MusicURL"]; - newData.PassHours = Convert.ToSingle(row["PassHours"]); - newData.PassPrice = Convert.ToInt32(row["PassPrice"]); - LLUUID authedbuyer = LLUUID.Zero; - LLUUID snapshotID = LLUUID.Zero; - - Helpers.TryParse((string)row["AuthBuyerID"], out authedbuyer); - Helpers.TryParse((string)row["SnapshotUUID"], out snapshotID); - - newData.AuthBuyerID = authedbuyer; - newData.SnapshotID = snapshotID; - try - { - newData.UserLocation = - new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), - Convert.ToSingle(row["UserLocationZ"])); - newData.UserLookAt = - new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), - Convert.ToSingle(row["UserLookAtZ"])); - } - catch (InvalidCastException) - { - newData.UserLocation = LLVector3.Zero; - newData.UserLookAt = LLVector3.Zero; - m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); - } - - newData.ParcelAccessList = new List(); - - return newData; - } - - /// - /// - /// - /// - /// - private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) - { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new LLUUID((string) row["AccessUUID"]); - entry.Flags = (ParcelManager.AccessList) Convert.ToInt32(row["Flags"]); - entry.Time = new DateTime(); - return entry; - } - - /// - /// - /// - /// - /// - private static Array serializeTerrain(double[,] val) - { - MemoryStream str = new MemoryStream(65536*sizeof (double)); - BinaryWriter bw = new BinaryWriter(str); - - // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) - { - double height = val[x, y]; - if (height == 0.0) - height = double.Epsilon; - - bw.Write(height); - } - - return str.ToArray(); - } - - /// - /// - /// - /// - /// - /// - /// - private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) - { - row["UUID"] = Util.ToRawUuidString(prim.UUID); - row["RegionUUID"] = Util.ToRawUuidString(regionUUID); - row["ParentID"] = prim.ParentID; - row["CreationDate"] = prim.CreationDate; - row["Name"] = prim.Name; - row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); - // the UUID of the root part for this SceneObjectGroup - // various text fields - row["Text"] = prim.Text; - row["Description"] = prim.Description; - row["SitName"] = prim.SitName; - row["TouchName"] = prim.TouchName; - // permissions - row["ObjectFlags"] = prim.ObjectFlags; - row["CreatorID"] = Util.ToRawUuidString(prim.CreatorID); - row["OwnerID"] = Util.ToRawUuidString(prim.OwnerID); - row["GroupID"] = Util.ToRawUuidString(prim.GroupID); - row["LastOwnerID"] = Util.ToRawUuidString(prim.LastOwnerID); - row["OwnerMask"] = prim.OwnerMask; - row["NextOwnerMask"] = prim.NextOwnerMask; - row["GroupMask"] = prim.GroupMask; - row["EveryoneMask"] = prim.EveryoneMask; - row["BaseMask"] = prim.BaseMask; - // vectors - row["PositionX"] = prim.OffsetPosition.X; - row["PositionY"] = prim.OffsetPosition.Y; - row["PositionZ"] = prim.OffsetPosition.Z; - row["GroupPositionX"] = prim.GroupPosition.X; - row["GroupPositionY"] = prim.GroupPosition.Y; - row["GroupPositionZ"] = prim.GroupPosition.Z; - row["VelocityX"] = prim.Velocity.X; - row["VelocityY"] = prim.Velocity.Y; - row["VelocityZ"] = prim.Velocity.Z; - row["AngularVelocityX"] = prim.AngularVelocity.X; - row["AngularVelocityY"] = prim.AngularVelocity.Y; - row["AngularVelocityZ"] = prim.AngularVelocity.Z; - row["AccelerationX"] = prim.Acceleration.X; - row["AccelerationY"] = prim.Acceleration.Y; - row["AccelerationZ"] = prim.Acceleration.Z; - // quaternions - row["RotationX"] = prim.RotationOffset.X; - row["RotationY"] = prim.RotationOffset.Y; - row["RotationZ"] = prim.RotationOffset.Z; - row["RotationW"] = prim.RotationOffset.W; - - try - { - // Sit target - LLVector3 sitTargetPos = prim.SitTargetPositionLL; - row["SitTargetOffsetX"] = sitTargetPos.X; - row["SitTargetOffsetY"] = sitTargetPos.Y; - row["SitTargetOffsetZ"] = sitTargetPos.Z; - - LLQuaternion sitTargetOrient = prim.SitTargetOrientationLL; - row["SitTargetOrientW"] = sitTargetOrient.W; - row["SitTargetOrientX"] = sitTargetOrient.X; - row["SitTargetOrientY"] = sitTargetOrient.Y; - row["SitTargetOrientZ"] = sitTargetOrient.Z; - } - catch (MySqlException) - { - // Database table was created before we got here and needs to be created! :P - - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } - - /// - /// - /// - /// - /// - private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) - { - row["itemID"] = taskItem.ItemID; - row["primID"] = taskItem.ParentPartID; - row["assetID"] = taskItem.AssetID; - row["parentFolderID"] = taskItem.ParentID; - - row["invType"] = taskItem.InvType; - row["assetType"] = taskItem.Type; - - row["name"] = taskItem.Name; - row["description"] = taskItem.Description; - row["creationDate"] = taskItem.CreationDate; - row["creatorID"] = taskItem.CreatorID; - row["ownerID"] = taskItem.OwnerID; - row["lastOwnerID"] = taskItem.LastOwnerID; - row["groupID"] = taskItem.GroupID; - row["nextPermissions"] = taskItem.NextPermissions; - row["currentPermissions"] = taskItem.CurrentPermissions; - row["basePermissions"] = taskItem.BasePermissions; - row["everyonePermissions"] = taskItem.EveryonePermissions; - row["groupPermissions"] = taskItem.GroupPermissions; - row["flags"] = taskItem.Flags; - } - - /// - /// - /// - private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) - { - row["regionUUID"] = settings.RegionUUID.ToString(); - row["block_terraform"] = settings.BlockTerraform; - row["block_fly"] = settings.BlockFly; - row["allow_damage"] = settings.AllowDamage; - row["restrict_pushing"] = settings.RestrictPushing; - row["allow_land_resell"] = settings.AllowLandResell; - row["allow_land_join_divide"] = settings.AllowLandJoinDivide; - row["block_show_in_search"] = settings.BlockShowInSearch; - row["agent_limit"] = settings.AgentLimit; - row["object_bonus"] = settings.ObjectBonus; - row["maturity"] = settings.Maturity; - row["disable_scripts"] = settings.DisableScripts; - row["disable_collisions"] = settings.DisableCollisions; - row["disable_physics"] = settings.DisablePhysics; - row["terrain_texture_1"] = settings.TerrainTexture1.ToString(); - row["terrain_texture_2"] = settings.TerrainTexture2.ToString(); - row["terrain_texture_3"] = settings.TerrainTexture3.ToString(); - row["terrain_texture_4"] = settings.TerrainTexture4.ToString(); - row["elevation_1_nw"] = settings.Elevation1NW; - row["elevation_2_nw"] = settings.Elevation2NW; - row["elevation_1_ne"] = settings.Elevation1NE; - row["elevation_2_ne"] = settings.Elevation2NE; - row["elevation_1_se"] = settings.Elevation1SE; - row["elevation_2_se"] = settings.Elevation2SE; - row["elevation_1_sw"] = settings.Elevation1SW; - row["elevation_2_sw"] = settings.Elevation2SW; - row["water_height"] = settings.WaterHeight; - row["terrain_raise_limit"] = settings.TerrainRaiseLimit; - row["terrain_lower_limit"] = settings.TerrainLowerLimit; - row["use_estate_sun"] = settings.UseEstateSun; - row["sandbox"] = settings.Sandbox; - row["fixed_sun"] = settings.FixedSun; - row["sun_position"] = settings.SunPosition; - row["covenant"] = settings.Covenant.ToString(); - } - - /// - /// - /// - /// - /// - /// - private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) - { - row["UUID"] = Util.ToRawUuidString(land.GlobalID); - row["RegionUUID"] = Util.ToRawUuidString(regionUUID); - row["LocalLandID"] = land.LocalID; - - // Bitmap is a byte[512] - row["Bitmap"] = land.Bitmap; - - row["Name"] = land.Name; - row["Description"] = land.Description; - row["OwnerUUID"] = Util.ToRawUuidString(land.OwnerID); - row["IsGroupOwned"] = land.IsGroupOwned; - row["Area"] = land.Area; - row["AuctionID"] = land.AuctionID; //Unemplemented - row["Category"] = land.Category; //Enum libsecondlife.Parcel.ParcelCategory - row["ClaimDate"] = land.ClaimDate; - row["ClaimPrice"] = land.ClaimPrice; - row["GroupUUID"] = Util.ToRawUuidString(land.GroupID); - row["SalePrice"] = land.SalePrice; - row["LandStatus"] = land.Status; //Enum. libsecondlife.Parcel.ParcelStatus - row["LandFlags"] = land.Flags; - row["LandingType"] = land.LandingType; - row["MediaAutoScale"] = land.MediaAutoScale; - row["MediaTextureUUID"] = Util.ToRawUuidString(land.MediaID); - row["MediaURL"] = land.MediaURL; - row["MusicURL"] = land.MusicURL; - row["PassHours"] = land.PassHours; - row["PassPrice"] = land.PassPrice; - row["SnapshotUUID"] = Util.ToRawUuidString(land.SnapshotID); - row["UserLocationX"] = land.UserLocation.X; - row["UserLocationY"] = land.UserLocation.Y; - row["UserLocationZ"] = land.UserLocation.Z; - row["UserLookAtX"] = land.UserLookAt.X; - row["UserLookAtY"] = land.UserLookAt.Y; - row["UserLookAtZ"] = land.UserLookAt.Z; - row["AuthBuyerID"] = land.AuthBuyerID; - } - - /// - /// - /// - /// - /// - /// - private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) - { - row["LandUUID"] = Util.ToRawUuidString(parcelID); - row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); - row["Flags"] = entry.Flags; - } - - /// - /// - /// - /// - /// - private PrimitiveBaseShape buildShape(DataRow row) - { - PrimitiveBaseShape s = new PrimitiveBaseShape(); - s.Scale = new LLVector3( - Convert.ToSingle(row["ScaleX"]), - Convert.ToSingle(row["ScaleY"]), - Convert.ToSingle(row["ScaleZ"]) - ); - // paths - s.PCode = Convert.ToByte(row["PCode"]); - s.PathBegin = Convert.ToUInt16(row["PathBegin"]); - s.PathEnd = Convert.ToUInt16(row["PathEnd"]); - s.PathScaleX = Convert.ToByte(row["PathScaleX"]); - s.PathScaleY = Convert.ToByte(row["PathScaleY"]); - s.PathShearX = Convert.ToByte(row["PathShearX"]); - s.PathShearY = Convert.ToByte(row["PathShearY"]); - s.PathSkew = Convert.ToSByte(row["PathSkew"]); - s.PathCurve = Convert.ToByte(row["PathCurve"]); - s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); - s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); - s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); - s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); - s.PathTwist = Convert.ToSByte(row["PathTwist"]); - s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); - // profile - s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); - s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); - s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); - s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - - byte[] textureEntry = (byte[]) row["Texture"]; - s.TextureEntry = textureEntry; - - s.ExtraParams = (byte[]) row["ExtraParams"]; - - try - { - s.State = Convert.ToByte(row["State"]); - } - catch (InvalidCastException) - { - // Database table was created before we got here and needs to be created! :P - lock (m_dataSet) - { - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } - - return s; - } - - /// - /// - /// - /// - /// - private void fillShapeRow(DataRow row, SceneObjectPart prim) - { - PrimitiveBaseShape s = prim.Shape; - row["UUID"] = Util.ToRawUuidString(prim.UUID); - // shape is an enum - row["Shape"] = 0; - // vectors - row["ScaleX"] = s.Scale.X; - row["ScaleY"] = s.Scale.Y; - row["ScaleZ"] = s.Scale.Z; - // paths - row["PCode"] = s.PCode; - row["PathBegin"] = s.PathBegin; - row["PathEnd"] = s.PathEnd; - row["PathScaleX"] = s.PathScaleX; - row["PathScaleY"] = s.PathScaleY; - row["PathShearX"] = s.PathShearX; - row["PathShearY"] = s.PathShearY; - row["PathSkew"] = s.PathSkew; - row["PathCurve"] = s.PathCurve; - row["PathRadiusOffset"] = s.PathRadiusOffset; - row["PathRevolutions"] = s.PathRevolutions; - row["PathTaperX"] = s.PathTaperX; - row["PathTaperY"] = s.PathTaperY; - row["PathTwist"] = s.PathTwist; - row["PathTwistBegin"] = s.PathTwistBegin; - // profile - row["ProfileBegin"] = s.ProfileBegin; - row["ProfileEnd"] = s.ProfileEnd; - row["ProfileCurve"] = s.ProfileCurve; - row["ProfileHollow"] = s.ProfileHollow; - row["Texture"] = s.TextureEntry; - row["ExtraParams"] = s.ExtraParams; - - try - { - row["State"] = s.State; - } - catch (MySqlException) - { - lock (m_dataSet) - { - // Database table was created before we got here and needs to be created! :P - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } - } - - /// - /// - /// - /// - /// - /// - private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) - { - lock (m_dataSet) - { - DataTable prims = m_dataSet.Tables["prims"]; - DataTable shapes = m_dataSet.Tables["primshapes"]; - - DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (primRow == null) - { - primRow = prims.NewRow(); - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - prims.Rows.Add(primRow); - } - else - { - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - } - - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow == null) - { - shapeRow = shapes.NewRow(); - fillShapeRow(shapeRow, prim); - shapes.Rows.Add(shapeRow); - } - else - { - fillShapeRow(shapeRow, prim); - } - } - } - - /// - /// see IRegionDatastore - /// - /// - /// - public void StorePrimInventory(LLUUID primID, ICollection items) - { - m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); - - // For now, we're just going to crudely remove all the previous inventory items - // no matter whether they have changed or not, and replace them with the current set. - lock (m_dataSet) - { - RemoveItems(primID); - - // repalce with current inventory details - foreach (TaskInventoryItem newItem in items) - { -// m_log.InfoFormat( -// "[REGION DB]: " + -// "Adding item {0}, {1} to prim ID {2}", -// newItem.Name, newItem.ItemID, newItem.ParentPartID); - - DataRow newItemRow = m_itemsTable.NewRow(); - fillItemRow(newItemRow, newItem); - m_itemsTable.Rows.Add(newItemRow); - } - } - - Commit(); - } - - /*********************************************************************** - * - * SQL Statement Creation Functions - * - * These functions create SQL statements for update, insert, and create. - * They can probably be factored later to have a db independant - * portion and a db specific portion - * - **********************************************************************/ - - /// - /// Create a MySQL insert command - /// - /// - /// - /// - /// - /// This is subtle enough to deserve some commentary. - /// Instead of doing *lots* and *lots of hardcoded strings - /// for database definitions we'll use the fact that - /// realistically all insert statements look like "insert - /// into A(b, c) values(:b, :c) on the parameterized query - /// front. If we just have a list of b, c, etc... we can - /// generate these strings instead of typing them out. - /// - private static MySqlCommand createInsertCommand(string table, DataTable dt) - { - - string[] cols = new string[dt.Columns.Count]; - for (int i = 0; i < dt.Columns.Count; i++) - { - DataColumn col = dt.Columns[i]; - cols[i] = col.ColumnName; - } - - string sql = "insert into " + table + "("; - sql += String.Join(", ", cols); - // important, the first ':' needs to be here, the rest get added in the join - sql += ") values (?"; - sql += String.Join(", ?", cols); - sql += ")"; - MySqlCommand cmd = new MySqlCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// Create a MySQL update command - /// - /// - /// - /// - /// - private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) - { - string sql = "update " + table + " set "; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ", "; - } - subsql += col.ColumnName + "=?" + col.ColumnName; - } - sql += subsql; - sql += " where " + pk; - MySqlCommand cmd = new MySqlCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// - /// - /// - /// - // private static string defineTable(DataTable dt) - // { - // string sql = "create table " + dt.TableName + "("; - // string subsql = String.Empty; - // foreach (DataColumn col in dt.Columns) - // { - // if (subsql.Length > 0) - // { - // // a map function would rock so much here - // subsql += ",\n"; - // } - // subsql += col.ColumnName + " " + MySqlType(col.DataType); - // if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) - // { - // subsql += " primary key"; - // } - // } - // sql += subsql; - // sql += ")"; - - // //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); - - // return sql; - // } - - /*********************************************************************** - * - * Database Binding functions - * - * These will be db specific due to typing, and minor differences - * in databases. - * - **********************************************************************/ - - /// - /// This is a convenience function that collapses 5 repetitive - /// lines for defining MySqlParameters to 2 parameters: - /// column name and database type. - /// - /// - /// It assumes certain conventions like ?param as the param - /// name to replace in parametrized queries, and that source - /// version is always current version, both of which are fine - /// for us. - /// - /// - /// a built MySql parameter - private static MySqlParameter createMySqlParameter(string name, Type type) - { - MySqlParameter param = new MySqlParameter(); - param.ParameterName = "?" + name; - param.DbType = dbtypeFromType(type); - param.SourceColumn = name; - param.SourceVersion = DataRowVersion.Current; - return param; - } - - /// - /// - /// - /// - /// - private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) - { - MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); - insertCommand.Connection = conn; - da.InsertCommand = insertCommand; - - MySqlCommand updateCommand = createUpdateCommand("prims", "UUID=?UUID", m_primTable); - updateCommand.Connection = conn; - da.UpdateCommand = updateCommand; - - MySqlCommand delete = new MySqlCommand("delete from prims where UUID=?UUID"); - delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// - private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("primitems", m_itemsTable); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("primitems", "itemID = ?itemID", m_itemsTable); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from primitems where itemID = ?itemID"); - delete.Parameters.Add(createMySqlParameter("itemID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - private void SetupRegionSettingsCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("regionsettings", m_regionSettingsTable); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID = ?regionUUID", m_regionSettingsTable); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from regionsettings where regionUUID = ?regionUUID"); - delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// - private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); - da.InsertCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("land", "UUID=?UUID", m_dataSet.Tables["land"]); - da.UpdateCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); - da.InsertCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("primshapes", "UUID=?UUID", m_dataSet.Tables["primshapes"]); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from primshapes where UUID = ?UUID"); - delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// MySQL connection handler - // private static void InitDB(MySqlConnection conn) - // { - // string createPrims = defineTable(createPrimTable()); - // string createShapes = defineTable(createShapeTable()); - // string createItems = defineTable(createItemsTable()); - // string createTerrain = defineTable(createTerrainTable()); - - // // Land table is created from the Versionable Test Table routine now. - // //string createLand = defineTable(createLandTable()); - // string createLandAccessList = defineTable(createLandAccessListTable()); - - // MySqlCommand pcmd = new MySqlCommand(createPrims, conn); - // MySqlCommand scmd = new MySqlCommand(createShapes, conn); - // MySqlCommand icmd = new MySqlCommand(createItems, conn); - // MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); - // //MySqlCommand lcmd = new MySqlCommand(createLand, conn); - // MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); - - // if (conn.State != ConnectionState.Open) - // { - // try - // { - // conn.Open(); - // } - // catch (Exception ex) - // { - // m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message); - // m_log.Error("[REGION DB]: Application is terminating!"); - // Thread.CurrentThread.Abort(); - // } - // } - - // try - // { - // pcmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e); - // } - - // try - // { - // scmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); - // } - - // try - // { - // icmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); - // } - - // try - // { - // tcmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e); - // } - - // //try - // //{ - // //lcmd.ExecuteNonQuery(); - // //} - // //catch (MySqlException e) - // //{ - // //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); - // //} - - // try - // { - // lalcmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e); - // } - // conn.Close(); - // } - - /// - /// - /// - /// - /// - /// - private bool TestTables(MySqlConnection conn, Migration m) - { - // we already have migrations, get out of here - if (m.Version > 0) - return false; - - MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); - MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); - MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); - MySqlDataAdapter sDa = new MySqlDataAdapter(shapeSelectCmd); - MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, conn); - MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd); - MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, conn); - MySqlDataAdapter tDa = new MySqlDataAdapter(terrainSelectCmd); - MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, conn); - MySqlDataAdapter lDa = new MySqlDataAdapter(landSelectCmd); - MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, conn); - MySqlDataAdapter lalDa = new MySqlDataAdapter(landAccessListSelectCmd); - - DataSet tmpDS = new DataSet(); - try - { - pDa.Fill(tmpDS, "prims"); - sDa.Fill(tmpDS, "primshapes"); - - iDa.Fill(tmpDS, "primitems"); - - tDa.Fill(tmpDS, "terrain"); - lDa.Fill(tmpDS, "land"); - lalDa.Fill(tmpDS, "landaccesslist"); - } - catch (MySqlException) - { - m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); - return false; - } - - // we have tables, but not a migration model yet - if (m.Version == 0) - m.Version = 1; - - return true; - - // pDa.Fill(tmpDS, "prims"); - // sDa.Fill(tmpDS, "primshapes"); - - // iDa.Fill(tmpDS, "primitems"); - - // tDa.Fill(tmpDS, "terrain"); - // lDa.Fill(tmpDS, "land"); - // lalDa.Fill(tmpDS, "landaccesslist"); - - // foreach (DataColumn col in createPrimTable().Columns) - // { - // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); - // return false; - // } - // } - - // foreach (DataColumn col in createShapeTable().Columns) - // { - // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); - // return false; - // } - // } - - // // XXX primitems should probably go here eventually - - // foreach (DataColumn col in createTerrainTable().Columns) - // { - // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); - // return false; - // } - // } - - // foreach (DataColumn col in createLandTable().Columns) - // { - // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); - // return false; - // } - // } - - // foreach (DataColumn col in createLandAccessListTable().Columns) - // { - // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); - // return false; - // } - // } - - // return true; - } - - /*********************************************************************** - * - * Type conversion functions - * - **********************************************************************/ - - /// - /// Type conversion functions - /// - /// - /// - private static DbType dbtypeFromType(Type type) - { - if (type == typeof (String)) - { - return DbType.String; - } - else if (type == typeof (Int32)) - { - return DbType.Int32; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Byte)) - { - return DbType.Byte; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Byte[])) - { - return DbType.Binary; - } - else - { - return DbType.String; - } - } - - /// - /// - /// - /// - /// this is something we'll need to implement for each db slightly differently. - // private static string MySqlType(Type type) - // { - // if (type == typeof (String)) - // { - // return "varchar(255)"; - // } - // else if (type == typeof (Int32)) - // { - // return "integer"; - // } - // else if (type == typeof (Int64)) - // { - // return "bigint"; - // } - // else if (type == typeof (Double)) - // { - // return "float"; - // } - // else if (type == typeof (Byte[])) - // { - // return "longblob"; - // } - // else - // { - // return "string"; - // } - // } - } -} diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs new file mode 100644 index 0000000..70b6d3c --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -0,0 +1,2360 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Reflection; +using System.Threading; +using libsecondlife; +using log4net; +using MySql.Data.MySqlClient; +using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for the Region Server + /// + public class MySQLDataStore : IRegionDataStore + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private const string m_primSelect = "select * from prims"; + private const string m_shapeSelect = "select * from primshapes"; + private const string m_itemsSelect = "select * from primitems"; + private const string m_terrainSelect = "select * from terrain limit 1"; + private const string m_landSelect = "select * from land"; + private const string m_landAccessListSelect = "select * from landaccesslist"; + private const string m_regionSettingsSelect = "select * from regionsettings"; + private const string m_waitTimeoutSelect = "select @@wait_timeout"; + + private MySqlConnection m_connection; + private string m_connectionString; + + /// + /// Wait timeout for our connection in ticks. + /// + private long m_waitTimeout; + + /// + /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long + /// running database operations. + /// + private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; + + /// + /// Holds the last tick time that the connection was used. + /// + private long m_lastConnectionUse; + + private DataSet m_dataSet; + private MySqlDataAdapter m_primDataAdapter; + private MySqlDataAdapter m_shapeDataAdapter; + private MySqlDataAdapter m_itemsDataAdapter; + private MySqlDataAdapter m_terrainDataAdapter; + private MySqlDataAdapter m_landDataAdapter; + private MySqlDataAdapter m_landAccessListDataAdapter; + private MySqlDataAdapter m_regionSettingsDataAdapter; + + private DataTable m_primTable; + private DataTable m_shapeTable; + private DataTable m_itemsTable; + private DataTable m_terrainTable; + private DataTable m_landTable; + private DataTable m_landAccessListTable; + private DataTable m_regionSettingsTable; + + /*********************************************************************** + * + * Public Interface Functions + * + **********************************************************************/ + + /// + /// see IRegionDataStore + /// + /// + public void Initialise(string connectionString) + { + m_connectionString = connectionString; + + m_dataSet = new DataSet(); + + int passPosition = 0; + int passEndPosition = 0; + string displayConnectionString = null; + + try + { // hide the password in the connection string + passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); + passPosition = m_connectionString.IndexOf("=", passPosition); + if (passPosition < m_connectionString.Length) + passPosition += 1; + passEndPosition = m_connectionString.IndexOf(";", passPosition); + + displayConnectionString = m_connectionString.Substring(0, passPosition); + displayConnectionString += "***"; + displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); + } + catch (Exception e ) + { + m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); + } + + m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + + GetWaitTimeout(); + + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_connection, assem, "RegionStore"); + + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m_connection, m); + + m.Update(); + + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); + m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); + + MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, m_connection); + m_shapeDataAdapter = new MySqlDataAdapter(shapeSelectCmd); + + MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, m_connection); + m_itemsDataAdapter = new MySqlDataAdapter(itemsSelectCmd); + + MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, m_connection); + m_terrainDataAdapter = new MySqlDataAdapter(terrainSelectCmd); + + MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, m_connection); + m_landDataAdapter = new MySqlDataAdapter(landSelectCmd); + + MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); + m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); + + MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); + m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); + + lock (m_dataSet) + { + m_primTable = createPrimTable(); + m_dataSet.Tables.Add(m_primTable); + SetupPrimCommands(m_primDataAdapter, m_connection); + m_primDataAdapter.Fill(m_primTable); + + m_shapeTable = createShapeTable(); + m_dataSet.Tables.Add(m_shapeTable); + SetupShapeCommands(m_shapeDataAdapter, m_connection); + m_shapeDataAdapter.Fill(m_shapeTable); + + + m_itemsTable = createItemsTable(); + m_dataSet.Tables.Add(m_itemsTable); + SetupItemsCommands(m_itemsDataAdapter, m_connection); + m_itemsDataAdapter.Fill(m_itemsTable); + + m_terrainTable = createTerrainTable(); + m_dataSet.Tables.Add(m_terrainTable); + SetupTerrainCommands(m_terrainDataAdapter, m_connection); + m_terrainDataAdapter.Fill(m_terrainTable); + + m_landTable = createLandTable(); + m_dataSet.Tables.Add(m_landTable); + setupLandCommands(m_landDataAdapter, m_connection); + m_landDataAdapter.Fill(m_landTable); + + m_landAccessListTable = createLandAccessListTable(); + m_dataSet.Tables.Add(m_landAccessListTable); + setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); + m_landAccessListDataAdapter.Fill(m_landAccessListTable); + + m_regionSettingsTable = createRegionSettingsTable(); + m_dataSet.Tables.Add(m_regionSettingsTable); + SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection); + m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); + } + } + + /// + /// Get the wait_timeout value for our connection + /// + protected void GetWaitTimeout() + { + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); + + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + + dbReader.Close(); + cmd.Dispose(); + } + + m_lastConnectionUse = System.DateTime.Now.Ticks; + + m_log.DebugFormat( + "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); + } + + /// + /// Should be called before any db operation. This checks to see if the connection has not timed out + /// + protected void CheckConnection() + { + //m_log.Debug("[REGION DB]: Checking connection"); + + long timeNow = System.DateTime.Now.Ticks; + if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) + { + m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); + + lock (m_connection) + { + m_connection.Close(); + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + } + } + + // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather + // than require the code to call another method - the timeout leeway should be large enough to cover the + // inaccuracy. + m_lastConnectionUse = timeNow; + } + + /// + /// Given a list of tables, return the version of the tables, as seen in the database + /// + /// The list of table + /// The database connection handler + public void GetTableVersion(Dictionary tableList, MySqlConnection dbcon) + { + lock (dbcon) + { + MySqlCommand tablesCmd = + new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon); + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + + CheckConnection(); + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + { + while (tables.Read()) + { + try + { + string tableName = (string)tables["TABLE_NAME"]; + string comment = (string)tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) + { + tableList[tableName] = comment; + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + tables.Close(); + } + } + } + // private void TestTablesVersionable(MySqlConnection dbconn) + // { + // Dictionary tableList = new Dictionary(); + + // tableList["land"] = null; + // dbconn.Open(); + // GetTableVersion(tableList,dbconn); + + // UpgradeLandTable(tableList["land"], dbconn); + // //database.Close(); + + // } + + /// + /// Execute a SQL statement stored in a resource, as a string + /// + /// the ressource name + /// The database connection handler + public void ExecuteResourceSql(string name, MySqlConnection dbcon) + { + MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); + cmd.ExecuteNonQuery(); + } + + /// + /// Extract a named string resource from the embedded resources + /// + /// name of embedded resource + /// string contained within the embedded resource + private string getResourceString(string name) + { + Assembly assem = GetType().Assembly; + string[] names = assem.GetManifestResourceNames(); + + foreach (string s in names) + { + if (s.EndsWith(name)) + { + using (Stream resource = assem.GetManifestResourceStream(s)) + { + using (StreamReader resourceReader = new StreamReader(resource)) + { + string resourceString = resourceReader.ReadToEnd(); + return resourceString; + } + } + } + } + throw new Exception(string.Format("Resource '{0}' was not found", name)); + } + + /// + /// + /// Execute CreateLandTable.sql if oldVersion == null + /// Execute UpgradeLandTable.sqm if oldVersion contain "Rev." + /// + /// + /// + /// The database connection handler + // private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) + // { + // // null as the version, indicates that the table didn't exist + // if (oldVersion == null) + // { + // ExecuteResourceSql("CreateLandTable.sql",dbconn); + // oldVersion = "Rev. 2; InnoDB free: 0 kB"; + // } + // if (!oldVersion.Contains("Rev.")) + // { + // ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); + // } + // } + + /// + /// Adds an object into region storage + /// + /// The object + /// The region UUID + public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) + { + lock (m_dataSet) + { + foreach (SceneObjectPart prim in obj.Children.Values) + { + if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0) + { + //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + addPrim(prim, obj.UUID, regionUUID); + } + else + { + // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); + } + } + Commit(); + } + } + + /// + /// removes an object from region storage + /// + /// The object + /// The Region UUID + public void RemoveObject(LLUUID obj, LLUUID regionUUID) + { + m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + + DataTable prims = m_primTable; + DataTable shapes = m_shapeTable; + + string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'"; + lock (m_dataSet) + { + DataRow[] primRows = prims.Select(selectExp); + foreach (DataRow row in primRows) + { + // Remove shapes row + LLUUID uuid = new LLUUID((string) row["UUID"]); + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); + if (shapeRow != null) + { + shapeRow.Delete(); + } + + RemoveItems(uuid); + + // Remove prim row + row.Delete(); + } + Commit(); + } + } + + /// + /// Remove all persisted items of the given prim. + /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. + /// + /// the Item UUID + private void RemoveItems(LLUUID uuid) + { + String sql = String.Format("primID = '{0}'", uuid); + DataRow[] itemRows = m_itemsTable.Select(sql); + + foreach (DataRow itemRow in itemRows) + { + itemRow.Delete(); + } + } + + /// + /// Load persisted objects from region storage. + /// + /// the Region UUID + /// List of loaded groups + public List LoadObjects(LLUUID regionUUID) + { + Dictionary createdObjects = new Dictionary(); + + List retvals = new List(); + + DataTable prims = m_primTable; + DataTable shapes = m_shapeTable; + + string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; + string orderByParent = "ParentID ASC"; + + lock (m_dataSet) + { + CheckConnection(); + DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); + m_log.Info("[REGION DB]: " + + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); + + foreach (DataRow primRow in primsForRegion) + { + try + { + string uuid = (string) primRow["UUID"]; + string objID = (string) primRow["SceneGroupID"]; + + SceneObjectPart prim = buildPrim(primRow); + + if (uuid == objID) //is new SceneObjectGroup ? + { + SceneObjectGroup group = new SceneObjectGroup(); + + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow != null) + { + prim.Shape = buildShape(shapeRow); + } + else + { + m_log.Info( + "No shape found for prim in storage, so setting default box shape"); + prim.Shape = PrimitiveBaseShape.Default; + } + group.AddPart(prim); + group.RootPart = prim; + + createdObjects.Add(group.UUID, group); + retvals.Add(group); + } + else + { + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow != null) + { + prim.Shape = buildShape(shapeRow); + } + else + { + m_log.Info( + "No shape found for prim in storage, so setting default box shape"); + prim.Shape = PrimitiveBaseShape.Default; + } + createdObjects[new LLUUID(objID)].AddPart(prim); + } + + LoadItems(prim); + } + catch (Exception e) + { + m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); + m_log.Info("[REGION DB]: " + e.ToString()); + foreach (DataColumn col in prims.Columns) + { + m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); + } + } + } + } + return retvals; + } + + /// + /// Load in a prim's persisted inventory. + /// + /// The prim + private void LoadItems(SceneObjectPart prim) + { + lock (m_dataSet) + { + CheckConnection(); + //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); + + DataTable dbItems = m_itemsTable; + + String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); + DataRow[] dbItemRows = dbItems.Select(sql); + + IList inventory = new List(); + + foreach (DataRow row in dbItemRows) + { + TaskInventoryItem item = buildItem(row); + inventory.Add(item); + + //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); + } + + prim.RestoreInventoryItems(inventory); + + // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in + // every item). This data should really be stored in the prim table itself. + if (dbItemRows.Length > 0) + { + prim.FolderID = inventory[0].ParentID; + } + } + } + + /// + /// Store a terrain revision in region storage + /// + /// HeightField data + /// region UUID + public void StoreTerrain(double[,] ter, LLUUID regionID) + { + int revision = 1; + m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); + + lock (m_dataSet) + { + MySqlCommand delete = new MySqlCommand("delete from terrain where RegionUUID=?RegionUUID", m_connection); + MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + + " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); + using (cmd) + { + delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + + CheckConnection(); + delete.ExecuteNonQuery(); + + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); + cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); + cmd.ExecuteNonQuery(); + } + } + } + + /// + /// Load the latest terrain revision from region storage + /// + /// the region UUID + /// Heightfield data + public double[,] LoadTerrain(LLUUID regionID) + { + double[,] terret = new double[256,256]; + terret.Initialize(); + + MySqlCommand cmd = new MySqlCommand( + @"select RegionUUID, Revision, Heightfield from terrain + where RegionUUID=?RegionUUID order by Revision desc limit 1" + , m_connection); + + // MySqlParameter param = new MySqlParameter(); + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + + if (m_connection.State != ConnectionState.Open) + { + m_connection.Open(); + } + + lock (m_dataSet) + { + CheckConnection(); + using (MySqlDataReader row = cmd.ExecuteReader()) + { + int rev = 0; + if (row.Read()) + { + MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); + BinaryReader br = new BinaryReader(str); + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + terret[x, y] = br.ReadDouble(); + } + } + rev = (int) row["Revision"]; + } + else + { + m_log.Info("[REGION DB]: No terrain found for region"); + return null; + } + + m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); + } + } + return terret; + } + + /// + /// + /// delete from land where UUID=globalID + /// delete from landaccesslist where LandUUID=globalID + /// + /// + /// + public void RemoveLandObject(LLUUID globalID) + { + lock (m_dataSet) + { + CheckConnection(); + using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection)) + { + cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); + cmd.ExecuteNonQuery(); + } + + using ( + MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?UUID", m_connection) + ) + { + cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); + cmd.ExecuteNonQuery(); + } + } + } + + /// + /// + /// + public void StoreLandObject(ILandObject parcel) + { + lock (m_dataSet) + { + CheckConnection(); + DataTable land = m_landTable; + DataTable landaccesslist = m_landAccessListTable; + + DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.GlobalID)); + if (landRow == null) + { + landRow = land.NewRow(); + fillLandRow(landRow, parcel.landData, parcel.regionUUID); + land.Rows.Add(landRow); + } + else + { + fillLandRow(landRow, parcel.landData, parcel.regionUUID); + } + + using ( + MySqlCommand cmd = + new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) + { + cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.GlobalID))); + cmd.ExecuteNonQuery(); + } + + foreach (ParcelManager.ParcelAccessEntry entry in parcel.landData.ParcelAccessList) + { + DataRow newAccessRow = landaccesslist.NewRow(); + fillLandAccessRow(newAccessRow, entry, parcel.landData.GlobalID); + landaccesslist.Rows.Add(newAccessRow); + } + + Commit(); + } + } + + public RegionSettings LoadRegionSettings(LLUUID regionUUID) + { + lock (m_dataSet) + { + CheckConnection(); + DataTable regionsettings = m_regionSettingsTable; + string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; + DataRow[] rawsettings = regionsettings.Select(searchExp); + if (rawsettings.Length == 0) + { + RegionSettings rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; + + StoreRegionSettings(rs); + + return rs; + } + DataRow row = rawsettings[0]; + + RegionSettings newSettings = buildRegionSettings(row); + newSettings.OnSave += StoreRegionSettings; + + return newSettings; + } + } + + public void StoreRegionSettings(RegionSettings rs) + { + lock (m_dataSet) + { + CheckConnection(); + DataTable regionsettings = m_dataSet.Tables["regionsettings"]; + + DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); + if (settingsRow == null) + { + settingsRow = regionsettings.NewRow(); + fillRegionSettingsRow(settingsRow, rs); + regionsettings.Rows.Add(settingsRow); + } + else + { + fillRegionSettingsRow(settingsRow, rs); + } + + Commit(); + } + } + + /// + /// + /// + /// + /// + public List LoadLandObjects(LLUUID regionUUID) + { + List landDataForRegion = new List(); + lock (m_dataSet) + { + CheckConnection(); + DataTable land = m_landTable; + DataTable landaccesslist = m_landAccessListTable; + string searchExp = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; + DataRow[] rawDataForRegion = land.Select(searchExp); + foreach (DataRow rawDataLand in rawDataForRegion) + { + LandData newLand = buildLandData(rawDataLand); + string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.GlobalID) + "'"; + DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); + foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) + { + newLand.ParcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); + } + + landDataForRegion.Add(newLand); + } + } + return landDataForRegion; + } + + /// + /// + /// + public void Commit() + { + lock (m_dataSet) + { + CheckConnection(); + // DisplayDataSet(m_dataSet, "Region DataSet"); + + m_primDataAdapter.Update(m_primTable); + m_shapeDataAdapter.Update(m_shapeTable); + + m_itemsDataAdapter.Update(m_itemsTable); + + m_terrainDataAdapter.Update(m_terrainTable); + m_landDataAdapter.Update(m_landTable); + m_landAccessListDataAdapter.Update(m_landAccessListTable); + m_regionSettingsDataAdapter.Update(m_regionSettingsTable); + + m_dataSet.AcceptChanges(); + } + } + + /// + /// See + /// + public void Shutdown() + { + Commit(); + } + + /*********************************************************************** + * + * Database Definition Functions + * + * This should be db agnostic as we define them in ADO.NET terms + * + **********************************************************************/ + + /// + /// + /// + /// + /// + /// + /// + private static DataColumn createCol(DataTable dt, string name, Type type) + { + DataColumn col = new DataColumn(name, type); + dt.Columns.Add(col); + return col; + } + + /// + /// Create the "terrain" table + /// + /// + private static DataTable createTerrainTable() + { + DataTable terrain = new DataTable("terrain"); + + createCol(terrain, "RegionUUID", typeof (String)); + createCol(terrain, "Revision", typeof (Int32)); + createCol(terrain, "Heightfield", typeof (Byte[])); + return terrain; + } + + /// + /// Create the "regionsettings" table + /// + /// + private static DataTable createRegionSettingsTable() + { + DataTable regionsettings = new DataTable("regionsettings"); + createCol(regionsettings, "regionUUID", typeof(String)); + createCol(regionsettings, "block_terraform", typeof (Int32)); + createCol(regionsettings, "block_fly", typeof (Int32)); + createCol(regionsettings, "allow_damage", typeof (Int32)); + createCol(regionsettings, "restrict_pushing", typeof (Int32)); + createCol(regionsettings, "allow_land_resell", typeof (Int32)); + createCol(regionsettings, "allow_land_join_divide", typeof (Int32)); + createCol(regionsettings, "block_show_in_search", typeof (Int32)); + createCol(regionsettings, "agent_limit", typeof (Int32)); + createCol(regionsettings, "object_bonus", typeof (Double)); + createCol(regionsettings, "maturity", typeof (Int32)); + createCol(regionsettings, "disable_scripts", typeof (Int32)); + createCol(regionsettings, "disable_collisions", typeof (Int32)); + createCol(regionsettings, "disable_physics", typeof (Int32)); + createCol(regionsettings, "terrain_texture_1", typeof(String)); + createCol(regionsettings, "terrain_texture_2", typeof(String)); + createCol(regionsettings, "terrain_texture_3", typeof(String)); + createCol(regionsettings, "terrain_texture_4", typeof(String)); + createCol(regionsettings, "elevation_1_nw", typeof (Double)); + createCol(regionsettings, "elevation_2_nw", typeof (Double)); + createCol(regionsettings, "elevation_1_ne", typeof (Double)); + createCol(regionsettings, "elevation_2_ne", typeof (Double)); + createCol(regionsettings, "elevation_1_se", typeof (Double)); + createCol(regionsettings, "elevation_2_se", typeof (Double)); + createCol(regionsettings, "elevation_1_sw", typeof (Double)); + createCol(regionsettings, "elevation_2_sw", typeof (Double)); + createCol(regionsettings, "water_height", typeof (Double)); + createCol(regionsettings, "terrain_raise_limit", typeof (Double)); + createCol(regionsettings, "terrain_lower_limit", typeof (Double)); + createCol(regionsettings, "use_estate_sun", typeof (Int32)); + createCol(regionsettings, "sandbox", typeof (Int32)); + createCol(regionsettings, "fixed_sun", typeof (Int32)); + createCol(regionsettings, "sun_position", typeof (Double)); + createCol(regionsettings, "covenant", typeof(String)); + + regionsettings.PrimaryKey = new DataColumn[] {regionsettings.Columns["RegionUUID"]}; + + return regionsettings; + } + + /// + /// Create the "prims" table + /// + /// + private static DataTable createPrimTable() + { + DataTable prims = new DataTable("prims"); + + createCol(prims, "UUID", typeof (String)); + createCol(prims, "RegionUUID", typeof (String)); + createCol(prims, "ParentID", typeof (Int32)); + createCol(prims, "CreationDate", typeof (Int32)); + createCol(prims, "Name", typeof (String)); + createCol(prims, "SceneGroupID", typeof (String)); + // various text fields + createCol(prims, "Text", typeof (String)); + createCol(prims, "Description", typeof (String)); + createCol(prims, "SitName", typeof (String)); + createCol(prims, "TouchName", typeof (String)); + // permissions + createCol(prims, "ObjectFlags", typeof (Int32)); + createCol(prims, "CreatorID", typeof (String)); + createCol(prims, "OwnerID", typeof (String)); + createCol(prims, "GroupID", typeof (String)); + createCol(prims, "LastOwnerID", typeof (String)); + createCol(prims, "OwnerMask", typeof (Int32)); + createCol(prims, "NextOwnerMask", typeof (Int32)); + createCol(prims, "GroupMask", typeof (Int32)); + createCol(prims, "EveryoneMask", typeof (Int32)); + createCol(prims, "BaseMask", typeof (Int32)); + // vectors + createCol(prims, "PositionX", typeof (Double)); + createCol(prims, "PositionY", typeof (Double)); + createCol(prims, "PositionZ", typeof (Double)); + createCol(prims, "GroupPositionX", typeof (Double)); + createCol(prims, "GroupPositionY", typeof (Double)); + createCol(prims, "GroupPositionZ", typeof (Double)); + createCol(prims, "VelocityX", typeof (Double)); + createCol(prims, "VelocityY", typeof (Double)); + createCol(prims, "VelocityZ", typeof (Double)); + createCol(prims, "AngularVelocityX", typeof (Double)); + createCol(prims, "AngularVelocityY", typeof (Double)); + createCol(prims, "AngularVelocityZ", typeof (Double)); + createCol(prims, "AccelerationX", typeof (Double)); + createCol(prims, "AccelerationY", typeof (Double)); + createCol(prims, "AccelerationZ", typeof (Double)); + // quaternions + createCol(prims, "RotationX", typeof (Double)); + createCol(prims, "RotationY", typeof (Double)); + createCol(prims, "RotationZ", typeof (Double)); + createCol(prims, "RotationW", typeof (Double)); + // sit target + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); + + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); + + + // Add in contraints + prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; + + return prims; + } + + /// + /// Create the "land" table + /// + /// + private static DataTable createLandTable() + { + DataTable land = new DataTable("land"); + createCol(land, "UUID", typeof (String)); + createCol(land, "RegionUUID", typeof (String)); + createCol(land, "LocalLandID", typeof (Int32)); + + // Bitmap is a byte[512] + createCol(land, "Bitmap", typeof (Byte[])); + + createCol(land, "Name", typeof (String)); + createCol(land, "Description", typeof (String)); + createCol(land, "OwnerUUID", typeof (String)); + createCol(land, "IsGroupOwned", typeof (Int32)); + createCol(land, "Area", typeof (Int32)); + createCol(land, "AuctionID", typeof (Int32)); //Unemplemented + createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory + createCol(land, "ClaimDate", typeof (Int32)); + createCol(land, "ClaimPrice", typeof (Int32)); + createCol(land, "GroupUUID", typeof (String)); + createCol(land, "SalePrice", typeof (Int32)); + createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus + createCol(land, "LandFlags", typeof (Int32)); + createCol(land, "LandingType", typeof (Int32)); + createCol(land, "MediaAutoScale", typeof (Int32)); + createCol(land, "MediaTextureUUID", typeof (String)); + createCol(land, "MediaURL", typeof (String)); + createCol(land, "MusicURL", typeof (String)); + createCol(land, "PassHours", typeof (Double)); + createCol(land, "PassPrice", typeof (Int32)); + createCol(land, "SnapshotUUID", typeof (String)); + createCol(land, "UserLocationX", typeof (Double)); + createCol(land, "UserLocationY", typeof (Double)); + createCol(land, "UserLocationZ", typeof (Double)); + createCol(land, "UserLookAtX", typeof (Double)); + createCol(land, "UserLookAtY", typeof (Double)); + createCol(land, "UserLookAtZ", typeof (Double)); + createCol(land, "AuthBuyerID", typeof (String)); + + land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; + + return land; + } + + /// + /// Create the "landaccesslist" table + /// + /// + private static DataTable createLandAccessListTable() + { + DataTable landaccess = new DataTable("landaccesslist"); + createCol(landaccess, "LandUUID", typeof (String)); + createCol(landaccess, "AccessUUID", typeof (String)); + createCol(landaccess, "Flags", typeof (Int32)); + + return landaccess; + } + + /// + /// Create the "primshapes" table + /// + /// + private static DataTable createShapeTable() + { + DataTable shapes = new DataTable("primshapes"); + createCol(shapes, "UUID", typeof (String)); + // shape is an enum + createCol(shapes, "Shape", typeof (Int32)); + // vectors + createCol(shapes, "ScaleX", typeof (Double)); + createCol(shapes, "ScaleY", typeof (Double)); + createCol(shapes, "ScaleZ", typeof (Double)); + // paths + createCol(shapes, "PCode", typeof (Int32)); + createCol(shapes, "PathBegin", typeof (Int32)); + createCol(shapes, "PathEnd", typeof (Int32)); + createCol(shapes, "PathScaleX", typeof (Int32)); + createCol(shapes, "PathScaleY", typeof (Int32)); + createCol(shapes, "PathShearX", typeof (Int32)); + createCol(shapes, "PathShearY", typeof (Int32)); + createCol(shapes, "PathSkew", typeof (Int32)); + createCol(shapes, "PathCurve", typeof (Int32)); + createCol(shapes, "PathRadiusOffset", typeof (Int32)); + createCol(shapes, "PathRevolutions", typeof (Int32)); + createCol(shapes, "PathTaperX", typeof (Int32)); + createCol(shapes, "PathTaperY", typeof (Int32)); + createCol(shapes, "PathTwist", typeof (Int32)); + createCol(shapes, "PathTwistBegin", typeof (Int32)); + // profile + createCol(shapes, "ProfileBegin", typeof (Int32)); + createCol(shapes, "ProfileEnd", typeof (Int32)); + createCol(shapes, "ProfileCurve", typeof (Int32)); + createCol(shapes, "ProfileHollow", typeof (Int32)); + createCol(shapes, "State", typeof(Int32)); + createCol(shapes, "Texture", typeof (Byte[])); + createCol(shapes, "ExtraParams", typeof (Byte[])); + + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; + + return shapes; + } + + /// + /// Create the "primitems" table + /// + /// + private static DataTable createItemsTable() + { + DataTable items = new DataTable("primitems"); + + createCol(items, "itemID", typeof (String)); + createCol(items, "primID", typeof (String)); + createCol(items, "assetID", typeof (String)); + createCol(items, "parentFolderID", typeof (String)); + + createCol(items, "invType", typeof (Int32)); + createCol(items, "assetType", typeof (Int32)); + + createCol(items, "name", typeof (String)); + createCol(items, "description", typeof (String)); + + createCol(items, "creationDate", typeof (Int64)); + createCol(items, "creatorID", typeof (String)); + createCol(items, "ownerID", typeof (String)); + createCol(items, "lastOwnerID", typeof (String)); + createCol(items, "groupID", typeof (String)); + + createCol(items, "nextPermissions", typeof (Int32)); + createCol(items, "currentPermissions", typeof (Int32)); + createCol(items, "basePermissions", typeof (Int32)); + createCol(items, "everyonePermissions", typeof (Int32)); + createCol(items, "groupPermissions", typeof (Int32)); + createCol(items, "flags", typeof (Int32)); + + items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; + + return items; + } + + /*********************************************************************** + * + * Convert between ADO.NET <=> OpenSim Objects + * + * These should be database independant + * + **********************************************************************/ + + /// + /// + /// + /// + /// + private SceneObjectPart buildPrim(DataRow row) + { + SceneObjectPart prim = new SceneObjectPart(); + prim.UUID = new LLUUID((String) row["UUID"]); + // explicit conversion of integers is required, which sort + // of sucks. No idea if there is a shortcut here or not. + prim.ParentID = Convert.ToUInt32(row["ParentID"]); + prim.CreationDate = Convert.ToInt32(row["CreationDate"]); + prim.Name = (String) row["Name"]; + // various text fields + prim.Text = (String) row["Text"]; + prim.Description = (String) row["Description"]; + prim.SitName = (String) row["SitName"]; + prim.TouchName = (String) row["TouchName"]; + // permissions + prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); + prim.CreatorID = new LLUUID((String) row["CreatorID"]); + prim.OwnerID = new LLUUID((String) row["OwnerID"]); + prim.GroupID = new LLUUID((String) row["GroupID"]); + prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); + prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); + prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); + prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); + prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); + prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); + // vectors + prim.OffsetPosition = new LLVector3( + Convert.ToSingle(row["PositionX"]), + Convert.ToSingle(row["PositionY"]), + Convert.ToSingle(row["PositionZ"]) + ); + prim.GroupPosition = new LLVector3( + Convert.ToSingle(row["GroupPositionX"]), + Convert.ToSingle(row["GroupPositionY"]), + Convert.ToSingle(row["GroupPositionZ"]) + ); + prim.Velocity = new LLVector3( + Convert.ToSingle(row["VelocityX"]), + Convert.ToSingle(row["VelocityY"]), + Convert.ToSingle(row["VelocityZ"]) + ); + prim.AngularVelocity = new LLVector3( + Convert.ToSingle(row["AngularVelocityX"]), + Convert.ToSingle(row["AngularVelocityY"]), + Convert.ToSingle(row["AngularVelocityZ"]) + ); + prim.Acceleration = new LLVector3( + Convert.ToSingle(row["AccelerationX"]), + Convert.ToSingle(row["AccelerationY"]), + Convert.ToSingle(row["AccelerationZ"]) + ); + // quaternions + prim.RotationOffset = new LLQuaternion( + Convert.ToSingle(row["RotationX"]), + Convert.ToSingle(row["RotationY"]), + Convert.ToSingle(row["RotationZ"]), + Convert.ToSingle(row["RotationW"]) + ); + try + { + prim.SitTargetPositionLL = new LLVector3( + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])); + prim.SitTargetOrientationLL = new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"])); + } + catch (InvalidCastException) + { + // Database table was created before we got here and needs to be created! :P + + lock (m_dataSet) + { + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + } + return prim; + } + + + /// + /// Build a prim inventory item from the persisted data. + /// + /// + /// + private static TaskInventoryItem buildItem(DataRow row) + { + TaskInventoryItem taskItem = new TaskInventoryItem(); + + taskItem.ItemID = new LLUUID((String)row["itemID"]); + taskItem.ParentPartID = new LLUUID((String)row["primID"]); + taskItem.AssetID = new LLUUID((String)row["assetID"]); + taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); + + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); + + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorID = new LLUUID((String)row["creatorID"]); + taskItem.OwnerID = new LLUUID((String)row["ownerID"]); + taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); + taskItem.GroupID = new LLUUID((String)row["groupID"]); + + taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); + taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); + taskItem.Flags = Convert.ToUInt32(row["flags"]); + + return taskItem; + } + + private static RegionSettings buildRegionSettings(DataRow row) + { + RegionSettings newSettings = new RegionSettings(); + + newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); + newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); + newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); + newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); + newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); + newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); + newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); + newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); + newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); + newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); + newSettings.Maturity = Convert.ToInt32(row["maturity"]); + newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); + newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); + newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); + newSettings.TerrainTexture1 = new LLUUID((String) row["terrain_texture_1"]); + newSettings.TerrainTexture2 = new LLUUID((String) row["terrain_texture_2"]); + newSettings.TerrainTexture3 = new LLUUID((String) row["terrain_texture_3"]); + newSettings.TerrainTexture4 = new LLUUID((String) row["terrain_texture_4"]); + newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); + newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); + newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); + newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); + newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); + newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); + newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); + newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); + newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); + newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); + newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); + newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); + newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); + newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); + newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); + newSettings.Covenant = new LLUUID((String) row["covenant"]); + + return newSettings; + } + + /// + /// + /// + /// + /// + private static LandData buildLandData(DataRow row) + { + LandData newData = new LandData(); + + newData.GlobalID = new LLUUID((String) row["UUID"]); + newData.LocalID = Convert.ToInt32(row["LocalLandID"]); + + // Bitmap is a byte[512] + newData.Bitmap = (Byte[]) row["Bitmap"]; + + newData.Name = (String) row["Name"]; + newData.Description = (String) row["Description"]; + newData.OwnerID = (String) row["OwnerUUID"]; + newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); + newData.Area = Convert.ToInt32(row["Area"]); + newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented + newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory + newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); + newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.GroupID = new LLUUID((String) row["GroupUUID"]); + newData.SalePrice = Convert.ToInt32(row["SalePrice"]); + newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus + newData.Flags = Convert.ToUInt32(row["LandFlags"]); + newData.LandingType = Convert.ToByte(row["LandingType"]); + newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); + newData.MediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.MediaURL = (String) row["MediaURL"]; + newData.MusicURL = (String) row["MusicURL"]; + newData.PassHours = Convert.ToSingle(row["PassHours"]); + newData.PassPrice = Convert.ToInt32(row["PassPrice"]); + LLUUID authedbuyer = LLUUID.Zero; + LLUUID snapshotID = LLUUID.Zero; + + Helpers.TryParse((string)row["AuthBuyerID"], out authedbuyer); + Helpers.TryParse((string)row["SnapshotUUID"], out snapshotID); + + newData.AuthBuyerID = authedbuyer; + newData.SnapshotID = snapshotID; + try + { + newData.UserLocation = + new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.UserLookAt = + new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); + } + catch (InvalidCastException) + { + newData.UserLocation = LLVector3.Zero; + newData.UserLookAt = LLVector3.Zero; + m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); + } + + newData.ParcelAccessList = new List(); + + return newData; + } + + /// + /// + /// + /// + /// + private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = new LLUUID((string) row["AccessUUID"]); + entry.Flags = (ParcelManager.AccessList) Convert.ToInt32(row["Flags"]); + entry.Time = new DateTime(); + return entry; + } + + /// + /// + /// + /// + /// + private static Array serializeTerrain(double[,] val) + { + MemoryStream str = new MemoryStream(65536*sizeof (double)); + BinaryWriter bw = new BinaryWriter(str); + + // TODO: COMPATIBILITY - Add byte-order conversions + for (int x = 0; x < 256; x++) + for (int y = 0; y < 256; y++) + { + double height = val[x, y]; + if (height == 0.0) + height = double.Epsilon; + + bw.Write(height); + } + + return str.ToArray(); + } + + /// + /// + /// + /// + /// + /// + /// + private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) + { + row["UUID"] = Util.ToRawUuidString(prim.UUID); + row["RegionUUID"] = Util.ToRawUuidString(regionUUID); + row["ParentID"] = prim.ParentID; + row["CreationDate"] = prim.CreationDate; + row["Name"] = prim.Name; + row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); + // the UUID of the root part for this SceneObjectGroup + // various text fields + row["Text"] = prim.Text; + row["Description"] = prim.Description; + row["SitName"] = prim.SitName; + row["TouchName"] = prim.TouchName; + // permissions + row["ObjectFlags"] = prim.ObjectFlags; + row["CreatorID"] = Util.ToRawUuidString(prim.CreatorID); + row["OwnerID"] = Util.ToRawUuidString(prim.OwnerID); + row["GroupID"] = Util.ToRawUuidString(prim.GroupID); + row["LastOwnerID"] = Util.ToRawUuidString(prim.LastOwnerID); + row["OwnerMask"] = prim.OwnerMask; + row["NextOwnerMask"] = prim.NextOwnerMask; + row["GroupMask"] = prim.GroupMask; + row["EveryoneMask"] = prim.EveryoneMask; + row["BaseMask"] = prim.BaseMask; + // vectors + row["PositionX"] = prim.OffsetPosition.X; + row["PositionY"] = prim.OffsetPosition.Y; + row["PositionZ"] = prim.OffsetPosition.Z; + row["GroupPositionX"] = prim.GroupPosition.X; + row["GroupPositionY"] = prim.GroupPosition.Y; + row["GroupPositionZ"] = prim.GroupPosition.Z; + row["VelocityX"] = prim.Velocity.X; + row["VelocityY"] = prim.Velocity.Y; + row["VelocityZ"] = prim.Velocity.Z; + row["AngularVelocityX"] = prim.AngularVelocity.X; + row["AngularVelocityY"] = prim.AngularVelocity.Y; + row["AngularVelocityZ"] = prim.AngularVelocity.Z; + row["AccelerationX"] = prim.Acceleration.X; + row["AccelerationY"] = prim.Acceleration.Y; + row["AccelerationZ"] = prim.Acceleration.Z; + // quaternions + row["RotationX"] = prim.RotationOffset.X; + row["RotationY"] = prim.RotationOffset.Y; + row["RotationZ"] = prim.RotationOffset.Z; + row["RotationW"] = prim.RotationOffset.W; + + try + { + // Sit target + LLVector3 sitTargetPos = prim.SitTargetPositionLL; + row["SitTargetOffsetX"] = sitTargetPos.X; + row["SitTargetOffsetY"] = sitTargetPos.Y; + row["SitTargetOffsetZ"] = sitTargetPos.Z; + + LLQuaternion sitTargetOrient = prim.SitTargetOrientationLL; + row["SitTargetOrientW"] = sitTargetOrient.W; + row["SitTargetOrientX"] = sitTargetOrient.X; + row["SitTargetOrientY"] = sitTargetOrient.Y; + row["SitTargetOrientZ"] = sitTargetOrient.Z; + } + catch (MySqlException) + { + // Database table was created before we got here and needs to be created! :P + + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + } + + /// + /// + /// + /// + /// + private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) + { + row["itemID"] = taskItem.ItemID; + row["primID"] = taskItem.ParentPartID; + row["assetID"] = taskItem.AssetID; + row["parentFolderID"] = taskItem.ParentID; + + row["invType"] = taskItem.InvType; + row["assetType"] = taskItem.Type; + + row["name"] = taskItem.Name; + row["description"] = taskItem.Description; + row["creationDate"] = taskItem.CreationDate; + row["creatorID"] = taskItem.CreatorID; + row["ownerID"] = taskItem.OwnerID; + row["lastOwnerID"] = taskItem.LastOwnerID; + row["groupID"] = taskItem.GroupID; + row["nextPermissions"] = taskItem.NextPermissions; + row["currentPermissions"] = taskItem.CurrentPermissions; + row["basePermissions"] = taskItem.BasePermissions; + row["everyonePermissions"] = taskItem.EveryonePermissions; + row["groupPermissions"] = taskItem.GroupPermissions; + row["flags"] = taskItem.Flags; + } + + /// + /// + /// + private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) + { + row["regionUUID"] = settings.RegionUUID.ToString(); + row["block_terraform"] = settings.BlockTerraform; + row["block_fly"] = settings.BlockFly; + row["allow_damage"] = settings.AllowDamage; + row["restrict_pushing"] = settings.RestrictPushing; + row["allow_land_resell"] = settings.AllowLandResell; + row["allow_land_join_divide"] = settings.AllowLandJoinDivide; + row["block_show_in_search"] = settings.BlockShowInSearch; + row["agent_limit"] = settings.AgentLimit; + row["object_bonus"] = settings.ObjectBonus; + row["maturity"] = settings.Maturity; + row["disable_scripts"] = settings.DisableScripts; + row["disable_collisions"] = settings.DisableCollisions; + row["disable_physics"] = settings.DisablePhysics; + row["terrain_texture_1"] = settings.TerrainTexture1.ToString(); + row["terrain_texture_2"] = settings.TerrainTexture2.ToString(); + row["terrain_texture_3"] = settings.TerrainTexture3.ToString(); + row["terrain_texture_4"] = settings.TerrainTexture4.ToString(); + row["elevation_1_nw"] = settings.Elevation1NW; + row["elevation_2_nw"] = settings.Elevation2NW; + row["elevation_1_ne"] = settings.Elevation1NE; + row["elevation_2_ne"] = settings.Elevation2NE; + row["elevation_1_se"] = settings.Elevation1SE; + row["elevation_2_se"] = settings.Elevation2SE; + row["elevation_1_sw"] = settings.Elevation1SW; + row["elevation_2_sw"] = settings.Elevation2SW; + row["water_height"] = settings.WaterHeight; + row["terrain_raise_limit"] = settings.TerrainRaiseLimit; + row["terrain_lower_limit"] = settings.TerrainLowerLimit; + row["use_estate_sun"] = settings.UseEstateSun; + row["sandbox"] = settings.Sandbox; + row["fixed_sun"] = settings.FixedSun; + row["sun_position"] = settings.SunPosition; + row["covenant"] = settings.Covenant.ToString(); + } + + /// + /// + /// + /// + /// + /// + private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) + { + row["UUID"] = Util.ToRawUuidString(land.GlobalID); + row["RegionUUID"] = Util.ToRawUuidString(regionUUID); + row["LocalLandID"] = land.LocalID; + + // Bitmap is a byte[512] + row["Bitmap"] = land.Bitmap; + + row["Name"] = land.Name; + row["Description"] = land.Description; + row["OwnerUUID"] = Util.ToRawUuidString(land.OwnerID); + row["IsGroupOwned"] = land.IsGroupOwned; + row["Area"] = land.Area; + row["AuctionID"] = land.AuctionID; //Unemplemented + row["Category"] = land.Category; //Enum libsecondlife.Parcel.ParcelCategory + row["ClaimDate"] = land.ClaimDate; + row["ClaimPrice"] = land.ClaimPrice; + row["GroupUUID"] = Util.ToRawUuidString(land.GroupID); + row["SalePrice"] = land.SalePrice; + row["LandStatus"] = land.Status; //Enum. libsecondlife.Parcel.ParcelStatus + row["LandFlags"] = land.Flags; + row["LandingType"] = land.LandingType; + row["MediaAutoScale"] = land.MediaAutoScale; + row["MediaTextureUUID"] = Util.ToRawUuidString(land.MediaID); + row["MediaURL"] = land.MediaURL; + row["MusicURL"] = land.MusicURL; + row["PassHours"] = land.PassHours; + row["PassPrice"] = land.PassPrice; + row["SnapshotUUID"] = Util.ToRawUuidString(land.SnapshotID); + row["UserLocationX"] = land.UserLocation.X; + row["UserLocationY"] = land.UserLocation.Y; + row["UserLocationZ"] = land.UserLocation.Z; + row["UserLookAtX"] = land.UserLookAt.X; + row["UserLookAtY"] = land.UserLookAt.Y; + row["UserLookAtZ"] = land.UserLookAt.Z; + row["AuthBuyerID"] = land.AuthBuyerID; + } + + /// + /// + /// + /// + /// + /// + private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) + { + row["LandUUID"] = Util.ToRawUuidString(parcelID); + row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); + row["Flags"] = entry.Flags; + } + + /// + /// + /// + /// + /// + private PrimitiveBaseShape buildShape(DataRow row) + { + PrimitiveBaseShape s = new PrimitiveBaseShape(); + s.Scale = new LLVector3( + Convert.ToSingle(row["ScaleX"]), + Convert.ToSingle(row["ScaleY"]), + Convert.ToSingle(row["ScaleZ"]) + ); + // paths + s.PCode = Convert.ToByte(row["PCode"]); + s.PathBegin = Convert.ToUInt16(row["PathBegin"]); + s.PathEnd = Convert.ToUInt16(row["PathEnd"]); + s.PathScaleX = Convert.ToByte(row["PathScaleX"]); + s.PathScaleY = Convert.ToByte(row["PathScaleY"]); + s.PathShearX = Convert.ToByte(row["PathShearX"]); + s.PathShearY = Convert.ToByte(row["PathShearY"]); + s.PathSkew = Convert.ToSByte(row["PathSkew"]); + s.PathCurve = Convert.ToByte(row["PathCurve"]); + s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); + s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); + s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); + s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); + s.PathTwist = Convert.ToSByte(row["PathTwist"]); + s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); + // profile + s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); + s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); + s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); + s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); + + byte[] textureEntry = (byte[]) row["Texture"]; + s.TextureEntry = textureEntry; + + s.ExtraParams = (byte[]) row["ExtraParams"]; + + try + { + s.State = Convert.ToByte(row["State"]); + } + catch (InvalidCastException) + { + // Database table was created before we got here and needs to be created! :P + lock (m_dataSet) + { + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + } + + return s; + } + + /// + /// + /// + /// + /// + private void fillShapeRow(DataRow row, SceneObjectPart prim) + { + PrimitiveBaseShape s = prim.Shape; + row["UUID"] = Util.ToRawUuidString(prim.UUID); + // shape is an enum + row["Shape"] = 0; + // vectors + row["ScaleX"] = s.Scale.X; + row["ScaleY"] = s.Scale.Y; + row["ScaleZ"] = s.Scale.Z; + // paths + row["PCode"] = s.PCode; + row["PathBegin"] = s.PathBegin; + row["PathEnd"] = s.PathEnd; + row["PathScaleX"] = s.PathScaleX; + row["PathScaleY"] = s.PathScaleY; + row["PathShearX"] = s.PathShearX; + row["PathShearY"] = s.PathShearY; + row["PathSkew"] = s.PathSkew; + row["PathCurve"] = s.PathCurve; + row["PathRadiusOffset"] = s.PathRadiusOffset; + row["PathRevolutions"] = s.PathRevolutions; + row["PathTaperX"] = s.PathTaperX; + row["PathTaperY"] = s.PathTaperY; + row["PathTwist"] = s.PathTwist; + row["PathTwistBegin"] = s.PathTwistBegin; + // profile + row["ProfileBegin"] = s.ProfileBegin; + row["ProfileEnd"] = s.ProfileEnd; + row["ProfileCurve"] = s.ProfileCurve; + row["ProfileHollow"] = s.ProfileHollow; + row["Texture"] = s.TextureEntry; + row["ExtraParams"] = s.ExtraParams; + + try + { + row["State"] = s.State; + } + catch (MySqlException) + { + lock (m_dataSet) + { + // Database table was created before we got here and needs to be created! :P + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", + m_connection)) + { + cmd.ExecuteNonQuery(); + } + } + } + } + + /// + /// + /// + /// + /// + /// + private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) + { + lock (m_dataSet) + { + DataTable prims = m_dataSet.Tables["prims"]; + DataTable shapes = m_dataSet.Tables["primshapes"]; + + DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (primRow == null) + { + primRow = prims.NewRow(); + fillPrimRow(primRow, prim, sceneGroupID, regionUUID); + prims.Rows.Add(primRow); + } + else + { + fillPrimRow(primRow, prim, sceneGroupID, regionUUID); + } + + DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); + if (shapeRow == null) + { + shapeRow = shapes.NewRow(); + fillShapeRow(shapeRow, prim); + shapes.Rows.Add(shapeRow); + } + else + { + fillShapeRow(shapeRow, prim); + } + } + } + + /// + /// see IRegionDatastore + /// + /// + /// + public void StorePrimInventory(LLUUID primID, ICollection items) + { + m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); + + // For now, we're just going to crudely remove all the previous inventory items + // no matter whether they have changed or not, and replace them with the current set. + lock (m_dataSet) + { + RemoveItems(primID); + + // repalce with current inventory details + foreach (TaskInventoryItem newItem in items) + { +// m_log.InfoFormat( +// "[REGION DB]: " + +// "Adding item {0}, {1} to prim ID {2}", +// newItem.Name, newItem.ItemID, newItem.ParentPartID); + + DataRow newItemRow = m_itemsTable.NewRow(); + fillItemRow(newItemRow, newItem); + m_itemsTable.Rows.Add(newItemRow); + } + } + + Commit(); + } + + /*********************************************************************** + * + * SQL Statement Creation Functions + * + * These functions create SQL statements for update, insert, and create. + * They can probably be factored later to have a db independant + * portion and a db specific portion + * + **********************************************************************/ + + /// + /// Create a MySQL insert command + /// + /// + /// + /// + /// + /// This is subtle enough to deserve some commentary. + /// Instead of doing *lots* and *lots of hardcoded strings + /// for database definitions we'll use the fact that + /// realistically all insert statements look like "insert + /// into A(b, c) values(:b, :c) on the parameterized query + /// front. If we just have a list of b, c, etc... we can + /// generate these strings instead of typing them out. + /// + private static MySqlCommand createInsertCommand(string table, DataTable dt) + { + + string[] cols = new string[dt.Columns.Count]; + for (int i = 0; i < dt.Columns.Count; i++) + { + DataColumn col = dt.Columns[i]; + cols[i] = col.ColumnName; + } + + string sql = "insert into " + table + "("; + sql += String.Join(", ", cols); + // important, the first ':' needs to be here, the rest get added in the join + sql += ") values (?"; + sql += String.Join(", ?", cols); + sql += ")"; + MySqlCommand cmd = new MySqlCommand(sql); + + // this provides the binding for all our parameters, so + // much less code than it used to be + foreach (DataColumn col in dt.Columns) + { + cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); + } + return cmd; + } + + /// + /// Create a MySQL update command + /// + /// + /// + /// + /// + private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) + { + string sql = "update " + table + " set "; + string subsql = String.Empty; + foreach (DataColumn col in dt.Columns) + { + if (subsql.Length > 0) + { + // a map function would rock so much here + subsql += ", "; + } + subsql += col.ColumnName + "=?" + col.ColumnName; + } + sql += subsql; + sql += " where " + pk; + MySqlCommand cmd = new MySqlCommand(sql); + + // this provides the binding for all our parameters, so + // much less code than it used to be + + foreach (DataColumn col in dt.Columns) + { + cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); + } + return cmd; + } + + /// + /// + /// + /// + /// + // private static string defineTable(DataTable dt) + // { + // string sql = "create table " + dt.TableName + "("; + // string subsql = String.Empty; + // foreach (DataColumn col in dt.Columns) + // { + // if (subsql.Length > 0) + // { + // // a map function would rock so much here + // subsql += ",\n"; + // } + // subsql += col.ColumnName + " " + MySqlType(col.DataType); + // if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) + // { + // subsql += " primary key"; + // } + // } + // sql += subsql; + // sql += ")"; + + // //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); + + // return sql; + // } + + /*********************************************************************** + * + * Database Binding functions + * + * These will be db specific due to typing, and minor differences + * in databases. + * + **********************************************************************/ + + /// + /// This is a convenience function that collapses 5 repetitive + /// lines for defining MySqlParameters to 2 parameters: + /// column name and database type. + /// + /// + /// It assumes certain conventions like ?param as the param + /// name to replace in parametrized queries, and that source + /// version is always current version, both of which are fine + /// for us. + /// + /// + /// a built MySql parameter + private static MySqlParameter createMySqlParameter(string name, Type type) + { + MySqlParameter param = new MySqlParameter(); + param.ParameterName = "?" + name; + param.DbType = dbtypeFromType(type); + param.SourceColumn = name; + param.SourceVersion = DataRowVersion.Current; + return param; + } + + /// + /// + /// + /// + /// + private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) + { + MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); + insertCommand.Connection = conn; + da.InsertCommand = insertCommand; + + MySqlCommand updateCommand = createUpdateCommand("prims", "UUID=?UUID", m_primTable); + updateCommand.Connection = conn; + da.UpdateCommand = updateCommand; + + MySqlCommand delete = new MySqlCommand("delete from prims where UUID=?UUID"); + delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + /// + /// + /// + /// + /// + private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("primitems", m_itemsTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("primitems", "itemID = ?itemID", m_itemsTable); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from primitems where itemID = ?itemID"); + delete.Parameters.Add(createMySqlParameter("itemID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + private void SetupRegionSettingsCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("regionsettings", m_regionSettingsTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID = ?regionUUID", m_regionSettingsTable); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from regionsettings where regionUUID = ?regionUUID"); + delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + /// + /// + /// + /// + /// + private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); + da.InsertCommand.Connection = conn; + } + + /// + /// + /// + /// + /// + private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("land", "UUID=?UUID", m_dataSet.Tables["land"]); + da.UpdateCommand.Connection = conn; + } + + /// + /// + /// + /// + /// + private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); + da.InsertCommand.Connection = conn; + } + + /// + /// + /// + /// + /// + private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("primshapes", "UUID=?UUID", m_dataSet.Tables["primshapes"]); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from primshapes where UUID = ?UUID"); + delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + + /// + /// + /// + /// MySQL connection handler + // private static void InitDB(MySqlConnection conn) + // { + // string createPrims = defineTable(createPrimTable()); + // string createShapes = defineTable(createShapeTable()); + // string createItems = defineTable(createItemsTable()); + // string createTerrain = defineTable(createTerrainTable()); + + // // Land table is created from the Versionable Test Table routine now. + // //string createLand = defineTable(createLandTable()); + // string createLandAccessList = defineTable(createLandAccessListTable()); + + // MySqlCommand pcmd = new MySqlCommand(createPrims, conn); + // MySqlCommand scmd = new MySqlCommand(createShapes, conn); + // MySqlCommand icmd = new MySqlCommand(createItems, conn); + // MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); + // //MySqlCommand lcmd = new MySqlCommand(createLand, conn); + // MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); + + // if (conn.State != ConnectionState.Open) + // { + // try + // { + // conn.Open(); + // } + // catch (Exception ex) + // { + // m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message); + // m_log.Error("[REGION DB]: Application is terminating!"); + // Thread.CurrentThread.Abort(); + // } + // } + + // try + // { + // pcmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e); + // } + + // try + // { + // scmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); + // } + + // try + // { + // icmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); + // } + + // try + // { + // tcmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e); + // } + + // //try + // //{ + // //lcmd.ExecuteNonQuery(); + // //} + // //catch (MySqlException e) + // //{ + // //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); + // //} + + // try + // { + // lalcmd.ExecuteNonQuery(); + // } + // catch (MySqlException e) + // { + // m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e); + // } + // conn.Close(); + // } + + /// + /// + /// + /// + /// + /// + private bool TestTables(MySqlConnection conn, Migration m) + { + // we already have migrations, get out of here + if (m.Version > 0) + return false; + + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); + MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); + MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); + MySqlDataAdapter sDa = new MySqlDataAdapter(shapeSelectCmd); + MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, conn); + MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd); + MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, conn); + MySqlDataAdapter tDa = new MySqlDataAdapter(terrainSelectCmd); + MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, conn); + MySqlDataAdapter lDa = new MySqlDataAdapter(landSelectCmd); + MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, conn); + MySqlDataAdapter lalDa = new MySqlDataAdapter(landAccessListSelectCmd); + + DataSet tmpDS = new DataSet(); + try + { + pDa.Fill(tmpDS, "prims"); + sDa.Fill(tmpDS, "primshapes"); + + iDa.Fill(tmpDS, "primitems"); + + tDa.Fill(tmpDS, "terrain"); + lDa.Fill(tmpDS, "land"); + lalDa.Fill(tmpDS, "landaccesslist"); + } + catch (MySqlException) + { + m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); + return false; + } + + // we have tables, but not a migration model yet + if (m.Version == 0) + m.Version = 1; + + return true; + + // pDa.Fill(tmpDS, "prims"); + // sDa.Fill(tmpDS, "primshapes"); + + // iDa.Fill(tmpDS, "primitems"); + + // tDa.Fill(tmpDS, "terrain"); + // lDa.Fill(tmpDS, "land"); + // lalDa.Fill(tmpDS, "landaccesslist"); + + // foreach (DataColumn col in createPrimTable().Columns) + // { + // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); + // return false; + // } + // } + + // foreach (DataColumn col in createShapeTable().Columns) + // { + // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); + // return false; + // } + // } + + // // XXX primitems should probably go here eventually + + // foreach (DataColumn col in createTerrainTable().Columns) + // { + // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); + // return false; + // } + // } + + // foreach (DataColumn col in createLandTable().Columns) + // { + // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); + // return false; + // } + // } + + // foreach (DataColumn col in createLandAccessListTable().Columns) + // { + // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) + // { + // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); + // return false; + // } + // } + + // return true; + } + + /*********************************************************************** + * + * Type conversion functions + * + **********************************************************************/ + + /// + /// Type conversion functions + /// + /// + /// + private static DbType dbtypeFromType(Type type) + { + if (type == typeof (String)) + { + return DbType.String; + } + else if (type == typeof (Int32)) + { + return DbType.Int32; + } + else if (type == typeof (Double)) + { + return DbType.Double; + } + else if (type == typeof (Byte)) + { + return DbType.Byte; + } + else if (type == typeof (Double)) + { + return DbType.Double; + } + else if (type == typeof (Byte[])) + { + return DbType.Binary; + } + else + { + return DbType.String; + } + } + + /// + /// + /// + /// + /// this is something we'll need to implement for each db slightly differently. + // private static string MySqlType(Type type) + // { + // if (type == typeof (String)) + // { + // return "varchar(255)"; + // } + // else if (type == typeof (Int32)) + // { + // return "integer"; + // } + // else if (type == typeof (Int64)) + // { + // return "bigint"; + // } + // else if (type == typeof (Double)) + // { + // return "float"; + // } + // else if (type == typeof (Byte[])) + // { + // return "longblob"; + // } + // else + // { + // return "string"; + // } + // } + } +} -- cgit v1.1 From 6ef9d4da901a346c232458317cca6268da888e2e Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 18 Aug 2008 00:39:10 +0000 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 +-- OpenSim/Data/MySQL/MySQLEstateData.cs | 62 ++++++++-------- OpenSim/Data/MySQL/MySQLGridData.cs | 6 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 18 ++--- OpenSim/Data/MySQL/MySQLLogData.cs | 8 +-- OpenSim/Data/MySQL/MySQLManager.cs | 18 ++--- OpenSim/Data/MySQL/MySQLRegionData.cs | 119 +++++++++++++++---------------- 7 files changed, 119 insertions(+), 120 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index cec736a..bdb1571 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -144,11 +144,11 @@ namespace OpenSim.Data.MySQL _dbConnection.GetTableVersion(tableList); // if there is no table, return, migrations will handle it. - if (tableList["assets"] == null) + if (tableList["assets"] == null) return; // if there is a table, and we don't have a migration, set it to 1 - if (m.Version == 0) + if (m.Version == 0) m.Version = 1; } @@ -272,12 +272,12 @@ namespace OpenSim.Data.MySQL lock (_dbConnection) { _dbConnection.CheckConnection(); - + MySqlCommand cmd = new MySqlCommand( "SELECT id FROM assets WHERE id=?id", _dbConnection.Connection); - + cmd.Parameters.AddWithValue("?id", uuid.ToString()); try diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 8991e02..2ab7d40 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -51,7 +51,7 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private long m_waitTimeout; private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; - private long m_lastConnectionUse; + private long m_lastConnectionUse; private FieldInfo[] m_Fields; private Dictionary m_FieldMap = @@ -83,13 +83,13 @@ namespace OpenSim.Data.MySQL } m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); - + //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); - - GetWaitTimeout(); + + GetWaitTimeout(); Assembly assem = GetType().Assembly; Migration m = new Migration(m_connection, assem, "EstateStore"); @@ -106,7 +106,7 @@ namespace OpenSim.Data.MySQL m_FieldMap[f.Name.Substring(2)] = f; } } - + private string[] FieldList { get { return new List(m_FieldMap.Keys).ToArray(); } @@ -116,28 +116,28 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); - + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (dbReader.Read()) { - m_waitTimeout + m_waitTimeout = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } - + } + dbReader.Close(); cmd.Dispose(); - } - + } + m_lastConnectionUse = System.DateTime.Now.Ticks; - + m_log.DebugFormat( "[REGION DB]: Connection wait timeout {0} seconds", - m_waitTimeout / TimeSpan.TicksPerSecond); + m_waitTimeout / TimeSpan.TicksPerSecond); } - + protected void CheckConnection() { long timeNow = System.DateTime.Now.Ticks; @@ -145,17 +145,17 @@ namespace OpenSim.Data.MySQL m_connection.State != ConnectionState.Open) { m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); - + lock (m_connection) { m_connection.Close(); m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); + m_connection.Open(); } } - - m_lastConnectionUse = timeNow; - } + + m_lastConnectionUse = timeNow; + } public EstateSettings LoadEstateSettings(LLUUID regionID) { @@ -210,7 +210,7 @@ namespace OpenSim.Data.MySQL names.Remove("EstateID"); sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")"; - + cmd.CommandText = sql; cmd.Parameters.Clear(); @@ -318,7 +318,7 @@ namespace OpenSim.Data.MySQL es.ClearBans(); CheckConnection(); - + MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; @@ -344,18 +344,18 @@ namespace OpenSim.Data.MySQL private void SaveBanList(EstateSettings es) { CheckConnection(); - + MySqlCommand cmd = m_connection.CreateCommand(); - + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); cmd.ExecuteNonQuery(); - + cmd.Parameters.Clear(); cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )"; - + foreach (EstateBan b in es.EstateBans) { cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); @@ -369,18 +369,18 @@ namespace OpenSim.Data.MySQL void SaveUUIDList(uint EstateID, string table, LLUUID[] data) { CheckConnection(); - + MySqlCommand cmd = m_connection.CreateCommand(); - + cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); cmd.ExecuteNonQuery(); - + cmd.Parameters.Clear(); cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; - + foreach (LLUUID uuid in data) { cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); @@ -396,7 +396,7 @@ namespace OpenSim.Data.MySQL List uuids = new List(); CheckConnection(); - + MySqlCommand cmd = m_connection.CreateCommand(); cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; @@ -414,7 +414,7 @@ namespace OpenSim.Data.MySQL uuids.Add(uuid); } r.Close(); - + return uuids.ToArray(); } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 4cddbe5..fcbceb8 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -49,8 +49,8 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; - override public void Initialise() - { + override public void Initialise() + { m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException (Name); } @@ -253,7 +253,7 @@ namespace OpenSim.Data.MySQL return null; } } - + /// /// Returns a sim profile from it's UUID /// diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index dd4d804..4e8200b 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -48,8 +48,8 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; - public void Initialise() - { + public void Initialise() + { m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException (Name); } @@ -81,7 +81,7 @@ namespace OpenSim.Data.MySQL string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - + database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); @@ -147,7 +147,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// MySQL connection handler /// @@ -180,7 +180,7 @@ namespace OpenSim.Data.MySQL // ... and set the version if (m.Version == 0) m.Version = 1; - + } #endregion @@ -290,7 +290,7 @@ namespace OpenSim.Data.MySQL } } - + /// /// see /// @@ -708,10 +708,10 @@ namespace OpenSim.Data.MySQL * - We will only need to hit the database twice instead of n times. * - We assume the database is well-formed - no stranded/dangling folders, all folders in heirarchy owned * by the same person, each user only has 1 inventory heirarchy - * - The returned list is not ordered, instead of breadth-first ordered + * - The returned list is not ordered, instead of breadth-first ordered There are basically 2 usage cases for getFolderHeirarchy: 1) Getting the user's entire inventory heirarchy when they log in - 2) Finding a subfolder heirarchy to delete when emptying the trash. + 2) Finding a subfolder heirarchy to delete when emptying the trash. This implementation will pull all inventory folders from the database, and then prune away any folder that is not part of the requested sub-heirarchy. The theory is that it is cheaper to make 1 request from the database than to make n requests. This pays off only if requested heirarchy is large. @@ -774,7 +774,7 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { InventoryFolderBase curFolder = readInventoryFolder(reader); - if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling + if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list else // else current folder has no known (yet) siblings { diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 456cfd2..c02016c 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -44,12 +44,12 @@ namespace OpenSim.Data.MySQL /// public MySQLManager database; - public void Initialise() - { + public void Initialise() + { m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException (Name); } - + /// /// Artificial constructor called when the plugin is loaded /// Uses the obsolete mysql_connection.ini if connect string is empty. @@ -100,7 +100,7 @@ namespace OpenSim.Data.MySQL Dictionary tableList = new Dictionary(); tableList["logs"] = null; database.GetTableVersion(tableList); - + // migrations will handle it if (tableList["logs"] == null) return; diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 58599a8..6ad6609 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -55,7 +55,7 @@ namespace OpenSim.Data.MySQL private string connectionString; private const string m_waitTimeoutSelect = "select @@wait_timeout"; - + /// /// Wait timeout for our connection in ticks. /// @@ -70,7 +70,7 @@ namespace OpenSim.Data.MySQL /// /// Holds the last tick time that the connection was used. /// - private long m_lastConnectionUse; + private long m_lastConnectionUse; /// /// Initialises and creates a new MySQL connection and maintains it. @@ -172,7 +172,7 @@ namespace OpenSim.Data.MySQL // inaccuracy. m_lastConnectionUse = timeNow; } - + /// /// Get the connection being used /// @@ -287,14 +287,14 @@ namespace OpenSim.Data.MySQL { lock (dbcon) { - CheckConnection(); - + CheckConnection(); + MySqlCommand tablesCmd = new MySqlCommand( "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { while (tables.Read()) @@ -541,7 +541,7 @@ namespace OpenSim.Data.MySQL LLUUID regionID = LLUUID.Zero; LLUUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero retval.HomeRegionID = regionID; - + retval.Created = Convert.ToInt32(reader["created"].ToString()); retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); @@ -1124,7 +1124,7 @@ namespace OpenSim.Data.MySQL sql += "?skirt_item, ?skirt_asset)"; bool returnval = false; - + // we want to send in byte data, which means we can't just pass down strings try { MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); @@ -1160,7 +1160,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); - + if (cmd.ExecuteNonQuery() > 0) returnval = true; diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 70b6d3c..85af5df 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -53,27 +53,27 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; - private const string m_regionSettingsSelect = "select * from regionsettings"; + private const string m_regionSettingsSelect = "select * from regionsettings"; private const string m_waitTimeoutSelect = "select @@wait_timeout"; private MySqlConnection m_connection; private string m_connectionString; - + /// /// Wait timeout for our connection in ticks. /// private long m_waitTimeout; - + /// /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long /// running database operations. /// private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; - + /// /// Holds the last tick time that the connection was used. /// - private long m_lastConnectionUse; + private long m_lastConnectionUse; private DataSet m_dataSet; private MySqlDataAdapter m_primDataAdapter; @@ -105,7 +105,7 @@ namespace OpenSim.Data.MySQL public void Initialise(string connectionString) { m_connectionString = connectionString; - + m_dataSet = new DataSet(); int passPosition = 0; @@ -132,8 +132,8 @@ namespace OpenSim.Data.MySQL m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); - - GetWaitTimeout(); + + GetWaitTimeout(); // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; @@ -177,12 +177,11 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_shapeTable); SetupShapeCommands(m_shapeDataAdapter, m_connection); m_shapeDataAdapter.Fill(m_shapeTable); - - m_itemsTable = createItemsTable(); - m_dataSet.Tables.Add(m_itemsTable); - SetupItemsCommands(m_itemsDataAdapter, m_connection); - m_itemsDataAdapter.Fill(m_itemsTable); + m_itemsTable = createItemsTable(); + m_dataSet.Tables.Add(m_itemsTable); + SetupItemsCommands(m_itemsDataAdapter, m_connection); + m_itemsDataAdapter.Fill(m_itemsTable); m_terrainTable = createTerrainTable(); m_dataSet.Tables.Add(m_terrainTable); @@ -205,58 +204,58 @@ namespace OpenSim.Data.MySQL m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); } } - + /// /// Get the wait_timeout value for our connection /// protected void GetWaitTimeout() { MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); - + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (dbReader.Read()) { - m_waitTimeout + m_waitTimeout = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } - + } + dbReader.Close(); cmd.Dispose(); - } - + } + m_lastConnectionUse = System.DateTime.Now.Ticks; - + m_log.DebugFormat( - "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); + "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); } - + /// /// Should be called before any db operation. This checks to see if the connection has not timed out /// protected void CheckConnection() { //m_log.Debug("[REGION DB]: Checking connection"); - + long timeNow = System.DateTime.Now.Ticks; if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) { m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); - + lock (m_connection) { m_connection.Close(); m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); + m_connection.Open(); } } - + // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather // than require the code to call another method - the timeout leeway should be large enough to cover the // inaccuracy. - m_lastConnectionUse = timeNow; - } - + m_lastConnectionUse = timeNow; + } + /// /// Given a list of tables, return the version of the tables, as seen in the database /// @@ -271,7 +270,7 @@ namespace OpenSim.Data.MySQL "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - + CheckConnection(); using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { @@ -465,7 +464,7 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { - CheckConnection(); + CheckConnection(); DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); m_log.Info("[REGION DB]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); @@ -587,10 +586,10 @@ namespace OpenSim.Data.MySQL using (cmd) { delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); - + CheckConnection(); delete.ExecuteNonQuery(); - + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); @@ -774,7 +773,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -805,7 +804,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// public void Commit() { @@ -845,7 +844,7 @@ namespace OpenSim.Data.MySQL **********************************************************************/ /// - /// + /// /// /// /// @@ -1139,7 +1138,7 @@ namespace OpenSim.Data.MySQL **********************************************************************/ /// - /// + /// /// /// /// @@ -1315,7 +1314,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1374,14 +1373,14 @@ namespace OpenSim.Data.MySQL newData.UserLookAt = LLVector3.Zero; m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); } - + newData.ParcelAccessList = new List(); return newData; } /// - /// + /// /// /// /// @@ -1395,7 +1394,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1419,7 +1418,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1502,7 +1501,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1532,7 +1531,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) { @@ -1573,7 +1572,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1618,7 +1617,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1631,7 +1630,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1694,7 +1693,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1731,7 +1730,7 @@ namespace OpenSim.Data.MySQL row["ProfileHollow"] = s.ProfileHollow; row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; - + try { row["State"] = s.State; @@ -1754,7 +1753,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1911,7 +1910,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1973,7 +1972,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -1994,7 +1993,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -2027,7 +2026,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -2038,7 +2037,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -2052,7 +2051,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -2063,7 +2062,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// /// @@ -2082,7 +2081,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// /// /// MySQL connection handler // private static void InitDB(MySqlConnection conn) @@ -2174,7 +2173,7 @@ namespace OpenSim.Data.MySQL // } /// - /// + /// /// /// /// -- cgit v1.1 From 05506cff499b999d6c01e0517e658293b4791317 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 18 Aug 2008 17:22:36 +0000 Subject: Avatar Attachment persistence!! Patch #9168 (Mantis #1171) Plumbs in attachment persistence and adds the tables. Currently MySQL only, no user functionality yet. --- OpenSim/Data/MySQL/MySQLManager.cs | 51 ++++++++++++++++++++++++++ OpenSim/Data/MySQL/MySQLUserData.cs | 25 +++++++++++++ OpenSim/Data/MySQL/Resources/005_UserStore.sql | 5 +++ 3 files changed, 81 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/005_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 6ad6609..3a62ec2 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Collections; using System.Data; using System.IO; using System.Reflection; @@ -660,6 +661,26 @@ namespace OpenSim.Data.MySQL } + // Read attachment list from data reader + public Hashtable readAttachments(IDataReader r) + { + Hashtable ret = new Hashtable(); + + while(r.Read()) + { + int attachpoint = Convert.ToInt32(r["attachpoint"]); + if(ret.ContainsKey(attachpoint)) + continue; + Hashtable item = new Hashtable(); + item.Add("item", r["item"].ToString()); + item.Add("asset", r["asset"].ToString()); + + ret.Add(attachpoint, item); + } + + return ret; + } + /// /// Inserts a new row into the log database /// @@ -1176,5 +1197,35 @@ namespace OpenSim.Data.MySQL } + public void writeAttachments(LLUUID agentID, Hashtable data) + { + string sql = "delete from avatarattachments where UUID = ?uuid"; + + MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); + + cmd.ExecuteNonQuery(); + + sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attchpoint, ?item, ?asset)"; + + cmd = (MySqlCommand) dbcon.CreateCommand(); + cmd.CommandText = sql; + + foreach(DictionaryEntry e in data) + { + int attachpoint = Convert.ToInt32(e.Key); + + Hashtable item = (Hashtable)e.Value; + + cmd.Parameters.Clear(); + cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); + cmd.Parameters.AddWithValue("?attachpoint", attachpoint); + cmd.Parameters.AddWithValue("?item", item["item"]); + cmd.Parameters.AddWithValue("?asset", item["asset"]); + + cmd.ExecuteNonQuery(); + } + } } } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index f77d947..627bc0c 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Data; using System.Reflection; @@ -34,6 +35,7 @@ using libsecondlife; using log4net; using OpenSim.Framework; using OpenSim.Data.Base; +using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL { @@ -737,6 +739,8 @@ namespace OpenSim.Data.MySQL reader.Dispose(); result.Dispose(); + appearance.SetAttachments(GetUserAttachments(user)); + return appearance; } } @@ -762,6 +766,8 @@ namespace OpenSim.Data.MySQL { appearance.Owner = user; database.insertAppearanceRow(appearance); + + UpdateUserAttachments(user, appearance.GetAttachments()); } } catch (Exception e) @@ -818,5 +824,24 @@ namespace OpenSim.Data.MySQL { get {return "0.1";} } + + public Hashtable GetUserAttachments(LLUUID agentID) + { + MySqlCommand cmd = (MySqlCommand) (database.Connection.CreateCommand()); + cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; + cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); + + IDataReader r = cmd.ExecuteReader(); + + return database.readAttachments(r); + } + + public void UpdateUserAttachments(LLUUID agentID, Hashtable data) + { + if(data == null) + return; + + database.writeAttachments(agentID, data); + } } } diff --git a/OpenSim/Data/MySQL/Resources/005_UserStore.sql b/OpenSim/Data/MySQL/Resources/005_UserStore.sql new file mode 100644 index 0000000..55896bc --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=InnoDB; + +COMMIT; -- cgit v1.1 From 9e6b38078a700affa3ed40fc81f9c04f70bb93b7 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 18 Aug 2008 21:18:59 +0000 Subject: * Properly dispose of the reader after readAttachments() has finished with it in the Mysql User data manager --- OpenSim/Data/MySQL/MySQLManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 3a62ec2..9f50c9f 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -660,13 +660,12 @@ namespace OpenSim.Data.MySQL return appearance; } - // Read attachment list from data reader public Hashtable readAttachments(IDataReader r) { Hashtable ret = new Hashtable(); - while(r.Read()) + while (r.Read()) { int attachpoint = Convert.ToInt32(r["attachpoint"]); if(ret.ContainsKey(attachpoint)) @@ -677,6 +676,8 @@ namespace OpenSim.Data.MySQL ret.Add(attachpoint, item); } + + r.Close(); return ret; } -- cgit v1.1 From a179089d1c0afbb9cb53e47b4d1f236cb6e452f2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 18 Aug 2008 21:46:07 +0000 Subject: * If two regions have configuration information that conflicts (save xy location, same uuid or same internal ip port) then complain loudly and don't start up --- OpenSim/Data/MySQL/MySQLUserData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 627bc0c..1ae5645 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -409,6 +409,7 @@ namespace OpenSim.Data.MySQL Lfli.Add(fli); } + reader.Dispose(); result.Dispose(); } -- cgit v1.1 From 6d2e1ad6ba73fb0eba51b3885ff0a4d7d1b5d611 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 02:12:40 +0000 Subject: Attachment persistence!!! Patch #9169 (Mantis #1171) Attachments now save to MySQL. No reattach on login yet. --- OpenSim/Data/MySQL/MySQLManager.cs | 5 ++++- OpenSim/Data/MySQL/MySQLUserData.cs | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 9f50c9f..b857aad 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -1208,7 +1208,10 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); - sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attchpoint, ?item, ?asset)"; + if (data == null) + return; + + sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; cmd = (MySqlCommand) dbcon.CreateCommand(); cmd.CommandText = sql; diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 1ae5645..82ca5b1 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -834,14 +834,15 @@ namespace OpenSim.Data.MySQL IDataReader r = cmd.ExecuteReader(); - return database.readAttachments(r); + Hashtable ret = database.readAttachments(r); + + r.Close(); + + return ret; } public void UpdateUserAttachments(LLUUID agentID, Hashtable data) { - if(data == null) - return; - database.writeAttachments(agentID, data); } } -- cgit v1.1 From bea7d4d81ad7a75706305be6c8ca06f8dc6e6eca Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 19 Aug 2008 02:59:27 +0000 Subject: Update svn properties, formatting cleanup. --- OpenSim/Data/MySQL/MySQLManager.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLUserData.cs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index b857aad..c9a0498 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -668,7 +668,7 @@ namespace OpenSim.Data.MySQL while (r.Read()) { int attachpoint = Convert.ToInt32(r["attachpoint"]); - if(ret.ContainsKey(attachpoint)) + if (ret.ContainsKey(attachpoint)) continue; Hashtable item = new Hashtable(); item.Add("item", r["item"].ToString()); @@ -676,7 +676,7 @@ namespace OpenSim.Data.MySQL ret.Add(attachpoint, item); } - + r.Close(); return ret; @@ -1205,7 +1205,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); cmd.CommandText = sql; cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - + cmd.ExecuteNonQuery(); if (data == null) @@ -1216,7 +1216,7 @@ namespace OpenSim.Data.MySQL cmd = (MySqlCommand) dbcon.CreateCommand(); cmd.CommandText = sql; - foreach(DictionaryEntry e in data) + foreach (DictionaryEntry e in data) { int attachpoint = Convert.ToInt32(e.Key); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 82ca5b1..9a056b2 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -57,8 +57,8 @@ namespace OpenSim.Data.MySQL private string m_appearanceTableName = "avatarappearance"; private string m_connectString; - public override void Initialise() - { + public override void Initialise() + { m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException (Name); } @@ -409,7 +409,7 @@ namespace OpenSim.Data.MySQL Lfli.Add(fli); } - + reader.Dispose(); result.Dispose(); } -- cgit v1.1 From 41440e184b1c12f1b83d894b2cd5b7b801b4ca38 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 18:34:46 +0000 Subject: Attachment persistence (Mantis #1711) Change user server to handle attachment assets record properly. Ensure that attachments are not re-rezzed on region crossing. Persistence will NOT WORK with earliser UGAI!! Change region server to match. --- OpenSim/Data/MySQL/MySQLUserData.cs | 39 +++++++++---------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 9a056b2..caae677 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -779,36 +779,6 @@ namespace OpenSim.Data.MySQL } /// - /// Adds an attachment item to a user - /// - /// the user UUID - /// the item UUID - override public void AddAttachment(LLUUID user, LLUUID item) - { - return; - } - - /// - /// Removes an attachment from a user - /// - /// the user UUID - /// the item UUID - override public void RemoveAttachment(LLUUID user, LLUUID item) - { - return; - } - - /// - /// Get the list of item attached to a user - /// - /// the user UUID - /// UUID list of attached item - override public List GetAttachments(LLUUID user) - { - return new List(); - } - - /// /// Database provider name /// /// Provider name @@ -845,5 +815,14 @@ namespace OpenSim.Data.MySQL { database.writeAttachments(agentID, data); } + + override public void ResetAttachments(LLUUID userID) + { + MySqlCommand cmd = (MySqlCommand) (database.Connection.CreateCommand()); + cmd.CommandText = "update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; + cmd.Parameters.AddWithValue("?uuid", userID.ToString()); + + cmd.ExecuteNonQuery(); + } } } -- cgit v1.1 From f9ec65bc21b39209e3093e91bb44f6fc058a9577 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 24 Aug 2008 03:15:02 +0000 Subject: Add the fields for the eye candy and sale featires to the prims table. No user functionality yet. Run prebuild. Contains a Migration. May contain nuts. --- OpenSim/Data/MySQL/Resources/016_RegionStore.sql | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/016_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/016_RegionStore.sql b/OpenSim/Data/MySQL/Resources/016_RegionStore.sql new file mode 100644 index 0000000..9bc265e --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/016_RegionStore.sql @@ -0,0 +1,27 @@ +BEGIN; + +ALTER TABLE prims ADD COLUMN PayPrice integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton1 integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton2 integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton3 integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton4 integer not null default 0; +ALTER TABLE prims ADD COLUMN LoopedSound char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE prims ADD COLUMN LoopedSoundGain float not null default 0.0; +ALTER TABLE prims ADD COLUMN TextureAnimation blob; +ALTER TABLE prims ADD COLUMN OmegaX float not null default 0.0; +ALTER TABLE prims ADD COLUMN OmegaY float not null default 0.0; +ALTER TABLE prims ADD COLUMN OmegaZ float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraAtOffsetX float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraAtOffsetY float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float not null default 0.0; +ALTER TABLE prims ADD COLUMN ForceMouselook tinyint not null default 0; +ALTER TABLE prims ADD COLUMN ScriptAccessPin integer not null default 0; +ALTER TABLE prims ADD COLUMN AllowedDrop tinyint not null default 0; +ALTER TABLE prims ADD COLUMN DieAtEdge tinyint not null default 0; +ALTER TABLE prims ADD COLUMN SalePrice integer not null default 10; +ALTER TABLE prims ADD COLUMN SaleType tinyint not null default 0; + +COMMIT; -- cgit v1.1 From c9b5641c499d23ff6674cafa1026b88ade1debec Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 24 Aug 2008 05:25:26 +0000 Subject: Plumb the data path for all those eye candy values. Saves texture animation, target omega, looped sound, script access pin, allowed drop state and sale data. Loads it, too. Not all tested. Code: No Nuts. Data: Cannot Guarantee Nut Free. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 194 ++++++++++++++++++++++++---------- 1 file changed, 139 insertions(+), 55 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 85af5df..c0ebbc6 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -979,6 +979,38 @@ namespace OpenSim.Data.MySQL createCol(prims, "SitTargetOrientY", typeof (Double)); createCol(prims, "SitTargetOrientZ", typeof (Double)); + createCol(prims, "PayPrice", typeof(Int32)); + createCol(prims, "PayButton1", typeof(Int32)); + createCol(prims, "PayButton2", typeof(Int32)); + createCol(prims, "PayButton3", typeof(Int32)); + createCol(prims, "PayButton4", typeof(Int32)); + + createCol(prims, "LoopedSound", typeof(String)); + createCol(prims, "LoopedSoundGain", typeof(Double)); + createCol(prims, "TextureAnimation", typeof(Byte[])); + + createCol(prims, "OmegaX", typeof (Double)); + createCol(prims, "OmegaY", typeof (Double)); + createCol(prims, "OmegaZ", typeof (Double)); + + createCol(prims, "CameraEyeOffsetX", typeof (Double)); + createCol(prims, "CameraEyeOffsetY", typeof (Double)); + createCol(prims, "CameraEyeOffsetZ", typeof (Double)); + + createCol(prims, "CameraAtOffsetX", typeof (Double)); + createCol(prims, "CameraAtOffsetY", typeof (Double)); + createCol(prims, "CameraAtOffsetZ", typeof (Double)); + + createCol(prims, "ForceMouselook", typeof (Int16)); + + createCol(prims, "ScriptAccessPin", typeof(Int32)); + + createCol(prims, "AllowedDrop", typeof (Int16)); + createCol(prims, "DieAtEdge", typeof (Int16)); + + createCol(prims, "SalePrice", typeof(Int32)); + createCol(prims, "SaleType", typeof (Int16)); + // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -1200,38 +1232,66 @@ namespace OpenSim.Data.MySQL Convert.ToSingle(row["RotationZ"]), Convert.ToSingle(row["RotationW"]) ); - try - { - prim.SitTargetPositionLL = new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])); - prim.SitTargetOrientationLL = new LLQuaternion( - Convert.ToSingle( - row["SitTargetOrientX"]), - Convert.ToSingle( - row["SitTargetOrientY"]), - Convert.ToSingle( - row["SitTargetOrientZ"]), - Convert.ToSingle( - row["SitTargetOrientW"])); - } - catch (InvalidCastException) - { - // Database table was created before we got here and needs to be created! :P + prim.SitTargetPositionLL = new LLVector3( + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"]) + ); + prim.SitTargetOrientationLL = new LLQuaternion( + Convert.ToSingle(row["SitTargetOrientX"]), + Convert.ToSingle(row["SitTargetOrientY"]), + Convert.ToSingle(row["SitTargetOrientZ"]), + Convert.ToSingle(row["SitTargetOrientW"]) + ); + + prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]); + prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]); + prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]); + prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); + prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); + + prim.Sound = new LLUUID(row["LoopedSound"].ToString()); + prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); + prim.SoundFlags = 1; // If it's persisted at all, it's looped + + if (!row.IsNull("TextureAnimation")) + prim.TextureAnimation = (Byte[])row["TextureAnimation"]; + + prim.RotationalVelocity = new LLVector3( + Convert.ToSingle(row["OmegaX"]), + Convert.ToSingle(row["OmegaY"]), + Convert.ToSingle(row["OmegaZ"]) + ); + + // TODO: Rotation + // OmegaX, OmegaY, OmegaZ + + prim.SetCameraEyeOffset(new LLVector3( + Convert.ToSingle(row["CameraEyeOffsetX"]), + Convert.ToSingle(row["CameraEyeOffsetY"]), + Convert.ToSingle(row["CameraEyeOffsetZ"]) + )); + + prim.SetCameraAtOffset(new LLVector3( + Convert.ToSingle(row["CameraAtOffsetX"]), + Convert.ToSingle(row["CameraAtOffsetY"]), + Convert.ToSingle(row["CameraAtOffsetZ"]) + )); + + if (Convert.ToInt16(row["ForceMouselook"]) != 0) + prim.SetForceMouselook(true); + + prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]); + + if (Convert.ToInt16(row["AllowedDrop"]) != 0) + prim.AllowedDrop = true; + + if (Convert.ToInt16(row["DieAtEdge"]) != 0) + prim.DIE_AT_EDGE = true; + + prim.SalePrice = Convert.ToInt32(row["SalePrice"]); + prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); - lock (m_dataSet) - { - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } return prim; } @@ -1471,33 +1531,57 @@ namespace OpenSim.Data.MySQL row["RotationZ"] = prim.RotationOffset.Z; row["RotationW"] = prim.RotationOffset.W; - try + // Sit target + LLVector3 sitTargetPos = prim.SitTargetPositionLL; + row["SitTargetOffsetX"] = sitTargetPos.X; + row["SitTargetOffsetY"] = sitTargetPos.Y; + row["SitTargetOffsetZ"] = sitTargetPos.Z; + + LLQuaternion sitTargetOrient = prim.SitTargetOrientationLL; + row["SitTargetOrientW"] = sitTargetOrient.W; + row["SitTargetOrientX"] = sitTargetOrient.X; + row["SitTargetOrientY"] = sitTargetOrient.Y; + row["SitTargetOrientZ"] = sitTargetOrient.Z; + + row["PayPrice"] = prim.PayPrice[0]; + row["PayButton1"] = prim.PayPrice[1]; + row["PayButton2"] = prim.PayPrice[2]; + row["PayButton3"] = prim.PayPrice[3]; + row["PayButton4"] = prim.PayPrice[4]; + + if ((prim.SoundFlags & 1) != 0) // Looped { - // Sit target - LLVector3 sitTargetPos = prim.SitTargetPositionLL; - row["SitTargetOffsetX"] = sitTargetPos.X; - row["SitTargetOffsetY"] = sitTargetPos.Y; - row["SitTargetOffsetZ"] = sitTargetPos.Z; - - LLQuaternion sitTargetOrient = prim.SitTargetOrientationLL; - row["SitTargetOrientW"] = sitTargetOrient.W; - row["SitTargetOrientX"] = sitTargetOrient.X; - row["SitTargetOrientY"] = sitTargetOrient.Y; - row["SitTargetOrientZ"] = sitTargetOrient.Z; + row["LoopedSound"] = prim.Sound.ToString(); + row["LoopedSoundGain"] = prim.SoundGain; } - catch (MySqlException) - { - // Database table was created before we got here and needs to be created! :P - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } + row["TextureAnimation"] = prim.TextureAnimation; + + row["OmegaX"] = prim.RotationalVelocity.X; + row["OmegaY"] = prim.RotationalVelocity.Y; + row["OmegaZ"] = prim.RotationalVelocity.Z; + + row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; + row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().Y; + row["CameraEyeOffsetZ"] = prim.GetCameraEyeOffset().Z; + + row["CameraAtOffsetX"] = prim.GetCameraAtOffset().X; + row["CameraAtOffsetX"] = prim.GetCameraAtOffset().Y; + row["CameraAtOffsetZ"] = prim.GetCameraAtOffset().Z; + + if (prim.GetForceMouselook()) + row["ForceMouselook"] = 1; + + row["ScriptAccessPin"] = prim.ScriptAccessPin; + + if (prim.AllowedDrop) + row["AllowedDrop"] = 1; + if (prim.DIE_AT_EDGE) + row["DieAtEdge"] = 1; + + row["SalePrice"] = prim.SalePrice; + row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); + } /// -- cgit v1.1 From 07cb1d4f0e9acfaba22b9b8ef1611613ab827a1a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 24 Aug 2008 06:39:54 +0000 Subject: Selling an object in-place (as original) now works. Builders can now ply their trade. Is that nuts? --- OpenSim/Data/MySQL/MySQLRegionData.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c0ebbc6..f6b49af 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1554,6 +1554,11 @@ namespace OpenSim.Data.MySQL row["LoopedSound"] = prim.Sound.ToString(); row["LoopedSoundGain"] = prim.SoundGain; } + else + { + row["LoopedSound"] = LLUUID.Zero; + row["LoopedSoundGain"] = 0.0f; + } row["TextureAnimation"] = prim.TextureAnimation; @@ -1562,22 +1567,29 @@ namespace OpenSim.Data.MySQL row["OmegaZ"] = prim.RotationalVelocity.Z; row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; - row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().Y; + row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; row["CameraEyeOffsetZ"] = prim.GetCameraEyeOffset().Z; row["CameraAtOffsetX"] = prim.GetCameraAtOffset().X; - row["CameraAtOffsetX"] = prim.GetCameraAtOffset().Y; + row["CameraAtOffsetY"] = prim.GetCameraAtOffset().Y; row["CameraAtOffsetZ"] = prim.GetCameraAtOffset().Z; if (prim.GetForceMouselook()) row["ForceMouselook"] = 1; + else + row["ForceMouselook"] = 0; row["ScriptAccessPin"] = prim.ScriptAccessPin; if (prim.AllowedDrop) row["AllowedDrop"] = 1; + else + row["AllowedDrop"] = 0; + if (prim.DIE_AT_EDGE) row["DieAtEdge"] = 1; + else + row["DieAtEdge"] = 0; row["SalePrice"] = prim.SalePrice; row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); -- cgit v1.1 From d2f2ec12fd3a41aa0b58716f59c950eeaf7b75ab Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 24 Aug 2008 18:32:39 +0000 Subject: Mantis#2027. Thank you kindly, HomerHorwitz for a patch that addresses: Analysis shows that the XMLRPC-request contains an empty string () for the custom_type parameter, which is deserialized wrongly to a null-value, thus leading to the exception above. The attached patch (against r5967) fixes the symptom and uses "" for customType in that case. --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index c9a0498..d193c72 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -902,7 +902,7 @@ namespace OpenSim.Data.MySQL parameters["?webLoginKey"] = webLoginKey.ToString(); parameters["?userFlags"] = userFlags.ToString(); parameters["?godLevel"] = godLevel.ToString(); - parameters["?customType"] = customType.ToString(); + parameters["?customType"] = customType == null ? "" : customType.ToString(); parameters["?partner"] = partner.ToString(); bool returnval = false; -- cgit v1.1 From 53afa236086c31663cfbae1f2c906e135b44c96b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 27 Aug 2008 18:51:36 +0000 Subject: 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. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 305 +--------------------------------- 1 file changed, 3 insertions(+), 302 deletions(-) (limited to 'OpenSim/Data/MySQL') 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 // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; Migration m = new Migration(m_connection, assem, "RegionStore"); - - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m_connection, m); - m.Update(); + MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); @@ -166,6 +162,7 @@ namespace OpenSim.Data.MySQL MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); + // TODO: move out the ADO.NET pieces here and just go to the db directly lock (m_dataSet) { m_primTable = createPrimTable(); @@ -294,18 +291,6 @@ namespace OpenSim.Data.MySQL } } } - // private void TestTablesVersionable(MySqlConnection dbconn) - // { - // Dictionary tableList = new Dictionary(); - - // tableList["land"] = null; - // dbconn.Open(); - // GetTableVersion(tableList,dbconn); - - // UpgradeLandTable(tableList["land"], dbconn); - // //database.Close(); - - // } /// /// Execute a SQL statement stored in a resource, as a string @@ -346,28 +331,6 @@ namespace OpenSim.Data.MySQL } /// - /// - /// Execute CreateLandTable.sql if oldVersion == null - /// Execute UpgradeLandTable.sqm if oldVersion contain "Rev." - /// - /// - /// - /// The database connection handler - // private void UpgradeLandTable(string oldVersion, MySqlConnection dbconn) - // { - // // null as the version, indicates that the table didn't exist - // if (oldVersion == null) - // { - // ExecuteResourceSql("CreateLandTable.sql",dbconn); - // oldVersion = "Rev. 2; InnoDB free: 0 kB"; - // } - // if (!oldVersion.Contains("Rev.")) - // { - // ExecuteResourceSql("UpgradeLandTableToVersion2.sql", dbconn); - // } - // } - - /// /// Adds an object into region storage /// /// The object @@ -816,7 +779,7 @@ namespace OpenSim.Data.MySQL m_primDataAdapter.Update(m_primTable); m_shapeDataAdapter.Update(m_shapeTable); - m_itemsDataAdapter.Update(m_itemsTable); + m_itemsDataAdapter.Update(m_itemsTable); m_terrainDataAdapter.Update(m_terrainTable); m_landDataAdapter.Update(m_landTable); @@ -2005,36 +1968,6 @@ namespace OpenSim.Data.MySQL return cmd; } - /// - /// - /// - /// - /// - // private static string defineTable(DataTable dt) - // { - // string sql = "create table " + dt.TableName + "("; - // string subsql = String.Empty; - // foreach (DataColumn col in dt.Columns) - // { - // if (subsql.Length > 0) - // { - // // a map function would rock so much here - // subsql += ",\n"; - // } - // subsql += col.ColumnName + " " + MySqlType(col.DataType); - // if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) - // { - // subsql += " primary key"; - // } - // } - // sql += subsql; - // sql += ")"; - - // //m_log.InfoFormat("[DATASTORE]: defineTable() sql {0}", sql); - - // return sql; - // } - /*********************************************************************** * * Database Binding functions @@ -2176,206 +2109,6 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } - /// - /// - /// - /// MySQL connection handler - // private static void InitDB(MySqlConnection conn) - // { - // string createPrims = defineTable(createPrimTable()); - // string createShapes = defineTable(createShapeTable()); - // string createItems = defineTable(createItemsTable()); - // string createTerrain = defineTable(createTerrainTable()); - - // // Land table is created from the Versionable Test Table routine now. - // //string createLand = defineTable(createLandTable()); - // string createLandAccessList = defineTable(createLandAccessListTable()); - - // MySqlCommand pcmd = new MySqlCommand(createPrims, conn); - // MySqlCommand scmd = new MySqlCommand(createShapes, conn); - // MySqlCommand icmd = new MySqlCommand(createItems, conn); - // MySqlCommand tcmd = new MySqlCommand(createTerrain, conn); - // //MySqlCommand lcmd = new MySqlCommand(createLand, conn); - // MySqlCommand lalcmd = new MySqlCommand(createLandAccessList, conn); - - // if (conn.State != ConnectionState.Open) - // { - // try - // { - // conn.Open(); - // } - // catch (Exception ex) - // { - // m_log.Error("[REGION DB]: Error connecting to MySQL server: " + ex.Message); - // m_log.Error("[REGION DB]: Application is terminating!"); - // Thread.CurrentThread.Abort(); - // } - // } - - // try - // { - // pcmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Primitives Table Already Exists: {0}", e); - // } - - // try - // { - // scmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Shapes Table Already Exists: {0}", e); - // } - - // try - // { - // icmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Items Table Already Exists: {0}", e); - // } - - // try - // { - // tcmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: Terrain Table Already Exists: {0}", e); - // } - - // //try - // //{ - // //lcmd.ExecuteNonQuery(); - // //} - // //catch (MySqlException e) - // //{ - // //m_log.WarnFormat("[MySql]: Land Table Already Exists: {0}", e); - // //} - - // try - // { - // lalcmd.ExecuteNonQuery(); - // } - // catch (MySqlException e) - // { - // m_log.WarnFormat("[REGION DB]: LandAccessList Table Already Exists: {0}", e); - // } - // conn.Close(); - // } - - /// - /// - /// - /// - /// - /// - private bool TestTables(MySqlConnection conn, Migration m) - { - // we already have migrations, get out of here - if (m.Version > 0) - return false; - - MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); - MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); - MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); - MySqlDataAdapter sDa = new MySqlDataAdapter(shapeSelectCmd); - MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, conn); - MySqlDataAdapter iDa = new MySqlDataAdapter(itemsSelectCmd); - MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, conn); - MySqlDataAdapter tDa = new MySqlDataAdapter(terrainSelectCmd); - MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, conn); - MySqlDataAdapter lDa = new MySqlDataAdapter(landSelectCmd); - MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, conn); - MySqlDataAdapter lalDa = new MySqlDataAdapter(landAccessListSelectCmd); - - DataSet tmpDS = new DataSet(); - try - { - pDa.Fill(tmpDS, "prims"); - sDa.Fill(tmpDS, "primshapes"); - - iDa.Fill(tmpDS, "primitems"); - - tDa.Fill(tmpDS, "terrain"); - lDa.Fill(tmpDS, "land"); - lalDa.Fill(tmpDS, "landaccesslist"); - } - catch (MySqlException) - { - m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); - return false; - } - - // we have tables, but not a migration model yet - if (m.Version == 0) - m.Version = 1; - - return true; - - // pDa.Fill(tmpDS, "prims"); - // sDa.Fill(tmpDS, "primshapes"); - - // iDa.Fill(tmpDS, "primitems"); - - // tDa.Fill(tmpDS, "terrain"); - // lDa.Fill(tmpDS, "land"); - // lalDa.Fill(tmpDS, "landaccesslist"); - - // foreach (DataColumn col in createPrimTable().Columns) - // { - // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); - // return false; - // } - // } - - // foreach (DataColumn col in createShapeTable().Columns) - // { - // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); - // return false; - // } - // } - - // // XXX primitems should probably go here eventually - - // foreach (DataColumn col in createTerrainTable().Columns) - // { - // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); - // return false; - // } - // } - - // foreach (DataColumn col in createLandTable().Columns) - // { - // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); - // return false; - // } - // } - - // foreach (DataColumn col in createLandAccessListTable().Columns) - // { - // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) - // { - // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); - // return false; - // } - // } - - // return true; - } - /*********************************************************************** * * Type conversion functions @@ -2419,37 +2152,5 @@ namespace OpenSim.Data.MySQL } } - /// - /// - /// - /// - /// this is something we'll need to implement for each db slightly differently. - // private static string MySqlType(Type type) - // { - // if (type == typeof (String)) - // { - // return "varchar(255)"; - // } - // else if (type == typeof (Int32)) - // { - // return "integer"; - // } - // else if (type == typeof (Int64)) - // { - // return "bigint"; - // } - // else if (type == typeof (Double)) - // { - // return "float"; - // } - // else if (type == typeof (Byte[])) - // { - // return "longblob"; - // } - // else - // { - // return "string"; - // } - // } } } -- cgit v1.1 From ba16a27ab0faa553f4dc57499456f274f3538188 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 27 Aug 2008 18:51:40 +0000 Subject: remove pre-Migration upgrade paths --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 92 -------------------------------- 1 file changed, 92 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 4e8200b..fe2d393 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -90,101 +90,9 @@ namespace OpenSim.Data.MySQL // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; Migration m = new Migration(database.Connection, assem, "InventoryStore"); - - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(database.Connection, m); - m.Update(); } - #region Test and initialization code - - /// - /// - /// Execute CreateFoldersTable.sql if oldVersion == null - /// do nothing if oldVersion != null - /// - /// - /// - private void UpgradeFoldersTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateFoldersTable.sql"); - return; - } - - //// if the table is already at the current version, then we can exit immediately - // if (oldVersion == "Rev. 2") - // return; - // database.ExecuteResourceSql("UpgradeFoldersTableToVersion2.sql"); - } - - /// - /// - /// Execute CreateItemsTable.sql if oldVersion == null - /// Execute "UpgradeItemsTableToVersion3.sql" if oldVersion start with "Rev. 2;" - /// - /// - /// - private void UpgradeItemsTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateItemsTable.sql"); - return; - } - - // if the table is already at the current version, then we can exit immediately - if (oldVersion.StartsWith("Rev. 2;")) - { - m_log.Info("[INVENTORY DB]: Upgrading inventory items table from Rev. 2 to Rev. 3"); - database.ExecuteResourceSql("UpgradeItemsTableToVersion3.sql"); - } - } - - /// - /// - /// - /// MySQL connection handler - /// - private void TestTables(MySqlConnection conn, Migration m) - { - Dictionary tableList = new Dictionary(); - - tableList["inventoryfolders"] = null; - tableList["inventoryitems"] = null; - - database.GetTableVersion(tableList); - - // if we've already started using migrations, get out of - // here, we've got this under control - if (m.Version > 0) - return; - - // if there are no tables, get out of here and let - // migrations do their job - if ( - tableList["inventoryfolders"] == null && - tableList["inventoryitems"] == null - ) - return; - - // otherwise, let the upgrade on legacy proceed... - UpgradeFoldersTable(tableList["inventoryfolders"]); - UpgradeItemsTable(tableList["inventoryitems"]); - - // ... and set the version - if (m.Version == 0) - m.Version = 1; - - } - - #endregion - /// /// The name of this DB provider /// -- cgit v1.1 From 49df7876655c8d452decee97bf0ee437257e0c8e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 27 Aug 2008 18:51:42 +0000 Subject: remove the legacy pre-Migration database upgrade paths --- OpenSim/Data/MySQL/MySQLAssetData.cs | 42 ------------------------------------ 1 file changed, 42 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index bdb1571..08a8c6e 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -78,10 +78,6 @@ namespace OpenSim.Data.MySQL Assembly assem = GetType().Assembly; Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore"); - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m); - m.Update(); } @@ -115,44 +111,6 @@ namespace OpenSim.Data.MySQL #region IAssetProviderPlugin Members /// - /// - /// Execute CreateAssetsTable.sql if oldVersion == null - /// do nothing if oldVersion != null - /// - /// - /// - // private void UpgradeAssetsTable(string oldVersion) - // { - // // null as the version, indicates that the table didn't exist - // if (oldVersion == null) - // { - // m_log.Info("[ASSETS DB]: Creating new database tables"); - // _dbConnection.ExecuteResourceSql("CreateAssetsTable.sql"); - // return; - // } - // } - - /// - /// Ensure that the assets related tables exists and are at the latest version - /// - /// - private void TestTables(Migration m) - { - Dictionary tableList = new Dictionary(); - - tableList["assets"] = null; - _dbConnection.GetTableVersion(tableList); - - // if there is no table, return, migrations will handle it. - if (tableList["assets"] == null) - return; - - // if there is a table, and we don't have a migration, set it to 1 - if (m.Version == 0) - m.Version = 1; - } - - /// /// Fetch Asset from database /// /// Asset UUID to fetch -- cgit v1.1 From 5bf5e1c32064a18426fcae0834a191e70596aeb8 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 27 Aug 2008 18:51:43 +0000 Subject: remove legacy pre-Migration database upgrade routines --- OpenSim/Data/MySQL/MySQLUserData.cs | 120 ------------------------------------ 1 file changed, 120 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index caae677..e04d36a 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -121,131 +121,11 @@ namespace OpenSim.Data.MySQL Assembly assem = GetType().Assembly; Migration m = new Migration(database.Connection, assem, "UserStore"); - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m); - m.Update(); } public override void Dispose () { } - - #region Test and initialization code - - /// - /// Ensure that the user related tables exists and are at the latest version - /// - private void TestTables(Migration m) - { - Dictionary tableList = new Dictionary(); - - tableList[m_agentsTableName] = null; - tableList[m_usersTableName] = null; - tableList[m_userFriendsTableName] = null; - tableList[m_appearanceTableName] = null; - database.GetTableVersion(tableList); - - // if we've already started using migrations, get out of - // here, we've got this under control - if (m.Version > 0) - return; - - // if there are no tables, get out of here and let - // migrations do their job - if ( - tableList[m_agentsTableName] == null && - tableList[m_usersTableName] == null && - tableList[m_userFriendsTableName] == null && - tableList[m_appearanceTableName] == null - ) - return; - - // otherwise, let the upgrade on legacy proceed... - UpgradeAgentsTable(tableList[m_agentsTableName]); - UpgradeUsersTable(tableList[m_usersTableName]); - UpgradeFriendsTable(tableList[m_userFriendsTableName]); - UpgradeAppearanceTable(tableList[m_appearanceTableName]); - - // ... and set the version - if (m.Version == 0) - m.Version = 1; - } - - /// - /// Create or upgrade the table if necessary - /// - /// A null indicates that the table does not - /// currently exist - private void UpgradeAgentsTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateAgentsTable.sql"); - return; - } - } - - /// - /// Create or upgrade the table if necessary - /// - /// A null indicates that the table does not - /// currently exist - private void UpgradeUsersTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateUsersTable.sql"); - return; - } - else if (oldVersion.Contains("Rev. 1")) - { - database.ExecuteResourceSql("UpgradeUsersTableToVersion2.sql"); - return; - } - //m_log.Info("[DB]: DBVers:" + oldVersion); - } - - /// - /// Create or upgrade the table if necessary - /// - /// A null indicates that the table does not - /// currently exist - private void UpgradeFriendsTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateUserFriendsTable.sql"); - return; - } - } - - /// - /// Create or upgrade the table if necessary - /// - /// A null indicates that the table does not - /// currently exist - private void UpgradeAppearanceTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateAvatarAppearance.sql"); - return; - } - else if (oldVersion.Contains("Rev.1")) - { - database.ExecuteSql("drop table avatarappearance"); - database.ExecuteResourceSql("CreateAvatarAppearance.sql"); - return; - } - } - - #endregion - // see IUserDataPlugin override public UserProfileData GetUserByName(string user, string last) { -- cgit v1.1 From 0a5280edb513bc2556da6f784b2abf661133637c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 13:38:46 +0000 Subject: * Added new "SuperManager" class for MySQL connections, for allowing multiple concurrent MySQL threads. * Implemented SuperManager inside of UserData. This means the userserver when running on MySQL will use 10 connections (+1 system connection) to handle requests, preventing the previous mire of locking resulting in singlethreadedness. * This requires testing and grids relying on stability should not upgrade to this revision until it's been properly tested. --- OpenSim/Data/MySQL/MySQLSuperManager.cs | 27 ++ OpenSim/Data/MySQL/MySQLUserData.cs | 588 +++++++++++++++++++------------- 2 files changed, 379 insertions(+), 236 deletions(-) create mode 100644 OpenSim/Data/MySQL/MySQLSuperManager.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs new file mode 100644 index 0000000..848a0bd --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLSuperManager.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; + +namespace OpenSim.Data.MySQL +{ + class MySQLSuperManager + { + public bool Locked; + private Mutex m_lock; + public MySQLManager Manager; + + public void GetLock() + { + Locked = true; + m_lock.WaitOne(); + } + + public void Release() + { + m_lock.ReleaseMutex(); + Locked = false; + } + + } +} diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index e04d36a..664203a 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -34,7 +34,6 @@ using System.Text.RegularExpressions; using libsecondlife; using log4net; using OpenSim.Framework; -using OpenSim.Data.Base; using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL @@ -51,6 +50,14 @@ namespace OpenSim.Data.MySQL /// public MySQLManager database; + /// + /// Better DB manager. Swap-in replacement too. + /// + public Dictionary m_dbconnections = new Dictionary(); + + public int m_maxConnections = 10; + public int m_lastConnect; + private string m_agentsTableName; private string m_usersTableName; private string m_userFriendsTableName; @@ -60,7 +67,28 @@ namespace OpenSim.Data.MySQL public override void Initialise() { m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!"); - throw new PluginNotInitialisedException (Name); + throw new PluginNotInitialisedException(Name); + } + + public MySQLSuperManager GetLockedConnection() + { + while (true) + { + m_lastConnect++; + MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; + if (!x.Locked) + { + x.GetLock(); + return x; + } + if (m_lastConnect > m_maxConnections) + { + m_lastConnect = 0; + System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. + m_log.Debug( + "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); + } + } } /// @@ -70,9 +98,10 @@ namespace OpenSim.Data.MySQL /// Checks for migration /// /// connect string. - override public void Initialise(string connect) + public override void Initialise(string connect) { - if (connect == String.Empty) { + if (connect == String.Empty) + { // TODO: actually do something with our connect string // instead of loading the second config @@ -103,8 +132,18 @@ namespace OpenSim.Data.MySQL m_agentsTableName = "agents"; } - m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" + - settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; + m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + + ";User ID=" + + settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; + + m_log.Info("Creating " + m_maxConnections + " DB connections..."); + for (int i = 0; i < m_maxConnections; i++) + { + m_log.Info("Connecting to DB... [" + i + "]"); + MySQLSuperManager msm = new MySQLSuperManager(); + msm.Manager = new MySQLManager(m_connectString); + m_dbconnections.Add(i, msm); + } database = new MySQLManager(m_connectString); } @@ -124,42 +163,50 @@ namespace OpenSim.Data.MySQL m.Update(); } - public override void Dispose () { } + public override void Dispose() + { + } // see IUserDataPlugin - override public UserProfileData GetUserByName(string user, string last) + public override UserProfileData GetUserByName(string user, string last) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { - Dictionary param = new Dictionary(); - param["?first"] = user; - param["?second"] = last; + Dictionary param = new Dictionary(); + param["?first"] = user; + param["?second"] = last; - IDbCommand result = - database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); - IDataReader reader = result.ExecuteReader(); + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); - UserProfileData row = database.readUserRow(reader); + UserProfileData row = dbm.Manager.readUserRow(reader); - reader.Dispose(); - result.Dispose(); - return row; - } + reader.Dispose(); + result.Dispose(); + return row; } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + } } #region User Friends List Data - override public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + public override void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { + MySQLSuperManager dbm = GetLockedConnection(); + int dtvalue = Util.UnixTimeSinceEpoch(); Dictionary param = new Dictionary(); @@ -170,68 +217,74 @@ namespace OpenSim.Data.MySQL try { - lock (database) - { - IDbCommand adder = - database.Query( + IDbCommand adder = + dbm.Manager.Query( "INSERT INTO `" + m_userFriendsTableName + "` " + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + "VALUES " + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", - param); - adder.ExecuteNonQuery(); + param); + adder.ExecuteNonQuery(); - adder = - database.Query( + adder = + dbm.Manager.Query( "INSERT INTO `" + m_userFriendsTableName + "` " + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + "VALUES " + "(?friendID,?ownerID,?friendPerms,?datetimestamp)", - param); - adder.ExecuteNonQuery(); - } + param); + adder.ExecuteNonQuery(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return; } + finally + { + dbm.Release(); + } } - override public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + public override void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { + MySQLSuperManager dbm = GetLockedConnection(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.UUID.ToString(); param["?friendID"] = friend.UUID.ToString(); try { - lock (database) - { - IDbCommand updater = - database.Query( - "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", - param); - updater.ExecuteNonQuery(); - - updater = - database.Query( - "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", - param); - updater.ExecuteNonQuery(); - } + IDbCommand updater = + dbm.Manager.Query( + "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", + param); + updater.ExecuteNonQuery(); + + updater = + dbm.Manager.Query( + "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", + param); + updater.ExecuteNonQuery(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return; } + finally + { + dbm.Release(); + } } - override public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + public override void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { + MySQLSuperManager dbm = GetLockedConnection(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.UUID.ToString(); param["?friendID"] = friend.UUID.ToString(); @@ -239,27 +292,29 @@ namespace OpenSim.Data.MySQL try { - lock (database) - { - IDbCommand updater = - database.Query( - "update " + m_userFriendsTableName + - " SET friendPerms = ?friendPerms " + - "where ownerID = ?ownerID and friendID = ?friendID", - param); - updater.ExecuteNonQuery(); - } + IDbCommand updater = + dbm.Manager.Query( + "update " + m_userFriendsTableName + + " SET friendPerms = ?friendPerms " + + "where ownerID = ?ownerID and friendID = ?friendID", + param); + updater.ExecuteNonQuery(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return; } + finally + { + dbm.Release(); + } } - override public List GetUserFriendList(LLUUID friendlistowner) + public override List GetUserFriendList(LLUUID friendlistowner) { + MySQLSuperManager dbm = GetLockedConnection(); List Lfli = new List(); Dictionary param = new Dictionary(); @@ -267,52 +322,56 @@ namespace OpenSim.Data.MySQL try { - lock (database) + //Left Join userfriends to itself + IDbCommand result = + dbm.Manager.Query( + "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - //Left Join userfriends to itself - IDbCommand result = - database.Query( - "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + - " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) - { - FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new LLUUID((string)reader["ownerID"]); - fli.Friend = new LLUUID((string)reader["friendID"]); - fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); + FriendListItem fli = new FriendListItem(); + fli.FriendListOwner = new LLUUID((string) reader["ownerID"]); + fli.Friend = new LLUUID((string) reader["friendID"]); + fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); - // This is not a real column in the database table, it's a joined column from the opposite record - fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); + // This is not a real column in the database table, it's a joined column from the opposite record + fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); - Lfli.Add(fli); - } - - reader.Dispose(); - result.Dispose(); + Lfli.Add(fli); } + + reader.Dispose(); + result.Dispose(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return Lfli; } + finally + { + dbm.Release(); + } return Lfli; } #endregion - override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) + public override void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) { //m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called"); } - override public List GeneratePickerResults(LLUUID queryID, string query) + public override List GeneratePickerResults(LLUUID queryID, string query) { + MySQLSuperManager dbm = GetLockedConnection(); + List returnlist = new List(); Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); @@ -326,66 +385,70 @@ namespace OpenSim.Data.MySQL param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; try { - lock (database) + IDbCommand result = + dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first AND lastname like ?second LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - IDbCommand result = - database.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first AND lastname like ?second LIMIT 100", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string) reader["UUID"]); - user.firstName = (string) reader["username"]; - user.lastName = (string) reader["lastname"]; - returnlist.Add(user); - } - reader.Dispose(); - result.Dispose(); + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); } + reader.Dispose(); + result.Dispose(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return returnlist; } + finally + { + dbm.Release(); + } } else if (querysplit.Length == 1) { try { - lock (database) + Dictionary param = new Dictionary(); + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; + + IDbCommand result = + dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first OR lastname like ?first LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - Dictionary param = new Dictionary(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - - IDbCommand result = - database.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first OR lastname like ?first LIMIT 100", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string) reader["UUID"]); - user.firstName = (string) reader["username"]; - user.lastName = (string) reader["lastname"]; - returnlist.Add(user); - } - reader.Dispose(); - result.Dispose(); + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); } + reader.Dispose(); + result.Dispose(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return returnlist; } + finally + { + dbm.Release(); + } } return returnlist; } @@ -395,32 +458,34 @@ namespace OpenSim.Data.MySQL /// /// User UUID /// User profile data - override public UserProfileData GetUserByUUID(LLUUID uuid) + public override UserProfileData GetUserByUUID(LLUUID uuid) { + MySQLSuperManager dbm = GetLockedConnection(); try { - lock (database) - { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); - IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); + IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); - UserProfileData row = database.readUserRow(reader); + UserProfileData row = dbm.Manager.readUserRow(reader); - reader.Dispose(); - result.Dispose(); + reader.Dispose(); + result.Dispose(); - return row; - } + return row; } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + } } /// @@ -428,7 +493,7 @@ namespace OpenSim.Data.MySQL /// /// The account name : "Username Lastname" /// The users session - override public UserAgentData GetAgentByName(string name) + public override UserAgentData GetAgentByName(string name) { return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]); } @@ -439,7 +504,7 @@ namespace OpenSim.Data.MySQL /// First part of the users account name /// Second part of the users account name /// The users session - override public UserAgentData GetAgentByName(string user, string last) + public override UserAgentData GetAgentByName(string user, string last) { UserProfileData profile = GetUserByName(user, last); return GetAgentByUUID(profile.ID); @@ -450,30 +515,33 @@ namespace OpenSim.Data.MySQL /// /// /// is it still used ? - override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) + public override void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) { + MySQLSuperManager dbm = GetLockedConnection(); + Dictionary param = new Dictionary(); param["?UUID"] = AgentID.UUID.ToString(); param["?webLoginKey"] = WebLoginKey.UUID.ToString(); try { - lock (database) - { - IDbCommand updater = - database.Query( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", - param); - updater.ExecuteNonQuery(); - } + IDbCommand updater = + dbm.Manager.Query( + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", + param); + updater.ExecuteNonQuery(); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return; } + finally + { + dbm.Release(); + } } /// @@ -481,94 +549,111 @@ namespace OpenSim.Data.MySQL /// /// The accounts UUID /// The users session - override public UserAgentData GetAgentByUUID(LLUUID uuid) + public override UserAgentData GetAgentByUUID(LLUUID uuid) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); - IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); + IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", + param); + IDataReader reader = result.ExecuteReader(); - UserAgentData row = database.readAgentRow(reader); + UserAgentData row = dbm.Manager.readAgentRow(reader); - reader.Dispose(); - result.Dispose(); + reader.Dispose(); + result.Dispose(); - return row; - } + return row; } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + } } /// /// Creates a new users profile /// /// The user profile to create - override public void AddNewUserProfile(UserProfileData user) + public override void AddNewUserProfile(UserProfileData user) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { - database.insertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, - user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, - user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.CanDoMask, user.WantDoMask, - user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey); - } + dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, + user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, + user.LastLogin, user.UserInventoryURI, user.UserAssetURI, + user.CanDoMask, user.WantDoMask, + user.AboutText, user.FirstLifeAboutText, user.Image, + user.FirstLifeImage, user.WebLoginKey); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); } + finally + { + dbm.Release(); + } } /// /// Creates a new agent /// /// The agent to create - override public void AddNewUserAgent(UserAgentData agent) + public override void AddNewUserAgent(UserAgentData agent) { + MySQLSuperManager dbm = GetLockedConnection(); try { - lock (database) - { - database.insertAgentRow(agent); - } + dbm.Manager.insertAgentRow(agent); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); } + finally + { + dbm.Release(); + } } /// /// Updates a user profile stored in the DB /// /// The profile data to use to update the DB - override public bool UpdateUserProfile(UserProfileData user) + public override bool UpdateUserProfile(UserProfileData user) { - lock (database) + MySQLSuperManager dbm = GetLockedConnection(); + try + { + dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, + user.UserInventoryURI, + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, + user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + } + finally { - database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Release(); } return true; @@ -581,7 +666,7 @@ namespace OpenSim.Data.MySQL /// The receivers account ID /// The amount to transfer /// Success? - override public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) + public override bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) { return false; } @@ -594,7 +679,7 @@ namespace OpenSim.Data.MySQL /// The receivers account ID /// The item to transfer /// Success? - override public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) + public override bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) { return false; } @@ -604,33 +689,37 @@ namespace OpenSim.Data.MySQL /// TODO: stubs for now to get us to a compiling state gently /// override /// - override public AvatarAppearance GetUserAppearance(LLUUID user) + public override AvatarAppearance GetUserAppearance(LLUUID user) { - try { - lock (database) - { - Dictionary param = new Dictionary(); - param["?owner"] = user.ToString(); + MySQLSuperManager dbm = GetLockedConnection(); + try + { + Dictionary param = new Dictionary(); + param["?owner"] = user.ToString(); - IDbCommand result = database.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); - IDataReader reader = result.ExecuteReader(); + IDbCommand result = dbm.Manager.Query( + "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); + IDataReader reader = result.ExecuteReader(); - AvatarAppearance appearance = database.readAppearanceRow(reader); + AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); - reader.Dispose(); - result.Dispose(); + reader.Dispose(); + result.Dispose(); - appearance.SetAttachments(GetUserAttachments(user)); + appearance.SetAttachments(GetUserAttachments(user)); - return appearance; - } + return appearance; } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + } } /// @@ -639,70 +728,97 @@ namespace OpenSim.Data.MySQL /// The user UUID /// The avatar appearance // override - override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) + public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { + MySQLSuperManager dbm = GetLockedConnection(); try { - lock (database) - { - appearance.Owner = user; - database.insertAppearanceRow(appearance); + appearance.Owner = user; + dbm.Manager.insertAppearanceRow(appearance); - UpdateUserAttachments(user, appearance.GetAttachments()); - } + UpdateUserAttachments(user, appearance.GetAttachments()); } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); } + finally + { + dbm.Release(); + } } /// /// Database provider name /// /// Provider name - override public string Name + public override string Name { - get {return "MySQL Userdata Interface";} + get { return "MySQL Userdata Interface"; } } /// /// Database provider version /// /// provider version - override public string Version + public override string Version { - get {return "0.1";} + get { return "0.1"; } } public Hashtable GetUserAttachments(LLUUID agentID) { - MySqlCommand cmd = (MySqlCommand) (database.Connection.CreateCommand()); - cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; - cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); + MySQLSuperManager dbm = GetLockedConnection(); - IDataReader r = cmd.ExecuteReader(); + try + { + MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); + cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; + cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - Hashtable ret = database.readAttachments(r); + IDataReader r = cmd.ExecuteReader(); - r.Close(); + Hashtable ret = dbm.Manager.readAttachments(r); - return ret; + r.Close(); + return ret; + } + finally + { + dbm.Release(); + } } public void UpdateUserAttachments(LLUUID agentID, Hashtable data) { - database.writeAttachments(agentID, data); + MySQLSuperManager dbm = GetLockedConnection(); + try + { + dbm.Manager.writeAttachments(agentID, data); + } + finally + { + dbm.Release(); + } } - override public void ResetAttachments(LLUUID userID) + public override void ResetAttachments(LLUUID userID) { - MySqlCommand cmd = (MySqlCommand) (database.Connection.CreateCommand()); - cmd.CommandText = "update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; - cmd.Parameters.AddWithValue("?uuid", userID.ToString()); + MySQLSuperManager dbm = GetLockedConnection(); + try + { + MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); + cmd.CommandText = + "update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; + cmd.Parameters.AddWithValue("?uuid", userID.ToString()); - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); + } + finally + { + dbm.Release(); + } } } -} +} \ No newline at end of file -- cgit v1.1 From b63922dcfed1aa4198eed47a01fb5999c4d6a339 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 13:46:04 +0000 Subject: * Minor fix to previous threading patch, every nTH request would previously have been delayed for 1000ms. This has been fixed. --- OpenSim/Data/MySQL/MySQLUserData.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 664203a..78d1092 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -72,18 +72,26 @@ namespace OpenSim.Data.MySQL public MySQLSuperManager GetLockedConnection() { + int lockedCons = 0; while (true) { m_lastConnect++; + + // Overflow protection + if(m_lastConnect == int.MaxValue) + m_lastConnect = 0; + MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; if (!x.Locked) { x.GetLock(); return x; } - if (m_lastConnect > m_maxConnections) + + lockedCons++; + if (lockedCons > m_maxConnections) { - m_lastConnect = 0; + lockedCons = 0; System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. m_log.Debug( "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); -- cgit v1.1 From e471a33961e047162f1a2335e26872ebbc2f9332 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 14:27:28 +0000 Subject: * Fix for Mantis #2087, Standalone MySQL broken with threading improvements. (Didnt realise this code was being shared with the gridservers) --- OpenSim/Data/MySQL/MySQLUserData.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 78d1092..7a44d3c 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -162,6 +162,15 @@ namespace OpenSim.Data.MySQL m_usersTableName = "users"; m_userFriendsTableName = "userfriends"; database = new MySQLManager(m_connectString); + + m_log.Info("Creating " + m_maxConnections + " DB connections..."); + for (int i = 0; i < m_maxConnections; i++) + { + m_log.Info("Connecting to DB... [" + i + "]"); + MySQLSuperManager msm = new MySQLSuperManager(); + msm.Manager = new MySQLManager(m_connectString); + m_dbconnections.Add(i, msm); + } } // This actually does the roll forward assembly stuff -- cgit v1.1 From 72b0a53ada9e8e8bc54a06e0097e87e5d95daaad Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 16:46:51 +0000 Subject: * Fixed #2807 Again, Whoops. --- OpenSim/Data/MySQL/MySQLSuperManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs index 848a0bd..effdac7 100644 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ b/OpenSim/Data/MySQL/MySQLSuperManager.cs @@ -8,7 +8,7 @@ namespace OpenSim.Data.MySQL class MySQLSuperManager { public bool Locked; - private Mutex m_lock; + private Mutex m_lock = new Mutex(false); public MySQLManager Manager; public void GetLock() -- cgit v1.1 From 2133fa56e7790ab63749d778c4d2db79a9b9e9bf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 19:35:22 +0000 Subject: * Added new MySQLSuperManager support for the grid servers. * In theory, login and a large number of grid functions should now at least be multithreaded. --- OpenSim/Data/MySQL/MySQLGridData.cs | 198 ++++++++++++++++++++++---------- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- OpenSim/Data/MySQL/MySQLSuperManager.cs | 9 +- 3 files changed, 140 insertions(+), 69 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index fcbceb8..9dc3d18 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -29,8 +29,6 @@ using System; using System.Collections.Generic; using System.Data; using System.Reflection; -using System.Security.Cryptography; -using System.Text; using libsecondlife; using log4net; using OpenSim.Framework; @@ -49,6 +47,45 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + + /// + /// Better DB manager. Swap-in replacement too. + /// + public Dictionary m_dbconnections = new Dictionary(); + + public int m_maxConnections = 10; + public int m_lastConnect; + + public MySQLSuperManager GetLockedConnection() + { + int lockedCons = 0; + while (true) + { + m_lastConnect++; + + // Overflow protection + if (m_lastConnect == int.MaxValue) + m_lastConnect = 0; + + MySQLSuperManager x = m_dbconnections[m_lastConnect % m_maxConnections]; + if (!x.Locked) + { + x.GetLock(); + return x; + } + + lockedCons++; + if (lockedCons > m_maxConnections) + { + lockedCons = 0; + System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. + m_log.Debug( + "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); + } + } + } + + override public void Initialise() { m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); @@ -71,6 +108,16 @@ namespace OpenSim.Data.MySQL if (connect != String.Empty) { database = new MySQLManager(connect); + + m_log.Info("Creating " + m_maxConnections + " DB connections..."); + for (int i = 0; i < m_maxConnections; i++) + { + m_log.Info("Connecting to DB... [" + i + "]"); + MySQLSuperManager msm = new MySQLSuperManager(); + msm.Manager = new MySQLManager(connect); + m_dbconnections.Add(i, msm); + } + } else { @@ -85,6 +132,16 @@ namespace OpenSim.Data.MySQL database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); + + m_log.Info("Creating " + m_maxConnections + " DB connections..."); + for (int i = 0; i < m_maxConnections; i++) + { + m_log.Info("Connecting to DB... [" + i + "]"); + MySQLSuperManager msm = new MySQLSuperManager(); + msm.Manager = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, + settingPooling, settingPort); + m_dbconnections.Add(i, msm); + } } // This actually does the roll forward assembly stuff @@ -184,10 +241,10 @@ namespace OpenSim.Data.MySQL /// Array of sim profiles override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { Dictionary param = new Dictionary(); param["?xmin"] = xmin.ToString(); param["?ymin"] = ymin.ToString(); @@ -195,7 +252,7 @@ namespace OpenSim.Data.MySQL param["?ymax"] = ymax.ToString(); IDbCommand result = - database.Query( + dbm.Manager.Query( "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); IDataReader reader = result.ExecuteReader(); @@ -204,7 +261,7 @@ namespace OpenSim.Data.MySQL List rows = new List(); - while ((row = database.readSimRow(reader)) != null) + while ((row = dbm.Manager.readSimRow(reader)) != null) { rows.Add(row); } @@ -212,14 +269,17 @@ namespace OpenSim.Data.MySQL result.Dispose(); return rows.ToArray(); - } } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + } } /// @@ -229,29 +289,32 @@ namespace OpenSim.Data.MySQL /// Sim profile override public RegionProfileData GetProfileByHandle(ulong handle) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { Dictionary param = new Dictionary(); param["?handle"] = handle.ToString(); - IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); IDataReader reader = result.ExecuteReader(); - RegionProfileData row = database.readSimRow(reader); + RegionProfileData row = dbm.Manager.readSimRow(reader); reader.Close(); result.Dispose(); return row; } - } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + } } /// @@ -261,70 +324,76 @@ namespace OpenSim.Data.MySQL /// The sim profile override public RegionProfileData GetProfileByLLUUID(LLUUID uuid) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); IDataReader reader = result.ExecuteReader(); - RegionProfileData row = database.readSimRow(reader); + RegionProfileData row = dbm.Manager.readSimRow(reader); reader.Close(); result.Dispose(); return row; } - } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; + } finally + { + dbm.Release(); } } /// /// Returns a sim profile from it's Region name string /// - /// The region name search query /// The sim profile override public RegionProfileData GetProfileByString(string regionName) { + MySQLSuperManager dbm = GetLockedConnection(); + if (regionName.Length > 2) { try { - lock (database) - { - Dictionary param = new Dictionary(); - // Add % because this is a like query. - param["?regionName"] = regionName + "%"; - // Order by statement will return shorter matches first. Only returns one record or no record. - IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", param); - IDataReader reader = result.ExecuteReader(); - - RegionProfileData row = database.readSimRow(reader); - reader.Close(); - result.Dispose(); - - return row; - } + Dictionary param = new Dictionary(); + // Add % because this is a like query. + param["?regionName"] = regionName + "%"; + // Order by statement will return shorter matches first. Only returns one record or no record. + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; } + finally + { + dbm.Release(); + + } } - else - { - m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); - return null; - } + dbm.Release(); + m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); + return null; } /// @@ -334,16 +403,17 @@ namespace OpenSim.Data.MySQL /// Successful? override public DataResponse AddProfile(RegionProfileData profile) { - lock (database) - { - if (database.insertRegion(profile)) + MySQLSuperManager dbm = GetLockedConnection(); + try { + if (dbm.Manager.insertRegion(profile)) { return DataResponse.RESPONSE_OK; } - else - { - return DataResponse.RESPONSE_ERROR; - } + return DataResponse.RESPONSE_ERROR; + } + finally + { + dbm.Release(); } } @@ -366,16 +436,18 @@ namespace OpenSim.Data.MySQL //public DataResponse DeleteProfile(RegionProfileData profile) public DataResponse DeleteProfile(string uuid) { - lock (database) - { - if (database.deleteRegion(uuid)) + MySQLSuperManager dbm = GetLockedConnection(); + + + try { + if (dbm.Manager.deleteRegion(uuid)) { return DataResponse.RESPONSE_OK; } - else - { - return DataResponse.RESPONSE_ERROR; - } + return DataResponse.RESPONSE_ERROR; + } finally + { + dbm.Release(); } } @@ -426,31 +498,33 @@ namespace OpenSim.Data.MySQL /// override public ReservationData GetReservationAtPoint(uint x, uint y) { + MySQLSuperManager dbm = GetLockedConnection(); + try { - lock (database) - { Dictionary param = new Dictionary(); param["?x"] = x.ToString(); param["?y"] = y.ToString(); IDbCommand result = - database.Query( + dbm.Manager.Query( "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param); IDataReader reader = result.ExecuteReader(); - ReservationData row = database.readReservationRow(reader); + ReservationData row = dbm.Manager.readReservationRow(reader); reader.Close(); result.Dispose(); return row; - } } catch (Exception e) { - database.Reconnect(); + dbm.Manager.Reconnect(); m_log.Error(e.ToString()); return null; + } finally + { + dbm.Release(); } } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index d193c72..15bdf44 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -41,7 +41,7 @@ namespace OpenSim.Data.MySQL /// /// A MySQL Database manager /// - internal class MySQLManager + public class MySQLManager { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs index effdac7..4a9c7fa 100644 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ b/OpenSim/Data/MySQL/MySQLSuperManager.cs @@ -1,14 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; +using System.Threading; namespace OpenSim.Data.MySQL { - class MySQLSuperManager + public class MySQLSuperManager { public bool Locked; - private Mutex m_lock = new Mutex(false); + private readonly Mutex m_lock = new Mutex(false); public MySQLManager Manager; public void GetLock() -- cgit v1.1 From abb0ad36bd887dbe8d6be4eb93a7d327f33ed5b4 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 2 Sep 2008 20:17:57 +0000 Subject: apparently I missed one of the old version routines that could be removed. Removing that now. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 39 ----------------------------------- 1 file changed, 39 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 5c86570..903f022 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -254,45 +254,6 @@ namespace OpenSim.Data.MySQL } /// - /// Given a list of tables, return the version of the tables, as seen in the database - /// - /// The list of table - /// The database connection handler - public void GetTableVersion(Dictionary tableList, MySqlConnection dbcon) - { - lock (dbcon) - { - MySqlCommand tablesCmd = - new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", - dbcon); - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - - CheckConnection(); - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) - { - while (tables.Read()) - { - try - { - string tableName = (string)tables["TABLE_NAME"]; - string comment = (string)tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) - { - tableList[tableName] = comment; - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - } - } - tables.Close(); - } - } - } - - /// /// Execute a SQL statement stored in a resource, as a string /// /// the ressource name -- cgit v1.1 From e98780fea5c9235da50062f09cac4d415c7f2125 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 3 Sep 2008 02:51:34 +0000 Subject: Mantis #2099 Thank you, cmickeyb, for a patch that corrects the database connection handling in the multithreaded user server. --- OpenSim/Data/MySQL/MySQLManager.cs | 13 ++++++++++++ OpenSim/Data/MySQL/MySQLUserData.cs | 41 ++++++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 15bdf44..e863216 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -280,6 +280,19 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + public void ExecuteParameterizedSql(string sql, Dictionary parameters) + { + CheckConnection(); + + MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); + cmd.CommandText = sql; + foreach (KeyValuePair param in parameters) + { + cmd.Parameters.AddWithValue(param.Key, param.Value); + } + cmd.ExecuteNonQuery(); + } + /// /// Given a list of tables, return the version of the tables, as seen in the database /// diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 7a44d3c..8d0b177 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -62,6 +62,7 @@ namespace OpenSim.Data.MySQL private string m_usersTableName; private string m_userFriendsTableName; private string m_appearanceTableName = "avatarappearance"; + private string m_attachmentsTableName = "avatarattachments"; private string m_connectString; public override void Initialise() @@ -542,12 +543,10 @@ namespace OpenSim.Data.MySQL try { - IDbCommand updater = - dbm.Manager.Query( + dbm.Manager.ExecuteParameterizedSql( "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + "where UUID = ?UUID", param); - updater.ExecuteNonQuery(); } catch (Exception e) { @@ -788,19 +787,27 @@ namespace OpenSim.Data.MySQL { MySQLSuperManager dbm = GetLockedConnection(); + Dictionary param = new Dictionary(); + param["?uuid"] = agentID.ToString(); + try { - MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); - cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; - cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - - IDataReader r = cmd.ExecuteReader(); + IDbCommand result = dbm.Manager.Query( + "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); - Hashtable ret = dbm.Manager.readAttachments(r); + Hashtable ret = dbm.Manager.readAttachments(reader); - r.Close(); + reader.Dispose(); + result.Dispose(); return ret; } + catch (Exception e) + { + dbm.Manager.Reconnect(); + m_log.Error(e.ToString()); + return null; + } finally { dbm.Release(); @@ -823,14 +830,16 @@ namespace OpenSim.Data.MySQL public override void ResetAttachments(LLUUID userID) { MySQLSuperManager dbm = GetLockedConnection(); + + Dictionary param = new Dictionary(); + param["?uuid"] = userID.ToString(); + try { - MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); - cmd.CommandText = - "update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; - cmd.Parameters.AddWithValue("?uuid", userID.ToString()); - - cmd.ExecuteNonQuery(); + dbm.Manager.ExecuteParameterizedSql( + "UPDATE " + m_attachmentsTableName + + " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", + param); } finally { -- cgit v1.1 From 9053e8510c5e829c4e641cc51bab9387894b5e3b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 3 Sep 2008 14:05:49 +0000 Subject: Update svn properties. --- OpenSim/Data/MySQL/MySQLSuperManager.cs | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs index 4a9c7fa..b2485b1 100644 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ b/OpenSim/Data/MySQL/MySQLSuperManager.cs @@ -1,24 +1,24 @@ -using System.Threading; - -namespace OpenSim.Data.MySQL -{ - public class MySQLSuperManager - { - public bool Locked; - private readonly Mutex m_lock = new Mutex(false); - public MySQLManager Manager; - - public void GetLock() - { - Locked = true; - m_lock.WaitOne(); - } - - public void Release() - { - m_lock.ReleaseMutex(); - Locked = false; - } - - } -} +using System.Threading; + +namespace OpenSim.Data.MySQL +{ + public class MySQLSuperManager + { + public bool Locked; + private readonly Mutex m_lock = new Mutex(false); + public MySQLManager Manager; + + public void GetLock() + { + Locked = true; + m_lock.WaitOne(); + } + + public void Release() + { + m_lock.ReleaseMutex(); + Locked = false; + } + + } +} -- cgit v1.1 From 7d89e122930be39e84a6d174548fa2d12ac0484a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 6 Sep 2008 07:52:41 +0000 Subject: * This is the fabled LibOMV update with all of the libOMV types from JHurliman * This is a HUGE OMG update and will definitely have unknown side effects.. so this is really only for the strong hearted at this point. Regular people should let the dust settle. * This has been tested to work with most basic functions. However.. make sure you back up 'everything' before using this. It's that big! * Essentially we're back at square 1 in the testing phase.. so lets identify things that broke. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 6 +- OpenSim/Data/MySQL/MySQLEstateData.cs | 26 +++--- OpenSim/Data/MySQL/MySQLGridData.cs | 12 +-- OpenSim/Data/MySQL/MySQLInventoryData.cs | 54 ++++++------ OpenSim/Data/MySQL/MySQLLogData.cs | 2 +- OpenSim/Data/MySQL/MySQLManager.cs | 134 +++++++++++++++--------------- OpenSim/Data/MySQL/MySQLRegionData.cs | 138 +++++++++++++++---------------- OpenSim/Data/MySQL/MySQLUserData.cs | 62 +++++++------- 8 files changed, 217 insertions(+), 217 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 08a8c6e..5c58a4b 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -29,7 +29,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Reflection; -using libsecondlife; +using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; @@ -116,7 +116,7 @@ namespace OpenSim.Data.MySQL /// Asset UUID to fetch /// Return the asset /// On failure : throw an exception and attempt to reconnect to database - override public AssetBase FetchAsset(LLUUID assetID) + override public AssetBase FetchAsset(UUID assetID) { AssetBase asset = null; lock (_dbConnection) @@ -223,7 +223,7 @@ namespace OpenSim.Data.MySQL /// /// The asset UUID /// true if exist. - override public bool ExistsAsset(LLUUID uuid) + override public bool ExistsAsset(UUID uuid) { bool assetExists = false; diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 2ab7d40..8eddec6 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -31,7 +31,7 @@ using System.Data; using System.IO; using System.Reflection; using System.Threading; -using libsecondlife; +using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; @@ -157,7 +157,7 @@ namespace OpenSim.Data.MySQL m_lastConnectionUse = timeNow; } - public EstateSettings LoadEstateSettings(LLUUID regionID) + public EstateSettings LoadEstateSettings(UUID regionID) { EstateSettings es = new EstateSettings(); es.OnSave += StoreEstateSettings; @@ -185,11 +185,11 @@ namespace OpenSim.Data.MySQL else m_FieldMap[name].SetValue(es, false); } - else if (m_FieldMap[name].GetValue(es) is libsecondlife.LLUUID) + else if(m_FieldMap[name].GetValue(es) is OpenMetaverse.UUID) { - LLUUID uuid = LLUUID.Zero; + UUID uuid = UUID.Zero; - LLUUID.TryParse(r[name].ToString(), out uuid); + UUID.TryParse(r[name].ToString(), out uuid); m_FieldMap[name].SetValue(es, uuid); } else @@ -330,8 +330,8 @@ namespace OpenSim.Data.MySQL { EstateBan eb = new EstateBan(); - LLUUID uuid = new LLUUID(); - LLUUID.TryParse(r["bannedUUID"].ToString(), out uuid); + UUID uuid = new UUID(); + UUID.TryParse(r["bannedUUID"].ToString(), out uuid); eb.bannedUUID = uuid; eb.bannedIP = "0.0.0.0"; @@ -366,7 +366,7 @@ namespace OpenSim.Data.MySQL } } - void SaveUUIDList(uint EstateID, string table, LLUUID[] data) + void SaveUUIDList(uint EstateID, string table, UUID[] data) { CheckConnection(); @@ -381,7 +381,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; - foreach (LLUUID uuid in data) + foreach (UUID uuid in data) { cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); @@ -391,9 +391,9 @@ namespace OpenSim.Data.MySQL } } - LLUUID[] LoadUUIDList(uint EstateID, string table) + UUID[] LoadUUIDList(uint EstateID, string table) { - List uuids = new List(); + List uuids = new List(); CheckConnection(); @@ -408,8 +408,8 @@ namespace OpenSim.Data.MySQL { // EstateBan eb = new EstateBan(); - LLUUID uuid = new LLUUID(); - LLUUID.TryParse(r["uuid"].ToString(), out uuid); + UUID uuid = new UUID(); + UUID.TryParse(r["uuid"].ToString(), out uuid); uuids.Add(uuid); } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 9dc3d18..fa5b33c 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -29,7 +29,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Reflection; -using libsecondlife; +using OpenMetaverse; using log4net; using OpenSim.Framework; @@ -121,7 +121,7 @@ namespace OpenSim.Data.MySQL } else { - m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); + m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.Xml and we'll use that instead"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); @@ -322,7 +322,7 @@ namespace OpenSim.Data.MySQL /// /// The region UUID /// The sim profile - override public RegionProfileData GetProfileByLLUUID(LLUUID uuid) + override public RegionProfileData GetProfileByUUID(UUID uuid) { MySQLSuperManager dbm = GetLockedConnection(); @@ -458,14 +458,14 @@ namespace OpenSim.Data.MySQL /// The attempted regionHandle of the challenger /// The secret /// Whether the secret and regionhandle match the database entry for UUID - override public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) + override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) { bool throwHissyFit = false; // Should be true by 1.0 if (throwHissyFit) throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); - RegionProfileData data = GetProfileByLLUUID(uuid); + RegionProfileData data = GetProfileByUUID(uuid); return (handle == data.regionHandle && authkey == data.regionSecret); } @@ -479,7 +479,7 @@ namespace OpenSim.Data.MySQL /// /// /// - public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge) + public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) { // SHA512Managed HashProvider = new SHA512Managed(); // Encoding TextProvider = new UTF8Encoding(); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index fe2d393..50d3cc7 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -28,7 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; -using libsecondlife; +using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; @@ -125,7 +125,7 @@ namespace OpenSim.Data.MySQL /// /// The folder to search /// A list containing inventory items - public List getInventoryInFolder(LLUUID folderID) + public List getInventoryInFolder(UUID folderID) { try { @@ -163,7 +163,7 @@ namespace OpenSim.Data.MySQL /// /// The user whos inventory is to be searched /// A list of folder objects - public List getUserRootFolders(LLUUID user) + public List getUserRootFolders(UUID user) { try { @@ -176,7 +176,7 @@ namespace OpenSim.Data.MySQL "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); MySqlDataReader reader = result.ExecuteReader(); List items = new List(); @@ -204,7 +204,7 @@ namespace OpenSim.Data.MySQL /// /// The user UUID /// - public InventoryFolderBase getUserRootFolder(LLUUID user) + public InventoryFolderBase getUserRootFolder(UUID user) { try { @@ -217,7 +217,7 @@ namespace OpenSim.Data.MySQL "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); MySqlDataReader reader = result.ExecuteReader(); @@ -258,7 +258,7 @@ namespace OpenSim.Data.MySQL /// /// The folder to search /// A list of inventory folders - public List getInventoryFolders(LLUUID parentID) + public List getInventoryFolders(UUID parentID) { try { @@ -302,23 +302,23 @@ namespace OpenSim.Data.MySQL { InventoryItemBase item = new InventoryItemBase(); - item.ID = new LLUUID((string) reader["inventoryID"]); - item.AssetID = new LLUUID((string) reader["assetID"]); + item.ID = new UUID((string) reader["inventoryID"]); + item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; - item.Folder = new LLUUID((string) reader["parentFolderID"]); - item.Owner = new LLUUID((string) reader["avatarID"]); + item.Folder = new UUID((string) reader["parentFolderID"]); + item.Owner = new UUID((string) reader["avatarID"]); item.Name = (string) reader["inventoryName"]; item.Description = (string) reader["inventoryDescription"]; item.NextPermissions = (uint) reader["inventoryNextPermissions"]; item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; item.InvType = (int) reader["invType"]; - item.Creator = new LLUUID((string) reader["creatorID"]); + item.Creator = new UUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; - item.GroupID = new LLUUID(reader["groupID"].ToString()); + item.GroupID = new UUID(reader["groupID"].ToString()); item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); item.Flags = (uint) reader["flags"]; @@ -337,7 +337,7 @@ namespace OpenSim.Data.MySQL /// /// The item to return /// An inventory item - public InventoryItemBase getInventoryItem(LLUUID itemID) + public InventoryItemBase getInventoryItem(UUID itemID) { try { @@ -378,9 +378,9 @@ namespace OpenSim.Data.MySQL try { InventoryFolderBase folder = new InventoryFolderBase(); - folder.Owner = new LLUUID((string) reader["agentID"]); - folder.ParentID = new LLUUID((string) reader["parentFolderID"]); - folder.ID = new LLUUID((string) reader["folderID"]); + folder.Owner = new UUID((string) reader["agentID"]); + folder.ParentID = new UUID((string) reader["parentFolderID"]); + folder.ID = new UUID((string) reader["folderID"]); folder.Name = (string) reader["folderName"]; folder.Type = (short) reader["type"]; folder.Version = (ushort) ((int) reader["version"]); @@ -400,7 +400,7 @@ namespace OpenSim.Data.MySQL /// /// The folder to return /// A folder class - public InventoryFolderBase getInventoryFolder(LLUUID folderID) + public InventoryFolderBase getInventoryFolder(UUID folderID) { try { @@ -498,7 +498,7 @@ namespace OpenSim.Data.MySQL /// Detele the specified inventory item /// /// The inventory item UUID to delete - public void deleteInventoryItem(LLUUID itemID) + public void deleteInventoryItem(UUID itemID) { try { @@ -596,7 +596,7 @@ namespace OpenSim.Data.MySQL /// /// list where folders will be appended /// ID of parent - protected void getInventoryFolders(ref List folders, LLUUID parentID) + protected void getInventoryFolders(ref List folders, UUID parentID) { List subfolderList = getInventoryFolders(parentID); @@ -610,7 +610,7 @@ namespace OpenSim.Data.MySQL /// /// /// - public List getFolderHierarchy(LLUUID parentID) + public List getFolderHierarchy(UUID parentID) { /* Note: There are subtle changes between this implementation of getFolderHierarchy and the previous one * - We will only need to hit the database twice instead of n times. @@ -631,8 +631,8 @@ namespace OpenSim.Data.MySQL try { List folders = new List(); - Dictionary> hashtable - = new Dictionary>(); ; + Dictionary> hashtable + = new Dictionary>(); ; List parentFolder = new List(); lock (database) { @@ -655,7 +655,7 @@ namespace OpenSim.Data.MySQL if (parentFolder.Count >= 1) // No result means parent folder does not exist { - if (parentFolder[0].ParentID == LLUUID.Zero) // We are querying the root folder + if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder { /* Get all of the agent's folders from the database, put them in a list and return it */ result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", @@ -728,7 +728,7 @@ namespace OpenSim.Data.MySQL /// Delete a folder from database /// /// the folder UUID - protected void deleteOneFolder(LLUUID folderID) + protected void deleteOneFolder(UUID folderID) { try { @@ -754,7 +754,7 @@ namespace OpenSim.Data.MySQL /// Delete all item in a folder /// /// the folder UUID - protected void deleteItemsInFolder(LLUUID folderID) + protected void deleteItemsInFolder(UUID folderID) { try { @@ -780,7 +780,7 @@ namespace OpenSim.Data.MySQL /// Deletes an inventory folder /// /// Id of folder to delete - public void deleteInventoryFolder(LLUUID folderID) + public void deleteInventoryFolder(UUID folderID) { List subFolders = getFolderHierarchy(folderID); diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index c02016c..07ef916 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -63,7 +63,7 @@ namespace OpenSim.Data.MySQL } else { - m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); + m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.Xml and we'll use that instead"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index e863216..6048f93 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -31,7 +31,7 @@ using System.Collections; using System.Data; using System.IO; using System.Reflection; -using libsecondlife; +using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; @@ -384,8 +384,8 @@ namespace OpenSim.Data.MySQL { retval.regionHandle = tmp64; } - LLUUID tmp_uuid; - if (!LLUUID.TryParse((string)reader["uuid"], out tmp_uuid)) + UUID tmp_uuid; + if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid)) { return null; } @@ -396,7 +396,7 @@ namespace OpenSim.Data.MySQL // non-critical parts retval.regionName = (string)reader["regionName"]; - retval.originUUID = new LLUUID((string) reader["originUUID"]); + retval.originUUID = new UUID((string) reader["originUUID"]); // Secrets retval.regionRecvKey = (string) reader["regionRecvKey"]; @@ -434,8 +434,8 @@ namespace OpenSim.Data.MySQL retval.regionUserSendKey = (string) reader["regionUserSendKey"]; // World Map Addition - LLUUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); - LLUUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); + UUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); + UUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); } else { @@ -463,8 +463,8 @@ namespace OpenSim.Data.MySQL retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); retval.reservationName = (string) reader["resName"]; retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; - LLUUID tmp; - LLUUID.TryParse((string) reader["userUUID"], out tmp); + UUID tmp; + UUID.TryParse((string) reader["userUUID"], out tmp); retval.userUUID = tmp; } else @@ -486,15 +486,15 @@ namespace OpenSim.Data.MySQL if (reader.Read()) { // Agent IDs - LLUUID tmp; - if (!LLUUID.TryParse((string)reader["UUID"], out tmp)) + UUID tmp; + if (!UUID.TryParse((string)reader["UUID"], out tmp)) return null; retval.ProfileID = tmp; - LLUUID.TryParse((string) reader["sessionID"], out tmp); + UUID.TryParse((string) reader["sessionID"], out tmp); retval.SessionID = tmp; - LLUUID.TryParse((string)reader["secureSessionID"], out tmp); + UUID.TryParse((string)reader["secureSessionID"], out tmp); retval.SecureSessionID = tmp; // Agent Who? @@ -507,10 +507,10 @@ namespace OpenSim.Data.MySQL retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); // Current position - retval.Region = new LLUUID((string)reader["currentRegion"]); + retval.Region = new UUID((string)reader["currentRegion"]); retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString()); - LLVector3 tmp_v; - LLVector3.TryParse((string) reader["currentPos"], out tmp_v); + Vector3 tmp_v; + Vector3.TryParse((string) reader["currentPos"], out tmp_v); retval.Position = tmp_v; } else @@ -531,8 +531,8 @@ namespace OpenSim.Data.MySQL if (reader.Read()) { - LLUUID id; - if (!LLUUID.TryParse((string)reader["UUID"], out id)) + UUID id; + if (!UUID.TryParse((string)reader["UUID"], out id)) return null; retval.ID = id; @@ -543,17 +543,17 @@ namespace OpenSim.Data.MySQL retval.PasswordSalt = (string) reader["passwordSalt"]; retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); - retval.HomeLocation = new LLVector3( + retval.HomeLocation = new Vector3( Convert.ToSingle(reader["homeLocationX"].ToString()), Convert.ToSingle(reader["homeLocationY"].ToString()), Convert.ToSingle(reader["homeLocationZ"].ToString())); - retval.HomeLookAt = new LLVector3( + retval.HomeLookAt = new Vector3( Convert.ToSingle(reader["homeLookAtX"].ToString()), Convert.ToSingle(reader["homeLookAtY"].ToString()), Convert.ToSingle(reader["homeLookAtZ"].ToString())); - LLUUID regionID = LLUUID.Zero; - LLUUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero + UUID regionID = UUID.Zero; + UUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use UUID.Zero retval.HomeRegionID = regionID; retval.Created = Convert.ToInt32(reader["created"].ToString()); @@ -576,29 +576,29 @@ namespace OpenSim.Data.MySQL retval.FirstLifeAboutText = (string)reader["profileFirstText"]; if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) - retval.Image = LLUUID.Zero; + retval.Image = UUID.Zero; else { - LLUUID tmp; - LLUUID.TryParse((string)reader["profileImage"], out tmp); + UUID tmp; + UUID.TryParse((string)reader["profileImage"], out tmp); retval.Image = tmp; } if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) - retval.FirstLifeImage = LLUUID.Zero; + retval.FirstLifeImage = UUID.Zero; else { - LLUUID tmp; - LLUUID.TryParse((string)reader["profileFirstImage"], out tmp); + UUID tmp; + UUID.TryParse((string)reader["profileFirstImage"], out tmp); retval.FirstLifeImage = tmp; } if (reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) { - retval.WebLoginKey = LLUUID.Zero; + retval.WebLoginKey = UUID.Zero; } else { - LLUUID tmp; - LLUUID.TryParse((string)reader["webLoginKey"], out tmp); + UUID tmp; + UUID.TryParse((string)reader["webLoginKey"], out tmp); retval.WebLoginKey = tmp; } @@ -611,12 +611,12 @@ namespace OpenSim.Data.MySQL if (reader.IsDBNull(reader.GetOrdinal("partner"))) { - retval.Partner = LLUUID.Zero; + retval.Partner = UUID.Zero; } else { - LLUUID tmp; - LLUUID.TryParse((string)reader["partner"], out tmp); + UUID tmp; + UUID.TryParse((string)reader["partner"], out tmp); retval.Partner = tmp; } } @@ -638,37 +638,37 @@ namespace OpenSim.Data.MySQL if (reader.Read()) { appearance = new AvatarAppearance(); - appearance.Owner = new LLUUID((string)reader["owner"]); + appearance.Owner = new UUID((string)reader["owner"]); appearance.Serial = Convert.ToInt32(reader["serial"]); appearance.VisualParams = (byte[])reader["visual_params"]; - appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); + appearance.Texture = new Primitive.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); - appearance.BodyItem = new LLUUID((string)reader["body_item"]); - appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); - appearance.SkinItem = new LLUUID((string)reader["skin_item"]); - appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); - appearance.HairItem = new LLUUID((string)reader["hair_item"]); - appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); - appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); - appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); - appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); - appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); - appearance.PantsItem = new LLUUID((string)reader["pants_item"]); - appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); - appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); - appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); - appearance.SocksItem = new LLUUID((string)reader["socks_item"]); - appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); - appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); - appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); - appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); - appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); - appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); - appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); - appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); - appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); - appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); - appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]); + appearance.BodyItem = new UUID((string)reader["body_item"]); + appearance.BodyAsset = new UUID((string)reader["body_asset"]); + appearance.SkinItem = new UUID((string)reader["skin_item"]); + appearance.SkinAsset = new UUID((string)reader["skin_asset"]); + appearance.HairItem = new UUID((string)reader["hair_item"]); + appearance.HairAsset = new UUID((string)reader["hair_asset"]); + appearance.EyesItem = new UUID((string)reader["eyes_item"]); + appearance.EyesAsset = new UUID((string)reader["eyes_asset"]); + appearance.ShirtItem = new UUID((string)reader["shirt_item"]); + appearance.ShirtAsset = new UUID((string)reader["shirt_asset"]); + appearance.PantsItem = new UUID((string)reader["pants_item"]); + appearance.PantsAsset = new UUID((string)reader["pants_asset"]); + appearance.ShoesItem = new UUID((string)reader["shoes_item"]); + appearance.ShoesAsset = new UUID((string)reader["shoes_asset"]); + appearance.SocksItem = new UUID((string)reader["socks_item"]); + appearance.SocksAsset = new UUID((string)reader["socks_asset"]); + appearance.JacketItem = new UUID((string)reader["jacket_item"]); + appearance.JacketAsset = new UUID((string)reader["jacket_asset"]); + appearance.GlovesItem = new UUID((string)reader["gloves_item"]); + appearance.GlovesAsset = new UUID((string)reader["gloves_asset"]); + appearance.UnderShirtItem = new UUID((string)reader["undershirt_item"]); + appearance.UnderShirtAsset = new UUID((string)reader["undershirt_asset"]); + appearance.UnderPantsItem = new UUID((string)reader["underpants_item"]); + appearance.UnderPantsAsset = new UUID((string)reader["underpants_asset"]); + appearance.SkirtItem = new UUID((string)reader["skirt_item"]); + appearance.SkirtAsset = new UUID((string)reader["skirt_asset"]); } return appearance; } @@ -766,12 +766,12 @@ namespace OpenSim.Data.MySQL /// UUID for firstlife image /// Ignored /// Success? - public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash, + public bool insertUserRow(UUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) + UUID profileImage, UUID firstImage, UUID webLoginKey) { m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); string sql = @@ -867,12 +867,12 @@ namespace OpenSim.Data.MySQL /// UUID for firstlife image /// UUID for weblogin Key /// Success? - public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, - string passwordSalt, UInt64 homeRegion, LLUUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, + public bool updateUserRow(UUID uuid, string username, string lastname, string passwordHash, + string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey, int userFlags, int godLevel, string customType, LLUUID partner) + UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; @@ -1211,7 +1211,7 @@ namespace OpenSim.Data.MySQL } - public void writeAttachments(LLUUID agentID, Hashtable data) + public void writeAttachments(UUID agentID, Hashtable data) { string sql = "delete from avatarattachments where UUID = ?uuid"; diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 903f022..9552ba1 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -31,7 +31,7 @@ using System.Data; using System.IO; using System.Reflection; using System.Threading; -using libsecondlife; +using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; @@ -296,15 +296,15 @@ namespace OpenSim.Data.MySQL /// /// The object /// The region UUID - public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) + public void StoreObject(SceneObjectGroup obj, UUID regionUUID) { lock (m_dataSet) { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0) + if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) { //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); @@ -323,9 +323,9 @@ namespace OpenSim.Data.MySQL /// /// The object /// The Region UUID - public void RemoveObject(LLUUID obj, LLUUID regionUUID) + public void RemoveObject(UUID obj, UUID regionUUID) { - m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj, regionUUID); DataTable prims = m_primTable; DataTable shapes = m_shapeTable; @@ -337,7 +337,7 @@ namespace OpenSim.Data.MySQL foreach (DataRow row in primRows) { // Remove shapes row - LLUUID uuid = new LLUUID((string) row["UUID"]); + UUID uuid = new UUID((string) row["UUID"]); DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); if (shapeRow != null) { @@ -358,7 +358,7 @@ namespace OpenSim.Data.MySQL /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. /// /// the Item UUID - private void RemoveItems(LLUUID uuid) + private void RemoveItems(UUID uuid) { String sql = String.Format("primID = '{0}'", uuid); DataRow[] itemRows = m_itemsTable.Select(sql); @@ -374,9 +374,9 @@ namespace OpenSim.Data.MySQL /// /// the Region UUID /// List of loaded groups - public List LoadObjects(LLUUID regionUUID) + public List LoadObjects(UUID regionUUID) { - Dictionary createdObjects = new Dictionary(); + Dictionary createdObjects = new Dictionary(); List retvals = new List(); @@ -436,7 +436,7 @@ namespace OpenSim.Data.MySQL "No shape found for prim in storage, so setting default box shape"); prim.Shape = PrimitiveBaseShape.Default; } - createdObjects[new LLUUID(objID)].AddPart(prim); + createdObjects[new UUID(objID)].AddPart(prim); } LoadItems(prim); @@ -497,7 +497,7 @@ namespace OpenSim.Data.MySQL /// /// HeightField data /// region UUID - public void StoreTerrain(double[,] ter, LLUUID regionID) + public void StoreTerrain(double[,] ter, UUID regionID) { int revision = 1; m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); @@ -527,7 +527,7 @@ namespace OpenSim.Data.MySQL /// /// the region UUID /// Heightfield data - public double[,] LoadTerrain(LLUUID regionID) + public double[,] LoadTerrain(UUID regionID) { double[,] terret = new double[256,256]; terret.Initialize(); @@ -583,7 +583,7 @@ namespace OpenSim.Data.MySQL /// /// /// - public void RemoveLandObject(LLUUID globalID) + public void RemoveLandObject(UUID globalID) { lock (m_dataSet) { @@ -646,7 +646,7 @@ namespace OpenSim.Data.MySQL } } - public RegionSettings LoadRegionSettings(LLUUID regionUUID) + public RegionSettings LoadRegionSettings(UUID regionUUID) { lock (m_dataSet) { @@ -701,7 +701,7 @@ namespace OpenSim.Data.MySQL /// /// /// - public List LoadLandObjects(LLUUID regionUUID) + public List LoadLandObjects(UUID regionUUID) { List landDataForRegion = new List(); lock (m_dataSet) @@ -1101,7 +1101,7 @@ namespace OpenSim.Data.MySQL private SceneObjectPart buildPrim(DataRow row) { SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new LLUUID((String) row["UUID"]); + prim.UUID = new UUID((String) row["UUID"]); // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. prim.ParentID = Convert.ToUInt32(row["ParentID"]); @@ -1114,54 +1114,54 @@ namespace OpenSim.Data.MySQL prim.TouchName = (String) row["TouchName"]; // permissions prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new LLUUID((String) row["CreatorID"]); - prim.OwnerID = new LLUUID((String) row["OwnerID"]); - prim.GroupID = new LLUUID((String) row["GroupID"]); - prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); + prim.CreatorID = new UUID((String) row["CreatorID"]); + prim.OwnerID = new UUID((String) row["OwnerID"]); + prim.GroupID = new UUID((String) row["GroupID"]); + prim.LastOwnerID = new UUID((String) row["LastOwnerID"]); prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); // vectors - prim.OffsetPosition = new LLVector3( + prim.OffsetPosition = new Vector3( Convert.ToSingle(row["PositionX"]), Convert.ToSingle(row["PositionY"]), Convert.ToSingle(row["PositionZ"]) ); - prim.GroupPosition = new LLVector3( + prim.GroupPosition = new Vector3( Convert.ToSingle(row["GroupPositionX"]), Convert.ToSingle(row["GroupPositionY"]), Convert.ToSingle(row["GroupPositionZ"]) ); - prim.Velocity = new LLVector3( + prim.Velocity = new Vector3( Convert.ToSingle(row["VelocityX"]), Convert.ToSingle(row["VelocityY"]), Convert.ToSingle(row["VelocityZ"]) ); - prim.AngularVelocity = new LLVector3( + prim.AngularVelocity = new Vector3( Convert.ToSingle(row["AngularVelocityX"]), Convert.ToSingle(row["AngularVelocityY"]), Convert.ToSingle(row["AngularVelocityZ"]) ); - prim.Acceleration = new LLVector3( + prim.Acceleration = new Vector3( Convert.ToSingle(row["AccelerationX"]), Convert.ToSingle(row["AccelerationY"]), Convert.ToSingle(row["AccelerationZ"]) ); // quaternions - prim.RotationOffset = new LLQuaternion( + prim.RotationOffset = new Quaternion( Convert.ToSingle(row["RotationX"]), Convert.ToSingle(row["RotationY"]), Convert.ToSingle(row["RotationZ"]), Convert.ToSingle(row["RotationW"]) ); - prim.SitTargetPositionLL = new LLVector3( + prim.SitTargetPositionLL = new Vector3( Convert.ToSingle(row["SitTargetOffsetX"]), Convert.ToSingle(row["SitTargetOffsetY"]), Convert.ToSingle(row["SitTargetOffsetZ"]) ); - prim.SitTargetOrientationLL = new LLQuaternion( + prim.SitTargetOrientationLL = new Quaternion( Convert.ToSingle(row["SitTargetOrientX"]), Convert.ToSingle(row["SitTargetOrientY"]), Convert.ToSingle(row["SitTargetOrientZ"]), @@ -1174,14 +1174,14 @@ namespace OpenSim.Data.MySQL prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); - prim.Sound = new LLUUID(row["LoopedSound"].ToString()); + prim.Sound = new UUID(row["LoopedSound"].ToString()); prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); prim.SoundFlags = 1; // If it's persisted at all, it's looped if (!row.IsNull("TextureAnimation")) prim.TextureAnimation = (Byte[])row["TextureAnimation"]; - prim.RotationalVelocity = new LLVector3( + prim.RotationalVelocity = new Vector3( Convert.ToSingle(row["OmegaX"]), Convert.ToSingle(row["OmegaY"]), Convert.ToSingle(row["OmegaZ"]) @@ -1190,13 +1190,13 @@ namespace OpenSim.Data.MySQL // TODO: Rotation // OmegaX, OmegaY, OmegaZ - prim.SetCameraEyeOffset(new LLVector3( + prim.SetCameraEyeOffset(new Vector3( Convert.ToSingle(row["CameraEyeOffsetX"]), Convert.ToSingle(row["CameraEyeOffsetY"]), Convert.ToSingle(row["CameraEyeOffsetZ"]) )); - prim.SetCameraAtOffset(new LLVector3( + prim.SetCameraAtOffset(new Vector3( Convert.ToSingle(row["CameraAtOffsetX"]), Convert.ToSingle(row["CameraAtOffsetY"]), Convert.ToSingle(row["CameraAtOffsetZ"]) @@ -1229,10 +1229,10 @@ namespace OpenSim.Data.MySQL { TaskInventoryItem taskItem = new TaskInventoryItem(); - taskItem.ItemID = new LLUUID((String)row["itemID"]); - taskItem.ParentPartID = new LLUUID((String)row["primID"]); - taskItem.AssetID = new LLUUID((String)row["assetID"]); - taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); + taskItem.ItemID = new UUID((String)row["itemID"]); + taskItem.ParentPartID = new UUID((String)row["primID"]); + taskItem.AssetID = new UUID((String)row["assetID"]); + taskItem.ParentID = new UUID((String)row["parentFolderID"]); taskItem.InvType = Convert.ToInt32(row["invType"]); taskItem.Type = Convert.ToInt32(row["assetType"]); @@ -1240,10 +1240,10 @@ namespace OpenSim.Data.MySQL taskItem.Name = (String)row["name"]; taskItem.Description = (String)row["description"]; taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorID = new LLUUID((String)row["creatorID"]); - taskItem.OwnerID = new LLUUID((String)row["ownerID"]); - taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); - taskItem.GroupID = new LLUUID((String)row["groupID"]); + taskItem.CreatorID = new UUID((String)row["creatorID"]); + taskItem.OwnerID = new UUID((String)row["ownerID"]); + taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]); + taskItem.GroupID = new UUID((String)row["groupID"]); taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); @@ -1259,7 +1259,7 @@ namespace OpenSim.Data.MySQL { RegionSettings newSettings = new RegionSettings(); - newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); + newSettings.RegionUUID = new UUID((string) row["regionUUID"]); newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); @@ -1273,10 +1273,10 @@ namespace OpenSim.Data.MySQL newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); - newSettings.TerrainTexture1 = new LLUUID((String) row["terrain_texture_1"]); - newSettings.TerrainTexture2 = new LLUUID((String) row["terrain_texture_2"]); - newSettings.TerrainTexture3 = new LLUUID((String) row["terrain_texture_3"]); - newSettings.TerrainTexture4 = new LLUUID((String) row["terrain_texture_4"]); + newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]); + newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]); + newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]); + newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]); newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); @@ -1292,7 +1292,7 @@ namespace OpenSim.Data.MySQL newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); - newSettings.Covenant = new LLUUID((String) row["covenant"]); + newSettings.Covenant = new UUID((String) row["covenant"]); return newSettings; } @@ -1306,7 +1306,7 @@ namespace OpenSim.Data.MySQL { LandData newData = new LandData(); - newData.GlobalID = new LLUUID((String) row["UUID"]); + newData.GlobalID = new UUID((String) row["UUID"]); newData.LocalID = Convert.ToInt32(row["LocalLandID"]); // Bitmap is a byte[512] @@ -1322,39 +1322,39 @@ namespace OpenSim.Data.MySQL //Enum libsecondlife.Parcel.ParcelCategory newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.GroupID = new LLUUID((String) row["GroupUUID"]); + newData.GroupID = new UUID((String) row["GroupUUID"]); newData.SalePrice = Convert.ToInt32(row["SalePrice"]); newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus newData.Flags = Convert.ToUInt32(row["LandFlags"]); newData.LandingType = Convert.ToByte(row["LandingType"]); newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.MediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.MediaID = new UUID((String) row["MediaTextureUUID"]); newData.MediaURL = (String) row["MediaURL"]; newData.MusicURL = (String) row["MusicURL"]; newData.PassHours = Convert.ToSingle(row["PassHours"]); newData.PassPrice = Convert.ToInt32(row["PassPrice"]); - LLUUID authedbuyer = LLUUID.Zero; - LLUUID snapshotID = LLUUID.Zero; + UUID authedbuyer = UUID.Zero; + UUID snapshotID = UUID.Zero; - Helpers.TryParse((string)row["AuthBuyerID"], out authedbuyer); - Helpers.TryParse((string)row["SnapshotUUID"], out snapshotID); + UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); + UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); newData.AuthBuyerID = authedbuyer; newData.SnapshotID = snapshotID; try { newData.UserLocation = - new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); newData.UserLookAt = - new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), Convert.ToSingle(row["UserLookAtZ"])); } catch (InvalidCastException) { - newData.UserLocation = LLVector3.Zero; - newData.UserLookAt = LLVector3.Zero; + newData.UserLocation = Vector3.Zero; + newData.UserLookAt = Vector3.Zero; m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); } @@ -1371,7 +1371,7 @@ namespace OpenSim.Data.MySQL private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new LLUUID((string) row["AccessUUID"]); + entry.AgentID = new UUID((string) row["AccessUUID"]); entry.Flags = (ParcelManager.AccessList) Convert.ToInt32(row["Flags"]); entry.Time = new DateTime(); return entry; @@ -1408,7 +1408,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) + private void fillPrimRow(DataRow row, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) { row["UUID"] = Util.ToRawUuidString(prim.UUID); row["RegionUUID"] = Util.ToRawUuidString(regionUUID); @@ -1456,12 +1456,12 @@ namespace OpenSim.Data.MySQL row["RotationW"] = prim.RotationOffset.W; // Sit target - LLVector3 sitTargetPos = prim.SitTargetPositionLL; + Vector3 sitTargetPos = prim.SitTargetPositionLL; row["SitTargetOffsetX"] = sitTargetPos.X; row["SitTargetOffsetY"] = sitTargetPos.Y; row["SitTargetOffsetZ"] = sitTargetPos.Z; - LLQuaternion sitTargetOrient = prim.SitTargetOrientationLL; + Quaternion sitTargetOrient = prim.SitTargetOrientationLL; row["SitTargetOrientW"] = sitTargetOrient.W; row["SitTargetOrientX"] = sitTargetOrient.X; row["SitTargetOrientY"] = sitTargetOrient.Y; @@ -1480,7 +1480,7 @@ namespace OpenSim.Data.MySQL } else { - row["LoopedSound"] = LLUUID.Zero; + row["LoopedSound"] = UUID.Zero; row["LoopedSoundGain"] = 0.0f; } @@ -1597,7 +1597,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) + private static void fillLandRow(DataRow row, LandData land, UUID regionUUID) { row["UUID"] = Util.ToRawUuidString(land.GlobalID); row["RegionUUID"] = Util.ToRawUuidString(regionUUID); @@ -1642,7 +1642,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) + private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, UUID parcelID) { row["LandUUID"] = Util.ToRawUuidString(parcelID); row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); @@ -1657,7 +1657,7 @@ namespace OpenSim.Data.MySQL private PrimitiveBaseShape buildShape(DataRow row) { PrimitiveBaseShape s = new PrimitiveBaseShape(); - s.Scale = new LLVector3( + s.Scale = new Vector3( Convert.ToSingle(row["ScaleX"]), Convert.ToSingle(row["ScaleY"]), Convert.ToSingle(row["ScaleZ"]) @@ -1778,7 +1778,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) + private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) { lock (m_dataSet) { @@ -1816,7 +1816,7 @@ namespace OpenSim.Data.MySQL /// /// /// - public void StorePrimInventory(LLUUID primID, ICollection items) + public void StorePrimInventory(UUID primID, ICollection items) { m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 8d0b177..42983b1 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using System.Text.RegularExpressions; -using libsecondlife; +using OpenMetaverse; using log4net; using OpenSim.Framework; using MySql.Data.MySqlClient; @@ -221,15 +221,15 @@ namespace OpenSim.Data.MySQL #region User Friends List Data - public override void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { MySQLSuperManager dbm = GetLockedConnection(); int dtvalue = Util.UnixTimeSinceEpoch(); Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.UUID.ToString(); - param["?friendID"] = friend.UUID.ToString(); + param["?ownerID"] = friendlistowner.ToString(); + param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); param["?datetimestamp"] = dtvalue.ToString(); @@ -265,13 +265,13 @@ namespace OpenSim.Data.MySQL } } - public override void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { MySQLSuperManager dbm = GetLockedConnection(); Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.UUID.ToString(); - param["?friendID"] = friend.UUID.ToString(); + param["?ownerID"] = friendlistowner.ToString(); + param["?friendID"] = friend.ToString(); try { @@ -299,13 +299,13 @@ namespace OpenSim.Data.MySQL } } - public override void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { MySQLSuperManager dbm = GetLockedConnection(); Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.UUID.ToString(); - param["?friendID"] = friend.UUID.ToString(); + param["?ownerID"] = friendlistowner.ToString(); + param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); try @@ -330,13 +330,13 @@ namespace OpenSim.Data.MySQL } } - public override List GetUserFriendList(LLUUID friendlistowner) + public override List GetUserFriendList(UUID friendlistowner) { MySQLSuperManager dbm = GetLockedConnection(); List Lfli = new List(); Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.UUID.ToString(); + param["?ownerID"] = friendlistowner.ToString(); try { @@ -352,8 +352,8 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new LLUUID((string) reader["ownerID"]); - fli.Friend = new LLUUID((string) reader["friendID"]); + fli.FriendListOwner = new UUID((string) reader["ownerID"]); + fli.Friend = new UUID((string) reader["friendID"]); fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); // This is not a real column in the database table, it's a joined column from the opposite record @@ -381,12 +381,12 @@ namespace OpenSim.Data.MySQL #endregion - public override void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) + public override void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle) { //m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called"); } - public override List GeneratePickerResults(LLUUID queryID, string query) + public override List GeneratePickerResults(UUID queryID, string query) { MySQLSuperManager dbm = GetLockedConnection(); @@ -413,7 +413,7 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string) reader["UUID"]); + user.AvatarID = new UUID((string) reader["UUID"]); user.firstName = (string) reader["username"]; user.lastName = (string) reader["lastname"]; returnlist.Add(user); @@ -449,7 +449,7 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string) reader["UUID"]); + user.AvatarID = new UUID((string) reader["UUID"]); user.firstName = (string) reader["username"]; user.lastName = (string) reader["lastname"]; returnlist.Add(user); @@ -476,7 +476,7 @@ namespace OpenSim.Data.MySQL /// /// User UUID /// User profile data - public override UserProfileData GetUserByUUID(LLUUID uuid) + public override UserProfileData GetUserByUUID(UUID uuid) { MySQLSuperManager dbm = GetLockedConnection(); try @@ -533,13 +533,13 @@ namespace OpenSim.Data.MySQL /// /// /// is it still used ? - public override void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) + public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) { MySQLSuperManager dbm = GetLockedConnection(); Dictionary param = new Dictionary(); - param["?UUID"] = AgentID.UUID.ToString(); - param["?webLoginKey"] = WebLoginKey.UUID.ToString(); + param["?UUID"] = AgentID.ToString(); + param["?webLoginKey"] = WebLoginKey.ToString(); try { @@ -565,7 +565,7 @@ namespace OpenSim.Data.MySQL /// /// The accounts UUID /// The users session - public override UserAgentData GetAgentByUUID(LLUUID uuid) + public override UserAgentData GetAgentByUUID(UUID uuid) { MySQLSuperManager dbm = GetLockedConnection(); @@ -682,7 +682,7 @@ namespace OpenSim.Data.MySQL /// The receivers account ID /// The amount to transfer /// Success? - public override bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) + public override bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } @@ -695,7 +695,7 @@ namespace OpenSim.Data.MySQL /// The receivers account ID /// The item to transfer /// Success? - public override bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) + public override bool InventoryTransferRequest(UUID from, UUID to, UUID item) { return false; } @@ -705,7 +705,7 @@ namespace OpenSim.Data.MySQL /// TODO: stubs for now to get us to a compiling state gently /// override /// - public override AvatarAppearance GetUserAppearance(LLUUID user) + public override AvatarAppearance GetUserAppearance(UUID user) { MySQLSuperManager dbm = GetLockedConnection(); try @@ -744,7 +744,7 @@ namespace OpenSim.Data.MySQL /// The user UUID /// The avatar appearance // override - public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) + public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { MySQLSuperManager dbm = GetLockedConnection(); try @@ -783,7 +783,7 @@ namespace OpenSim.Data.MySQL get { return "0.1"; } } - public Hashtable GetUserAttachments(LLUUID agentID) + public Hashtable GetUserAttachments(UUID agentID) { MySQLSuperManager dbm = GetLockedConnection(); @@ -814,7 +814,7 @@ namespace OpenSim.Data.MySQL } } - public void UpdateUserAttachments(LLUUID agentID, Hashtable data) + public void UpdateUserAttachments(UUID agentID, Hashtable data) { MySQLSuperManager dbm = GetLockedConnection(); try @@ -827,7 +827,7 @@ namespace OpenSim.Data.MySQL } } - public override void ResetAttachments(LLUUID userID) + public override void ResetAttachments(UUID userID) { MySQLSuperManager dbm = GetLockedConnection(); @@ -847,4 +847,4 @@ namespace OpenSim.Data.MySQL } } } -} \ No newline at end of file +} -- cgit v1.1 From 9e545c9984790ddeabba0bf86e229af90da09ad6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 6 Sep 2008 14:58:23 +0000 Subject: Mantis #2133 Thank you, Xugu Madison and ChrisDown, for a patch that fixes linux filename extensions from .Xml back to .xml --- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- OpenSim/Data/MySQL/MySQLLogData.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index fa5b33c..4e4d32c 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -121,7 +121,7 @@ namespace OpenSim.Data.MySQL } else { - m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.Xml and we'll use that instead"); + m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 07ef916..c02016c 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -63,7 +63,7 @@ namespace OpenSim.Data.MySQL } else { - m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.Xml and we'll use that instead"); + m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); -- cgit v1.1 From 490ac0be005a989c86ebde62aad137fd2da7cbd8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 8 Sep 2008 02:40:20 +0000 Subject: Implement proper persistence of the following prim properties: Floating text, Rotation, Texture animation, Particle System This will make "Eye Candy" scripts work without modification in XEngine. The use of the CHANGED_REGION_RESTART hack is no longer needed. Implemented in MySQL only, hovertext also in SQLite. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 20 +++++++++++++++++--- OpenSim/Data/MySQL/Resources/017_RegionStore.sql | 9 +++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/017_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 9552ba1..b7fc70b 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -31,6 +31,7 @@ using System.Data; using System.IO; using System.Reflection; using System.Threading; +using System.Drawing; using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; @@ -858,6 +859,10 @@ namespace OpenSim.Data.MySQL createCol(prims, "SceneGroupID", typeof (String)); // various text fields createCol(prims, "Text", typeof (String)); + createCol(prims, "ColorR", typeof (Int32)); + createCol(prims, "ColorG", typeof (Int32)); + createCol(prims, "ColorB", typeof (Int32)); + createCol(prims, "ColorA", typeof (Int32)); createCol(prims, "Description", typeof (String)); createCol(prims, "SitName", typeof (String)); createCol(prims, "TouchName", typeof (String)); @@ -912,6 +917,7 @@ namespace OpenSim.Data.MySQL createCol(prims, "LoopedSound", typeof(String)); createCol(prims, "LoopedSoundGain", typeof(Double)); createCol(prims, "TextureAnimation", typeof(Byte[])); + createCol(prims, "ParticleSystem", typeof(Byte[])); createCol(prims, "OmegaX", typeof (Double)); createCol(prims, "OmegaY", typeof (Double)); @@ -1109,6 +1115,10 @@ namespace OpenSim.Data.MySQL prim.Name = (String) row["Name"]; // various text fields prim.Text = (String) row["Text"]; + prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), + Convert.ToInt32(row["ColorR"]), + Convert.ToInt32(row["ColorG"]), + Convert.ToInt32(row["ColorB"])); prim.Description = (String) row["Description"]; prim.SitName = (String) row["SitName"]; prim.TouchName = (String) row["TouchName"]; @@ -1180,6 +1190,8 @@ namespace OpenSim.Data.MySQL if (!row.IsNull("TextureAnimation")) prim.TextureAnimation = (Byte[])row["TextureAnimation"]; + if (!row.IsNull("ParticleSystem")) + prim.ParticleSystem = (Byte[])row["ParticleSystem"]; prim.RotationalVelocity = new Vector3( Convert.ToSingle(row["OmegaX"]), @@ -1187,9 +1199,6 @@ namespace OpenSim.Data.MySQL Convert.ToSingle(row["OmegaZ"]) ); - // TODO: Rotation - // OmegaX, OmegaY, OmegaZ - prim.SetCameraEyeOffset(new Vector3( Convert.ToSingle(row["CameraEyeOffsetX"]), Convert.ToSingle(row["CameraEyeOffsetY"]), @@ -1419,6 +1428,10 @@ namespace OpenSim.Data.MySQL // the UUID of the root part for this SceneObjectGroup // various text fields row["Text"] = prim.Text; + row["ColorR"] = prim.Color.R; + row["ColorG"] = prim.Color.G; + row["ColorB"] = prim.Color.B; + row["ColorA"] = prim.Color.A; row["Description"] = prim.Description; row["SitName"] = prim.SitName; row["TouchName"] = prim.TouchName; @@ -1485,6 +1498,7 @@ namespace OpenSim.Data.MySQL } row["TextureAnimation"] = prim.TextureAnimation; + row["ParticleSystem"] = prim.ParticleSystem; row["OmegaX"] = prim.RotationalVelocity.X; row["OmegaY"] = prim.RotationalVelocity.Y; diff --git a/OpenSim/Data/MySQL/Resources/017_RegionStore.sql b/OpenSim/Data/MySQL/Resources/017_RegionStore.sql new file mode 100644 index 0000000..0304f30 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/017_RegionStore.sql @@ -0,0 +1,9 @@ +BEGIN; + +ALTER TABLE prims ADD COLUMN ColorR integer not null default 0; +ALTER TABLE prims ADD COLUMN ColorG integer not null default 0; +ALTER TABLE prims ADD COLUMN ColorB integer not null default 0; +ALTER TABLE prims ADD COLUMN ColorA integer not null default 0; +ALTER TABLE prims ADD COLUMN ParticleSystem blob; + +COMMIT; -- cgit v1.1 From fae34bb10cfa10702faf5c19d8c8517faa018cb5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 9 Sep 2008 01:26:48 +0000 Subject: Update svn properties, formatting cleanup. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 8eddec6..57151b3 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -185,7 +185,7 @@ namespace OpenSim.Data.MySQL else m_FieldMap[name].SetValue(es, false); } - else if(m_FieldMap[name].GetValue(es) is OpenMetaverse.UUID) + else if (m_FieldMap[name].GetValue(es) is OpenMetaverse.UUID) { UUID uuid = UUID.Zero; diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 42983b1..81acbfb 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -79,7 +79,7 @@ namespace OpenSim.Data.MySQL m_lastConnect++; // Overflow protection - if(m_lastConnect == int.MaxValue) + if (m_lastConnect == int.MaxValue) m_lastConnect = 0; MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; -- cgit v1.1 From e0d092ec537a7187d3b5a367f27b834fccad778d Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 10 Sep 2008 00:19:36 +0000 Subject: Thanks, nlin, for a patch implementing persistence for "When Left Clicked" object property. Fix issue 2149. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 +++++ OpenSim/Data/MySQL/Resources/018_RegionStore.sql | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/018_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index b7fc70b..920a001 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -941,6 +941,7 @@ namespace OpenSim.Data.MySQL createCol(prims, "SalePrice", typeof(Int32)); createCol(prims, "SaleType", typeof (Int16)); + createCol(prims, "ClickAction", typeof (Byte)); // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -1225,6 +1226,8 @@ namespace OpenSim.Data.MySQL prim.SalePrice = Convert.ToInt32(row["SalePrice"]); prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); + prim.ClickAction = Convert.ToByte(row["ClickAction"]); + return prim; } @@ -1532,6 +1535,8 @@ namespace OpenSim.Data.MySQL row["SalePrice"] = prim.SalePrice; row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); + byte clickAction = prim.ClickAction; + row["ClickAction"] = clickAction; } /// diff --git a/OpenSim/Data/MySQL/Resources/018_RegionStore.sql b/OpenSim/Data/MySQL/Resources/018_RegionStore.sql new file mode 100644 index 0000000..68c489c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/018_RegionStore.sql @@ -0,0 +1,6 @@ +begin; + +ALTER TABLE prims ADD COLUMN ClickAction tinyint NOT NULL default 0; + +commit; + -- cgit v1.1 From a68e34b5587723899cbc20e6e27a47ad01234718 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 10 Sep 2008 06:14:38 +0000 Subject: Mantis #511 Allow parsing of hexadecimal int constants from strings. Also fixes a DBNull value in the touch type field crashing the sim --- OpenSim/Data/MySQL/MySQLRegionData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 920a001..9c36d49 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1226,7 +1226,8 @@ namespace OpenSim.Data.MySQL prim.SalePrice = Convert.ToInt32(row["SalePrice"]); prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); - prim.ClickAction = Convert.ToByte(row["ClickAction"]); + if (!row.IsNull("ClickAction")) + prim.ClickAction = Convert.ToByte(row["ClickAction"]); return prim; } -- cgit v1.1 From 52a4c4d82f9c5b808e6c61fd51c1c70e42865565 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Sep 2008 20:12:03 +0000 Subject: * Check in first part of http://opensimulator.org/mantis/view.php?id=2073 * This patch aims to introduce look at direction persistence between logins. It won't be active until the second part of the patch is committed in about two weeks time. At this point, region servers that haven't upgraded past this revision may run into problems * This checkin upgrades the user database. As always, we recommend you have backups in case something goes wrong. * Many thanks to tyre for this patch. --- OpenSim/Data/MySQL/MySQLManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 6048f93..5f830bb 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -512,6 +512,8 @@ namespace OpenSim.Data.MySQL Vector3 tmp_v; Vector3.TryParse((string) reader["currentPos"], out tmp_v); retval.Position = tmp_v; + Vector3.TryParse((string)reader["currentLookAt"], out tmp_v); + retval.LookAt = tmp_v; } else { @@ -1095,8 +1097,8 @@ namespace OpenSim.Data.MySQL { string sql = String.Empty; sql += "REPLACE INTO "; - sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES "; - sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos);"; + sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES "; + sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);"; Dictionary parameters = new Dictionary(); parameters["?UUID"] = agentdata.ProfileID.ToString(); @@ -1109,7 +1111,8 @@ namespace OpenSim.Data.MySQL parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); parameters["?currentRegion"] = agentdata.Region.ToString(); parameters["?currentHandle"] = agentdata.Handle.ToString(); - parameters["?currentPos"] = "<" + ((int)agentdata.Position.X).ToString() + "," + ((int)agentdata.Position.Y).ToString() + "," + ((int)agentdata.Position.Z).ToString() + ">"; + parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString() + "," + (agentdata.Position.Y).ToString() + "," + (agentdata.Position.Z).ToString() + ">"; + parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString() + "," + (agentdata.LookAt.Y).ToString() + "," + (agentdata.LookAt.Z).ToString() + ">"; bool returnval = false; -- cgit v1.1 From 2d7aca6d9dfe58ff35dd86b01b0fc79a85dc529e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Sep 2008 20:38:20 +0000 Subject: * Add userstore sql upgrade I carelessly forgot to check in a couple of revisions ago * Hopefully there wasn't a problem anyway, since the look at stuff isn't enabled yet --- OpenSim/Data/MySQL/Resources/006_UserStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/006_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/006_UserStore.sql b/OpenSim/Data/MySQL/Resources/006_UserStore.sql new file mode 100644 index 0000000..10b321e --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/006_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE agents add currentLookAt varchar(36) not null default ''; + +COMMIT; -- cgit v1.1 From 1d5e870ee2a45d6df6f2114c8df90de0015bcb6e Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 14 Sep 2008 02:56:51 +0000 Subject: Thank you kindly, CMickeyb for a patch that: Moved intialization of appearance from the SendInitialData event handler into CompleteMovement handler. That ensures that m_appearance is initialized before the inventory is retrieved (so there is a place to check on attachments). --- OpenSim/Data/MySQL/MySQLUserData.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 81acbfb..5f7db15 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -722,6 +722,12 @@ namespace OpenSim.Data.MySQL reader.Dispose(); result.Dispose(); + if (null == appearance) + { + m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); + return null; + } + appearance.SetAttachments(GetUserAttachments(user)); return appearance; -- cgit v1.1 From 281955949910eb257b5f7e42e54535ba7812418e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 14 Sep 2008 13:23:02 +0000 Subject: Mantis #2124 Thank you, RuudL, for a patch that brings MSSQL up to the same implementation level as MySQL. --- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 4e4d32c..1155ae3 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -434,7 +434,7 @@ namespace OpenSim.Data.MySQL /// the sim UUID /// Successful? //public DataResponse DeleteProfile(RegionProfileData profile) - public DataResponse DeleteProfile(string uuid) + override public DataResponse DeleteProfile(string uuid) { MySQLSuperManager dbm = GetLockedConnection(); -- cgit v1.1 From 1c08f46ec3397f4e4fd5897107c0df89bec70d84 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Thu, 18 Sep 2008 20:10:09 +0000 Subject: - Add Dispose method to IRegionDataStore - Add necessary dummy Dispose-methods where they are missing - Implement the SQLite Dispose-methods (currently only used for unit tests, in the next commit) --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 9c36d49..284c970 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -203,6 +203,8 @@ namespace OpenSim.Data.MySQL } } + public void Dispose() {} + /// /// Get the wait_timeout value for our connection /// -- cgit v1.1 From 908f1bcbe23a92ff4e8c51013ead449fc843924a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 23 Sep 2008 18:38:25 +0000 Subject: check in stubbing for mysql tests. This is ignored with Assert.Ignore() for now, so it won't change anything, but I want to make sure it doesn't break the bamboo infrastructure in it's current state. --- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs new file mode 100644 index 0000000..0e63835 --- /dev/null +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -0,0 +1,74 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Environment.Scenes; +using OpenMetaverse; +using log4net; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLInventoryTest : BasicInventoryTest + { + public string file; + public string connect; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + try + { + log4net.Config.XmlConfigurator.Configure(); + } + catch (Exception) + { + // I don't care, just leave log4net off + } + + Assert.Ignore(); + + file = Path.GetTempFileName() + ".db"; + connect = "URI=file:" + file + ",version=3"; + + } + + [TestFixtureTearDown] + public void Cleanup() + { + db.Dispose(); + } + } +} -- cgit v1.1 From 9a17d2b1fd325410549b9c5cfb45d952cd24c602 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 23 Sep 2008 19:11:06 +0000 Subject: remove log4net references, see if that helps fix bamboo --- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index 0e63835..c856b9a 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -49,14 +49,6 @@ namespace OpenSim.Data.MySQL.Tests public void Init() { SuperInit(); - try - { - log4net.Config.XmlConfigurator.Configure(); - } - catch (Exception) - { - // I don't care, just leave log4net off - } Assert.Ignore(); @@ -68,7 +60,7 @@ namespace OpenSim.Data.MySQL.Tests [TestFixtureTearDown] public void Cleanup() { - db.Dispose(); + } } } -- cgit v1.1 From a70efd1fdf6a8de57e8129a27fbc8ba94535b2ab Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 23 Sep 2008 21:03:03 +0000 Subject: create the first attempted mysql test. This only runs locally if you have a database configured as opensim-nunit with user opensim-nunit / password opensim-nunit that has full perms on the database. --- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 27 ++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index c856b9a..c299452 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -43,24 +43,35 @@ namespace OpenSim.Data.MySQL.Tests public class MySQLInventoryTest : BasicInventoryTest { public string file; - public string connect; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; [TestFixtureSetUp] public void Init() { SuperInit(); - - Assert.Ignore(); - - file = Path.GetTempFileName() + ".db"; - connect = "URI=file:" + file + ",version=3"; - + try + { + database = new MySQLManager(connect); + db = new MySQLInventoryData(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } } [TestFixtureTearDown] public void Cleanup() { - + if (database != null) + { + database.ExecuteSql("drop table migrations"); + database.ExecuteSql("drop table inventoryitems"); + database.ExecuteSql("drop table inventoryfolders"); + } } } } -- cgit v1.1 From 639267133562c5d71a988fd222c93275887bcb8f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 24 Sep 2008 20:43:32 +0000 Subject: let the asset tests run on MySQL. Interesting difference here, the sqlite driver can handle .Data = Null, the mysql driver can not. We should decide which is the right behavior and adjust code for it. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 83 ++++++++++++++++++++++++++ OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 8 +++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 5c58a4b..e270b9c 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -40,7 +40,7 @@ namespace OpenSim.Data.MySQL /// /// A MySQL Interface for the Asset Server /// - internal class MySQLAssetData : AssetDataBase + public class MySQLAssetData : AssetDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs new file mode 100644 index 0000000..0419e21 --- /dev/null +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -0,0 +1,83 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Environment.Scenes; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLAssetTest : BasicAssetTest + { + public string file; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. + try + { + database = new MySQLManager(connect); + db = new MySQLAssetData(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } + } + + [TestFixtureTearDown] + public void Cleanup() + { + if (db != null) + { + db.Dispose(); + } + if (database != null) + { + database.ExecuteSql("drop table migrations"); + database.ExecuteSql("drop table assets"); + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index c299452..5e6b7f9 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -50,6 +50,10 @@ namespace OpenSim.Data.MySQL.Tests public void Init() { SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. try { database = new MySQLManager(connect); @@ -66,6 +70,10 @@ namespace OpenSim.Data.MySQL.Tests [TestFixtureTearDown] public void Cleanup() { + if (db != null) + { + db.Dispose(); + } if (database != null) { database.ExecuteSql("drop table migrations"); -- cgit v1.1 From cffb975dd9ccef5eac703d58e52acb8d7a71f10e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 24 Sep 2008 21:03:11 +0000 Subject: light the mysql region tests --- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 97 +++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs new file mode 100644 index 0000000..aed4cea --- /dev/null +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -0,0 +1,97 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Environment.Scenes; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLRegionTest : BasicRegionTest + { + public string file; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. + try + { + database = new MySQLManager(connect); + db = new MySQLDataStore(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } + } + + [TestFixtureTearDown] + public void Cleanup() + { + if (db != null) + { + db.Dispose(); + } + // if a new table is added, it has to be dropped here + if (database != null) + { + database.ExecuteSql("drop table migrations"); + database.ExecuteSql("drop table prims"); + database.ExecuteSql("drop table primshapes"); + database.ExecuteSql("drop table primitems"); + database.ExecuteSql("drop table terrain"); + database.ExecuteSql("drop table land"); + database.ExecuteSql("drop table landaccesslist"); + database.ExecuteSql("drop table regionban"); + database.ExecuteSql("drop table regionsettings"); + database.ExecuteSql("drop table estate_managers"); + database.ExecuteSql("drop table estate_groups"); + database.ExecuteSql("drop table estate_users"); + database.ExecuteSql("drop table estateban"); + database.ExecuteSql("drop table estate_settings"); + database.ExecuteSql("drop table estate_map"); + } + } + } +} \ No newline at end of file -- cgit v1.1 From fe9aea258ff4142e718b4916ccefeeedef229768 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Wed, 24 Sep 2008 21:12:21 +0000 Subject: Add persistence of active gestures. This needs an UGAIM update to work. Active gestures are sent as part of the login-response. Added fetchActiveGestures to SQLite and MySQL; added an empty one for MSSQL and NHibernate. Using the empty ones won't cause errors, but doesn't provide persistence either, of course. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 50d3cc7..68885e1 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -795,5 +795,41 @@ namespace OpenSim.Data.MySQL deleteOneFolder(folderID); deleteItemsInFolder(folderID); } + + public List fetchActiveGestures(UUID avatarID) + { + MySqlDataReader result = null; + MySqlCommand sqlCmd = null; + lock (database) + { + try + { + database.CheckConnection(); + sqlCmd = new MySqlCommand( + "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", + database.Connection); + sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); + sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + result = sqlCmd.ExecuteReader(); + + List list = new List(); + while (result.Read()) + list.Add(readInventoryItem(result)); + + return list; + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + finally + { + if(result != null) result.Close(); + if(sqlCmd != null) sqlCmd.Dispose(); + } + } + } } } -- cgit v1.1 From dabb3117115d9bfa8cca19eef029511971f62d02 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 24 Sep 2008 21:16:47 +0000 Subject: remove configurable table names from the mysql user driver. That doesn't work in a world of migrations anyway, and is only cruft that will confuse people. --- OpenSim/Data/MySQL/MySQLUserData.cs | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 5f7db15..3226162 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -58,9 +58,9 @@ namespace OpenSim.Data.MySQL public int m_maxConnections = 10; public int m_lastConnect; - private string m_agentsTableName; - private string m_usersTableName; - private string m_userFriendsTableName; + private string m_agentsTableName = "agents"; + private string m_usersTableName = "users"; + private string m_userFriendsTableName = "userfriends"; private string m_appearanceTableName = "avatarappearance"; private string m_attachmentsTableName = "avatarattachments"; private string m_connectString; @@ -123,24 +123,6 @@ namespace OpenSim.Data.MySQL string settingPooling = iniFile.ParseFileReadValue("pooling"); string settingPort = iniFile.ParseFileReadValue("port"); - m_usersTableName = iniFile.ParseFileReadValue("userstablename"); - if (m_usersTableName == null) - { - m_usersTableName = "users"; - } - - m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); - if (m_userFriendsTableName == null) - { - m_userFriendsTableName = "userfriends"; - } - - m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); - if (m_agentsTableName == null) - { - m_agentsTableName = "agents"; - } - m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" + settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; @@ -159,9 +141,6 @@ namespace OpenSim.Data.MySQL else { m_connectString = connect; - m_agentsTableName = "agents"; - m_usersTableName = "users"; - m_userFriendsTableName = "userfriends"; database = new MySQLManager(m_connectString); m_log.Info("Creating " + m_maxConnections + " DB connections..."); -- cgit v1.1 From b4f204e5266acbc95c25389704127a7dd0bf3e0e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 24 Sep 2008 21:16:56 +0000 Subject: expose MySQLUserData class so that it can be tested --- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 3226162..8248463 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -41,7 +41,7 @@ namespace OpenSim.Data.MySQL /// /// A database interface class to a user profile storage system /// - internal class MySQLUserData : UserDataBase + class MySQLUserData : UserDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 2ef1b194fd9bad7650fcbd7c9f59630f9b13a539 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 24 Sep 2008 21:16:58 +0000 Subject: expose it for real, missed the public keyword --- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 8248463..c668d56 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -41,7 +41,7 @@ namespace OpenSim.Data.MySQL /// /// A database interface class to a user profile storage system /// - class MySQLUserData : UserDataBase + public class MySQLUserData : UserDataBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From c3f66be4054a177fd094a13ef54cbc1ebaa996d7 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 24 Sep 2008 21:17:00 +0000 Subject: light mysql user tests --- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 OpenSim/Data/MySQL/Tests/MySQLUserTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs new file mode 100644 index 0000000..c036f6c --- /dev/null +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Environment.Scenes; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLUserTest : BasicUserTest + { + public string file; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. + try + { + database = new MySQLManager(connect); + db = new MySQLUserData(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } + } + + [TestFixtureTearDown] + public void Cleanup() + { + if (db != null) + { + db.Dispose(); + } + // if a new table is added, it has to be dropped here + if (database != null) + { + database.ExecuteSql("drop table migrations"); + database.ExecuteSql("drop table users"); + database.ExecuteSql("drop table userfriends"); + database.ExecuteSql("drop table agents"); + database.ExecuteSql("drop table avatarappearance"); + database.ExecuteSql("drop table avatarattachments"); + } + } + } +} \ No newline at end of file -- cgit v1.1 From 7117f8b6803d1ef2bf9bbbdef2a8e4e3649c25e2 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 25 Sep 2008 00:20:57 +0000 Subject: removal of more dead alter table code --- OpenSim/Data/MySQL/MySQLRegionData.cs | 41 ++--------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 284c970..c94e6a3 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1711,25 +1711,7 @@ namespace OpenSim.Data.MySQL s.ExtraParams = (byte[]) row["ExtraParams"]; - try - { - s.State = Convert.ToByte(row["State"]); - } - catch (InvalidCastException) - { - // Database table was created before we got here and needs to be created! :P - lock (m_dataSet) - { - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } + s.State = Convert.ToByte(row["State"]); return s; } @@ -1772,26 +1754,7 @@ namespace OpenSim.Data.MySQL row["ProfileHollow"] = s.ProfileHollow; row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; - - try - { - row["State"] = s.State; - } - catch (MySqlException) - { - lock (m_dataSet) - { - // Database table was created before we got here and needs to be created! :P - using ( - MySqlCommand cmd = - new MySqlCommand( - "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", - m_connection)) - { - cmd.ExecuteNonQuery(); - } - } - } + row["State"] = s.State; } /// -- cgit v1.1 From 16b6738cdadc70966a93b6d025ae469738955dcb Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 26 Sep 2008 17:25:22 +0000 Subject: * Patch from JHurliman * Updates to libomv r2243, * Remove lots of unnecessary typecasts * Improves SendWindData() Thanks jhurliman. * Will update OpenSim-libs in 10 minutes.. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c94e6a3..e6a9686 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1329,10 +1329,10 @@ namespace OpenSim.Data.MySQL newData.Name = (String) row["Name"]; newData.Description = (String) row["Description"]; - newData.OwnerID = (String) row["OwnerUUID"]; + newData.OwnerID = (UUID)(String)row["OwnerUUID"]; newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); newData.Area = Convert.ToInt32(row["Area"]); - newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented + newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); @@ -1387,7 +1387,7 @@ namespace OpenSim.Data.MySQL { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = new UUID((string) row["AccessUUID"]); - entry.Flags = (ParcelManager.AccessList) Convert.ToInt32(row["Flags"]); + entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); entry.Time = new DateTime(); return entry; } -- cgit v1.1 From 0b4415849ace5ad7bf91a6d0c0374fc101f7136e Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 28 Sep 2008 03:21:11 +0000 Subject: Update svn properties. Minor formatting cleanup. Fix a compiler warning. Fix a UUID vs null comparison. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 68885e1..f9583cf 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -826,8 +826,8 @@ namespace OpenSim.Data.MySQL } finally { - if(result != null) result.Close(); - if(sqlCmd != null) sqlCmd.Dispose(); + if (result != null) result.Close(); + if (sqlCmd != null) sqlCmd.Dispose(); } } } -- cgit v1.1 From d0099271948e6c908a11da0158ca3471d2afb568 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 1 Oct 2008 15:41:36 +0000 Subject: add delete prim tests. Found and fixed bugs where region is not respected by sqlite or mysql drivers so that deleting and object in a region actually deletes that object from any region. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e6a9686..0e8ca68 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -333,7 +333,7 @@ namespace OpenSim.Data.MySQL DataTable prims = m_primTable; DataTable shapes = m_shapeTable; - string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'"; + string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "' and RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; lock (m_dataSet) { DataRow[] primRows = prims.Select(selectExp); @@ -347,7 +347,7 @@ namespace OpenSim.Data.MySQL shapeRow.Delete(); } - RemoveItems(uuid); + RemoveItems(uuid); // Remove prim row row.Delete(); -- cgit v1.1 From ec47a1bff2f8bf18be308a059ca8aaa193c9f540 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 3 Oct 2008 12:11:38 +0000 Subject: Add database persistence for material setting --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 +++++ OpenSim/Data/MySQL/Resources/019_RegionStore.sql | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/019_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 0e8ca68..521490c 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -944,6 +944,7 @@ namespace OpenSim.Data.MySQL createCol(prims, "SaleType", typeof (Int16)); createCol(prims, "ClickAction", typeof (Byte)); + createCol(prims, "Material", typeof (Byte)); // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -1228,6 +1229,8 @@ namespace OpenSim.Data.MySQL prim.SalePrice = Convert.ToInt32(row["SalePrice"]); prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); + prim.Material = Convert.ToByte(row["Material"]); + if (!row.IsNull("ClickAction")) prim.ClickAction = Convert.ToByte(row["ClickAction"]); @@ -1540,6 +1543,8 @@ namespace OpenSim.Data.MySQL byte clickAction = prim.ClickAction; row["ClickAction"] = clickAction; + + row["Material"] = prim.Material; } /// diff --git a/OpenSim/Data/MySQL/Resources/019_RegionStore.sql b/OpenSim/Data/MySQL/Resources/019_RegionStore.sql new file mode 100644 index 0000000..4c14f2a --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/019_RegionStore.sql @@ -0,0 +1,6 @@ +begin; + +ALTER TABLE prims ADD COLUMN Material tinyint NOT NULL default 3; + +commit; + -- cgit v1.1 From 16d68749a457acf079a6737f4ca9a9adb9e53e2f Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Fri, 3 Oct 2008 23:00:42 +0000 Subject: Add the missing bits for the new region-search: - Added lookup in the data-layer - MySQL works - SQLite doesn't have a grid-db, so it won't work there - I added MSSQL-code to the best of my knowledge; but I don't know MSSQL :-) - Added the plumbing up to OGS1GridServices. This speaks with the grid-server via XMLRPC. - Modified MapSearchModule to use the new data. It's backward compatible; if used with an old grid-server, it just returns one found region instead of a list. - Refactored a bit. Note: This updates data, grid-server and region code. No new files. --- OpenSim/Data/MySQL/MySQLGridData.cs | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 1155ae3..26a8591 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -283,6 +283,52 @@ namespace OpenSim.Data.MySQL } /// + /// Returns up to maxNum profiles of regions that have a name starting with namePrefix + /// + /// The name to match against + /// Maximum number of profiles to return + /// A list of sim profiles + override public List GetRegionsByName(string namePrefix, uint maxNum) + { + MySQLSuperManager dbm = GetLockedConnection(); + + try + { + Dictionary param = new Dictionary(); + param["?name"] = namePrefix + "%"; + + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName LIKE ?name", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row; + + List rows = new List(); + + while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); + } + reader.Close(); + result.Dispose(); + + return rows; + } + catch (Exception e) + { + dbm.Manager.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + finally + { + dbm.Release(); + } + } + + /// /// Returns a sim profile from it's location /// /// Region location handle -- cgit v1.1 From fa8c0d7683d567743f5138813f08a502aff8e3d0 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 15 Oct 2008 18:15:43 +0000 Subject: - Makes MySQL reject inserting UUID 0 - Makes SQLite mimick MySQL default behavior on first and last name already on db: it does not insert the new record. - Added tests for UUID 0 and for new UUID with existing first and last name. --- OpenSim/Data/MySQL/MySQLUserData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index c668d56..3a088cf 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -582,6 +582,11 @@ namespace OpenSim.Data.MySQL /// The user profile to create public override void AddNewUserProfile(UserProfileData user) { + UUID zero = UUID.Zero; + if (user.ID == zero) + { + return; + } MySQLSuperManager dbm = GetLockedConnection(); try -- cgit v1.1 From fac4d02d7e9437b8f6eb6208823a491443b1be1c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 15 Oct 2008 19:54:07 +0000 Subject: * minor: comment out persisting prim inventory log messages --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 521490c..ae048fe 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1808,7 +1808,7 @@ namespace OpenSim.Data.MySQL /// public void StorePrimInventory(UUID primID, ICollection items) { - m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); + //m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); // For now, we're just going to crudely remove all the previous inventory items // no matter whether they have changed or not, and replace them with the current set. -- cgit v1.1 From 72725a08940cb087e54ddb847224c0039e5d617b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 16 Oct 2008 15:57:59 +0000 Subject: - Enforced no user or agent with UUID 0 on agent DB insertion --- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 3a088cf..ecd534a 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -617,6 +617,10 @@ namespace OpenSim.Data.MySQL /// The agent to create public override void AddNewUserAgent(UserAgentData agent) { + UUID zero = UUID.Zero; + if (agent.ProfileID == zero || agent.SessionID == zero) + return; + MySQLSuperManager dbm = GetLockedConnection(); try { -- cgit v1.1 From efe3f3eb2a0a31b1da474974c7d8193c2b28e13f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 18 Oct 2008 05:51:36 +0000 Subject: Megapatch. :) Fix skull attachment editing. Streamline Object terse updates. Add rezzing time to objects. Add Object return and traffic fields to land database. Add plumbing for auto return. Implement auto return. Contains a migration. May contain nuts. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 6 ++++++ OpenSim/Data/MySQL/Resources/020_RegionStore.sql | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/020_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ae048fe..ab7e92d 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -994,6 +994,8 @@ namespace OpenSim.Data.MySQL createCol(land, "UserLookAtY", typeof (Double)); createCol(land, "UserLookAtZ", typeof (Double)); createCol(land, "AuthBuyerID", typeof (String)); + createCol(land, "OtherCleanTime", typeof(Int32)); + createCol(land, "Dwell", typeof(Int32)); land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; @@ -1357,6 +1359,8 @@ namespace OpenSim.Data.MySQL UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); + newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); + newData.Dwell = Convert.ToInt32(row["Dwell"]); newData.AuthBuyerID = authedbuyer; newData.SnapshotID = snapshotID; @@ -1661,6 +1665,8 @@ namespace OpenSim.Data.MySQL row["UserLookAtY"] = land.UserLookAt.Y; row["UserLookAtZ"] = land.UserLookAt.Z; row["AuthBuyerID"] = land.AuthBuyerID; + row["OtherCleanTime"] = land.OtherCleanTime; + row["Dwell"] = land.Dwell; } /// diff --git a/OpenSim/Data/MySQL/Resources/020_RegionStore.sql b/OpenSim/Data/MySQL/Resources/020_RegionStore.sql new file mode 100644 index 0000000..814ef48 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/020_RegionStore.sql @@ -0,0 +1,7 @@ +begin; + +ALTER TABLE land ADD COLUMN OtherCleanTime integer NOT NULL default 0; +ALTER TABLE land ADD COLUMN Dwell integer NOT NULL default 0; + +commit; + -- cgit v1.1 From 409e7262df255649de687eec828d9ef476edc03b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 30 Oct 2008 12:56:04 +0000 Subject: Mid-work, trying to fix region part insertion and retrieval SQLite reports System NUll Reference, but works, inside LoadItems, on SQLiteRegionData.cs From: Arthur Rodrigo S Valadares --- OpenSim/Data/MySQL/MySQLRegionData.cs | 36 ++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ab7e92d..fb08049 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -395,7 +395,8 @@ namespace OpenSim.Data.MySQL DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); m_log.Info("[REGION DB]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); - + + // First, create all groups foreach (DataRow primRow in primsForRegion) { try @@ -422,11 +423,33 @@ namespace OpenSim.Data.MySQL } group.AddPart(prim); group.RootPart = prim; - createdObjects.Add(group.UUID, group); retvals.Add(group); } - else + LoadItems(prim); + } + catch (Exception e) + { + m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); + m_log.Info("[REGION DB]: " + e.ToString()); + foreach (DataColumn col in prims.Columns) + { + m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); + } + } + } + + // Now fill the groups with part data + foreach (DataRow primRow in primsForRegion) + { + try + { + string uuid = (string) primRow["UUID"]; + string objID = (string) primRow["SceneGroupID"]; + + SceneObjectPart prim = buildPrim(primRow); + + if (uuid != objID) //is new SceneObjectGroup ? { DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); if (shapeRow != null) @@ -441,9 +464,8 @@ namespace OpenSim.Data.MySQL } createdObjects[new UUID(objID)].AddPart(prim); } - - LoadItems(prim); - } + LoadItems(prim); + } catch (Exception e) { m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); @@ -473,7 +495,7 @@ namespace OpenSim.Data.MySQL String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); DataRow[] dbItemRows = dbItems.Select(sql); - + Console.WriteLine("dbItemRows MYSQL Length: {0}",dbItemRows.Length); IList inventory = new List(); foreach (DataRow row in dbItemRows) -- cgit v1.1 From 9e353d5713e116e0ea1243df7db085bfba08d6e9 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 30 Oct 2008 12:56:10 +0000 Subject: - Includes consistency test for new and updated objects, as some fixes in MySQL and SQLite From: Arthur Rodrigo S Valadares --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index fb08049..ac8165c 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -425,8 +425,8 @@ namespace OpenSim.Data.MySQL group.RootPart = prim; createdObjects.Add(group.UUID, group); retvals.Add(group); + LoadItems(prim); } - LoadItems(prim); } catch (Exception e) { @@ -463,8 +463,8 @@ namespace OpenSim.Data.MySQL prim.Shape = PrimitiveBaseShape.Default; } createdObjects[new UUID(objID)].AddPart(prim); + LoadItems(prim); } - LoadItems(prim); } catch (Exception e) { @@ -495,7 +495,6 @@ namespace OpenSim.Data.MySQL String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); DataRow[] dbItemRows = dbItems.Select(sql); - Console.WriteLine("dbItemRows MYSQL Length: {0}",dbItemRows.Length); IList inventory = new List(); foreach (DataRow row in dbItemRows) -- cgit v1.1 From 129610e797548f7b384f772408d2069ae58e00ce Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 31 Oct 2008 04:58:14 +0000 Subject: * Added some debug information to MySQL UserDataManager to help diagnose a potential issue when in high load. Related to mantis #2508. --- OpenSim/Data/MySQL/MySQLSuperManager.cs | 1 + OpenSim/Data/MySQL/MySQLUserData.cs | 42 +++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs index b2485b1..f4341d4 100644 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ b/OpenSim/Data/MySQL/MySQLSuperManager.cs @@ -7,6 +7,7 @@ namespace OpenSim.Data.MySQL public bool Locked; private readonly Mutex m_lock = new Mutex(false); public MySQLManager Manager; + public string Running; public void GetLock() { diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index ecd534a..2937ea8 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -71,7 +71,7 @@ namespace OpenSim.Data.MySQL throw new PluginNotInitialisedException(Name); } - public MySQLSuperManager GetLockedConnection() + public MySQLSuperManager GetLockedConnection(string why) { int lockedCons = 0; while (true) @@ -86,6 +86,7 @@ namespace OpenSim.Data.MySQL if (!x.Locked) { x.GetLock(); + x.Running = why; return x; } @@ -96,6 +97,11 @@ namespace OpenSim.Data.MySQL System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. m_log.Debug( "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); + m_log.Debug("Current connections-in-use dump:"); + foreach (KeyValuePair kvp in m_dbconnections) + { + m_log.Debug(kvp.Value.Running); + } } } } @@ -167,7 +173,7 @@ namespace OpenSim.Data.MySQL // see IUserDataPlugin public override UserProfileData GetUserByName(string user, string last) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GetUserByName"); try { @@ -202,7 +208,7 @@ namespace OpenSim.Data.MySQL public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("AddNewUserFriend"); int dtvalue = Util.UnixTimeSinceEpoch(); @@ -246,7 +252,7 @@ namespace OpenSim.Data.MySQL public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("RemoveUserFriend"); Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); @@ -280,7 +286,7 @@ namespace OpenSim.Data.MySQL public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("UpdateUserFriendPerms"); Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); @@ -311,7 +317,7 @@ namespace OpenSim.Data.MySQL public override List GetUserFriendList(UUID friendlistowner) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); List Lfli = new List(); Dictionary param = new Dictionary(); @@ -367,7 +373,7 @@ namespace OpenSim.Data.MySQL public override List GeneratePickerResults(UUID queryID, string query) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); List returnlist = new List(); @@ -457,7 +463,7 @@ namespace OpenSim.Data.MySQL /// User profile data public override UserProfileData GetUserByUUID(UUID uuid) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID"); try { Dictionary param = new Dictionary(); @@ -514,7 +520,7 @@ namespace OpenSim.Data.MySQL /// is it still used ? public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("StoreWebLoginKey"); Dictionary param = new Dictionary(); param["?UUID"] = AgentID.ToString(); @@ -546,7 +552,7 @@ namespace OpenSim.Data.MySQL /// The users session public override UserAgentData GetAgentByUUID(UUID uuid) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GetAgentByUUID"); try { @@ -587,7 +593,7 @@ namespace OpenSim.Data.MySQL { return; } - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("AddNewUserProfile"); try { @@ -621,7 +627,7 @@ namespace OpenSim.Data.MySQL if (agent.ProfileID == zero || agent.SessionID == zero) return; - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("AddNewUserAgent"); try { dbm.Manager.insertAgentRow(agent); @@ -643,7 +649,7 @@ namespace OpenSim.Data.MySQL /// The profile data to use to update the DB public override bool UpdateUserProfile(UserProfileData user) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); try { dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, @@ -695,7 +701,7 @@ namespace OpenSim.Data.MySQL /// public override AvatarAppearance GetUserAppearance(UUID user) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance"); try { Dictionary param = new Dictionary(); @@ -740,7 +746,7 @@ namespace OpenSim.Data.MySQL // override public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("UpdateUserAppearance"); try { appearance.Owner = user; @@ -779,7 +785,7 @@ namespace OpenSim.Data.MySQL public Hashtable GetUserAttachments(UUID agentID) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); Dictionary param = new Dictionary(); param["?uuid"] = agentID.ToString(); @@ -810,7 +816,7 @@ namespace OpenSim.Data.MySQL public void UpdateUserAttachments(UUID agentID, Hashtable data) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("UpdateUserAttachments"); try { dbm.Manager.writeAttachments(agentID, data); @@ -823,7 +829,7 @@ namespace OpenSim.Data.MySQL public override void ResetAttachments(UUID userID) { - MySQLSuperManager dbm = GetLockedConnection(); + MySQLSuperManager dbm = GetLockedConnection("ResetAttachments"); Dictionary param = new Dictionary(); param["?uuid"] = userID.ToString(); -- cgit v1.1 From 4fb2d7037358c320540edc3b2f5660e3cb3531a6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 1 Nov 2008 15:10:45 +0000 Subject: A stab a getting the user server to act right. Move acquisition of the locks to just before the try/catch/finally block, so that an exception thrown between taking the lock and entering the try doesn't leave a mutex locked --- OpenSim/Data/MySQL/MySQLGridData.cs | 6 +++--- OpenSim/Data/MySQL/MySQLUserData.cs | 33 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 26a8591..b6d481c 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -403,10 +403,10 @@ namespace OpenSim.Data.MySQL /// The sim profile override public RegionProfileData GetProfileByString(string regionName) { - MySQLSuperManager dbm = GetLockedConnection(); - if (regionName.Length > 2) { + MySQLSuperManager dbm = GetLockedConnection(); + try { Dictionary param = new Dictionary(); @@ -436,8 +436,8 @@ namespace OpenSim.Data.MySQL dbm.Release(); } + dbm.Release(); } - dbm.Release(); m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 2937ea8..e671989 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -208,8 +208,6 @@ namespace OpenSim.Data.MySQL public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { - MySQLSuperManager dbm = GetLockedConnection("AddNewUserFriend"); - int dtvalue = Util.UnixTimeSinceEpoch(); Dictionary param = new Dictionary(); @@ -218,6 +216,8 @@ namespace OpenSim.Data.MySQL param["?friendPerms"] = perms.ToString(); param["?datetimestamp"] = dtvalue.ToString(); + MySQLSuperManager dbm = GetLockedConnection("AddNewUserFriend"); + try { IDbCommand adder = @@ -252,12 +252,12 @@ namespace OpenSim.Data.MySQL public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { - MySQLSuperManager dbm = GetLockedConnection("RemoveUserFriend"); - Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); + MySQLSuperManager dbm = GetLockedConnection("RemoveUserFriend"); + try { IDbCommand updater = @@ -286,13 +286,13 @@ namespace OpenSim.Data.MySQL public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { - MySQLSuperManager dbm = GetLockedConnection("UpdateUserFriendPerms"); - Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); + MySQLSuperManager dbm = GetLockedConnection("UpdateUserFriendPerms"); + try { IDbCommand updater = @@ -317,12 +317,13 @@ namespace OpenSim.Data.MySQL public override List GetUserFriendList(UUID friendlistowner) { - MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); List Lfli = new List(); Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); + MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); + try { //Left Join userfriends to itself @@ -373,8 +374,6 @@ namespace OpenSim.Data.MySQL public override List GeneratePickerResults(UUID queryID, string query) { - MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); - List returnlist = new List(); Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); @@ -386,6 +385,8 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; + MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); + try { IDbCommand result = @@ -419,6 +420,8 @@ namespace OpenSim.Data.MySQL } else if (querysplit.Length == 1) { + MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); + try { Dictionary param = new Dictionary(); @@ -520,12 +523,12 @@ namespace OpenSim.Data.MySQL /// is it still used ? public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) { - MySQLSuperManager dbm = GetLockedConnection("StoreWebLoginKey"); - Dictionary param = new Dictionary(); param["?UUID"] = AgentID.ToString(); param["?webLoginKey"] = WebLoginKey.ToString(); + MySQLSuperManager dbm = GetLockedConnection("StoreWebLoginKey"); + try { dbm.Manager.ExecuteParameterizedSql( @@ -785,11 +788,11 @@ namespace OpenSim.Data.MySQL public Hashtable GetUserAttachments(UUID agentID) { - MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); - Dictionary param = new Dictionary(); param["?uuid"] = agentID.ToString(); + MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); + try { IDbCommand result = dbm.Manager.Query( @@ -829,11 +832,11 @@ namespace OpenSim.Data.MySQL public override void ResetAttachments(UUID userID) { - MySQLSuperManager dbm = GetLockedConnection("ResetAttachments"); - Dictionary param = new Dictionary(); param["?uuid"] = userID.ToString(); + MySQLSuperManager dbm = GetLockedConnection("ResetAttachments"); + try { dbm.Manager.ExecuteParameterizedSql( -- cgit v1.1 From 44e377d1fbde657a86be5f9d55a79aff97db9e1f Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 1 Nov 2008 21:55:48 +0000 Subject: Fix a compile warning about unreachable code --- OpenSim/Data/MySQL/MySQLGridData.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index b6d481c..da01ad3 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -434,9 +434,7 @@ namespace OpenSim.Data.MySQL finally { dbm.Release(); - } - dbm.Release(); } m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; -- cgit v1.1 From 38e8853e5761d09a7e8f580dd277d9b99b834696 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 1 Nov 2008 22:09:48 +0000 Subject: Megapatch that fixes/adds: friend offer/deny/accept, friendship termination, on-/offline updates, calling cards for friends. This adds methods in the DB layer and changes the MessagingServer, so a full update (incl. UGAIM) is necessary to get it working. Older regions shouldn't break, nor should older UGAIM break newer regions, but friends/presence will only work with all concerned parts (UGAIM, source region and destination region) at this revision (or later). I added the DB code for MSSQL, too, but couldn't test that. BEWARE: May contain bugs. --- OpenSim/Data/MySQL/MySQLUserData.cs | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index e671989..c3aade0 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -365,6 +365,49 @@ namespace OpenSim.Data.MySQL return Lfli; } + override public Dictionary GetFriendRegionInfos (List uuids) + { + MySQLSuperManager dbm = GetLockedConnection("GetFriendRegionInfos"); + Dictionary infos = new Dictionary(); + + try + { + foreach (UUID uuid in uuids) + { + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); + IDbCommand result = + dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + + " where UUID = ?uuid", param); + + IDataReader reader = result.ExecuteReader(); + while (reader.Read()) + { + FriendRegionInfo fri = new FriendRegionInfo(); + fri.isOnline = (sbyte)reader["agentOnline"] != 0; + fri.regionHandle = (ulong)reader["currentHandle"]; + + infos[uuid] = fri; + } + + reader.Dispose(); + result.Dispose(); + } + } + catch (Exception e) + { + m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); + dbm.Manager.Reconnect(); + m_log.Error(e.ToString()); + } + finally + { + dbm.Release(); + } + + return infos; + } + #endregion public override void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle) -- cgit v1.1 From 84136c70d8a8e3278d1ff3949971e993f6c3f1fb Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 1 Nov 2008 22:20:54 +0000 Subject: * Minor cleanup * Added additional error message when a Object/SOG DB save fails so we can trace why. --- OpenSim/Data/MySQL/MySQLUserData.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index c3aade0..6baf4b6 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -34,7 +34,6 @@ using System.Text.RegularExpressions; using OpenMetaverse; using log4net; using OpenSim.Framework; -using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL { -- cgit v1.1 From 702249358badda5413e67ee0267063c2e2a61498 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 4 Nov 2008 14:54:42 +0000 Subject: implement email field for MySQL and SQLite From: Sean Dague --- OpenSim/Data/MySQL/MySQLManager.cs | 29 ++++++++++++++------------ OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- OpenSim/Data/MySQL/Resources/007_UserStore.sql | 5 +++++ 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/007_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 5f830bb..7096efa 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -540,6 +540,7 @@ namespace OpenSim.Data.MySQL retval.ID = id; retval.FirstName = (string) reader["username"]; retval.SurName = (string) reader["lastname"]; + retval.Email = (string) reader["email"]; retval.PasswordHash = (string) reader["passwordHash"]; retval.PasswordSalt = (string) reader["passwordSalt"]; @@ -768,7 +769,7 @@ namespace OpenSim.Data.MySQL /// UUID for firstlife image /// Ignored /// Success? - public bool insertUserRow(UUID uuid, string username, string lastname, string passwordHash, + public bool insertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, @@ -777,14 +778,14 @@ namespace OpenSim.Data.MySQL { m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); string sql = - "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; + "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, "; sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES "; - sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; + sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, "; sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; sql += @@ -793,10 +794,11 @@ namespace OpenSim.Data.MySQL Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); - parameters["?username"] = username.ToString(); - parameters["?lastname"] = lastname.ToString(); - parameters["?passwordHash"] = passwordHash.ToString(); - parameters["?passwordSalt"] = passwordSalt.ToString(); + parameters["?username"] = username; + parameters["?lastname"] = lastname; + parameters["?email"] = email; + parameters["?passwordHash"] = passwordHash; + parameters["?passwordSalt"] = passwordSalt; parameters["?homeRegion"] = homeRegion.ToString(); parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationY"] = homeLocY.ToString(); @@ -869,14 +871,14 @@ namespace OpenSim.Data.MySQL /// UUID for firstlife image /// UUID for weblogin Key /// Success? - public bool updateUserRow(UUID uuid, string username, string lastname, string passwordHash, + public bool updateUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) { - string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; + string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname, `email` = ?email "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , "; sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; @@ -892,10 +894,11 @@ namespace OpenSim.Data.MySQL Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); - parameters["?username"] = username.ToString(); - parameters["?lastname"] = lastname.ToString(); - parameters["?passwordHash"] = passwordHash.ToString(); - parameters["?passwordSalt"] = passwordSalt.ToString(); + parameters["?username"] = username; + parameters["?lastname"] = lastname; + parameters["?email"] = email; + parameters["?passwordHash"] = passwordHash; + parameters["?passwordSalt"] = passwordSalt; parameters["?homeRegion"] = homeRegion.ToString(); parameters["?homeRegionID"] = homeRegionID.ToString(); parameters["?homeLocationX"] = homeLocX.ToString(); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 6baf4b6..47670d2 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -642,7 +642,7 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, @@ -697,7 +697,7 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); try { - dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, + dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, diff --git a/OpenSim/Data/MySQL/Resources/007_UserStore.sql b/OpenSim/Data/MySQL/Resources/007_UserStore.sql new file mode 100644 index 0000000..3ab5261 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE users add email varchar(250); + +COMMIT; -- cgit v1.1 From 7d6dc3b0999d5d4dbe0ec560db43a1de047408b7 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 4 Nov 2008 19:26:17 +0000 Subject: add some null protection on email From: Sean Dague --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 7096efa..c584eb9 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -540,7 +540,7 @@ namespace OpenSim.Data.MySQL retval.ID = id; retval.FirstName = (string) reader["username"]; retval.SurName = (string) reader["lastname"]; - retval.Email = (string) reader["email"]; + retval.Email = (reader.IsDBNull(reader.GetOrdinal("email"))) ? "" : (string) reader["email"]; retval.PasswordHash = (string) reader["passwordHash"]; retval.PasswordSalt = (string) reader["passwordSalt"]; -- cgit v1.1 From 46492f3c1182d68139f914bfe89c81ca8dae1733 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 6 Nov 2008 17:07:08 +0000 Subject: From: arthursv@linux.vnet.ibm.com Add more unit tests for user cases Persist more user fields into mysql that already had columns defined but weren't getting passed to the mysql manager. --- OpenSim/Data/MySQL/MySQLManager.cs | 38 ++++++++++++++++++------------------- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index c584eb9..a54c020 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -561,7 +561,7 @@ namespace OpenSim.Data.MySQL retval.Created = Convert.ToInt32(reader["created"].ToString()); retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); - + retval.UserInventoryURI = (string) reader["userInventoryURI"]; retval.UserAssetURI = (string) reader["userAssetURI"]; @@ -751,6 +751,7 @@ namespace OpenSim.Data.MySQL /// A salted hash of the users password /// The salt used for the password hash /// A regionHandle of the users home region + /// The UUID of the user's home region /// Home region position vector /// Home region position vector /// Home region position vector @@ -770,22 +771,22 @@ namespace OpenSim.Data.MySQL /// Ignored /// Success? public bool insertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, - string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - UUID profileImage, UUID firstImage, UUID webLoginKey) + UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) { m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); string sql = - "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, "; + "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, "; sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES "; - sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, "; + sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, ?homeRegionID, "; sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; sql += @@ -800,6 +801,7 @@ namespace OpenSim.Data.MySQL parameters["?passwordHash"] = passwordHash; parameters["?passwordSalt"] = passwordSalt; parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegionID"] = homeRegionID.ToString(); parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationY"] = homeLocY.ToString(); parameters["?homeLocationZ"] = homeLocZ.ToString(); @@ -808,23 +810,21 @@ namespace OpenSim.Data.MySQL parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); parameters["?created"] = created.ToString(); parameters["?lastLogin"] = lastlogin.ToString(); - parameters["?userInventoryURI"] = String.Empty; - parameters["?userAssetURI"] = String.Empty; - parameters["?profileCanDoMask"] = "0"; - parameters["?profileWantDoMask"] = "0"; + parameters["?userInventoryURI"] = inventoryURI; + parameters["?userAssetURI"] = assetURI; + parameters["?profileCanDoMask"] = canDoMask.ToString(); + parameters["?profileWantDoMask"] = wantDoMask.ToString(); parameters["?profileAboutText"] = aboutText; parameters["?profileFirstText"] = firstText; parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); - parameters["?webLoginKey"] = string.Empty; - parameters["?userFlags"] = "0"; - parameters["?godLevel"] = "0"; - parameters["?customType"] = ""; - parameters["?partner"] = ""; - - + parameters["?webLoginKey"] = webLoginKey.ToString(); + parameters["?userFlags"] = userFlags.ToString(); + parameters["?godLevel"] = godLevel.ToString(); + parameters["?customType"] = customType == null ? "" : customType; + parameters["?partner"] = partner.ToString(); bool returnval = false; - + try { IDbCommand result = Query(sql, parameters); @@ -911,8 +911,8 @@ namespace OpenSim.Data.MySQL parameters["?lastLogin"] = lastlogin.ToString(); parameters["?userInventoryURI"] = inventoryURI; parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = "0"; - parameters["?profileWantDoMask"] = "0"; + parameters["?profileCanDoMask"] = canDoMask.ToString(); + parameters["?profileWantDoMask"] = wantDoMask.ToString(); parameters["?profileAboutText"] = aboutText; parameters["?profileFirstText"] = firstText; parameters["?profileImage"] = profileImage.ToString(); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 47670d2..82b5bbc 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -643,13 +643,13 @@ namespace OpenSim.Data.MySQL try { dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey); + user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } catch (Exception e) { -- cgit v1.1 From 629b0d9f28d2027b4d0aecc10bc78f7aefb5d7f3 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 6 Nov 2008 21:21:46 +0000 Subject: add create_time and access_time to asset db for mysql, as well as the code to update these at the appropriate time. This isn't surfaced in AssetBase yet. Change the replace into to an insert into for asset create. Assets are not supposed to be updatable, and the replace into is more expensive. From: Sean Dague --- OpenSim/Data/MySQL/MySQLAssetData.cs | 48 +++++++++++++++++++++++-- OpenSim/Data/MySQL/Resources/005_AssetStore.sql | 6 ++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/005_AssetStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index e270b9c..4b51bda 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -45,6 +45,7 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private MySQLManager _dbConnection; + private long TicksToEpoch; #region IPlugin Members @@ -61,6 +62,8 @@ namespace OpenSim.Data.MySQL /// connect string override public void Initialise(string connect) { + TicksToEpoch = new System.DateTime(1970,1,1).Ticks; + // TODO: This will let you pass in the connect string in // the config, though someone will need to write that. if (connect == String.Empty) @@ -146,6 +149,8 @@ namespace OpenSim.Data.MySQL dbReader.Close(); cmd.Dispose(); } + if (asset != null) + UpdateAccessTime(asset); } catch (Exception e) { @@ -178,8 +183,8 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand( - "REPLACE INTO assets(id, name, description, assetType, local, temporary, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?data)", + "insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", _dbConnection.Connection); // need to ensure we dispose @@ -187,12 +192,16 @@ namespace OpenSim.Data.MySQL { using (cmd) { + // create unix epoch time + int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); cmd.Parameters.AddWithValue("?id", asset.FullID.ToString()); cmd.Parameters.AddWithValue("?name", asset.Name); cmd.Parameters.AddWithValue("?description", asset.Description); cmd.Parameters.AddWithValue("?assetType", asset.Type); cmd.Parameters.AddWithValue("?local", asset.Local); cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?create_time", now); + cmd.Parameters.AddWithValue("?access_time", now); cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); cmd.Dispose(); @@ -209,6 +218,41 @@ namespace OpenSim.Data.MySQL } } + private void UpdateAccessTime(AssetBase asset) + { + lock (_dbConnection) + { + _dbConnection.CheckConnection(); + + MySqlCommand cmd = + new MySqlCommand("update assets set access_time=?access_time where id=?id", + _dbConnection.Connection); + + // need to ensure we dispose + try + { + using (cmd) + { + // create unix epoch time + int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); + cmd.Parameters.AddWithValue("?id", asset.FullID.ToString()); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: " + + "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + _dbConnection.Reconnect(); + } + } + + } + /// /// Update a asset in database, see /// diff --git a/OpenSim/Data/MySQL/Resources/005_AssetStore.sql b/OpenSim/Data/MySQL/Resources/005_AssetStore.sql new file mode 100644 index 0000000..bfeb652 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_AssetStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE assets add create_time integer default 0; +ALTER TABLE assets add access_time integer default 0; + +COMMIT; -- cgit v1.1 From bbb8d6fc51020a8734163313bfc0b8aac9e402c2 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 8 Nov 2008 14:28:43 +0000 Subject: Remove empty OSUUID.cs file. Add copyright headers. Minor formatting cleanup. --- OpenSim/Data/MySQL/MySQLSuperManager.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs index f4341d4..c579432 100644 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ b/OpenSim/Data/MySQL/MySQLSuperManager.cs @@ -1,4 +1,31 @@ -using System.Threading; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Threading; namespace OpenSim.Data.MySQL { -- cgit v1.1 From 344b725d3bcf84ab2e18103e84bd85a43536d80a Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 8 Nov 2008 20:04:28 +0000 Subject: Mantis#2598: Thanks Fly-Man- for a patch that fixes a client-thread crash by allowing landFlags bit 31 to be used (Int32 -> UInt32). --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ac8165c..27bfec8 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -999,7 +999,7 @@ namespace OpenSim.Data.MySQL createCol(land, "GroupUUID", typeof (String)); createCol(land, "SalePrice", typeof (Int32)); createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof (Int32)); + createCol(land, "LandFlags", typeof (UInt32)); createCol(land, "LandingType", typeof (Int32)); createCol(land, "MediaAutoScale", typeof (Int32)); createCol(land, "MediaTextureUUID", typeof (String)); -- cgit v1.1 From 0e180b0ad30d5f468be1c239865688449b8747cc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 10 Nov 2008 20:04:55 +0000 Subject: * refactor: Expose SOG.SetRootPart for outsiders to use rather than setting RootPart and adding the part separately * Make RootPart read only --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 27bfec8..70940db 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -421,8 +421,8 @@ namespace OpenSim.Data.MySQL "No shape found for prim in storage, so setting default box shape"); prim.Shape = PrimitiveBaseShape.Default; } - group.AddPart(prim); - group.RootPart = prim; + + group.SetRootPart(prim); createdObjects.Add(group.UUID, group); retvals.Add(group); LoadItems(prim); -- cgit v1.1 From c18ce34d066fc409f1982caed94217b83c152f58 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 13 Nov 2008 03:24:23 +0000 Subject: Update avatar picker search to work with OpenSearch people search --- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 82b5bbc..288ca86 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -422,7 +422,7 @@ namespace OpenSim.Data.MySQL string[] querysplit; querysplit = query.Split(' '); - if (querysplit.Length == 2) + if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty) { Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; @@ -460,7 +460,7 @@ namespace OpenSim.Data.MySQL dbm.Release(); } } - else if (querysplit.Length == 1) + else { MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); -- cgit v1.1 From cc5ccfb3151544212a51b18ee224951b9c4ad927 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 13 Nov 2008 22:53:49 +0000 Subject: make inventory item listing more robust. It turns out that a bad item (one that won't parse right) will prevent all other items in that folder to load when inventory is requested. This is very careful to no longer add inventory items that return as null to the hash table for getInventoryInFolder, as well as be more careful parsing UUIDs for fields that aren't marked not null in MySQL. The net result, you may see previously missing inventory items return after this checkin. Folders probably need to be hardened in the same way, but I'm out of time for today. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 36 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index f9583cf..755dbab 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -141,8 +141,13 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?uuid", folderID.ToString()); MySqlDataReader reader = result.ExecuteReader(); - while (reader.Read()) - items.Add(readInventoryItem(reader)); + while (reader.Read()) + { + // A null item (because something went wrong) breaks everything in the folder + InventoryItemBase item = readInventoryItem(reader); + if (item != null) + items.Add(item); + } reader.Close(); result.Dispose(); @@ -301,24 +306,36 @@ namespace OpenSim.Data.MySQL try { InventoryItemBase item = new InventoryItemBase(); - + // Be a bit safer in parsing these because the + // database doesn't enforce them to be not null, and + // the inventory still works if these are weird in the + // db + + UUID Owner = UUID.Zero; + UUID Creator = UUID.Zero; + UUID GroupID = UUID.Zero; + UUID.TryParse((string)reader["avatarID"], out Owner); + UUID.TryParse((string)reader["creatorID"], out Creator); + UUID.TryParse((string)reader["groupID"], out GroupID); + item.Owner = Owner; + item.Creator = Creator; + item.GroupID = GroupID; + + // Rest of the parsing. If these UUID's fail, we're dead anyway item.ID = new UUID((string) reader["inventoryID"]); item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; item.Folder = new UUID((string) reader["parentFolderID"]); - item.Owner = new UUID((string) reader["avatarID"]); item.Name = (string) reader["inventoryName"]; item.Description = (string) reader["inventoryDescription"]; item.NextPermissions = (uint) reader["inventoryNextPermissions"]; item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; item.InvType = (int) reader["invType"]; - item.Creator = new UUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; - item.GroupID = new UUID(reader["groupID"].ToString()); item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); item.Flags = (uint) reader["flags"]; @@ -814,8 +831,11 @@ namespace OpenSim.Data.MySQL List list = new List(); while (result.Read()) - list.Add(readInventoryItem(result)); - + { + InventoryItemBase item = readInventoryItem(result); + if (item != null) + list.Add(item); + } return list; } catch (Exception e) -- cgit v1.1 From d66f3993de49d80d1db9f139ff08485c2d7d9664 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 14 Nov 2008 18:54:38 +0000 Subject: Add group permissions to agent inventory. Contains a migration. May contain nuts. Please back up your inventory data store. This revision changes the interface version!! No older regions can connect to these new UGAIM, and the new regions can't connect to the old UGAIM. Fixes a long-standing issue of permissions loss Currently persisted on MySQL only. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 755dbab..efc781d 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -333,6 +333,7 @@ namespace OpenSim.Data.MySQL item.InvType = (int) reader["invType"]; item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; + item.GroupPermissions = (uint) reader["inventoryGroupPermissions"]; item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; @@ -455,12 +456,12 @@ namespace OpenSim.Data.MySQL string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName" + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType" - + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType" + + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType" + ", creationDate, groupID, groupOwned, flags) VALUES "; sql += "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription" + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID" - + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?salePrice, ?saleType, ?creationDate" + + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" + ", ?groupID, ?groupOwned, ?flags)"; try @@ -482,6 +483,7 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); + result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); result.Parameters.AddWithValue("?salePrice", item.SalePrice); result.Parameters.AddWithValue("?saleType", item.SaleType); result.Parameters.AddWithValue("?creationDate", item.CreationDate); -- cgit v1.1 From 1bd0721dbec03ea833ec639c1759abcc1e7cbdae Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 14 Nov 2008 19:00:14 +0000 Subject: Add SQLite and the missing migrations files for last commit --- OpenSim/Data/MySQL/Resources/003_InventoryStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_InventoryStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/003_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/003_InventoryStore.sql new file mode 100644 index 0000000..4c6da91 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_InventoryStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +alter table inventoryitems add column inventoryGroupPermissions integer unsigned not null default 0; + +COMMIT; -- cgit v1.1 From e26169f0b083a4e13bf8f6af01b499149d2b03de Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 15 Nov 2008 18:00:34 +0000 Subject: Mantis#2552: Thanks idb, for a patch that fixes persistence of physical prims. (added a fix for the broken build from last commit, too) --- OpenSim/Data/MySQL/MySQLRegionData.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 70940db..e793b7e 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -305,8 +305,7 @@ namespace OpenSim.Data.MySQL { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 + if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) { //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); -- cgit v1.1 From 8e119130c506a2debff44a991af7a9106d188759 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 16 Nov 2008 04:39:41 +0000 Subject: Make a quick stab at the "Open data reader" issue. MySqlDataReader needs to be Close()d explicitly. Disposing it or letting it fall out of scope will not free it's hold on the connection. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e793b7e..fcb4c0b 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -212,16 +212,23 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + lock (m_dataSet) { - if (dbReader.Read()) + MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow); + try { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } - dbReader.Close(); - cmd.Dispose(); + cmd.Dispose(); + } + finally + { + dbReader.Close(); + } } m_lastConnectionUse = System.DateTime.Now.Ticks; @@ -571,7 +578,8 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { CheckConnection(); - using (MySqlDataReader row = cmd.ExecuteReader()) + MySqlDataReader row = cmd.ExecuteReader(); + try { int rev = 0; if (row.Read()) @@ -595,6 +603,10 @@ namespace OpenSim.Data.MySQL m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); } + finally + { + row.Close(); + } } return terret; } -- cgit v1.1 From 5517ea3dfd9201217a829eadc38d20030bd65117 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 18 Nov 2008 12:48:36 +0000 Subject: Fixed MySQL and SQLite so they will save the variable sun vector, adding 3 new fields on both. From: Arthur Rodrigo S Valadares --- OpenSim/Data/MySQL/MySQLRegionData.cs | 11 +++++++++++ OpenSim/Data/MySQL/Resources/021_RegionStore.sql | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/021_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index fcb4c0b..effe10b 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -868,6 +868,9 @@ namespace OpenSim.Data.MySQL createCol(regionsettings, "terrain_lower_limit", typeof (Double)); createCol(regionsettings, "use_estate_sun", typeof (Int32)); createCol(regionsettings, "sandbox", typeof (Int32)); + createCol(regionsettings, "sunvectorx",typeof (Double)); + createCol(regionsettings, "sunvectory",typeof (Double)); + createCol(regionsettings, "sunvectorz",typeof (Double)); createCol(regionsettings, "fixed_sun", typeof (Int32)); createCol(regionsettings, "sun_position", typeof (Double)); createCol(regionsettings, "covenant", typeof(String)); @@ -1342,6 +1345,11 @@ namespace OpenSim.Data.MySQL newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); + newSettings.SunVector = new Vector3 ( + Convert.ToSingle(row["sunvectorx"]), + Convert.ToSingle(row["sunvectory"]), + Convert.ToSingle(row["sunvectorz"]) + ); newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new UUID((String) row["covenant"]); @@ -1649,6 +1657,9 @@ namespace OpenSim.Data.MySQL row["terrain_lower_limit"] = settings.TerrainLowerLimit; row["use_estate_sun"] = settings.UseEstateSun; row["sandbox"] = settings.Sandbox; + row["sunvectorx"] = settings.SunVector.X; + row["sunvectory"] = settings.SunVector.Y; + row["sunvectorz"] = settings.SunVector.Z; row["fixed_sun"] = settings.FixedSun; row["sun_position"] = settings.SunPosition; row["covenant"] = settings.Covenant.ToString(); diff --git a/OpenSim/Data/MySQL/Resources/021_RegionStore.sql b/OpenSim/Data/MySQL/Resources/021_RegionStore.sql new file mode 100644 index 0000000..c59b27e --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/021_RegionStore.sql @@ -0,0 +1,8 @@ +begin; + +ALTER TABLE regionsettings ADD COLUMN sunvectorx double NOT NULL default 0; +ALTER TABLE regionsettings ADD COLUMN sunvectory double NOT NULL default 0; +ALTER TABLE regionsettings ADD COLUMN sunvectorz double NOT NULL default 0; + +commit; + -- cgit v1.1 From 44c56a974c428379ebf82386aac7b7443fd82a7d Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 19 Nov 2008 18:30:16 +0000 Subject: Mantis#2656. Thank you kindly, Nlin for a patch that: Attached patch implements llCollisionSound. Thanks T. Sado. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 9 +++++++++ OpenSim/Data/MySQL/Resources/022_RegionStore.sql | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/022_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index effe10b..1daefe4 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -981,6 +981,9 @@ namespace OpenSim.Data.MySQL createCol(prims, "ClickAction", typeof (Byte)); createCol(prims, "Material", typeof (Byte)); + createCol(prims, "CollisionSound", typeof(String)); + createCol(prims, "CollisionSoundVolume", typeof(Double)); + // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -1271,6 +1274,9 @@ namespace OpenSim.Data.MySQL if (!row.IsNull("ClickAction")) prim.ClickAction = Convert.ToByte(row["ClickAction"]); + prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); + prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); + return prim; } @@ -1589,6 +1595,9 @@ namespace OpenSim.Data.MySQL row["ClickAction"] = clickAction; row["Material"] = prim.Material; + + row["CollisionSound"] = prim.CollisionSound.ToString(); + row["CollisionSoundVolume"] = prim.CollisionSoundVolume; } /// diff --git a/OpenSim/Data/MySQL/Resources/022_RegionStore.sql b/OpenSim/Data/MySQL/Resources/022_RegionStore.sql new file mode 100644 index 0000000..af4fdce --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/022_RegionStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE prims ADD COLUMN CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE prims ADD COLUMN CollisionSoundVolume float not null default 0.0; + +COMMIT; -- cgit v1.1 From ecac5c9c5a18241c62a25834b20be38ee0e38843 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 21 Nov 2008 18:44:48 +0000 Subject: Update svn properties, minor formatting cleanup. --- OpenSim/Data/MySQL/Resources/022_RegionStore.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/022_RegionStore.sql b/OpenSim/Data/MySQL/Resources/022_RegionStore.sql index af4fdce..df0bb7d 100644 --- a/OpenSim/Data/MySQL/Resources/022_RegionStore.sql +++ b/OpenSim/Data/MySQL/Resources/022_RegionStore.sql @@ -1,6 +1,6 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE prims ADD COLUMN CollisionSoundVolume float not null default 0.0; - -COMMIT; +BEGIN; + +ALTER TABLE prims ADD COLUMN CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE prims ADD COLUMN CollisionSoundVolume float not null default 0.0; + +COMMIT; -- cgit v1.1 From 915593bfbc2f0d6729efe4dfe8d4c8a3f0fc9fbe Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 21 Nov 2008 21:16:42 +0000 Subject: * refactor: Rip out SOP inventory from the partial into a separate class * SceneObjectPartInventory.cs isn't a particularly good name but it's probably not got a long life * A proper inventory interface to follow * Parallel changes for other inventory partial classes to follow at a later date --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 1daefe4..2e36123 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -511,7 +511,7 @@ namespace OpenSim.Data.MySQL //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); } - prim.RestoreInventoryItems(inventory); + prim.Inventory.RestoreInventoryItems(inventory); // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in // every item). This data should really be stored in the prim table itself. -- cgit v1.1 From cbd02218704287640ba5c7b564440a6590e038cf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 05:16:07 +0000 Subject: Plumb in the presence notifications and region shutdown/restart messages from the presence module to the message server, through the user server and on into the database. This should fix the "Already logged in" issue that grids see after a sim crashes, or a user crashes out of a sim. Not yet a 100% solution for friends, but getting there. --- OpenSim/Data/MySQL/MySQLUserData.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 288ca86..f203a66 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -891,5 +891,31 @@ namespace OpenSim.Data.MySQL dbm.Release(); } } + + public override void LogoutUsers(UUID regionID) + { + Dictionary param = new Dictionary(); + param["?regionID"] = regionID.ToString(); + + MySQLSuperManager dbm = GetLockedConnection("LogoutUsers"); + + try + { + dbm.Manager.ExecuteParameterizedSql( + "update " + m_agentsTableName + " SET agentOnline = 0 " + + "where currentRegion = ?regionID", + param); + } + catch (Exception e) + { + dbm.Manager.Reconnect(); + m_log.Error(e.ToString()); + return; + } + finally + { + dbm.Release(); + } + } } } -- cgit v1.1 From fba9e3f513a0d9b4e0ccaf5a9fe24899d96e98c8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 20:39:51 +0000 Subject: Don't serve texture preview from other people's objects if you havenever seen that texture before. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 52 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 2e36123..f57d485 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -141,6 +141,14 @@ namespace OpenSim.Data.MySQL Migration m = new Migration(m_connection, assem, "RegionStore"); m.Update(); + PrepareConnection(); + } + + public void Dispose() {} + + private void PrepareConnection() + { + GetWaitTimeout(); MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); @@ -203,8 +211,6 @@ namespace OpenSim.Data.MySQL } } - public void Dispose() {} - /// /// Get the wait_timeout value for our connection /// @@ -254,6 +260,8 @@ namespace OpenSim.Data.MySQL m_connection.Close(); m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); + + PrepareConnection(); } } @@ -308,22 +316,40 @@ namespace OpenSim.Data.MySQL /// The region UUID public void StoreObject(SceneObjectGroup obj, UUID regionUUID) { - lock (m_dataSet) + int tries = 3; + while (tries > 0) { - foreach (SceneObjectPart prim in obj.Children.Values) + tries--; + + try { - if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) - { - //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } - else + lock (m_dataSet) { - // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); + foreach (SceneObjectPart prim in obj.Children.Values) + { + if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) + { + //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + addPrim(prim, obj.UUID, regionUUID); + } + else + { + // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); + } + } + Commit(); + return; } } - Commit(); + catch(MySqlException) + { + m_connection.Close(); + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + + PrepareConnection(); + } } } -- cgit v1.1 From 95fec142015fed4449a827155bcb12e019aaa7a2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 21:03:54 +0000 Subject: Remove code from an experimantal patch that wasn't supposed to be committed --- OpenSim/Data/MySQL/MySQLRegionData.cs | 52 +++++++++-------------------------- 1 file changed, 13 insertions(+), 39 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index f57d485..2e36123 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -141,14 +141,6 @@ namespace OpenSim.Data.MySQL Migration m = new Migration(m_connection, assem, "RegionStore"); m.Update(); - PrepareConnection(); - } - - public void Dispose() {} - - private void PrepareConnection() - { - GetWaitTimeout(); MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); @@ -211,6 +203,8 @@ namespace OpenSim.Data.MySQL } } + public void Dispose() {} + /// /// Get the wait_timeout value for our connection /// @@ -260,8 +254,6 @@ namespace OpenSim.Data.MySQL m_connection.Close(); m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); - - PrepareConnection(); } } @@ -316,40 +308,22 @@ namespace OpenSim.Data.MySQL /// The region UUID public void StoreObject(SceneObjectGroup obj, UUID regionUUID) { - int tries = 3; - while (tries > 0) + lock (m_dataSet) { - tries--; - - try + foreach (SceneObjectPart prim in obj.Children.Values) { - lock (m_dataSet) + if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 + && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) { - foreach (SceneObjectPart prim in obj.Children.Values) - { - if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) - { - //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } - else - { - // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); - } - } - Commit(); - return; + //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + addPrim(prim, obj.UUID, regionUUID); + } + else + { + // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); } } - catch(MySqlException) - { - m_connection.Close(); - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); - - PrepareConnection(); - } + Commit(); } } -- cgit v1.1 From 3efdccbb12fc2d5339870ade39e1b1d54da4fe9b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 26 Nov 2008 07:34:38 +0000 Subject: Committing the LCO database layer. Native MySQL, no ADO. New reconnect mechanism to prevent prim loss. Preserve link order on sim restart and drag copy. Fix drag-copied prims' inventories. Fix persistence of child prim inventories. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2212 ++++++++-------------- OpenSim/Data/MySQL/Resources/023_RegionStore.sql | 6 + 2 files changed, 746 insertions(+), 1472 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/023_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 2e36123..743c0d9 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -48,1107 +48,678 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private const string m_primSelect = "select * from prims"; - private const string m_shapeSelect = "select * from primshapes"; - private const string m_itemsSelect = "select * from primitems"; - private const string m_terrainSelect = "select * from terrain limit 1"; - private const string m_landSelect = "select * from land"; - private const string m_landAccessListSelect = "select * from landaccesslist"; - private const string m_regionSettingsSelect = "select * from regionsettings"; - private const string m_waitTimeoutSelect = "select @@wait_timeout"; - - private MySqlConnection m_connection; - private string m_connectionString; + private string m_ConnectionString; - /// - /// Wait timeout for our connection in ticks. - /// - private long m_waitTimeout; - - /// - /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long - /// running database operations. - /// - private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; - - /// - /// Holds the last tick time that the connection was used. - /// - private long m_lastConnectionUse; - - private DataSet m_dataSet; - private MySqlDataAdapter m_primDataAdapter; - private MySqlDataAdapter m_shapeDataAdapter; - private MySqlDataAdapter m_itemsDataAdapter; - private MySqlDataAdapter m_terrainDataAdapter; - private MySqlDataAdapter m_landDataAdapter; - private MySqlDataAdapter m_landAccessListDataAdapter; - private MySqlDataAdapter m_regionSettingsDataAdapter; - - private DataTable m_primTable; - private DataTable m_shapeTable; - private DataTable m_itemsTable; - private DataTable m_terrainTable; - private DataTable m_landTable; - private DataTable m_landAccessListTable; - private DataTable m_regionSettingsTable; - - /*********************************************************************** - * - * Public Interface Functions - * - **********************************************************************/ + private MySqlConnection m_Connection = null; - /// - /// see IRegionDataStore - /// - /// public void Initialise(string connectionString) { - m_connectionString = connectionString; + m_ConnectionString = connectionString; - m_dataSet = new DataSet(); + m_Connection = new MySqlConnection(m_ConnectionString); - int passPosition = 0; - int passEndPosition = 0; - string displayConnectionString = null; - - try - { // hide the password in the connection string - passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); - passPosition = m_connectionString.IndexOf("=", passPosition); - if (passPosition < m_connectionString.Length) - passPosition += 1; - passEndPosition = m_connectionString.IndexOf(";", passPosition); - - displayConnectionString = m_connectionString.Substring(0, passPosition); - displayConnectionString += "***"; - displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); - } - catch (Exception e ) - { - m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); - } + m_Connection.Open(); - m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); - - GetWaitTimeout(); - - // This actually does the roll forward assembly stuff + // Apply new Migrations + // Assembly assem = GetType().Assembly; - Migration m = new Migration(m_connection, assem, "RegionStore"); + Migration m = new Migration(m_Connection, assem, "RegionStore"); m.Update(); - - MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); - m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); - - MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, m_connection); - m_shapeDataAdapter = new MySqlDataAdapter(shapeSelectCmd); - - MySqlCommand itemsSelectCmd = new MySqlCommand(m_itemsSelect, m_connection); - m_itemsDataAdapter = new MySqlDataAdapter(itemsSelectCmd); - - MySqlCommand terrainSelectCmd = new MySqlCommand(m_terrainSelect, m_connection); - m_terrainDataAdapter = new MySqlDataAdapter(terrainSelectCmd); - - MySqlCommand landSelectCmd = new MySqlCommand(m_landSelect, m_connection); - m_landDataAdapter = new MySqlDataAdapter(landSelectCmd); - - MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); - m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); - - MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); - m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); - - // TODO: move out the ADO.NET pieces here and just go to the db directly - lock (m_dataSet) - { - m_primTable = createPrimTable(); - m_dataSet.Tables.Add(m_primTable); - SetupPrimCommands(m_primDataAdapter, m_connection); - m_primDataAdapter.Fill(m_primTable); - - m_shapeTable = createShapeTable(); - m_dataSet.Tables.Add(m_shapeTable); - SetupShapeCommands(m_shapeDataAdapter, m_connection); - m_shapeDataAdapter.Fill(m_shapeTable); - - m_itemsTable = createItemsTable(); - m_dataSet.Tables.Add(m_itemsTable); - SetupItemsCommands(m_itemsDataAdapter, m_connection); - m_itemsDataAdapter.Fill(m_itemsTable); - - m_terrainTable = createTerrainTable(); - m_dataSet.Tables.Add(m_terrainTable); - SetupTerrainCommands(m_terrainDataAdapter, m_connection); - m_terrainDataAdapter.Fill(m_terrainTable); - - m_landTable = createLandTable(); - m_dataSet.Tables.Add(m_landTable); - setupLandCommands(m_landDataAdapter, m_connection); - m_landDataAdapter.Fill(m_landTable); - - m_landAccessListTable = createLandAccessListTable(); - m_dataSet.Tables.Add(m_landAccessListTable); - setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); - m_landAccessListDataAdapter.Fill(m_landAccessListTable); - - m_regionSettingsTable = createRegionSettingsTable(); - m_dataSet.Tables.Add(m_regionSettingsTable); - SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection); - m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); - } + // Clean dropped attachments + // + MySqlCommand cmd = m_Connection.CreateCommand(); + cmd.CommandText = "delete from prims, primshapes using prims " + + "left join primshapes on prims.uuid = primshapes.uuid " + + "where PCode = 9 and State <> 0"; + ExecuteNonQuery(cmd); } - public void Dispose() {} - - /// - /// Get the wait_timeout value for our connection - /// - protected void GetWaitTimeout() + private IDataReader ExecuteReader(MySqlCommand c) { - MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); + IDataReader r = null; + bool errorSeen = false; - lock (m_dataSet) + while (true) { - MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow); try { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } - - cmd.Dispose(); + r = c.ExecuteReader(); } - finally + catch (MySqlException) { - dbReader.Close(); + System.Threading.Thread.Sleep(500); + + m_Connection.Close(); + m_Connection.Open(); + + if (!errorSeen) + { + errorSeen = true; + continue; + continue; + } + throw; } - } - m_lastConnectionUse = System.DateTime.Now.Ticks; + break; + } - m_log.DebugFormat( - "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); + return r; } - /// - /// Should be called before any db operation. This checks to see if the connection has not timed out - /// - protected void CheckConnection() + private void ExecuteNonQuery(MySqlCommand c) { - //m_log.Debug("[REGION DB]: Checking connection"); + bool errorSeen = false; - long timeNow = System.DateTime.Now.Ticks; - if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) + while (true) { - m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); - - lock (m_connection) + try { - m_connection.Close(); - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); + c.ExecuteNonQuery(); } - } - - // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather - // than require the code to call another method - the timeout leeway should be large enough to cover the - // inaccuracy. - m_lastConnectionUse = timeNow; - } - - /// - /// Execute a SQL statement stored in a resource, as a string - /// - /// the ressource name - /// The database connection handler - public void ExecuteResourceSql(string name, MySqlConnection dbcon) - { - MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); - cmd.ExecuteNonQuery(); - } + catch (MySqlException) + { + System.Threading.Thread.Sleep(500); - /// - /// Extract a named string resource from the embedded resources - /// - /// name of embedded resource - /// string contained within the embedded resource - private string getResourceString(string name) - { - Assembly assem = GetType().Assembly; - string[] names = assem.GetManifestResourceNames(); + m_Connection.Close(); + m_Connection.Open(); - foreach (string s in names) - { - if (s.EndsWith(name)) - { - using (Stream resource = assem.GetManifestResourceStream(s)) + if (!errorSeen) { - using (StreamReader resourceReader = new StreamReader(resource)) - { - string resourceString = resourceReader.ReadToEnd(); - return resourceString; - } + errorSeen = true; + continue; } + throw; } + + break; } - throw new Exception(string.Format("Resource '{0}' was not found", name)); } - /// - /// Adds an object into region storage - /// - /// The object - /// The region UUID + public void Dispose() {} + public void StoreObject(SceneObjectGroup obj, UUID regionUUID) { - lock (m_dataSet) + uint flags = obj.RootPart.GetEffectiveObjectFlags(); + + // Eligibility check + // + if ((flags & (uint)PrimFlags.Temporary) != 0) + return; + if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) + return; + + lock (m_Connection) { + MySqlCommand cmd = m_Connection.CreateCommand(); + foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 - && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) - { - //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } - else - { - // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); - } + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims ("+ + "UUID, ParentID, CreationDate, "+ + "Name, Text, Description, "+ + "SitName, TouchName, ObjectFlags, "+ + "OwnerMask, NextOwnerMask, GroupMask, "+ + "EveryoneMask, BaseMask, PositionX, "+ + "PositionY, PositionZ, GroupPositionX, "+ + "GroupPositionY, GroupPositionZ, VelocityX, "+ + "VelocityY, VelocityZ, AngularVelocityX, "+ + "AngularVelocityY, AngularVelocityZ, "+ + "AccelerationX, AccelerationY, "+ + "AccelerationZ, RotationX, "+ + "RotationY, RotationZ, "+ + "RotationW, SitTargetOffsetX, "+ + "SitTargetOffsetY, SitTargetOffsetZ, "+ + "SitTargetOrientW, SitTargetOrientX, "+ + "SitTargetOrientY, SitTargetOrientZ, "+ + "RegionUUID, CreatorID, "+ + "OwnerID, GroupID, "+ + "LastOwnerID, SceneGroupID, "+ + "PayPrice, PayButton1, "+ + "PayButton2, PayButton3, "+ + "PayButton4, LoopedSound, "+ + "LoopedSoundGain, TextureAnimation, "+ + "OmegaX, OmegaY, OmegaZ, "+ + "CameraEyeOffsetX, CameraEyeOffsetY, "+ + "CameraEyeOffsetZ, CameraAtOffsetX, "+ + "CameraAtOffsetY, CameraAtOffsetZ, "+ + "ForceMouselook, ScriptAccessPin, "+ + "AllowedDrop, DieAtEdge, "+ + "SalePrice, SaleType, "+ + "ColorR, ColorG, ColorB, ColorA, "+ + "ParticleSystem, ClickAction, Material, "+ + "CollisionSound, CollisionSoundVolume, "+ + "LinkNumber) values (" + "?UUID, ?ParentID, "+ + "?CreationDate, ?Name, ?Text, "+ + "?Description, ?SitName, ?TouchName, "+ + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ + "?GroupMask, ?EveryoneMask, ?BaseMask, "+ + "?PositionX, ?PositionY, ?PositionZ, "+ + "?GroupPositionX, ?GroupPositionY, "+ + "?GroupPositionZ, ?VelocityX, "+ + "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ + "?AngularVelocityY, ?AngularVelocityZ, "+ + "?AccelerationX, ?AccelerationY, "+ + "?AccelerationZ, ?RotationX, "+ + "?RotationY, ?RotationZ, "+ + "?RotationW, ?SitTargetOffsetX, "+ + "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ + "?SitTargetOrientW, ?SitTargetOrientX, "+ + "?SitTargetOrientY, ?SitTargetOrientZ, "+ + "?RegionUUID, ?CreatorID, ?OwnerID, "+ + "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ + "?PayPrice, ?PayButton1, ?PayButton2, "+ + "?PayButton3, ?PayButton4, ?LoopedSound, "+ + "?LoopedSoundGain, ?TextureAnimation, "+ + "?OmegaX, ?OmegaY, ?OmegaZ, "+ + "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ + "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ + "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ + "?ForceMouselook, ?ScriptAccessPin, "+ + "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ + "?SaleType, ?ColorR, ?ColorG, "+ + "?ColorB, ?ColorA, ?ParticleSystem, "+ + "?ClickAction, ?Material, ?CollisionSound, "+ + "?CollisionSoundVolume, ?LinkNumber)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes ("+ + "UUID, Shape, ScaleX, ScaleY, "+ + "ScaleZ, PCode, PathBegin, PathEnd, "+ + "PathScaleX, PathScaleY, PathShearX, "+ + "PathShearY, PathSkew, PathCurve, "+ + "PathRadiusOffset, PathRevolutions, "+ + "PathTaperX, PathTaperY, PathTwist, "+ + "PathTwistBegin, ProfileBegin, ProfileEnd, "+ + "ProfileCurve, ProfileHollow, Texture, "+ + "ExtraParams, State) values (?UUID, "+ + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ + "?PCode, ?PathBegin, ?PathEnd, "+ + "?PathScaleX, ?PathScaleY, "+ + "?PathShearX, ?PathShearY, "+ + "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ + "?PathRevolutions, ?PathTaperX, "+ + "?PathTaperY, ?PathTwist, "+ + "?PathTwistBegin, ?ProfileBegin, "+ + "?ProfileEnd, ?ProfileCurve, "+ + "?ProfileHollow, ?Texture, ?ExtraParams, "+ + "?State)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); } - Commit(); } } - /// - /// removes an object from region storage - /// - /// The object - /// The Region UUID public void RemoveObject(UUID obj, UUID regionUUID) { - m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj, regionUUID); + // Formerly, this used to check the region UUID. + // That makes no sense, as we remove the contents of a prim + // unconditionally, but the prim dependent on the region ID. + // So, we would destroy an object and cause hard to detect + // issues if we delete the contents only. Deleting it all may + // cause the loss of a prim, but is cleaner. + // It's also faster because it uses the primary key. + // + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - DataTable prims = m_primTable; - DataTable shapes = m_shapeTable; + cmd.CommandText = "select UUID from prims where "+ + "SceneGroupID= ?UUID"; - string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "' and RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; - lock (m_dataSet) - { - DataRow[] primRows = prims.Select(selectExp); - foreach (DataRow row in primRows) + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(obj)); + + List uuids = new List(); + + IDataReader reader = ExecuteReader(cmd); + + try { - // Remove shapes row - UUID uuid = new UUID((string) row["UUID"]); - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); - if (shapeRow != null) + while(reader.Read()) { - shapeRow.Delete(); + uuids.Add(new UUID(reader["UUID"].ToString())); } + } + finally + { + reader.Close(); + } + foreach (UUID uuid in uuids) RemoveItems(uuid); - // Remove prim row - row.Delete(); - } - Commit(); + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + + ExecuteNonQuery(cmd); + + cmd.CommandText = "delete from primshapes where UUID = ?UUID"; + + ExecuteNonQuery(cmd); } } - /// - /// Remove all persisted items of the given prim. - /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. - /// - /// the Item UUID private void RemoveItems(UUID uuid) { - String sql = String.Format("primID = '{0}'", uuid); - DataRow[] itemRows = m_itemsTable.Select(sql); - - foreach (DataRow itemRow in itemRows) + lock (m_Connection) { - itemRow.Delete(); + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "delete from primitems where " + + "PrimID = ?PrimID"; + + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + + ExecuteNonQuery(cmd); } } - /// - /// Load persisted objects from region storage. - /// - /// the Region UUID - /// List of loaded groups public List LoadObjects(UUID regionUUID) { - Dictionary createdObjects = new Dictionary(); - - List retvals = new List(); - - DataTable prims = m_primTable; - DataTable shapes = m_shapeTable; + UUID lastGroupID = UUID.Zero; + List objects = new List(); + List prims = new List(); + SceneObjectGroup grp = null; - string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; - string orderByParent = "ParentID ASC"; - - lock (m_dataSet) + lock (m_Connection) { - CheckConnection(); - DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - m_log.Info("[REGION DB]: " + - "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "select *, " + + "case when prims.UUID = SceneGroupID " + + "then 0 else 1 end as sort from prims " + + "left join primshapes on prims.UUID = primshapes.UUID "+ + "where RegionUUID = ?RegionUUID " + + "order by SceneGroupID asc, sort asc, LinkNumber asc"; - // First, create all groups - foreach (DataRow primRow in primsForRegion) + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionUUID)); + + IDataReader reader = ExecuteReader(cmd); + + try { - try + while (reader.Read()) { - string uuid = (string) primRow["UUID"]; - string objID = (string) primRow["SceneGroupID"]; + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); - SceneObjectPart prim = buildPrim(primRow); + prim.FolderID = prim.UUID; // A relic from when we + // we thought prims contained + // folder objects. In + // reality, prim == folder + prims.Add(prim); - if (uuid == objID) //is new SceneObjectGroup ? - { - SceneObjectGroup group = new SceneObjectGroup(); + UUID groupID = new UUID(reader["SceneGroupID"].ToString()); - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - m_log.Info( - "No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } - - group.SetRootPart(prim); - createdObjects.Add(group.UUID, group); - retvals.Add(group); - LoadItems(prim); - } - } - catch (Exception e) - { - m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); - m_log.Info("[REGION DB]: " + e.ToString()); - foreach (DataColumn col in prims.Columns) + if (groupID != lastGroupID) // New SOG { - m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); - } - } - } - - // Now fill the groups with part data - foreach (DataRow primRow in primsForRegion) - { - try - { - string uuid = (string) primRow["UUID"]; - string objID = (string) primRow["SceneGroupID"]; + if (grp != null) + objects.Add(grp); - SceneObjectPart prim = buildPrim(primRow); + lastGroupID = groupID; - if (uuid != objID) //is new SceneObjectGroup ? - { - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - m_log.Info( - "No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } - createdObjects[new UUID(objID)].AddPart(prim); - LoadItems(prim); + grp = new SceneObjectGroup(prim); } - } - catch (Exception e) - { - m_log.Error("[REGION DB]: Failed create prim object, exception and data follows"); - m_log.Info("[REGION DB]: " + e.ToString()); - foreach (DataColumn col in prims.Columns) + else { - m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); + // Black magic to preserve link numbers + // + int link = prim.LinkNum; + + grp.AddPart(prim); + + if (link != 0) + prim.LinkNum = link; } } } + finally + { + reader.Close(); + } + + if (grp != null) + objects.Add(grp); } - return retvals; + + foreach (SceneObjectPart part in prims) + LoadItems(part); + + m_log.DebugFormat("[DATABASE] Loaded {0} objects using {1} prims", objects.Count, prims.Count); + + return objects; } - /// - /// Load in a prim's persisted inventory. - /// - /// The prim private void LoadItems(SceneObjectPart prim) { - lock (m_dataSet) + lock (m_Connection) { - CheckConnection(); - //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); + MySqlCommand cmd = m_Connection.CreateCommand(); - DataTable dbItems = m_itemsTable; + cmd.CommandText = "select * from primitems where "+ + "PrimID = ?PrimID"; - String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); - DataRow[] dbItemRows = dbItems.Select(sql); - IList inventory = new List(); + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); - foreach (DataRow row in dbItemRows) + IDataReader reader = ExecuteReader(cmd); + List inventory = + new List(); + + try { - TaskInventoryItem item = buildItem(row); - inventory.Add(item); + while (reader.Read()) + { + TaskInventoryItem item = BuildItem(reader); - //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); + item.ParentID = prim.UUID; // Values in database are + // often wrong + inventory.Add(item); + } } - - prim.Inventory.RestoreInventoryItems(inventory); - - // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in - // every item). This data should really be stored in the prim table itself. - if (dbItemRows.Length > 0) + finally { - prim.FolderID = inventory[0].ParentID; + reader.Close(); } + + prim.Inventory.RestoreInventoryItems(inventory); } } - /// - /// Store a terrain revision in region storage - /// - /// HeightField data - /// region UUID public void StoreTerrain(double[,] ter, UUID regionID) { - int revision = 1; - m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); + m_log.Info("[REGION DB]: Storing terrain"); - lock (m_dataSet) + lock (m_Connection) { - MySqlCommand delete = new MySqlCommand("delete from terrain where RegionUUID=?RegionUUID", m_connection); - MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + - " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); - using (cmd) - { - delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + MySqlCommand cmd = m_Connection.CreateCommand(); - CheckConnection(); - delete.ExecuteNonQuery(); + cmd.CommandText = "delete from terrain where " + + "RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionID)); - cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); - cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); - cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); - cmd.ExecuteNonQuery(); - } + ExecuteNonQuery(cmd); + + cmd.CommandText = "insert into terrain (RegionUUID, " + + "Revision, Heightfield) values (?RegionUUID, " + + "1, ?Heightfield)"; + + cmd.Parameters.AddWithValue("Heightfield", + SerializeTerrain(ter)); + + ExecuteNonQuery(cmd); } } - /// - /// Load the latest terrain revision from region storage - /// - /// the region UUID - /// Heightfield data public double[,] LoadTerrain(UUID regionID) { - double[,] terret = new double[256,256]; - terret.Initialize(); + double[,] terrain = new double[256,256]; + terrain.Initialize(); - MySqlCommand cmd = new MySqlCommand( - @"select RegionUUID, Revision, Heightfield from terrain - where RegionUUID=?RegionUUID order by Revision desc limit 1" - , m_connection); - - // MySqlParameter param = new MySqlParameter(); - cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); - - if (m_connection.State != ConnectionState.Open) + lock (m_Connection) { - m_connection.Open(); - } + MySqlCommand cmd = m_Connection.CreateCommand(); + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID "+ + "order by Revision desc limit 1"; + cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID)); + + IDataReader reader = ExecuteReader(cmd); - lock (m_dataSet) - { - CheckConnection(); - MySqlDataReader row = cmd.ExecuteReader(); try { - int rev = 0; - if (row.Read()) + while (reader.Read()) { - MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); - BinaryReader br = new BinaryReader(str); + MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); + int rev = 0; + + BinaryReader br = new BinaryReader(mstr); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { - terret[x, y] = br.ReadDouble(); + terrain[x, y] = br.ReadDouble(); } + rev = Convert.ToInt32(reader["Revision"]); } - rev = (int) row["Revision"]; - } - else - { - m_log.Info("[REGION DB]: No terrain found for region"); - return null; - } + m_log.InfoFormat("[REGION DB]: Loaded terrain " + + "revision r{0}", rev); - m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); + return terrain; + } } finally { - row.Close(); + reader.Close(); } } - return terret; + + return terrain; } - /// - /// - /// delete from land where UUID=globalID - /// delete from landaccesslist where LandUUID=globalID - /// - /// - /// public void RemoveLandObject(UUID globalID) { - lock (m_dataSet) + lock (m_Connection) { - CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection)) - { - cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); - cmd.ExecuteNonQuery(); - } + MySqlCommand cmd = m_Connection.CreateCommand(); - using ( - MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?UUID", m_connection) - ) - { - cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); - cmd.ExecuteNonQuery(); - } + cmd.CommandText = "delete from land where UUID = ?UUID"; + + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); + + ExecuteNonQuery(cmd); } } - /// - /// - /// public void StoreLandObject(ILandObject parcel) { - lock (m_dataSet) + lock (m_Connection) { - CheckConnection(); - DataTable land = m_landTable; - DataTable landaccesslist = m_landAccessListTable; - - DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.GlobalID)); - if (landRow == null) - { - landRow = land.NewRow(); - fillLandRow(landRow, parcel.landData, parcel.regionUUID); - land.Rows.Add(landRow); - } - else - { - fillLandRow(landRow, parcel.landData, parcel.regionUUID); - } - - using ( - MySqlCommand cmd = - new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "replace into land (UUID, RegionUUID, " + + "LocalLandID, Bitmap, Name, Description, " + + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + + "Category, ClaimDate, ClaimPrice, GroupUUID, " + + "SalePrice, LandStatus, LandFlags, LandingType, " + + "MediaAutoScale, MediaTextureUUID, MediaURL, " + + "MusicURL, PassHours, PassPrice, SnapshotUUID, " + + "UserLocationX, UserLocationY, UserLocationZ, " + + "UserLookAtX, UserLookAtY, UserLookAtZ, " + + "AuthbuyerID, OtherCleanTime, Dwell) values (" + + "?UUID, ?RegionUUID, " + + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + + "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + + "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + + "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + + "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; + + FillLandCommand(cmd, parcel.landData, parcel.regionUUID); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "delete from landaccesslist where " + + "LandUUID = ?UUID"; + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in + parcel.landData.ParcelAccessList) { - cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.GlobalID))); - cmd.ExecuteNonQuery(); + FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); } - - foreach (ParcelManager.ParcelAccessEntry entry in parcel.landData.ParcelAccessList) - { - DataRow newAccessRow = landaccesslist.NewRow(); - fillLandAccessRow(newAccessRow, entry, parcel.landData.GlobalID); - landaccesslist.Rows.Add(newAccessRow); - } - - Commit(); } } public RegionSettings LoadRegionSettings(UUID regionUUID) { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionsettings = m_regionSettingsTable; - string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; - DataRow[] rawsettings = regionsettings.Select(searchExp); - if (rawsettings.Length == 0) - { - RegionSettings rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; - - StoreRegionSettings(rs); + RegionSettings rs = null; - return rs; - } - DataRow row = rawsettings[0]; - - RegionSettings newSettings = buildRegionSettings(row); - newSettings.OnSave += StoreRegionSettings; - - return newSettings; - } - } - - public void StoreRegionSettings(RegionSettings rs) - { - lock (m_dataSet) + lock (m_Connection) { - CheckConnection(); - DataTable regionsettings = m_dataSet.Tables["regionsettings"]; + MySqlCommand cmd = m_Connection.CreateCommand(); - DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); - if (settingsRow == null) - { - settingsRow = regionsettings.NewRow(); - fillRegionSettingsRow(settingsRow, rs); - regionsettings.Rows.Add(settingsRow); - } - else - { - fillRegionSettingsRow(settingsRow, rs); - } + cmd.CommandText = "select * from regionsettings where " + + "regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); - Commit(); - } - } + IDataReader reader = ExecuteReader(cmd); - /// - /// - /// - /// - /// - public List LoadLandObjects(UUID regionUUID) - { - List landDataForRegion = new List(); - lock (m_dataSet) - { - CheckConnection(); - DataTable land = m_landTable; - DataTable landaccesslist = m_landAccessListTable; - string searchExp = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; - DataRow[] rawDataForRegion = land.Select(searchExp); - foreach (DataRow rawDataLand in rawDataForRegion) + try { - LandData newLand = buildLandData(rawDataLand); - string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.GlobalID) + "'"; - DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); - foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) + if (reader.Read()) { - newLand.ParcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; } + else + { + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; - landDataForRegion.Add(newLand); + StoreRegionSettings(rs); + } + } + finally + { + reader.Close(); } } - return landDataForRegion; + + return rs; } - /// - /// - /// - public void Commit() + public void StoreRegionSettings(RegionSettings rs) { - lock (m_dataSet) + lock (m_Connection) { - CheckConnection(); - // DisplayDataSet(m_dataSet, "Region DataSet"); - - m_primDataAdapter.Update(m_primTable); - m_shapeDataAdapter.Update(m_shapeTable); - - m_itemsDataAdapter.Update(m_itemsTable); - - m_terrainDataAdapter.Update(m_terrainTable); - m_landDataAdapter.Update(m_landTable); - m_landAccessListDataAdapter.Update(m_landAccessListTable); - m_regionSettingsDataAdapter.Update(m_regionSettingsTable); - - m_dataSet.AcceptChanges(); + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, "+ + "elevation_2_se, elevation_1_sw, "+ + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ)"; + + FillRegionSettingsCommand(cmd, rs); + + ExecuteNonQuery(cmd); } } - /// - /// See - /// - public void Shutdown() - { - Commit(); - } - - /*********************************************************************** - * - * Database Definition Functions - * - * This should be db agnostic as we define them in ADO.NET terms - * - **********************************************************************/ - - /// - /// - /// - /// - /// - /// - /// - private static DataColumn createCol(DataTable dt, string name, Type type) - { - DataColumn col = new DataColumn(name, type); - dt.Columns.Add(col); - return col; - } - - /// - /// Create the "terrain" table - /// - /// - private static DataTable createTerrainTable() - { - DataTable terrain = new DataTable("terrain"); - - createCol(terrain, "RegionUUID", typeof (String)); - createCol(terrain, "Revision", typeof (Int32)); - createCol(terrain, "Heightfield", typeof (Byte[])); - return terrain; - } - - /// - /// Create the "regionsettings" table - /// - /// - private static DataTable createRegionSettingsTable() - { - DataTable regionsettings = new DataTable("regionsettings"); - createCol(regionsettings, "regionUUID", typeof(String)); - createCol(regionsettings, "block_terraform", typeof (Int32)); - createCol(regionsettings, "block_fly", typeof (Int32)); - createCol(regionsettings, "allow_damage", typeof (Int32)); - createCol(regionsettings, "restrict_pushing", typeof (Int32)); - createCol(regionsettings, "allow_land_resell", typeof (Int32)); - createCol(regionsettings, "allow_land_join_divide", typeof (Int32)); - createCol(regionsettings, "block_show_in_search", typeof (Int32)); - createCol(regionsettings, "agent_limit", typeof (Int32)); - createCol(regionsettings, "object_bonus", typeof (Double)); - createCol(regionsettings, "maturity", typeof (Int32)); - createCol(regionsettings, "disable_scripts", typeof (Int32)); - createCol(regionsettings, "disable_collisions", typeof (Int32)); - createCol(regionsettings, "disable_physics", typeof (Int32)); - createCol(regionsettings, "terrain_texture_1", typeof(String)); - createCol(regionsettings, "terrain_texture_2", typeof(String)); - createCol(regionsettings, "terrain_texture_3", typeof(String)); - createCol(regionsettings, "terrain_texture_4", typeof(String)); - createCol(regionsettings, "elevation_1_nw", typeof (Double)); - createCol(regionsettings, "elevation_2_nw", typeof (Double)); - createCol(regionsettings, "elevation_1_ne", typeof (Double)); - createCol(regionsettings, "elevation_2_ne", typeof (Double)); - createCol(regionsettings, "elevation_1_se", typeof (Double)); - createCol(regionsettings, "elevation_2_se", typeof (Double)); - createCol(regionsettings, "elevation_1_sw", typeof (Double)); - createCol(regionsettings, "elevation_2_sw", typeof (Double)); - createCol(regionsettings, "water_height", typeof (Double)); - createCol(regionsettings, "terrain_raise_limit", typeof (Double)); - createCol(regionsettings, "terrain_lower_limit", typeof (Double)); - createCol(regionsettings, "use_estate_sun", typeof (Int32)); - createCol(regionsettings, "sandbox", typeof (Int32)); - createCol(regionsettings, "sunvectorx",typeof (Double)); - createCol(regionsettings, "sunvectory",typeof (Double)); - createCol(regionsettings, "sunvectorz",typeof (Double)); - createCol(regionsettings, "fixed_sun", typeof (Int32)); - createCol(regionsettings, "sun_position", typeof (Double)); - createCol(regionsettings, "covenant", typeof(String)); - - regionsettings.PrimaryKey = new DataColumn[] {regionsettings.Columns["RegionUUID"]}; - - return regionsettings; - } - - /// - /// Create the "prims" table - /// - /// - private static DataTable createPrimTable() + public List LoadLandObjects(UUID regionUUID) { - DataTable prims = new DataTable("prims"); - - createCol(prims, "UUID", typeof (String)); - createCol(prims, "RegionUUID", typeof (String)); - createCol(prims, "ParentID", typeof (Int32)); - createCol(prims, "CreationDate", typeof (Int32)); - createCol(prims, "Name", typeof (String)); - createCol(prims, "SceneGroupID", typeof (String)); - // various text fields - createCol(prims, "Text", typeof (String)); - createCol(prims, "ColorR", typeof (Int32)); - createCol(prims, "ColorG", typeof (Int32)); - createCol(prims, "ColorB", typeof (Int32)); - createCol(prims, "ColorA", typeof (Int32)); - createCol(prims, "Description", typeof (String)); - createCol(prims, "SitName", typeof (String)); - createCol(prims, "TouchName", typeof (String)); - // permissions - createCol(prims, "ObjectFlags", typeof (Int32)); - createCol(prims, "CreatorID", typeof (String)); - createCol(prims, "OwnerID", typeof (String)); - createCol(prims, "GroupID", typeof (String)); - createCol(prims, "LastOwnerID", typeof (String)); - createCol(prims, "OwnerMask", typeof (Int32)); - createCol(prims, "NextOwnerMask", typeof (Int32)); - createCol(prims, "GroupMask", typeof (Int32)); - createCol(prims, "EveryoneMask", typeof (Int32)); - createCol(prims, "BaseMask", typeof (Int32)); - // vectors - createCol(prims, "PositionX", typeof (Double)); - createCol(prims, "PositionY", typeof (Double)); - createCol(prims, "PositionZ", typeof (Double)); - createCol(prims, "GroupPositionX", typeof (Double)); - createCol(prims, "GroupPositionY", typeof (Double)); - createCol(prims, "GroupPositionZ", typeof (Double)); - createCol(prims, "VelocityX", typeof (Double)); - createCol(prims, "VelocityY", typeof (Double)); - createCol(prims, "VelocityZ", typeof (Double)); - createCol(prims, "AngularVelocityX", typeof (Double)); - createCol(prims, "AngularVelocityY", typeof (Double)); - createCol(prims, "AngularVelocityZ", typeof (Double)); - createCol(prims, "AccelerationX", typeof (Double)); - createCol(prims, "AccelerationY", typeof (Double)); - createCol(prims, "AccelerationZ", typeof (Double)); - // quaternions - createCol(prims, "RotationX", typeof (Double)); - createCol(prims, "RotationY", typeof (Double)); - createCol(prims, "RotationZ", typeof (Double)); - createCol(prims, "RotationW", typeof (Double)); - // sit target - createCol(prims, "SitTargetOffsetX", typeof (Double)); - createCol(prims, "SitTargetOffsetY", typeof (Double)); - createCol(prims, "SitTargetOffsetZ", typeof (Double)); - - createCol(prims, "SitTargetOrientW", typeof (Double)); - createCol(prims, "SitTargetOrientX", typeof (Double)); - createCol(prims, "SitTargetOrientY", typeof (Double)); - createCol(prims, "SitTargetOrientZ", typeof (Double)); - - createCol(prims, "PayPrice", typeof(Int32)); - createCol(prims, "PayButton1", typeof(Int32)); - createCol(prims, "PayButton2", typeof(Int32)); - createCol(prims, "PayButton3", typeof(Int32)); - createCol(prims, "PayButton4", typeof(Int32)); - - createCol(prims, "LoopedSound", typeof(String)); - createCol(prims, "LoopedSoundGain", typeof(Double)); - createCol(prims, "TextureAnimation", typeof(Byte[])); - createCol(prims, "ParticleSystem", typeof(Byte[])); - - createCol(prims, "OmegaX", typeof (Double)); - createCol(prims, "OmegaY", typeof (Double)); - createCol(prims, "OmegaZ", typeof (Double)); - - createCol(prims, "CameraEyeOffsetX", typeof (Double)); - createCol(prims, "CameraEyeOffsetY", typeof (Double)); - createCol(prims, "CameraEyeOffsetZ", typeof (Double)); + List landData = new List(); - createCol(prims, "CameraAtOffsetX", typeof (Double)); - createCol(prims, "CameraAtOffsetY", typeof (Double)); - createCol(prims, "CameraAtOffsetZ", typeof (Double)); - - createCol(prims, "ForceMouselook", typeof (Int16)); - - createCol(prims, "ScriptAccessPin", typeof(Int32)); - - createCol(prims, "AllowedDrop", typeof (Int16)); - createCol(prims, "DieAtEdge", typeof (Int16)); - - createCol(prims, "SalePrice", typeof(Int32)); - createCol(prims, "SaleType", typeof (Int16)); - - createCol(prims, "ClickAction", typeof (Byte)); - createCol(prims, "Material", typeof (Byte)); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - createCol(prims, "CollisionSound", typeof(String)); - createCol(prims, "CollisionSoundVolume", typeof(Double)); + cmd.CommandText = "select * from land where " + + "RegionUUID = ?RegionUUID"; - // Add in contraints - prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionUUID)); - return prims; - } + IDataReader reader = ExecuteReader(cmd); - /// - /// Create the "land" table - /// - /// - private static DataTable createLandTable() - { - DataTable land = new DataTable("land"); - createCol(land, "UUID", typeof (String)); - createCol(land, "RegionUUID", typeof (String)); - createCol(land, "LocalLandID", typeof (Int32)); + try + { + while (reader.Read()) + { + LandData newLand = BuildLandData(reader); + landData.Add(newLand); + } + } + finally + { + reader.Close(); + } - // Bitmap is a byte[512] - createCol(land, "Bitmap", typeof (Byte[])); - - createCol(land, "Name", typeof (String)); - createCol(land, "Description", typeof (String)); - createCol(land, "OwnerUUID", typeof (String)); - createCol(land, "IsGroupOwned", typeof (Int32)); - createCol(land, "Area", typeof (Int32)); - createCol(land, "AuctionID", typeof (Int32)); //Unemplemented - createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory - createCol(land, "ClaimDate", typeof (Int32)); - createCol(land, "ClaimPrice", typeof (Int32)); - createCol(land, "GroupUUID", typeof (String)); - createCol(land, "SalePrice", typeof (Int32)); - createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof (UInt32)); - createCol(land, "LandingType", typeof (Int32)); - createCol(land, "MediaAutoScale", typeof (Int32)); - createCol(land, "MediaTextureUUID", typeof (String)); - createCol(land, "MediaURL", typeof (String)); - createCol(land, "MusicURL", typeof (String)); - createCol(land, "PassHours", typeof (Double)); - createCol(land, "PassPrice", typeof (Int32)); - createCol(land, "SnapshotUUID", typeof (String)); - createCol(land, "UserLocationX", typeof (Double)); - createCol(land, "UserLocationY", typeof (Double)); - createCol(land, "UserLocationZ", typeof (Double)); - createCol(land, "UserLookAtX", typeof (Double)); - createCol(land, "UserLookAtY", typeof (Double)); - createCol(land, "UserLookAtZ", typeof (Double)); - createCol(land, "AuthBuyerID", typeof (String)); - createCol(land, "OtherCleanTime", typeof(Int32)); - createCol(land, "Dwell", typeof(Int32)); - - land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; - - return land; - } + foreach (LandData land in landData) + { + cmd.Parameters.Clear(); - /// - /// Create the "landaccesslist" table - /// - /// - private static DataTable createLandAccessListTable() - { - DataTable landaccess = new DataTable("landaccesslist"); - createCol(landaccess, "LandUUID", typeof (String)); - createCol(landaccess, "AccessUUID", typeof (String)); - createCol(landaccess, "Flags", typeof (Int32)); + cmd.CommandText = "select * from landaccesslist " + + "where LandUUID = ?LandUUID"; - return landaccess; - } + cmd.Parameters.AddWithValue("LandUUID", + Util.ToRawUuidString(land.GlobalID)); - /// - /// Create the "primshapes" table - /// - /// - private static DataTable createShapeTable() - { - DataTable shapes = new DataTable("primshapes"); - createCol(shapes, "UUID", typeof (String)); - // shape is an enum - createCol(shapes, "Shape", typeof (Int32)); - // vectors - createCol(shapes, "ScaleX", typeof (Double)); - createCol(shapes, "ScaleY", typeof (Double)); - createCol(shapes, "ScaleZ", typeof (Double)); - // paths - createCol(shapes, "PCode", typeof (Int32)); - createCol(shapes, "PathBegin", typeof (Int32)); - createCol(shapes, "PathEnd", typeof (Int32)); - createCol(shapes, "PathScaleX", typeof (Int32)); - createCol(shapes, "PathScaleY", typeof (Int32)); - createCol(shapes, "PathShearX", typeof (Int32)); - createCol(shapes, "PathShearY", typeof (Int32)); - createCol(shapes, "PathSkew", typeof (Int32)); - createCol(shapes, "PathCurve", typeof (Int32)); - createCol(shapes, "PathRadiusOffset", typeof (Int32)); - createCol(shapes, "PathRevolutions", typeof (Int32)); - createCol(shapes, "PathTaperX", typeof (Int32)); - createCol(shapes, "PathTaperY", typeof (Int32)); - createCol(shapes, "PathTwist", typeof (Int32)); - createCol(shapes, "PathTwistBegin", typeof (Int32)); - // profile - createCol(shapes, "ProfileBegin", typeof (Int32)); - createCol(shapes, "ProfileEnd", typeof (Int32)); - createCol(shapes, "ProfileCurve", typeof (Int32)); - createCol(shapes, "ProfileHollow", typeof (Int32)); - createCol(shapes, "State", typeof(Int32)); - createCol(shapes, "Texture", typeof (Byte[])); - createCol(shapes, "ExtraParams", typeof (Byte[])); + reader = ExecuteReader(cmd); - shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; + try + { + while (reader.Read()) + { + land.ParcelAccessList.Add(BuildLandAccessData(reader)); + } + } + finally + { + reader.Close(); + } + } + } - return shapes; + return landData; } - /// - /// Create the "primitems" table - /// - /// - private static DataTable createItemsTable() + public void Shutdown() { - DataTable items = new DataTable("primitems"); - - createCol(items, "itemID", typeof (String)); - createCol(items, "primID", typeof (String)); - createCol(items, "assetID", typeof (String)); - createCol(items, "parentFolderID", typeof (String)); - - createCol(items, "invType", typeof (Int32)); - createCol(items, "assetType", typeof (Int32)); - - createCol(items, "name", typeof (String)); - createCol(items, "description", typeof (String)); - - createCol(items, "creationDate", typeof (Int64)); - createCol(items, "creatorID", typeof (String)); - createCol(items, "ownerID", typeof (String)); - createCol(items, "lastOwnerID", typeof (String)); - createCol(items, "groupID", typeof (String)); - - createCol(items, "nextPermissions", typeof (Int32)); - createCol(items, "currentPermissions", typeof (Int32)); - createCol(items, "basePermissions", typeof (Int32)); - createCol(items, "everyonePermissions", typeof (Int32)); - createCol(items, "groupPermissions", typeof (Int32)); - createCol(items, "flags", typeof (Int32)); - - items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; - - return items; } - /*********************************************************************** - * - * Convert between ADO.NET <=> OpenSim Objects - * - * These should be database independant - * - **********************************************************************/ - - /// - /// - /// - /// - /// - private SceneObjectPart buildPrim(DataRow row) + private SceneObjectPart BuildPrim(IDataReader row) { SceneObjectPart prim = new SceneObjectPart(); prim.UUID = new UUID((String) row["UUID"]); @@ -1232,9 +803,9 @@ namespace OpenSim.Data.MySQL prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); prim.SoundFlags = 1; // If it's persisted at all, it's looped - if (!row.IsNull("TextureAnimation")) + if (!(row["TextureAnimation"] is DBNull)) prim.TextureAnimation = (Byte[])row["TextureAnimation"]; - if (!row.IsNull("ParticleSystem")) + if (!(row["ParticleSystem"] is DBNull)) prim.ParticleSystem = (Byte[])row["ParticleSystem"]; prim.RotationalVelocity = new Vector3( @@ -1271,11 +842,12 @@ namespace OpenSim.Data.MySQL prim.Material = Convert.ToByte(row["Material"]); - if (!row.IsNull("ClickAction")) - prim.ClickAction = Convert.ToByte(row["ClickAction"]); + if (!(row["ClickAction"] is DBNull)) + prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]); prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); + prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); return prim; } @@ -1286,7 +858,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private static TaskInventoryItem buildItem(DataRow row) + private static TaskInventoryItem BuildItem(IDataReader row) { TaskInventoryItem taskItem = new TaskInventoryItem(); @@ -1316,7 +888,7 @@ namespace OpenSim.Data.MySQL return taskItem; } - private static RegionSettings buildRegionSettings(DataRow row) + private static RegionSettings BuildRegionSettings(IDataReader row) { RegionSettings newSettings = new RegionSettings(); @@ -1368,7 +940,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private static LandData buildLandData(DataRow row) + private static LandData BuildLandData(IDataReader row) { LandData newData = new LandData(); @@ -1436,7 +1008,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) + private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = new UUID((string) row["AccessUUID"]); @@ -1450,7 +1022,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private static Array serializeTerrain(double[,] val) + private static Array SerializeTerrain(double[,] val) { MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); @@ -1476,128 +1048,129 @@ namespace OpenSim.Data.MySQL /// /// /// - private void fillPrimRow(DataRow row, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) + private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) { - row["UUID"] = Util.ToRawUuidString(prim.UUID); - row["RegionUUID"] = Util.ToRawUuidString(regionUUID); - row["ParentID"] = prim.ParentID; - row["CreationDate"] = prim.CreationDate; - row["Name"] = prim.Name; - row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID)); + cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID)); + cmd.Parameters.AddWithValue("ParentID", prim.ParentID); + cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); + cmd.Parameters.AddWithValue("Name", prim.Name); + cmd.Parameters.AddWithValue("SceneGroupID", Util.ToRawUuidString(sceneGroupID)); // the UUID of the root part for this SceneObjectGroup // various text fields - row["Text"] = prim.Text; - row["ColorR"] = prim.Color.R; - row["ColorG"] = prim.Color.G; - row["ColorB"] = prim.Color.B; - row["ColorA"] = prim.Color.A; - row["Description"] = prim.Description; - row["SitName"] = prim.SitName; - row["TouchName"] = prim.TouchName; + cmd.Parameters.AddWithValue("Text", prim.Text); + cmd.Parameters.AddWithValue("ColorR", prim.Color.R); + cmd.Parameters.AddWithValue("ColorG", prim.Color.G); + cmd.Parameters.AddWithValue("ColorB", prim.Color.B); + cmd.Parameters.AddWithValue("ColorA", prim.Color.A); + cmd.Parameters.AddWithValue("Description", prim.Description); + cmd.Parameters.AddWithValue("SitName", prim.SitName); + cmd.Parameters.AddWithValue("TouchName", prim.TouchName); // permissions - row["ObjectFlags"] = prim.ObjectFlags; - row["CreatorID"] = Util.ToRawUuidString(prim.CreatorID); - row["OwnerID"] = Util.ToRawUuidString(prim.OwnerID); - row["GroupID"] = Util.ToRawUuidString(prim.GroupID); - row["LastOwnerID"] = Util.ToRawUuidString(prim.LastOwnerID); - row["OwnerMask"] = prim.OwnerMask; - row["NextOwnerMask"] = prim.NextOwnerMask; - row["GroupMask"] = prim.GroupMask; - row["EveryoneMask"] = prim.EveryoneMask; - row["BaseMask"] = prim.BaseMask; + cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags); + cmd.Parameters.AddWithValue("CreatorID", Util.ToRawUuidString(prim.CreatorID)); + cmd.Parameters.AddWithValue("OwnerID", Util.ToRawUuidString(prim.OwnerID)); + cmd.Parameters.AddWithValue("GroupID", Util.ToRawUuidString(prim.GroupID)); + cmd.Parameters.AddWithValue("LastOwnerID", Util.ToRawUuidString(prim.LastOwnerID)); + cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); + cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); + cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); + cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask); + cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask); // vectors - row["PositionX"] = prim.OffsetPosition.X; - row["PositionY"] = prim.OffsetPosition.Y; - row["PositionZ"] = prim.OffsetPosition.Z; - row["GroupPositionX"] = prim.GroupPosition.X; - row["GroupPositionY"] = prim.GroupPosition.Y; - row["GroupPositionZ"] = prim.GroupPosition.Z; - row["VelocityX"] = prim.Velocity.X; - row["VelocityY"] = prim.Velocity.Y; - row["VelocityZ"] = prim.Velocity.Z; - row["AngularVelocityX"] = prim.AngularVelocity.X; - row["AngularVelocityY"] = prim.AngularVelocity.Y; - row["AngularVelocityZ"] = prim.AngularVelocity.Z; - row["AccelerationX"] = prim.Acceleration.X; - row["AccelerationY"] = prim.Acceleration.Y; - row["AccelerationZ"] = prim.Acceleration.Z; + cmd.Parameters.AddWithValue("PositionX", prim.OffsetPosition.X); + cmd.Parameters.AddWithValue("PositionY", prim.OffsetPosition.Y); + cmd.Parameters.AddWithValue("PositionZ", prim.OffsetPosition.Z); + cmd.Parameters.AddWithValue("GroupPositionX", prim.GroupPosition.X); + cmd.Parameters.AddWithValue("GroupPositionY", prim.GroupPosition.Y); + cmd.Parameters.AddWithValue("GroupPositionZ", prim.GroupPosition.Z); + cmd.Parameters.AddWithValue("VelocityX", prim.Velocity.X); + cmd.Parameters.AddWithValue("VelocityY", prim.Velocity.Y); + cmd.Parameters.AddWithValue("VelocityZ", prim.Velocity.Z); + cmd.Parameters.AddWithValue("AngularVelocityX", prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("AngularVelocityY", prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("AngularVelocityZ", prim.AngularVelocity.Z); + cmd.Parameters.AddWithValue("AccelerationX", prim.Acceleration.X); + cmd.Parameters.AddWithValue("AccelerationY", prim.Acceleration.Y); + cmd.Parameters.AddWithValue("AccelerationZ", prim.Acceleration.Z); // quaternions - row["RotationX"] = prim.RotationOffset.X; - row["RotationY"] = prim.RotationOffset.Y; - row["RotationZ"] = prim.RotationOffset.Z; - row["RotationW"] = prim.RotationOffset.W; + cmd.Parameters.AddWithValue("RotationX", prim.RotationOffset.X); + cmd.Parameters.AddWithValue("RotationY", prim.RotationOffset.Y); + cmd.Parameters.AddWithValue("RotationZ", prim.RotationOffset.Z); + cmd.Parameters.AddWithValue("RotationW", prim.RotationOffset.W); // Sit target Vector3 sitTargetPos = prim.SitTargetPositionLL; - row["SitTargetOffsetX"] = sitTargetPos.X; - row["SitTargetOffsetY"] = sitTargetPos.Y; - row["SitTargetOffsetZ"] = sitTargetPos.Z; + cmd.Parameters.AddWithValue("SitTargetOffsetX", sitTargetPos.X); + cmd.Parameters.AddWithValue("SitTargetOffsetY", sitTargetPos.Y); + cmd.Parameters.AddWithValue("SitTargetOffsetZ", sitTargetPos.Z); Quaternion sitTargetOrient = prim.SitTargetOrientationLL; - row["SitTargetOrientW"] = sitTargetOrient.W; - row["SitTargetOrientX"] = sitTargetOrient.X; - row["SitTargetOrientY"] = sitTargetOrient.Y; - row["SitTargetOrientZ"] = sitTargetOrient.Z; + cmd.Parameters.AddWithValue("SitTargetOrientW", sitTargetOrient.W); + cmd.Parameters.AddWithValue("SitTargetOrientX", sitTargetOrient.X); + cmd.Parameters.AddWithValue("SitTargetOrientY", sitTargetOrient.Y); + cmd.Parameters.AddWithValue("SitTargetOrientZ", sitTargetOrient.Z); - row["PayPrice"] = prim.PayPrice[0]; - row["PayButton1"] = prim.PayPrice[1]; - row["PayButton2"] = prim.PayPrice[2]; - row["PayButton3"] = prim.PayPrice[3]; - row["PayButton4"] = prim.PayPrice[4]; + cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]); + cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]); + cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]); + cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]); + cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]); if ((prim.SoundFlags & 1) != 0) // Looped { - row["LoopedSound"] = prim.Sound.ToString(); - row["LoopedSoundGain"] = prim.SoundGain; + cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString()); + cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain); } else { - row["LoopedSound"] = UUID.Zero; - row["LoopedSoundGain"] = 0.0f; + cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero); + cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f); } - row["TextureAnimation"] = prim.TextureAnimation; - row["ParticleSystem"] = prim.ParticleSystem; + cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); + cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); - row["OmegaX"] = prim.RotationalVelocity.X; - row["OmegaY"] = prim.RotationalVelocity.Y; - row["OmegaZ"] = prim.RotationalVelocity.Z; + cmd.Parameters.AddWithValue("OmegaX", prim.RotationalVelocity.X); + cmd.Parameters.AddWithValue("OmegaY", prim.RotationalVelocity.Y); + cmd.Parameters.AddWithValue("OmegaZ", prim.RotationalVelocity.Z); - row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; - row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; - row["CameraEyeOffsetZ"] = prim.GetCameraEyeOffset().Z; + cmd.Parameters.AddWithValue("CameraEyeOffsetX", prim.GetCameraEyeOffset().X); + cmd.Parameters.AddWithValue("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y); + cmd.Parameters.AddWithValue("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z); - row["CameraAtOffsetX"] = prim.GetCameraAtOffset().X; - row["CameraAtOffsetY"] = prim.GetCameraAtOffset().Y; - row["CameraAtOffsetZ"] = prim.GetCameraAtOffset().Z; + cmd.Parameters.AddWithValue("CameraAtOffsetX", prim.GetCameraAtOffset().X); + cmd.Parameters.AddWithValue("CameraAtOffsetY", prim.GetCameraAtOffset().Y); + cmd.Parameters.AddWithValue("CameraAtOffsetZ", prim.GetCameraAtOffset().Z); if (prim.GetForceMouselook()) - row["ForceMouselook"] = 1; + cmd.Parameters.AddWithValue("ForceMouselook", 1); else - row["ForceMouselook"] = 0; + cmd.Parameters.AddWithValue("ForceMouselook", 0); - row["ScriptAccessPin"] = prim.ScriptAccessPin; + cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin); if (prim.AllowedDrop) - row["AllowedDrop"] = 1; + cmd.Parameters.AddWithValue("AllowedDrop", 1); else - row["AllowedDrop"] = 0; + cmd.Parameters.AddWithValue("AllowedDrop", 0); if (prim.DIE_AT_EDGE) - row["DieAtEdge"] = 1; + cmd.Parameters.AddWithValue("DieAtEdge", 1); else - row["DieAtEdge"] = 0; + cmd.Parameters.AddWithValue("DieAtEdge", 0); - row["SalePrice"] = prim.SalePrice; - row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); + cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); + cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType)); byte clickAction = prim.ClickAction; - row["ClickAction"] = clickAction; + cmd.Parameters.AddWithValue("ClickAction", clickAction); - row["Material"] = prim.Material; + cmd.Parameters.AddWithValue("Material", prim.Material); - row["CollisionSound"] = prim.CollisionSound.ToString(); - row["CollisionSoundVolume"] = prim.CollisionSoundVolume; + cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); + cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); + cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); } /// @@ -1605,73 +1178,73 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) + private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem) { - row["itemID"] = taskItem.ItemID; - row["primID"] = taskItem.ParentPartID; - row["assetID"] = taskItem.AssetID; - row["parentFolderID"] = taskItem.ParentID; - - row["invType"] = taskItem.InvType; - row["assetType"] = taskItem.Type; - - row["name"] = taskItem.Name; - row["description"] = taskItem.Description; - row["creationDate"] = taskItem.CreationDate; - row["creatorID"] = taskItem.CreatorID; - row["ownerID"] = taskItem.OwnerID; - row["lastOwnerID"] = taskItem.LastOwnerID; - row["groupID"] = taskItem.GroupID; - row["nextPermissions"] = taskItem.NextPermissions; - row["currentPermissions"] = taskItem.CurrentPermissions; - row["basePermissions"] = taskItem.BasePermissions; - row["everyonePermissions"] = taskItem.EveryonePermissions; - row["groupPermissions"] = taskItem.GroupPermissions; - row["flags"] = taskItem.Flags; + cmd.Parameters.AddWithValue("itemID", taskItem.ItemID); + cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID); + cmd.Parameters.AddWithValue("assetID", taskItem.AssetID); + cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID); + + cmd.Parameters.AddWithValue("invType", taskItem.InvType); + cmd.Parameters.AddWithValue("assetType", taskItem.Type); + + cmd.Parameters.AddWithValue("name", taskItem.Name); + cmd.Parameters.AddWithValue("description", taskItem.Description); + cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate); + cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID); + cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID); + cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID); + cmd.Parameters.AddWithValue("groupID", taskItem.GroupID); + cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions); + cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions); + cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions); + cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions); + cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions); + cmd.Parameters.AddWithValue("flags", taskItem.Flags); } /// /// /// - private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) + private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings) { - row["regionUUID"] = settings.RegionUUID.ToString(); - row["block_terraform"] = settings.BlockTerraform; - row["block_fly"] = settings.BlockFly; - row["allow_damage"] = settings.AllowDamage; - row["restrict_pushing"] = settings.RestrictPushing; - row["allow_land_resell"] = settings.AllowLandResell; - row["allow_land_join_divide"] = settings.AllowLandJoinDivide; - row["block_show_in_search"] = settings.BlockShowInSearch; - row["agent_limit"] = settings.AgentLimit; - row["object_bonus"] = settings.ObjectBonus; - row["maturity"] = settings.Maturity; - row["disable_scripts"] = settings.DisableScripts; - row["disable_collisions"] = settings.DisableCollisions; - row["disable_physics"] = settings.DisablePhysics; - row["terrain_texture_1"] = settings.TerrainTexture1.ToString(); - row["terrain_texture_2"] = settings.TerrainTexture2.ToString(); - row["terrain_texture_3"] = settings.TerrainTexture3.ToString(); - row["terrain_texture_4"] = settings.TerrainTexture4.ToString(); - row["elevation_1_nw"] = settings.Elevation1NW; - row["elevation_2_nw"] = settings.Elevation2NW; - row["elevation_1_ne"] = settings.Elevation1NE; - row["elevation_2_ne"] = settings.Elevation2NE; - row["elevation_1_se"] = settings.Elevation1SE; - row["elevation_2_se"] = settings.Elevation2SE; - row["elevation_1_sw"] = settings.Elevation1SW; - row["elevation_2_sw"] = settings.Elevation2SW; - row["water_height"] = settings.WaterHeight; - row["terrain_raise_limit"] = settings.TerrainRaiseLimit; - row["terrain_lower_limit"] = settings.TerrainLowerLimit; - row["use_estate_sun"] = settings.UseEstateSun; - row["sandbox"] = settings.Sandbox; - row["sunvectorx"] = settings.SunVector.X; - row["sunvectory"] = settings.SunVector.Y; - row["sunvectorz"] = settings.SunVector.Z; - row["fixed_sun"] = settings.FixedSun; - row["sun_position"] = settings.SunPosition; - row["covenant"] = settings.Covenant.ToString(); + cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform); + cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly); + cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage); + cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing); + cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell); + cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide); + cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch); + cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit); + cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus); + cmd.Parameters.AddWithValue("Maturity", settings.Maturity); + cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts); + cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions); + cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics); + cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString()); + cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW); + cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW); + cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE); + cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE); + cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE); + cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE); + cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW); + cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW); + cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight); + cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit); + cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit); + cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun); + cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox); + cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X); + cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y); + cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z); + cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); + cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); + cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); } /// @@ -1680,45 +1253,45 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void fillLandRow(DataRow row, LandData land, UUID regionUUID) + private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID) { - row["UUID"] = Util.ToRawUuidString(land.GlobalID); - row["RegionUUID"] = Util.ToRawUuidString(regionUUID); - row["LocalLandID"] = land.LocalID; + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(land.GlobalID)); + cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID)); + cmd.Parameters.AddWithValue("LocalLandID", land.LocalID); // Bitmap is a byte[512] - row["Bitmap"] = land.Bitmap; - - row["Name"] = land.Name; - row["Description"] = land.Description; - row["OwnerUUID"] = Util.ToRawUuidString(land.OwnerID); - row["IsGroupOwned"] = land.IsGroupOwned; - row["Area"] = land.Area; - row["AuctionID"] = land.AuctionID; //Unemplemented - row["Category"] = land.Category; //Enum libsecondlife.Parcel.ParcelCategory - row["ClaimDate"] = land.ClaimDate; - row["ClaimPrice"] = land.ClaimPrice; - row["GroupUUID"] = Util.ToRawUuidString(land.GroupID); - row["SalePrice"] = land.SalePrice; - row["LandStatus"] = land.Status; //Enum. libsecondlife.Parcel.ParcelStatus - row["LandFlags"] = land.Flags; - row["LandingType"] = land.LandingType; - row["MediaAutoScale"] = land.MediaAutoScale; - row["MediaTextureUUID"] = Util.ToRawUuidString(land.MediaID); - row["MediaURL"] = land.MediaURL; - row["MusicURL"] = land.MusicURL; - row["PassHours"] = land.PassHours; - row["PassPrice"] = land.PassPrice; - row["SnapshotUUID"] = Util.ToRawUuidString(land.SnapshotID); - row["UserLocationX"] = land.UserLocation.X; - row["UserLocationY"] = land.UserLocation.Y; - row["UserLocationZ"] = land.UserLocation.Z; - row["UserLookAtX"] = land.UserLookAt.X; - row["UserLookAtY"] = land.UserLookAt.Y; - row["UserLookAtZ"] = land.UserLookAt.Z; - row["AuthBuyerID"] = land.AuthBuyerID; - row["OtherCleanTime"] = land.OtherCleanTime; - row["Dwell"] = land.Dwell; + cmd.Parameters.AddWithValue("Bitmap", land.Bitmap); + + cmd.Parameters.AddWithValue("Name", land.Name); + cmd.Parameters.AddWithValue("Description", land.Description); + cmd.Parameters.AddWithValue("OwnerUUID", Util.ToRawUuidString(land.OwnerID)); + cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned); + cmd.Parameters.AddWithValue("Area", land.Area); + cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented + cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory + cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate); + cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice); + cmd.Parameters.AddWithValue("GroupUUID", Util.ToRawUuidString(land.GroupID)); + cmd.Parameters.AddWithValue("SalePrice", land.SalePrice); + cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus + cmd.Parameters.AddWithValue("LandFlags", land.Flags); + cmd.Parameters.AddWithValue("LandingType", land.LandingType); + cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale); + cmd.Parameters.AddWithValue("MediaTextureUUID", Util.ToRawUuidString(land.MediaID)); + cmd.Parameters.AddWithValue("MediaURL", land.MediaURL); + cmd.Parameters.AddWithValue("MusicURL", land.MusicURL); + cmd.Parameters.AddWithValue("PassHours", land.PassHours); + cmd.Parameters.AddWithValue("PassPrice", land.PassPrice); + cmd.Parameters.AddWithValue("SnapshotUUID", Util.ToRawUuidString(land.SnapshotID)); + cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X); + cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y); + cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z); + cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X); + cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y); + cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); + cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); + cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); + cmd.Parameters.AddWithValue("Dwell", land.Dwell); } /// @@ -1727,11 +1300,11 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, UUID parcelID) + private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) { - row["LandUUID"] = Util.ToRawUuidString(parcelID); - row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); - row["Flags"] = entry.Flags; + cmd.Parameters.AddWithValue("LandUUID", Util.ToRawUuidString(parcelID)); + cmd.Parameters.AddWithValue("AccessUUID", Util.ToRawUuidString(entry.AgentID)); + cmd.Parameters.AddWithValue("Flags", entry.Flags); } /// @@ -1739,7 +1312,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private PrimitiveBaseShape buildShape(DataRow row) + private PrimitiveBaseShape BuildShape(IDataReader row) { PrimitiveBaseShape s = new PrimitiveBaseShape(); s.Scale = new Vector3( @@ -1768,8 +1341,7 @@ namespace OpenSim.Data.MySQL s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - - byte[] textureEntry = (byte[]) row["Texture"]; +byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; s.ExtraParams = (byte[]) row["ExtraParams"]; @@ -1784,382 +1356,78 @@ namespace OpenSim.Data.MySQL /// /// /// - private void fillShapeRow(DataRow row, SceneObjectPart prim) + private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim) { PrimitiveBaseShape s = prim.Shape; - row["UUID"] = Util.ToRawUuidString(prim.UUID); + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID)); // shape is an enum - row["Shape"] = 0; + cmd.Parameters.AddWithValue("Shape", 0); // vectors - row["ScaleX"] = s.Scale.X; - row["ScaleY"] = s.Scale.Y; - row["ScaleZ"] = s.Scale.Z; + cmd.Parameters.AddWithValue("ScaleX", s.Scale.X); + cmd.Parameters.AddWithValue("ScaleY", s.Scale.Y); + cmd.Parameters.AddWithValue("ScaleZ", s.Scale.Z); // paths - row["PCode"] = s.PCode; - row["PathBegin"] = s.PathBegin; - row["PathEnd"] = s.PathEnd; - row["PathScaleX"] = s.PathScaleX; - row["PathScaleY"] = s.PathScaleY; - row["PathShearX"] = s.PathShearX; - row["PathShearY"] = s.PathShearY; - row["PathSkew"] = s.PathSkew; - row["PathCurve"] = s.PathCurve; - row["PathRadiusOffset"] = s.PathRadiusOffset; - row["PathRevolutions"] = s.PathRevolutions; - row["PathTaperX"] = s.PathTaperX; - row["PathTaperY"] = s.PathTaperY; - row["PathTwist"] = s.PathTwist; - row["PathTwistBegin"] = s.PathTwistBegin; + cmd.Parameters.AddWithValue("PCode", s.PCode); + cmd.Parameters.AddWithValue("PathBegin", s.PathBegin); + cmd.Parameters.AddWithValue("PathEnd", s.PathEnd); + cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX); + cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY); + cmd.Parameters.AddWithValue("PathShearX", s.PathShearX); + cmd.Parameters.AddWithValue("PathShearY", s.PathShearY); + cmd.Parameters.AddWithValue("PathSkew", s.PathSkew); + cmd.Parameters.AddWithValue("PathCurve", s.PathCurve); + cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset); + cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions); + cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX); + cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY); + cmd.Parameters.AddWithValue("PathTwist", s.PathTwist); + cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin); // profile - row["ProfileBegin"] = s.ProfileBegin; - row["ProfileEnd"] = s.ProfileEnd; - row["ProfileCurve"] = s.ProfileCurve; - row["ProfileHollow"] = s.ProfileHollow; - row["Texture"] = s.TextureEntry; - row["ExtraParams"] = s.ExtraParams; - row["State"] = s.State; + cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin); + cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd); + cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve); + cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow); + cmd.Parameters.AddWithValue("Texture", s.TextureEntry); + cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); + cmd.Parameters.AddWithValue("State", s.State); } - /// - /// - /// - /// - /// - /// - private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) - { - lock (m_dataSet) - { - DataTable prims = m_dataSet.Tables["prims"]; - DataTable shapes = m_dataSet.Tables["primshapes"]; - - DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (primRow == null) - { - primRow = prims.NewRow(); - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - prims.Rows.Add(primRow); - } - else - { - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - } - - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow == null) - { - shapeRow = shapes.NewRow(); - fillShapeRow(shapeRow, prim); - shapes.Rows.Add(shapeRow); - } - else - { - fillShapeRow(shapeRow, prim); - } - } - } - - /// - /// see IRegionDatastore - /// - /// - /// public void StorePrimInventory(UUID primID, ICollection items) { - //m_log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); - - // For now, we're just going to crudely remove all the previous inventory items - // no matter whether they have changed or not, and replace them with the current set. - lock (m_dataSet) + lock (m_Connection) { RemoveItems(primID); - // repalce with current inventory details - foreach (TaskInventoryItem newItem in items) + MySqlCommand cmd = m_Connection.CreateCommand(); + + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems ("+ + "invType, assetType, name, "+ + "description, creationDate, nextPermissions, "+ + "currentPermissions, basePermissions, "+ + "everyonePermissions, groupPermissions, "+ + "flags, itemID, primID, assetID, "+ + "parentFolderID, creatorID, ownerID, "+ + "groupID, lastOwnerID) values (?invType, "+ + "?assetType, ?name, ?description, "+ + "?creationDate, ?nextPermissions, "+ + "?currentPermissions, ?basePermissions, "+ + "?everyonePermissions, ?groupPermissions, "+ + "?flags, ?itemID, ?primID, ?assetID, "+ + "?parentFolderID, ?creatorID, ?ownerID, "+ + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) { -// m_log.InfoFormat( -// "[REGION DB]: " + -// "Adding item {0}, {1} to prim ID {2}", -// newItem.Name, newItem.ItemID, newItem.ParentPartID); - - DataRow newItemRow = m_itemsTable.NewRow(); - fillItemRow(newItemRow, newItem); - m_itemsTable.Rows.Add(newItemRow); - } - } - - Commit(); - } - - /*********************************************************************** - * - * SQL Statement Creation Functions - * - * These functions create SQL statements for update, insert, and create. - * They can probably be factored later to have a db independant - * portion and a db specific portion - * - **********************************************************************/ - - /// - /// Create a MySQL insert command - /// - /// - /// - /// - /// - /// This is subtle enough to deserve some commentary. - /// Instead of doing *lots* and *lots of hardcoded strings - /// for database definitions we'll use the fact that - /// realistically all insert statements look like "insert - /// into A(b, c) values(:b, :c) on the parameterized query - /// front. If we just have a list of b, c, etc... we can - /// generate these strings instead of typing them out. - /// - private static MySqlCommand createInsertCommand(string table, DataTable dt) - { + cmd.Parameters.Clear(); - string[] cols = new string[dt.Columns.Count]; - for (int i = 0; i < dt.Columns.Count; i++) - { - DataColumn col = dt.Columns[i]; - cols[i] = col.ColumnName; - } + FillItemCommand(cmd, item); - string sql = "insert into " + table + "("; - sql += String.Join(", ", cols); - // important, the first ':' needs to be here, the rest get added in the join - sql += ") values (?"; - sql += String.Join(", ?", cols); - sql += ")"; - MySqlCommand cmd = new MySqlCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// Create a MySQL update command - /// - /// - /// - /// - /// - private static MySqlCommand createUpdateCommand(string table, string pk, DataTable dt) - { - string sql = "update " + table + " set "; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ", "; + ExecuteNonQuery(cmd); } - subsql += col.ColumnName + "=?" + col.ColumnName; - } - sql += subsql; - sql += " where " + pk; - MySqlCommand cmd = new MySqlCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createMySqlParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /*********************************************************************** - * - * Database Binding functions - * - * These will be db specific due to typing, and minor differences - * in databases. - * - **********************************************************************/ - - /// - /// This is a convenience function that collapses 5 repetitive - /// lines for defining MySqlParameters to 2 parameters: - /// column name and database type. - /// - /// - /// It assumes certain conventions like ?param as the param - /// name to replace in parametrized queries, and that source - /// version is always current version, both of which are fine - /// for us. - /// - /// - /// a built MySql parameter - private static MySqlParameter createMySqlParameter(string name, Type type) - { - MySqlParameter param = new MySqlParameter(); - param.ParameterName = "?" + name; - param.DbType = dbtypeFromType(type); - param.SourceColumn = name; - param.SourceVersion = DataRowVersion.Current; - return param; - } - - /// - /// - /// - /// - /// - private void SetupPrimCommands(MySqlDataAdapter da, MySqlConnection conn) - { - MySqlCommand insertCommand = createInsertCommand("prims", m_primTable); - insertCommand.Connection = conn; - da.InsertCommand = insertCommand; - - MySqlCommand updateCommand = createUpdateCommand("prims", "UUID=?UUID", m_primTable); - updateCommand.Connection = conn; - da.UpdateCommand = updateCommand; - - MySqlCommand delete = new MySqlCommand("delete from prims where UUID=?UUID"); - delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// - private void SetupItemsCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("primitems", m_itemsTable); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("primitems", "itemID = ?itemID", m_itemsTable); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from primitems where itemID = ?itemID"); - delete.Parameters.Add(createMySqlParameter("itemID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - private void SetupRegionSettingsCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("regionsettings", m_regionSettingsTable); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID = ?regionUUID", m_regionSettingsTable); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from regionsettings where regionUUID = ?regionUUID"); - delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// - private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); - da.InsertCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupLandCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("land", "UUID=?UUID", m_dataSet.Tables["land"]); - da.UpdateCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupLandAccessCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); - da.InsertCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void SetupShapeCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("primshapes", "UUID=?UUID", m_dataSet.Tables["primshapes"]); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from primshapes where UUID = ?UUID"); - delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /*********************************************************************** - * - * Type conversion functions - * - **********************************************************************/ - - /// - /// Type conversion functions - /// - /// - /// - private static DbType dbtypeFromType(Type type) - { - if (type == typeof (String)) - { - return DbType.String; - } - else if (type == typeof (Int32)) - { - return DbType.Int32; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Byte)) - { - return DbType.Byte; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Byte[])) - { - return DbType.Binary; - } - else - { - return DbType.String; } } - } } diff --git a/OpenSim/Data/MySQL/Resources/023_RegionStore.sql b/OpenSim/Data/MySQL/Resources/023_RegionStore.sql new file mode 100644 index 0000000..559591f --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/023_RegionStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE prims ADD COLUMN LinkNumber integer not null default 0; + +COMMIT; + -- cgit v1.1 From 3388584aa8c84eea8dcb98a34ecb556794e2fa7c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 26 Nov 2008 08:06:14 +0000 Subject: Fix 2 of the failed tests. Cause terrain queries to return null when no terrain is found, rather than a default "0" terrain. Remove the "remove object wrong region" test. UUIDs either are unique or they're not. This test tested a bad behavior I have chosen not to duplicate. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 743c0d9..a3ac38e 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -507,7 +507,7 @@ namespace OpenSim.Data.MySQL } } - return terrain; + return null; } public void RemoveLandObject(UUID globalID) -- cgit v1.1 From 841c53003f74ef98f50590d854df7a199803dc36 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 26 Nov 2008 09:05:11 +0000 Subject: A migration to convert the floats int the database to doubles. Maybe we don't have to say "Shift happens" as often anymore.... --- OpenSim/Data/MySQL/Resources/024_RegionStore.sql | 18 ++++++++++ OpenSim/Data/MySQL/Resources/025_RegionStore.sql | 42 ++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/024_RegionStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/025_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/024_RegionStore.sql b/OpenSim/Data/MySQL/Resources/024_RegionStore.sql new file mode 100644 index 0000000..defbf5c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/024_RegionStore.sql @@ -0,0 +1,18 @@ +BEGIN; + +alter table regionsettings change column `object_bonus` `object_bonus` double NOT NULL; +alter table regionsettings change column `elevation_1_nw` `elevation_1_nw` double NOT NULL; +alter table regionsettings change column `elevation_2_nw` `elevation_2_nw` double NOT NULL; +alter table regionsettings change column `elevation_1_ne` `elevation_1_ne` double NOT NULL; +alter table regionsettings change column `elevation_2_ne` `elevation_2_ne` double NOT NULL; +alter table regionsettings change column `elevation_1_se` `elevation_1_se` double NOT NULL; +alter table regionsettings change column `elevation_2_se` `elevation_2_se` double NOT NULL; +alter table regionsettings change column `elevation_1_sw` `elevation_1_sw` double NOT NULL; +alter table regionsettings change column `elevation_2_sw` `elevation_2_sw` double NOT NULL; +alter table regionsettings change column `water_height` `water_height` double NOT NULL; +alter table regionsettings change column `terrain_raise_limit` `terrain_raise_limit` double NOT NULL; +alter table regionsettings change column `terrain_lower_limit` `terrain_lower_limit` double NOT NULL; +alter table regionsettings change column `sun_position` `sun_position` double NOT NULL; + +COMMIT; + diff --git a/OpenSim/Data/MySQL/Resources/025_RegionStore.sql b/OpenSim/Data/MySQL/Resources/025_RegionStore.sql new file mode 100644 index 0000000..47fb6dd --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/025_RegionStore.sql @@ -0,0 +1,42 @@ +BEGIN; + +alter table prims change column `PositionX` `PositionX` float default NULL; +alter table prims change column `PositionY` `PositionY` float default NULL; +alter table prims change column `PositionZ` `PositionZ` float default NULL; +alter table prims change column `GroupPositionX` `GroupPositionX` float default NULL; +alter table prims change column `GroupPositionY` `GroupPositionY` float default NULL; +alter table prims change column `GroupPositionZ` `GroupPositionZ` float default NULL; +alter table prims change column `VelocityX` `VelocityX` float default NULL; +alter table prims change column `VelocityY` `VelocityY` float default NULL; +alter table prims change column `VelocityZ` `VelocityZ` float default NULL; +alter table prims change column `AngularVelocityX` `AngularVelocityX` float default NULL; +alter table prims change column `AngularVelocityY` `AngularVelocityY` float default NULL; +alter table prims change column `AngularVelocityZ` `AngularVelocityZ` float default NULL; +alter table prims change column `AccelerationX` `AccelerationX` float default NULL; +alter table prims change column `AccelerationY` `AccelerationY` float default NULL; +alter table prims change column `AccelerationZ` `AccelerationZ` float default NULL; +alter table prims change column `RotationX` `RotationX` float default NULL; +alter table prims change column `RotationY` `RotationY` float default NULL; +alter table prims change column `RotationZ` `RotationZ` float default NULL; +alter table prims change column `RotationW` `RotationW` float default NULL; +alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` float default NULL; +alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` float default NULL; +alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` float default NULL; +alter table prims change column `SitTargetOrientW` `SitTargetOrientW` float default NULL; +alter table prims change column `SitTargetOrientX` `SitTargetOrientX` float default NULL; +alter table prims change column `SitTargetOrientY` `SitTargetOrientY` float default NULL; +alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` float default NULL; +alter table prims change column `LoopedSoundGain` `LoopedSoundGain` float NOT NULL default '0'; +alter table prims change column `OmegaX` `OmegaX` float NOT NULL default '0'; +alter table prims change column `OmegaY` `OmegaY` float NOT NULL default '0'; +alter table prims change column `OmegaZ` `OmegaZ` float NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` float NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` float NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` float NOT NULL default '0'; +alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` float NOT NULL default '0'; +alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` float NOT NULL default '0'; +alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` float NOT NULL default '0'; +alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` float NOT NULL default '0'; + +COMMIT; + -- cgit v1.1 From 4fdda32cd3a5a92e72ef6f965850d64e0358c223 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 26 Nov 2008 11:38:58 +0000 Subject: A migration to make the floats in prims table be doubles --- OpenSim/Data/MySQL/Resources/026_RegionStore.sql | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/026_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/026_RegionStore.sql b/OpenSim/Data/MySQL/Resources/026_RegionStore.sql new file mode 100644 index 0000000..91af8a8 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/026_RegionStore.sql @@ -0,0 +1,41 @@ +begin; + +alter table prims change column `PositionX` `PositionX` double default NULL; +alter table prims change column `PositionY` `PositionY` double default NULL; +alter table prims change column `PositionZ` `PositionZ` double default NULL; +alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL; +alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL; +alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL; +alter table prims change column `VelocityX` `VelocityX` double default NULL; +alter table prims change column `VelocityY` `VelocityY` double default NULL; +alter table prims change column `VelocityZ` `VelocityZ` double default NULL; +alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL; +alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL; +alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL; +alter table prims change column `AccelerationX` `AccelerationX` double default NULL; +alter table prims change column `AccelerationY` `AccelerationY` double default NULL; +alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL; +alter table prims change column `RotationX` `RotationX` double default NULL; +alter table prims change column `RotationY` `RotationY` double default NULL; +alter table prims change column `RotationZ` `RotationZ` double default NULL; +alter table prims change column `RotationW` `RotationW` double default NULL; +alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL; +alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL; +alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL; +alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL; +alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL; +alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL; +alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL; +alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0'; +alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0'; +alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0'; +alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0'; +alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0'; + +commit; -- cgit v1.1 From fdf5f55a5b0e8936277053d3d24faef23a8f3061 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 26 Nov 2008 12:23:56 +0000 Subject: Yay for unit tests. Increased the type width of the prims and primshapes tables, and changed the database modules to actually push these doubles down into the database layer. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 76 +++++++++++------------ OpenSim/Data/MySQL/Resources/025_RegionStore.sql | 78 +++++++++++++----------- 2 files changed, 79 insertions(+), 75 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a3ac38e..f64b142 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1078,38 +1078,38 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask); cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask); // vectors - cmd.Parameters.AddWithValue("PositionX", prim.OffsetPosition.X); - cmd.Parameters.AddWithValue("PositionY", prim.OffsetPosition.Y); - cmd.Parameters.AddWithValue("PositionZ", prim.OffsetPosition.Z); - cmd.Parameters.AddWithValue("GroupPositionX", prim.GroupPosition.X); - cmd.Parameters.AddWithValue("GroupPositionY", prim.GroupPosition.Y); - cmd.Parameters.AddWithValue("GroupPositionZ", prim.GroupPosition.Z); - cmd.Parameters.AddWithValue("VelocityX", prim.Velocity.X); - cmd.Parameters.AddWithValue("VelocityY", prim.Velocity.Y); - cmd.Parameters.AddWithValue("VelocityZ", prim.Velocity.Z); - cmd.Parameters.AddWithValue("AngularVelocityX", prim.AngularVelocity.X); - cmd.Parameters.AddWithValue("AngularVelocityY", prim.AngularVelocity.Y); - cmd.Parameters.AddWithValue("AngularVelocityZ", prim.AngularVelocity.Z); - cmd.Parameters.AddWithValue("AccelerationX", prim.Acceleration.X); - cmd.Parameters.AddWithValue("AccelerationY", prim.Acceleration.Y); - cmd.Parameters.AddWithValue("AccelerationZ", prim.Acceleration.Z); + cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X); + cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y); + cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z); + cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X); + cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y); + cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z); + cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X); + cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y); + cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z); + cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z); + cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X); + cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y); + cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z); // quaternions - cmd.Parameters.AddWithValue("RotationX", prim.RotationOffset.X); - cmd.Parameters.AddWithValue("RotationY", prim.RotationOffset.Y); - cmd.Parameters.AddWithValue("RotationZ", prim.RotationOffset.Z); - cmd.Parameters.AddWithValue("RotationW", prim.RotationOffset.W); + cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X); + cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y); + cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z); + cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W); // Sit target Vector3 sitTargetPos = prim.SitTargetPositionLL; - cmd.Parameters.AddWithValue("SitTargetOffsetX", sitTargetPos.X); - cmd.Parameters.AddWithValue("SitTargetOffsetY", sitTargetPos.Y); - cmd.Parameters.AddWithValue("SitTargetOffsetZ", sitTargetPos.Z); + cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X); + cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y); + cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z); Quaternion sitTargetOrient = prim.SitTargetOrientationLL; - cmd.Parameters.AddWithValue("SitTargetOrientW", sitTargetOrient.W); - cmd.Parameters.AddWithValue("SitTargetOrientX", sitTargetOrient.X); - cmd.Parameters.AddWithValue("SitTargetOrientY", sitTargetOrient.Y); - cmd.Parameters.AddWithValue("SitTargetOrientZ", sitTargetOrient.Z); + cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W); + cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X); + cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y); + cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z); cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]); cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]); @@ -1131,17 +1131,17 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); - cmd.Parameters.AddWithValue("OmegaX", prim.RotationalVelocity.X); - cmd.Parameters.AddWithValue("OmegaY", prim.RotationalVelocity.Y); - cmd.Parameters.AddWithValue("OmegaZ", prim.RotationalVelocity.Z); + cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); + cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); + cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); - cmd.Parameters.AddWithValue("CameraEyeOffsetX", prim.GetCameraEyeOffset().X); - cmd.Parameters.AddWithValue("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y); - cmd.Parameters.AddWithValue("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z); + cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); + cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); + cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z); - cmd.Parameters.AddWithValue("CameraAtOffsetX", prim.GetCameraAtOffset().X); - cmd.Parameters.AddWithValue("CameraAtOffsetY", prim.GetCameraAtOffset().Y); - cmd.Parameters.AddWithValue("CameraAtOffsetZ", prim.GetCameraAtOffset().Z); + cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X); + cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y); + cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z); if (prim.GetForceMouselook()) cmd.Parameters.AddWithValue("ForceMouselook", 1); @@ -1363,9 +1363,9 @@ byte[] textureEntry = (byte[]) row["Texture"]; // shape is an enum cmd.Parameters.AddWithValue("Shape", 0); // vectors - cmd.Parameters.AddWithValue("ScaleX", s.Scale.X); - cmd.Parameters.AddWithValue("ScaleY", s.Scale.Y); - cmd.Parameters.AddWithValue("ScaleZ", s.Scale.Z); + cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X); + cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y); + cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z); // paths cmd.Parameters.AddWithValue("PCode", s.PCode); cmd.Parameters.AddWithValue("PathBegin", s.PathBegin); diff --git a/OpenSim/Data/MySQL/Resources/025_RegionStore.sql b/OpenSim/Data/MySQL/Resources/025_RegionStore.sql index 47fb6dd..e8f5d70 100644 --- a/OpenSim/Data/MySQL/Resources/025_RegionStore.sql +++ b/OpenSim/Data/MySQL/Resources/025_RegionStore.sql @@ -1,42 +1,46 @@ BEGIN; -alter table prims change column `PositionX` `PositionX` float default NULL; -alter table prims change column `PositionY` `PositionY` float default NULL; -alter table prims change column `PositionZ` `PositionZ` float default NULL; -alter table prims change column `GroupPositionX` `GroupPositionX` float default NULL; -alter table prims change column `GroupPositionY` `GroupPositionY` float default NULL; -alter table prims change column `GroupPositionZ` `GroupPositionZ` float default NULL; -alter table prims change column `VelocityX` `VelocityX` float default NULL; -alter table prims change column `VelocityY` `VelocityY` float default NULL; -alter table prims change column `VelocityZ` `VelocityZ` float default NULL; -alter table prims change column `AngularVelocityX` `AngularVelocityX` float default NULL; -alter table prims change column `AngularVelocityY` `AngularVelocityY` float default NULL; -alter table prims change column `AngularVelocityZ` `AngularVelocityZ` float default NULL; -alter table prims change column `AccelerationX` `AccelerationX` float default NULL; -alter table prims change column `AccelerationY` `AccelerationY` float default NULL; -alter table prims change column `AccelerationZ` `AccelerationZ` float default NULL; -alter table prims change column `RotationX` `RotationX` float default NULL; -alter table prims change column `RotationY` `RotationY` float default NULL; -alter table prims change column `RotationZ` `RotationZ` float default NULL; -alter table prims change column `RotationW` `RotationW` float default NULL; -alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` float default NULL; -alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` float default NULL; -alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` float default NULL; -alter table prims change column `SitTargetOrientW` `SitTargetOrientW` float default NULL; -alter table prims change column `SitTargetOrientX` `SitTargetOrientX` float default NULL; -alter table prims change column `SitTargetOrientY` `SitTargetOrientY` float default NULL; -alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` float default NULL; -alter table prims change column `LoopedSoundGain` `LoopedSoundGain` float NOT NULL default '0'; -alter table prims change column `OmegaX` `OmegaX` float NOT NULL default '0'; -alter table prims change column `OmegaY` `OmegaY` float NOT NULL default '0'; -alter table prims change column `OmegaZ` `OmegaZ` float NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` float NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` float NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` float NOT NULL default '0'; -alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` float NOT NULL default '0'; -alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` float NOT NULL default '0'; -alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` float NOT NULL default '0'; -alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` float NOT NULL default '0'; +alter table prims change column `PositionX` `PositionX` double default NULL; +alter table prims change column `PositionY` `PositionY` double default NULL; +alter table prims change column `PositionZ` `PositionZ` double default NULL; +alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL; +alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL; +alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL; +alter table prims change column `VelocityX` `VelocityX` double default NULL; +alter table prims change column `VelocityY` `VelocityY` double default NULL; +alter table prims change column `VelocityZ` `VelocityZ` double default NULL; +alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL; +alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL; +alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL; +alter table prims change column `AccelerationX` `AccelerationX` double default NULL; +alter table prims change column `AccelerationY` `AccelerationY` double default NULL; +alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL; +alter table prims change column `RotationX` `RotationX` double default NULL; +alter table prims change column `RotationY` `RotationY` double default NULL; +alter table prims change column `RotationZ` `RotationZ` double default NULL; +alter table prims change column `RotationW` `RotationW` double default NULL; +alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL; +alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL; +alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL; +alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL; +alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL; +alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL; +alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL; +alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0'; +alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0'; +alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0'; +alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0'; +alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0'; + +alter table primshapes change column `ScaleX` `ScaleX` double NOT NULL default '0'; +alter table primshapes change column `ScaleY` `ScaleY` double NOT NULL default '0'; +alter table primshapes change column `ScaleZ` `ScaleZ` double NOT NULL default '0'; COMMIT; -- cgit v1.1 From c85e2a0fb0702ad6fea544b0b3a01cf0a0580f5b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 26 Nov 2008 17:42:35 +0000 Subject: * restore deleted method documentation, some to IRegionDataStore and some to MySQLRegionData * I would like to keep documentation on methods, even if it sometimes seems obvious (and not all of these are) --- OpenSim/Data/MySQL/MySQLRegionData.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index f64b142..992e84d 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -307,7 +307,12 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } } - + + /// + /// Remove all persisted items of the given prim. + /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. + /// + /// the Item UUID private void RemoveItems(UUID uuid) { lock (m_Connection) @@ -403,6 +408,10 @@ namespace OpenSim.Data.MySQL return objects; } + /// + /// Load in a prim's persisted inventory. + /// + /// The prim private void LoadItems(SceneObjectPart prim) { lock (m_Connection) -- cgit v1.1 From 45c50998c23657764918649b8966f429674b0c92 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 27 Nov 2008 19:43:26 +0000 Subject: * Remove unused and largely unimplemented UpdateUserCurrentRegion() * please say if this causes you a problem --- OpenSim/Data/MySQL/MySQLUserData.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index f203a66..14d178b 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -409,11 +409,6 @@ namespace OpenSim.Data.MySQL #endregion - public override void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle) - { - //m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called"); - } - public override List GeneratePickerResults(UUID queryID, string query) { List returnlist = new List(); -- cgit v1.1 From 8ba6b2b11a37b660e26b01fa04ce00ac4fab3e90 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 27 Nov 2008 19:51:11 +0000 Subject: * minor: remove mono compiler warnings --- OpenSim/Data/MySQL/MySQLRegionData.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 992e84d..bd74166 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -97,7 +97,6 @@ namespace OpenSim.Data.MySQL { errorSeen = true; continue; - continue; } throw; } -- cgit v1.1 From d579246257cfc5eb9a5268a4b2382f341b9c56e7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 29 Nov 2008 21:24:54 +0000 Subject: Explicitly Dispose() all cmd objects --- OpenSim/Data/MySQL/MySQLRegionData.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index bd74166..af70d11 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -73,6 +73,7 @@ namespace OpenSim.Data.MySQL "left join primshapes on prims.uuid = primshapes.uuid " + "where PCode = 9 and State <> 0"; ExecuteNonQuery(cmd); + cmd.Dispose(); } private IDataReader ExecuteReader(MySqlCommand c) @@ -256,6 +257,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + cmd.Dispose(); } } @@ -304,12 +306,13 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "delete from primshapes where UUID = ?UUID"; ExecuteNonQuery(cmd); + cmd.Dispose(); } } /// /// Remove all persisted items of the given prim. - /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. + /// The caller must acquire the necessrary synchronization locks /// /// the Item UUID private void RemoveItems(UUID uuid) @@ -324,6 +327,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); ExecuteNonQuery(cmd); + cmd.Dispose(); } } @@ -397,6 +401,7 @@ namespace OpenSim.Data.MySQL if (grp != null) objects.Add(grp); + cmd.Dispose(); } foreach (SceneObjectPart part in prims) @@ -442,6 +447,7 @@ namespace OpenSim.Data.MySQL reader.Close(); } + cmd.Dispose(); prim.Inventory.RestoreInventoryItems(inventory); } } @@ -469,6 +475,7 @@ namespace OpenSim.Data.MySQL SerializeTerrain(ter)); ExecuteNonQuery(cmd); + cmd.Dispose(); } } @@ -513,6 +520,7 @@ namespace OpenSim.Data.MySQL { reader.Close(); } + cmd.Dispose(); } return null; @@ -529,6 +537,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); ExecuteNonQuery(cmd); + cmd.Dispose(); } } @@ -580,6 +589,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); cmd.Parameters.Clear(); } + cmd.Dispose(); } } @@ -617,6 +627,7 @@ namespace OpenSim.Data.MySQL { reader.Close(); } + cmd.Dispose(); } return rs; @@ -662,6 +673,7 @@ namespace OpenSim.Data.MySQL FillRegionSettingsCommand(cmd, rs); ExecuteNonQuery(cmd); + cmd.Dispose(); } } @@ -718,6 +730,7 @@ namespace OpenSim.Data.MySQL reader.Close(); } } + cmd.Dispose(); } return landData; @@ -1435,6 +1448,7 @@ byte[] textureEntry = (byte[]) row["Texture"]; ExecuteNonQuery(cmd); } + cmd.Dispose(); } } } -- cgit v1.1 From 077314cdd3b0acdebb2d39eb0c0108814313f8f0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 30 Nov 2008 00:51:40 +0000 Subject: Update svn properties. Add copyright header. Minor formatting cleanup. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index af70d11..33e005b 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -286,7 +286,7 @@ namespace OpenSim.Data.MySQL try { - while(reader.Read()) + while (reader.Read()) { uuids.Add(new UUID(reader["UUID"].ToString())); } -- cgit v1.1 From 38380def178150d66a307702bcc4484f21934bba Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 30 Nov 2008 05:20:19 +0000 Subject: More changes to the MySQL adapter. take advantage of pooling and run lock-free. This should finally kill the "There is already an open data reader associated with this connection, which must be closed first" error that makes people's builds not save --- OpenSim/Data/MySQL/MySQLRegionData.cs | 979 ++++++++++++++++------------------ 1 file changed, 472 insertions(+), 507 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 33e005b..3fb0a8a 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -72,69 +72,10 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "delete from prims, primshapes using prims " + "left join primshapes on prims.uuid = primshapes.uuid " + "where PCode = 9 and State <> 0"; - ExecuteNonQuery(cmd); + cmd.ExecuteNonQuery(); cmd.Dispose(); - } - - private IDataReader ExecuteReader(MySqlCommand c) - { - IDataReader r = null; - bool errorSeen = false; - - while (true) - { - try - { - r = c.ExecuteReader(); - } - catch (MySqlException) - { - System.Threading.Thread.Sleep(500); - - m_Connection.Close(); - m_Connection.Open(); - - if (!errorSeen) - { - errorSeen = true; - continue; - } - throw; - } - - break; - } - - return r; - } - - private void ExecuteNonQuery(MySqlCommand c) - { - bool errorSeen = false; - - while (true) - { - try - { - c.ExecuteNonQuery(); - } - catch (MySqlException) - { - System.Threading.Thread.Sleep(500); - - m_Connection.Close(); - m_Connection.Open(); - if (!errorSeen) - { - errorSeen = true; - continue; - } - throw; - } - - break; - } + m_Connection.Close(); } public void Dispose() {} @@ -150,115 +91,116 @@ namespace OpenSim.Data.MySQL if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) return; - lock (m_Connection) + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); + + MySqlCommand cmd = c.CreateCommand(); + + foreach (SceneObjectPart prim in obj.Children.Values) { - MySqlCommand cmd = m_Connection.CreateCommand(); + cmd.Parameters.Clear(); - foreach (SceneObjectPart prim in obj.Children.Values) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims ("+ - "UUID, ParentID, CreationDate, "+ - "Name, Text, Description, "+ - "SitName, TouchName, ObjectFlags, "+ - "OwnerMask, NextOwnerMask, GroupMask, "+ - "EveryoneMask, BaseMask, PositionX, "+ - "PositionY, PositionZ, GroupPositionX, "+ - "GroupPositionY, GroupPositionZ, VelocityX, "+ - "VelocityY, VelocityZ, AngularVelocityX, "+ - "AngularVelocityY, AngularVelocityZ, "+ - "AccelerationX, AccelerationY, "+ - "AccelerationZ, RotationX, "+ - "RotationY, RotationZ, "+ - "RotationW, SitTargetOffsetX, "+ - "SitTargetOffsetY, SitTargetOffsetZ, "+ - "SitTargetOrientW, SitTargetOrientX, "+ - "SitTargetOrientY, SitTargetOrientZ, "+ - "RegionUUID, CreatorID, "+ - "OwnerID, GroupID, "+ - "LastOwnerID, SceneGroupID, "+ - "PayPrice, PayButton1, "+ - "PayButton2, PayButton3, "+ - "PayButton4, LoopedSound, "+ - "LoopedSoundGain, TextureAnimation, "+ - "OmegaX, OmegaY, OmegaZ, "+ - "CameraEyeOffsetX, CameraEyeOffsetY, "+ - "CameraEyeOffsetZ, CameraAtOffsetX, "+ - "CameraAtOffsetY, CameraAtOffsetZ, "+ - "ForceMouselook, ScriptAccessPin, "+ - "AllowedDrop, DieAtEdge, "+ - "SalePrice, SaleType, "+ - "ColorR, ColorG, ColorB, ColorA, "+ - "ParticleSystem, ClickAction, Material, "+ - "CollisionSound, CollisionSoundVolume, "+ - "LinkNumber) values (" + "?UUID, ?ParentID, "+ - "?CreationDate, ?Name, ?Text, "+ - "?Description, ?SitName, ?TouchName, "+ - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ - "?GroupMask, ?EveryoneMask, ?BaseMask, "+ - "?PositionX, ?PositionY, ?PositionZ, "+ - "?GroupPositionX, ?GroupPositionY, "+ - "?GroupPositionZ, ?VelocityX, "+ - "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ - "?AngularVelocityY, ?AngularVelocityZ, "+ - "?AccelerationX, ?AccelerationY, "+ - "?AccelerationZ, ?RotationX, "+ - "?RotationY, ?RotationZ, "+ - "?RotationW, ?SitTargetOffsetX, "+ - "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ - "?SitTargetOrientW, ?SitTargetOrientX, "+ - "?SitTargetOrientY, ?SitTargetOrientZ, "+ - "?RegionUUID, ?CreatorID, ?OwnerID, "+ - "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ - "?PayPrice, ?PayButton1, ?PayButton2, "+ - "?PayButton3, ?PayButton4, ?LoopedSound, "+ - "?LoopedSoundGain, ?TextureAnimation, "+ - "?OmegaX, ?OmegaY, ?OmegaZ, "+ - "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ - "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ - "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ - "?ForceMouselook, ?ScriptAccessPin, "+ - "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ - "?SaleType, ?ColorR, ?ColorG, "+ - "?ColorB, ?ColorA, ?ParticleSystem, "+ - "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?LinkNumber)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes ("+ - "UUID, Shape, ScaleX, ScaleY, "+ - "ScaleZ, PCode, PathBegin, PathEnd, "+ - "PathScaleX, PathScaleY, PathShearX, "+ - "PathShearY, PathSkew, PathCurve, "+ - "PathRadiusOffset, PathRevolutions, "+ - "PathTaperX, PathTaperY, PathTwist, "+ - "PathTwistBegin, ProfileBegin, ProfileEnd, "+ - "ProfileCurve, ProfileHollow, Texture, "+ - "ExtraParams, State) values (?UUID, "+ - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ - "?PCode, ?PathBegin, ?PathEnd, "+ - "?PathScaleX, ?PathScaleY, "+ - "?PathShearX, ?PathShearY, "+ - "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ - "?PathRevolutions, ?PathTaperX, "+ - "?PathTaperY, ?PathTwist, "+ - "?PathTwistBegin, ?ProfileBegin, "+ - "?ProfileEnd, ?ProfileCurve, "+ - "?ProfileHollow, ?Texture, ?ExtraParams, "+ - "?State)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); - } - cmd.Dispose(); + cmd.CommandText = "replace into prims ("+ + "UUID, ParentID, CreationDate, "+ + "Name, Text, Description, "+ + "SitName, TouchName, ObjectFlags, "+ + "OwnerMask, NextOwnerMask, GroupMask, "+ + "EveryoneMask, BaseMask, PositionX, "+ + "PositionY, PositionZ, GroupPositionX, "+ + "GroupPositionY, GroupPositionZ, VelocityX, "+ + "VelocityY, VelocityZ, AngularVelocityX, "+ + "AngularVelocityY, AngularVelocityZ, "+ + "AccelerationX, AccelerationY, "+ + "AccelerationZ, RotationX, "+ + "RotationY, RotationZ, "+ + "RotationW, SitTargetOffsetX, "+ + "SitTargetOffsetY, SitTargetOffsetZ, "+ + "SitTargetOrientW, SitTargetOrientX, "+ + "SitTargetOrientY, SitTargetOrientZ, "+ + "RegionUUID, CreatorID, "+ + "OwnerID, GroupID, "+ + "LastOwnerID, SceneGroupID, "+ + "PayPrice, PayButton1, "+ + "PayButton2, PayButton3, "+ + "PayButton4, LoopedSound, "+ + "LoopedSoundGain, TextureAnimation, "+ + "OmegaX, OmegaY, OmegaZ, "+ + "CameraEyeOffsetX, CameraEyeOffsetY, "+ + "CameraEyeOffsetZ, CameraAtOffsetX, "+ + "CameraAtOffsetY, CameraAtOffsetZ, "+ + "ForceMouselook, ScriptAccessPin, "+ + "AllowedDrop, DieAtEdge, "+ + "SalePrice, SaleType, "+ + "ColorR, ColorG, ColorB, ColorA, "+ + "ParticleSystem, ClickAction, Material, "+ + "CollisionSound, CollisionSoundVolume, "+ + "LinkNumber) values (" + "?UUID, ?ParentID, "+ + "?CreationDate, ?Name, ?Text, "+ + "?Description, ?SitName, ?TouchName, "+ + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ + "?GroupMask, ?EveryoneMask, ?BaseMask, "+ + "?PositionX, ?PositionY, ?PositionZ, "+ + "?GroupPositionX, ?GroupPositionY, "+ + "?GroupPositionZ, ?VelocityX, "+ + "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ + "?AngularVelocityY, ?AngularVelocityZ, "+ + "?AccelerationX, ?AccelerationY, "+ + "?AccelerationZ, ?RotationX, "+ + "?RotationY, ?RotationZ, "+ + "?RotationW, ?SitTargetOffsetX, "+ + "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ + "?SitTargetOrientW, ?SitTargetOrientX, "+ + "?SitTargetOrientY, ?SitTargetOrientZ, "+ + "?RegionUUID, ?CreatorID, ?OwnerID, "+ + "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ + "?PayPrice, ?PayButton1, ?PayButton2, "+ + "?PayButton3, ?PayButton4, ?LoopedSound, "+ + "?LoopedSoundGain, ?TextureAnimation, "+ + "?OmegaX, ?OmegaY, ?OmegaZ, "+ + "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ + "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ + "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ + "?ForceMouselook, ?ScriptAccessPin, "+ + "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ + "?SaleType, ?ColorR, ?ColorG, "+ + "?ColorB, ?ColorA, ?ParticleSystem, "+ + "?ClickAction, ?Material, ?CollisionSound, "+ + "?CollisionSoundVolume, ?LinkNumber)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes ("+ + "UUID, Shape, ScaleX, ScaleY, "+ + "ScaleZ, PCode, PathBegin, PathEnd, "+ + "PathScaleX, PathScaleY, PathShearX, "+ + "PathShearY, PathSkew, PathCurve, "+ + "PathRadiusOffset, PathRevolutions, "+ + "PathTaperX, PathTaperY, PathTwist, "+ + "PathTwistBegin, ProfileBegin, ProfileEnd, "+ + "ProfileCurve, ProfileHollow, Texture, "+ + "ExtraParams, State) values (?UUID, "+ + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ + "?PCode, ?PathBegin, ?PathEnd, "+ + "?PathScaleX, ?PathScaleY, "+ + "?PathShearX, ?PathShearY, "+ + "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ + "?PathRevolutions, ?PathTaperX, "+ + "?PathTaperY, ?PathTwist, "+ + "?PathTwistBegin, ?ProfileBegin, "+ + "?ProfileEnd, ?ProfileCurve, "+ + "?ProfileHollow, ?Texture, ?ExtraParams, "+ + "?State)"; + + FillShapeCommand(cmd, prim); + + cmd.ExecuteNonQuery(); } + cmd.Dispose(); + c.Close(); } public void RemoveObject(UUID obj, UUID regionUUID) @@ -271,43 +213,51 @@ namespace OpenSim.Data.MySQL // cause the loss of a prim, but is cleaner. // It's also faster because it uses the primary key. // - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - cmd.CommandText = "select UUID from prims where "+ - "SceneGroupID= ?UUID"; + MySqlCommand cmd = c.CreateCommand(); - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(obj)); + cmd.CommandText = "select UUID from prims where "+ + "SceneGroupID= ?UUID"; - List uuids = new List(); + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(obj)); - IDataReader reader = ExecuteReader(cmd); + List uuids = new List(); - try - { - while (reader.Read()) - { - uuids.Add(new UUID(reader["UUID"].ToString())); - } - } - finally + IDataReader reader = cmd.ExecuteReader(); + + try + { + while(reader.Read()) { - reader.Close(); + uuids.Add(new UUID(reader["UUID"].ToString())); } + } + finally + { + reader.Close(); + } - foreach (UUID uuid in uuids) - RemoveItems(uuid); + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + cmd.ExecuteNonQuery(); - ExecuteNonQuery(cmd); + cmd.CommandText = "delete from primshapes where UUID = ?UUID"; - cmd.CommandText = "delete from primshapes where UUID = ?UUID"; + foreach (UUID uuid in uuids) + { + cmd.Parameters.Clear(); + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(uuid)); - ExecuteNonQuery(cmd); - cmd.Dispose(); + cmd.ExecuteNonQuery(); } + + cmd.Dispose(); + c.Close(); + + foreach (UUID uuid in uuids) + RemoveItems(uuid); } /// @@ -317,18 +267,19 @@ namespace OpenSim.Data.MySQL /// the Item UUID private void RemoveItems(UUID uuid) { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - cmd.CommandText = "delete from primitems where " + - "PrimID = ?PrimID"; + MySqlCommand cmd = c.CreateCommand(); - cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + cmd.CommandText = "delete from primitems where " + + "PrimID = ?PrimID"; - ExecuteNonQuery(cmd); - cmd.Dispose(); - } + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Dispose(); + c.Close(); } public List LoadObjects(UUID regionUUID) @@ -338,71 +289,72 @@ namespace OpenSim.Data.MySQL List prims = new List(); SceneObjectGroup grp = null; - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - cmd.CommandText = "select *, " + - "case when prims.UUID = SceneGroupID " + - "then 0 else 1 end as sort from prims " + - "left join primshapes on prims.UUID = primshapes.UUID "+ - "where RegionUUID = ?RegionUUID " + - "order by SceneGroupID asc, sort asc, LinkNumber asc"; - - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionUUID)); + MySqlCommand cmd = c.CreateCommand(); - IDataReader reader = ExecuteReader(cmd); + cmd.CommandText = "select *, " + + "case when prims.UUID = SceneGroupID " + + "then 0 else 1 end as sort from prims " + + "left join primshapes on prims.UUID = primshapes.UUID "+ + "where RegionUUID = ?RegionUUID " + + "order by SceneGroupID asc, sort asc, LinkNumber asc"; + + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionUUID)); - try + IDataReader reader = cmd.ExecuteReader(); + + try + { + while (reader.Read()) { - while (reader.Read()) - { - SceneObjectPart prim = BuildPrim(reader); - if (reader["Shape"] is DBNull) - prim.Shape = PrimitiveBaseShape.Default; - else - prim.Shape = BuildShape(reader); + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); - prim.FolderID = prim.UUID; // A relic from when we - // we thought prims contained - // folder objects. In - // reality, prim == folder - prims.Add(prim); + prim.FolderID = prim.UUID; // A relic from when we + // we thought prims contained + // folder objects. In + // reality, prim == folder + prims.Add(prim); - UUID groupID = new UUID(reader["SceneGroupID"].ToString()); + UUID groupID = new UUID(reader["SceneGroupID"].ToString()); - if (groupID != lastGroupID) // New SOG - { - if (grp != null) - objects.Add(grp); + if (groupID != lastGroupID) // New SOG + { + if (grp != null) + objects.Add(grp); - lastGroupID = groupID; + lastGroupID = groupID; - grp = new SceneObjectGroup(prim); - } - else - { - // Black magic to preserve link numbers - // - int link = prim.LinkNum; + grp = new SceneObjectGroup(prim); + } + else + { + // Black magic to preserve link numbers + // + int link = prim.LinkNum; - grp.AddPart(prim); + grp.AddPart(prim); - if (link != 0) - prim.LinkNum = link; - } + if (link != 0) + prim.LinkNum = link; } } - finally - { - reader.Close(); - } - - if (grp != null) - objects.Add(grp); - cmd.Dispose(); } + finally + { + reader.Close(); + } + + if (grp != null) + objects.Add(grp); + cmd.Dispose(); + c.Close(); foreach (SceneObjectPart part in prims) LoadItems(part); @@ -418,65 +370,67 @@ namespace OpenSim.Data.MySQL /// The prim private void LoadItems(SceneObjectPart prim) { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - cmd.CommandText = "select * from primitems where "+ - "PrimID = ?PrimID"; + MySqlCommand cmd = c.CreateCommand(); - cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + cmd.CommandText = "select * from primitems where "+ + "PrimID = ?PrimID"; - IDataReader reader = ExecuteReader(cmd); - List inventory = - new List(); + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); - try - { - while (reader.Read()) - { - TaskInventoryItem item = BuildItem(reader); + IDataReader reader = cmd.ExecuteReader(); + List inventory = + new List(); - item.ParentID = prim.UUID; // Values in database are - // often wrong - inventory.Add(item); - } - } - finally + try + { + while (reader.Read()) { - reader.Close(); - } + TaskInventoryItem item = BuildItem(reader); - cmd.Dispose(); - prim.Inventory.RestoreInventoryItems(inventory); + item.ParentID = prim.UUID; // Values in database are + // often wrong + inventory.Add(item); + } } + finally + { + reader.Close(); + } + + cmd.Dispose(); + c.Close(); + prim.Inventory.RestoreInventoryItems(inventory); } public void StoreTerrain(double[,] ter, UUID regionID) { m_log.Info("[REGION DB]: Storing terrain"); - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "delete from terrain where " + - "RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionID)); - - ExecuteNonQuery(cmd); - - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; - - cmd.Parameters.AddWithValue("Heightfield", - SerializeTerrain(ter)); - - ExecuteNonQuery(cmd); - cmd.Dispose(); - } + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); + + MySqlCommand cmd = c.CreateCommand(); + + cmd.CommandText = "delete from terrain where " + + "RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionID)); + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "insert into terrain (RegionUUID, " + + "Revision, Heightfield) values (?RegionUUID, " + + "1, ?Heightfield)"; + + cmd.Parameters.AddWithValue("Heightfield", + SerializeTerrain(ter)); + + cmd.ExecuteNonQuery(); + cmd.Dispose(); + c.Close(); } public double[,] LoadTerrain(UUID regionID) @@ -484,254 +438,264 @@ namespace OpenSim.Data.MySQL double[,] terrain = new double[256,256]; terrain.Initialize(); - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select RegionUUID, Revision, Heightfield " + - "from terrain where RegionUUID = ?RegionUUID "+ - "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID)); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - IDataReader reader = ExecuteReader(cmd); + MySqlCommand cmd = c.CreateCommand(); - try + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID "+ + "order by Revision desc limit 1"; + cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID)); + + IDataReader reader = cmd.ExecuteReader(); + + try + { + while (reader.Read()) { - while (reader.Read()) - { - MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); - int rev = 0; + MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); + int rev = 0; - BinaryReader br = new BinaryReader(mstr); - for (int x = 0; x < 256; x++) + BinaryReader br = new BinaryReader(mstr); + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) { - for (int y = 0; y < 256; y++) - { - terrain[x, y] = br.ReadDouble(); - } - rev = Convert.ToInt32(reader["Revision"]); + terrain[x, y] = br.ReadDouble(); } - m_log.InfoFormat("[REGION DB]: Loaded terrain " + - "revision r{0}", rev); - - return terrain; + rev = Convert.ToInt32(reader["Revision"]); } - } - finally - { + m_log.InfoFormat("[REGION DB]: Loaded terrain " + + "revision r{0}", rev); + reader.Close(); + cmd.Dispose(); + c.Close(); + return terrain; } - cmd.Dispose(); } + catch (Exception) + { + } + reader.Close(); + cmd.Dispose(); + c.Close(); return null; } public void RemoveLandObject(UUID globalID) { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - cmd.CommandText = "delete from land where UUID = ?UUID"; + MySqlCommand cmd = c.CreateCommand(); - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); + cmd.CommandText = "delete from land where UUID = ?UUID"; - ExecuteNonQuery(cmd); - cmd.Dispose(); - } + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); + + cmd.ExecuteNonQuery(); + cmd.Dispose(); + c.Close(); } public void StoreLandObject(ILandObject parcel) { - lock (m_Connection) + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); + + MySqlCommand cmd = c.CreateCommand(); + + cmd.CommandText = "replace into land (UUID, RegionUUID, " + + "LocalLandID, Bitmap, Name, Description, " + + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + + "Category, ClaimDate, ClaimPrice, GroupUUID, " + + "SalePrice, LandStatus, LandFlags, LandingType, " + + "MediaAutoScale, MediaTextureUUID, MediaURL, " + + "MusicURL, PassHours, PassPrice, SnapshotUUID, " + + "UserLocationX, UserLocationY, UserLocationZ, " + + "UserLookAtX, UserLookAtY, UserLookAtZ, " + + "AuthbuyerID, OtherCleanTime, Dwell) values (" + + "?UUID, ?RegionUUID, " + + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + + "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + + "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + + "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + + "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; + + FillLandCommand(cmd, parcel.landData, parcel.regionUUID); + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "delete from landaccesslist where " + + "LandUUID = ?UUID"; + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in + parcel.landData.ParcelAccessList) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "replace into land (UUID, RegionUUID, " + - "LocalLandID, Bitmap, Name, Description, " + - "OwnerUUID, IsGroupOwned, Area, AuctionID, " + - "Category, ClaimDate, ClaimPrice, GroupUUID, " + - "SalePrice, LandStatus, LandFlags, LandingType, " + - "MediaAutoScale, MediaTextureUUID, MediaURL, " + - "MusicURL, PassHours, PassPrice, SnapshotUUID, " + - "UserLocationX, UserLocationY, UserLocationZ, " + - "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, Dwell) values (" + - "?UUID, ?RegionUUID, " + - "?LocalLandID, ?Bitmap, ?Name, ?Description, " + - "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + - "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + - "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + - "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + - "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + - "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + - "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; - - FillLandCommand(cmd, parcel.landData, parcel.regionUUID); - - ExecuteNonQuery(cmd); - - cmd.CommandText = "delete from landaccesslist where " + - "LandUUID = ?UUID"; - - ExecuteNonQuery(cmd); - + FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); + cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); - cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; - - foreach (ParcelManager.ParcelAccessEntry entry in - parcel.landData.ParcelAccessList) - { - FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); - ExecuteNonQuery(cmd); - cmd.Parameters.Clear(); - } - cmd.Dispose(); } + cmd.Dispose(); + c.Close(); } public RegionSettings LoadRegionSettings(UUID regionUUID) { RegionSettings rs = null; - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); - cmd.CommandText = "select * from regionsettings where " + - "regionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("regionUUID", regionUUID); + MySqlCommand cmd = c.CreateCommand(); - IDataReader reader = ExecuteReader(cmd); + cmd.CommandText = "select * from regionsettings where " + + "regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); - try - { - if (reader.Read()) - { - rs = BuildRegionSettings(reader); - rs.OnSave += StoreRegionSettings; - } - else - { - rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; + IDataReader reader = cmd.ExecuteReader(); - StoreRegionSettings(rs); - } + try + { + if (reader.Read()) + { + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; } - finally + else { - reader.Close(); + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; + + StoreRegionSettings(rs); } - cmd.Dispose(); } + finally + { + reader.Close(); + } + cmd.Dispose(); + c.Close(); return rs; } public void StoreRegionSettings(RegionSettings rs) { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "replace into regionsettings (regionUUID, " + - "block_terraform, block_fly, allow_damage, " + - "restrict_pushing, allow_land_resell, " + - "allow_land_join_divide, block_show_in_search, " + - "agent_limit, object_bonus, maturity, " + - "disable_scripts, disable_collisions, " + - "disable_physics, terrain_texture_1, " + - "terrain_texture_2, terrain_texture_3, " + - "terrain_texture_4, elevation_1_nw, " + - "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, "+ - "elevation_2_se, elevation_1_sw, "+ - "elevation_2_sw, water_height, " + - "terrain_raise_limit, terrain_lower_limit, " + - "use_estate_sun, fixed_sun, sun_position, " + - "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " + - "?BlockFly, ?AllowDamage, ?RestrictPushing, " + - "?AllowLandResell, ?AllowLandJoinDivide, " + - "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + - "?Maturity, ?DisableScripts, ?DisableCollisions, " + - "?DisablePhysics, ?TerrainTexture1, " + - "?TerrainTexture2, ?TerrainTexture3, " + - "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + - "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + - "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + - "?WaterHeight, ?TerrainRaiseLimit, " + - "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ)"; - - FillRegionSettingsCommand(cmd, rs); - - ExecuteNonQuery(cmd); - cmd.Dispose(); - } + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); + + MySqlCommand cmd = c.CreateCommand(); + + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, "+ + "elevation_2_se, elevation_1_sw, "+ + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ)"; + + FillRegionSettingsCommand(cmd, rs); + + cmd.ExecuteNonQuery(); + cmd.Dispose(); + c.Close(); } public List LoadLandObjects(UUID regionUUID) { List landData = new List(); - lock (m_Connection) + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); + + MySqlCommand cmd = c.CreateCommand(); + + cmd.CommandText = "select * from land where " + + "RegionUUID = ?RegionUUID"; + + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionUUID)); + + IDataReader reader = cmd.ExecuteReader(); + + try + { + while (reader.Read()) + { + LandData newLand = BuildLandData(reader); + landData.Add(newLand); + } + } + finally { - MySqlCommand cmd = m_Connection.CreateCommand(); + reader.Close(); + } - cmd.CommandText = "select * from land where " + - "RegionUUID = ?RegionUUID"; + foreach (LandData land in landData) + { + cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionUUID)); + cmd.CommandText = "select * from landaccesslist " + + "where LandUUID = ?LandUUID"; - IDataReader reader = ExecuteReader(cmd); + cmd.Parameters.AddWithValue("LandUUID", + Util.ToRawUuidString(land.GlobalID)); + + reader = cmd.ExecuteReader(); try { while (reader.Read()) { - LandData newLand = BuildLandData(reader); - landData.Add(newLand); + land.ParcelAccessList.Add(BuildLandAccessData(reader)); } } finally { reader.Close(); } - - foreach (LandData land in landData) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "select * from landaccesslist " + - "where LandUUID = ?LandUUID"; - - cmd.Parameters.AddWithValue("LandUUID", - Util.ToRawUuidString(land.GlobalID)); - - reader = ExecuteReader(cmd); - - try - { - while (reader.Read()) - { - land.ParcelAccessList.Add(BuildLandAccessData(reader)); - } - } - finally - { - reader.Close(); - } - } - cmd.Dispose(); } + cmd.Dispose(); + c.Close(); return landData; } @@ -1415,41 +1379,42 @@ byte[] textureEntry = (byte[]) row["Texture"]; public void StorePrimInventory(UUID primID, ICollection items) { - lock (m_Connection) + RemoveItems(primID); + + MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + c.Open(); + + MySqlCommand cmd = c.CreateCommand(); + + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems ("+ + "invType, assetType, name, "+ + "description, creationDate, nextPermissions, "+ + "currentPermissions, basePermissions, "+ + "everyonePermissions, groupPermissions, "+ + "flags, itemID, primID, assetID, "+ + "parentFolderID, creatorID, ownerID, "+ + "groupID, lastOwnerID) values (?invType, "+ + "?assetType, ?name, ?description, "+ + "?creationDate, ?nextPermissions, "+ + "?currentPermissions, ?basePermissions, "+ + "?everyonePermissions, ?groupPermissions, "+ + "?flags, ?itemID, ?primID, ?assetID, "+ + "?parentFolderID, ?creatorID, ?ownerID, "+ + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) { - RemoveItems(primID); - - MySqlCommand cmd = m_Connection.CreateCommand(); - - if (items.Count == 0) - return; - - cmd.CommandText = "insert into primitems ("+ - "invType, assetType, name, "+ - "description, creationDate, nextPermissions, "+ - "currentPermissions, basePermissions, "+ - "everyonePermissions, groupPermissions, "+ - "flags, itemID, primID, assetID, "+ - "parentFolderID, creatorID, ownerID, "+ - "groupID, lastOwnerID) values (?invType, "+ - "?assetType, ?name, ?description, "+ - "?creationDate, ?nextPermissions, "+ - "?currentPermissions, ?basePermissions, "+ - "?everyonePermissions, ?groupPermissions, "+ - "?flags, ?itemID, ?primID, ?assetID, "+ - "?parentFolderID, ?creatorID, ?ownerID, "+ - "?groupID, ?lastOwnerID)"; - - foreach (TaskInventoryItem item in items) - { - cmd.Parameters.Clear(); + cmd.Parameters.Clear(); - FillItemCommand(cmd, item); + FillItemCommand(cmd, item); - ExecuteNonQuery(cmd); - } - cmd.Dispose(); + cmd.ExecuteNonQuery(); } + cmd.Dispose(); + c.Close(); } } } -- cgit v1.1 From 5727146d61c4e28876ce236e82cbffb480aee19c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 1 Dec 2008 18:59:13 +0000 Subject: More reverts. Revert the MySQL database module. This caused more issues than it solved by trying to use, and then exhausting, the connection pool --- OpenSim/Data/MySQL/MySQLRegionData.cs | 987 ++++++++++++++++++---------------- 1 file changed, 513 insertions(+), 474 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3fb0a8a..73605f9 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -72,10 +72,73 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "delete from prims, primshapes using prims " + "left join primshapes on prims.uuid = primshapes.uuid " + "where PCode = 9 and State <> 0"; - cmd.ExecuteNonQuery(); + ExecuteNonQuery(cmd); cmd.Dispose(); + } + + private IDataReader ExecuteReader(MySqlCommand c) + { + IDataReader r = null; + bool errorSeen = false; + + while (true) + { + try + { + r = c.ExecuteReader(); + } + catch (MySqlException) + { + System.Threading.Thread.Sleep(500); + + m_Connection.Close(); + m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + m_Connection.Open(); + c.Connection = m_Connection; + + if (!errorSeen) + { + errorSeen = true; + continue; + } + throw; + } + + break; + } + + return r; + } + + private void ExecuteNonQuery(MySqlCommand c) + { + bool errorSeen = false; + + while (true) + { + try + { + c.ExecuteNonQuery(); + } + catch (MySqlException) + { + System.Threading.Thread.Sleep(500); + + m_Connection.Close(); + m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + m_Connection.Open(); + c.Connection = m_Connection; - m_Connection.Close(); + if (!errorSeen) + { + errorSeen = true; + continue; + } + throw; + } + + break; + } } public void Dispose() {} @@ -91,116 +154,115 @@ namespace OpenSim.Data.MySQL if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) return; - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); - - foreach (SceneObjectPart prim in obj.Children.Values) + lock (m_Connection) { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims ("+ - "UUID, ParentID, CreationDate, "+ - "Name, Text, Description, "+ - "SitName, TouchName, ObjectFlags, "+ - "OwnerMask, NextOwnerMask, GroupMask, "+ - "EveryoneMask, BaseMask, PositionX, "+ - "PositionY, PositionZ, GroupPositionX, "+ - "GroupPositionY, GroupPositionZ, VelocityX, "+ - "VelocityY, VelocityZ, AngularVelocityX, "+ - "AngularVelocityY, AngularVelocityZ, "+ - "AccelerationX, AccelerationY, "+ - "AccelerationZ, RotationX, "+ - "RotationY, RotationZ, "+ - "RotationW, SitTargetOffsetX, "+ - "SitTargetOffsetY, SitTargetOffsetZ, "+ - "SitTargetOrientW, SitTargetOrientX, "+ - "SitTargetOrientY, SitTargetOrientZ, "+ - "RegionUUID, CreatorID, "+ - "OwnerID, GroupID, "+ - "LastOwnerID, SceneGroupID, "+ - "PayPrice, PayButton1, "+ - "PayButton2, PayButton3, "+ - "PayButton4, LoopedSound, "+ - "LoopedSoundGain, TextureAnimation, "+ - "OmegaX, OmegaY, OmegaZ, "+ - "CameraEyeOffsetX, CameraEyeOffsetY, "+ - "CameraEyeOffsetZ, CameraAtOffsetX, "+ - "CameraAtOffsetY, CameraAtOffsetZ, "+ - "ForceMouselook, ScriptAccessPin, "+ - "AllowedDrop, DieAtEdge, "+ - "SalePrice, SaleType, "+ - "ColorR, ColorG, ColorB, ColorA, "+ - "ParticleSystem, ClickAction, Material, "+ - "CollisionSound, CollisionSoundVolume, "+ - "LinkNumber) values (" + "?UUID, ?ParentID, "+ - "?CreationDate, ?Name, ?Text, "+ - "?Description, ?SitName, ?TouchName, "+ - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ - "?GroupMask, ?EveryoneMask, ?BaseMask, "+ - "?PositionX, ?PositionY, ?PositionZ, "+ - "?GroupPositionX, ?GroupPositionY, "+ - "?GroupPositionZ, ?VelocityX, "+ - "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ - "?AngularVelocityY, ?AngularVelocityZ, "+ - "?AccelerationX, ?AccelerationY, "+ - "?AccelerationZ, ?RotationX, "+ - "?RotationY, ?RotationZ, "+ - "?RotationW, ?SitTargetOffsetX, "+ - "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ - "?SitTargetOrientW, ?SitTargetOrientX, "+ - "?SitTargetOrientY, ?SitTargetOrientZ, "+ - "?RegionUUID, ?CreatorID, ?OwnerID, "+ - "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ - "?PayPrice, ?PayButton1, ?PayButton2, "+ - "?PayButton3, ?PayButton4, ?LoopedSound, "+ - "?LoopedSoundGain, ?TextureAnimation, "+ - "?OmegaX, ?OmegaY, ?OmegaZ, "+ - "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ - "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ - "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ - "?ForceMouselook, ?ScriptAccessPin, "+ - "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ - "?SaleType, ?ColorR, ?ColorG, "+ - "?ColorB, ?ColorA, ?ParticleSystem, "+ - "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?LinkNumber)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "replace into primshapes ("+ - "UUID, Shape, ScaleX, ScaleY, "+ - "ScaleZ, PCode, PathBegin, PathEnd, "+ - "PathScaleX, PathScaleY, PathShearX, "+ - "PathShearY, PathSkew, PathCurve, "+ - "PathRadiusOffset, PathRevolutions, "+ - "PathTaperX, PathTaperY, PathTwist, "+ - "PathTwistBegin, ProfileBegin, ProfileEnd, "+ - "ProfileCurve, ProfileHollow, Texture, "+ - "ExtraParams, State) values (?UUID, "+ - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ - "?PCode, ?PathBegin, ?PathEnd, "+ - "?PathScaleX, ?PathScaleY, "+ - "?PathShearX, ?PathShearY, "+ - "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ - "?PathRevolutions, ?PathTaperX, "+ - "?PathTaperY, ?PathTwist, "+ - "?PathTwistBegin, ?ProfileBegin, "+ - "?ProfileEnd, ?ProfileCurve, "+ - "?ProfileHollow, ?Texture, ?ExtraParams, "+ - "?State)"; - - FillShapeCommand(cmd, prim); - - cmd.ExecuteNonQuery(); + foreach (SceneObjectPart prim in obj.Children.Values) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims ("+ + "UUID, ParentID, CreationDate, "+ + "Name, Text, Description, "+ + "SitName, TouchName, ObjectFlags, "+ + "OwnerMask, NextOwnerMask, GroupMask, "+ + "EveryoneMask, BaseMask, PositionX, "+ + "PositionY, PositionZ, GroupPositionX, "+ + "GroupPositionY, GroupPositionZ, VelocityX, "+ + "VelocityY, VelocityZ, AngularVelocityX, "+ + "AngularVelocityY, AngularVelocityZ, "+ + "AccelerationX, AccelerationY, "+ + "AccelerationZ, RotationX, "+ + "RotationY, RotationZ, "+ + "RotationW, SitTargetOffsetX, "+ + "SitTargetOffsetY, SitTargetOffsetZ, "+ + "SitTargetOrientW, SitTargetOrientX, "+ + "SitTargetOrientY, SitTargetOrientZ, "+ + "RegionUUID, CreatorID, "+ + "OwnerID, GroupID, "+ + "LastOwnerID, SceneGroupID, "+ + "PayPrice, PayButton1, "+ + "PayButton2, PayButton3, "+ + "PayButton4, LoopedSound, "+ + "LoopedSoundGain, TextureAnimation, "+ + "OmegaX, OmegaY, OmegaZ, "+ + "CameraEyeOffsetX, CameraEyeOffsetY, "+ + "CameraEyeOffsetZ, CameraAtOffsetX, "+ + "CameraAtOffsetY, CameraAtOffsetZ, "+ + "ForceMouselook, ScriptAccessPin, "+ + "AllowedDrop, DieAtEdge, "+ + "SalePrice, SaleType, "+ + "ColorR, ColorG, ColorB, ColorA, "+ + "ParticleSystem, ClickAction, Material, "+ + "CollisionSound, CollisionSoundVolume, "+ + "LinkNumber) values (" + "?UUID, ?ParentID, "+ + "?CreationDate, ?Name, ?Text, "+ + "?Description, ?SitName, ?TouchName, "+ + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ + "?GroupMask, ?EveryoneMask, ?BaseMask, "+ + "?PositionX, ?PositionY, ?PositionZ, "+ + "?GroupPositionX, ?GroupPositionY, "+ + "?GroupPositionZ, ?VelocityX, "+ + "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ + "?AngularVelocityY, ?AngularVelocityZ, "+ + "?AccelerationX, ?AccelerationY, "+ + "?AccelerationZ, ?RotationX, "+ + "?RotationY, ?RotationZ, "+ + "?RotationW, ?SitTargetOffsetX, "+ + "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ + "?SitTargetOrientW, ?SitTargetOrientX, "+ + "?SitTargetOrientY, ?SitTargetOrientZ, "+ + "?RegionUUID, ?CreatorID, ?OwnerID, "+ + "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ + "?PayPrice, ?PayButton1, ?PayButton2, "+ + "?PayButton3, ?PayButton4, ?LoopedSound, "+ + "?LoopedSoundGain, ?TextureAnimation, "+ + "?OmegaX, ?OmegaY, ?OmegaZ, "+ + "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ + "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ + "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ + "?ForceMouselook, ?ScriptAccessPin, "+ + "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ + "?SaleType, ?ColorR, ?ColorG, "+ + "?ColorB, ?ColorA, ?ParticleSystem, "+ + "?ClickAction, ?Material, ?CollisionSound, "+ + "?CollisionSoundVolume, ?LinkNumber)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes ("+ + "UUID, Shape, ScaleX, ScaleY, "+ + "ScaleZ, PCode, PathBegin, PathEnd, "+ + "PathScaleX, PathScaleY, PathShearX, "+ + "PathShearY, PathSkew, PathCurve, "+ + "PathRadiusOffset, PathRevolutions, "+ + "PathTaperX, PathTaperY, PathTwist, "+ + "PathTwistBegin, ProfileBegin, ProfileEnd, "+ + "ProfileCurve, ProfileHollow, Texture, "+ + "ExtraParams, State) values (?UUID, "+ + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ + "?PCode, ?PathBegin, ?PathEnd, "+ + "?PathScaleX, ?PathScaleY, "+ + "?PathShearX, ?PathShearY, "+ + "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ + "?PathRevolutions, ?PathTaperX, "+ + "?PathTaperY, ?PathTwist, "+ + "?PathTwistBegin, ?ProfileBegin, "+ + "?ProfileEnd, ?ProfileCurve, "+ + "?ProfileHollow, ?Texture, ?ExtraParams, "+ + "?State)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); + } + cmd.Dispose(); } - cmd.Dispose(); - c.Close(); } public void RemoveObject(UUID obj, UUID regionUUID) @@ -213,51 +275,43 @@ namespace OpenSim.Data.MySQL // cause the loss of a prim, but is cleaner. // It's also faster because it uses the primary key. // - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select UUID from prims where "+ - "SceneGroupID= ?UUID"; + cmd.CommandText = "select UUID from prims where "+ + "SceneGroupID= ?UUID"; - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(obj)); + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(obj)); - List uuids = new List(); + List uuids = new List(); - IDataReader reader = cmd.ExecuteReader(); + IDataReader reader = ExecuteReader(cmd); - try - { - while(reader.Read()) + try { - uuids.Add(new UUID(reader["UUID"].ToString())); + while (reader.Read()) + { + uuids.Add(new UUID(reader["UUID"].ToString())); + } + } + finally + { + reader.Close(); } - } - finally - { - reader.Close(); - } - cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + foreach (UUID uuid in uuids) + RemoveItems(uuid); - cmd.ExecuteNonQuery(); + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - cmd.CommandText = "delete from primshapes where UUID = ?UUID"; + ExecuteNonQuery(cmd); - foreach (UUID uuid in uuids) - { - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(uuid)); + cmd.CommandText = "delete from primshapes where UUID = ?UUID"; - cmd.ExecuteNonQuery(); + ExecuteNonQuery(cmd); + cmd.Dispose(); } - - cmd.Dispose(); - c.Close(); - - foreach (UUID uuid in uuids) - RemoveItems(uuid); } /// @@ -267,19 +321,18 @@ namespace OpenSim.Data.MySQL /// the Item UUID private void RemoveItems(UUID uuid) { - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "delete from primitems where " + - "PrimID = ?PrimID"; + cmd.CommandText = "delete from primitems where " + + "PrimID = ?PrimID"; - cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); - cmd.ExecuteNonQuery(); - cmd.Dispose(); - c.Close(); + ExecuteNonQuery(cmd); + cmd.Dispose(); + } } public List LoadObjects(UUID regionUUID) @@ -289,72 +342,71 @@ namespace OpenSim.Data.MySQL List prims = new List(); SceneObjectGroup grp = null; - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select *, " + - "case when prims.UUID = SceneGroupID " + - "then 0 else 1 end as sort from prims " + - "left join primshapes on prims.UUID = primshapes.UUID "+ - "where RegionUUID = ?RegionUUID " + - "order by SceneGroupID asc, sort asc, LinkNumber asc"; - - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionUUID)); + cmd.CommandText = "select *, " + + "case when prims.UUID = SceneGroupID " + + "then 0 else 1 end as sort from prims " + + "left join primshapes on prims.UUID = primshapes.UUID "+ + "where RegionUUID = ?RegionUUID " + + "order by SceneGroupID asc, sort asc, LinkNumber asc"; + + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionUUID)); - IDataReader reader = cmd.ExecuteReader(); + IDataReader reader = ExecuteReader(cmd); - try - { - while (reader.Read()) + try { - SceneObjectPart prim = BuildPrim(reader); - if (reader["Shape"] is DBNull) - prim.Shape = PrimitiveBaseShape.Default; - else - prim.Shape = BuildShape(reader); + while (reader.Read()) + { + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); - prim.FolderID = prim.UUID; // A relic from when we - // we thought prims contained - // folder objects. In - // reality, prim == folder - prims.Add(prim); + prim.FolderID = prim.UUID; // A relic from when we + // we thought prims contained + // folder objects. In + // reality, prim == folder + prims.Add(prim); - UUID groupID = new UUID(reader["SceneGroupID"].ToString()); + UUID groupID = new UUID(reader["SceneGroupID"].ToString()); - if (groupID != lastGroupID) // New SOG - { - if (grp != null) - objects.Add(grp); + if (groupID != lastGroupID) // New SOG + { + if (grp != null) + objects.Add(grp); - lastGroupID = groupID; + lastGroupID = groupID; - grp = new SceneObjectGroup(prim); - } - else - { - // Black magic to preserve link numbers - // - int link = prim.LinkNum; + grp = new SceneObjectGroup(prim); + } + else + { + // Black magic to preserve link numbers + // + int link = prim.LinkNum; - grp.AddPart(prim); + grp.AddPart(prim); - if (link != 0) - prim.LinkNum = link; + if (link != 0) + prim.LinkNum = link; + } } } - } - finally - { - reader.Close(); - } + finally + { + reader.Close(); + } - if (grp != null) - objects.Add(grp); - cmd.Dispose(); - c.Close(); + if (grp != null) + objects.Add(grp); + cmd.Dispose(); + } foreach (SceneObjectPart part in prims) LoadItems(part); @@ -370,332 +422,320 @@ namespace OpenSim.Data.MySQL /// The prim private void LoadItems(SceneObjectPart prim) { - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select * from primitems where "+ - "PrimID = ?PrimID"; + cmd.CommandText = "select * from primitems where "+ + "PrimID = ?PrimID"; - cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); - IDataReader reader = cmd.ExecuteReader(); - List inventory = - new List(); + IDataReader reader = ExecuteReader(cmd); + List inventory = + new List(); - try - { - while (reader.Read()) + try { - TaskInventoryItem item = BuildItem(reader); + while (reader.Read()) + { + TaskInventoryItem item = BuildItem(reader); - item.ParentID = prim.UUID; // Values in database are - // often wrong - inventory.Add(item); + item.ParentID = prim.UUID; // Values in database are + // often wrong + inventory.Add(item); + } + } + finally + { + reader.Close(); } - } - finally - { - reader.Close(); - } - cmd.Dispose(); - c.Close(); - prim.Inventory.RestoreInventoryItems(inventory); + cmd.Dispose(); + prim.Inventory.RestoreInventoryItems(inventory); + } } public void StoreTerrain(double[,] ter, UUID regionID) { m_log.Info("[REGION DB]: Storing terrain"); - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); - - cmd.CommandText = "delete from terrain where " + - "RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionID)); - - cmd.ExecuteNonQuery(); - - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; - - cmd.Parameters.AddWithValue("Heightfield", - SerializeTerrain(ter)); - - cmd.ExecuteNonQuery(); - cmd.Dispose(); - c.Close(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "delete from terrain where " + + "RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionID)); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "insert into terrain (RegionUUID, " + + "Revision, Heightfield) values (?RegionUUID, " + + "1, ?Heightfield)"; + + cmd.Parameters.AddWithValue("Heightfield", + SerializeTerrain(ter)); + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } } public double[,] LoadTerrain(UUID regionID) { - double[,] terrain = new double[256,256]; - terrain.Initialize(); - - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); + double[,] terrain = null; - MySqlCommand cmd = c.CreateCommand(); - - cmd.CommandText = "select RegionUUID, Revision, Heightfield " + - "from terrain where RegionUUID = ?RegionUUID "+ - "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID)); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID "+ + "order by Revision desc limit 1"; + cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID)); - IDataReader reader = cmd.ExecuteReader(); + IDataReader reader = ExecuteReader(cmd); - try - { - while (reader.Read()) + try { - MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); - int rev = 0; - - BinaryReader br = new BinaryReader(mstr); - for (int x = 0; x < 256; x++) + while (reader.Read()) { - for (int y = 0; y < 256; y++) + terrain = new double[256,256]; + terrain.Initialize(); + + MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); + int rev = 0; + + BinaryReader br = new BinaryReader(mstr); + for (int x = 0; x < 256; x++) { - terrain[x, y] = br.ReadDouble(); + for (int y = 0; y < 256; y++) + { + terrain[x, y] = br.ReadDouble(); + } + rev = Convert.ToInt32(reader["Revision"]); } - rev = Convert.ToInt32(reader["Revision"]); + m_log.InfoFormat("[REGION DB]: Loaded terrain " + + "revision r{0}", rev); } - m_log.InfoFormat("[REGION DB]: Loaded terrain " + - "revision r{0}", rev); - + } + finally + { reader.Close(); - cmd.Dispose(); - c.Close(); - return terrain; } + cmd.Dispose(); } - catch (Exception) - { - } - reader.Close(); - cmd.Dispose(); - c.Close(); return null; } public void RemoveLandObject(UUID globalID) { - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "delete from land where UUID = ?UUID"; + cmd.CommandText = "delete from land where UUID = ?UUID"; - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); + cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); - cmd.ExecuteNonQuery(); - cmd.Dispose(); - c.Close(); + ExecuteNonQuery(cmd); + cmd.Dispose(); + } } public void StoreLandObject(ILandObject parcel) { - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); - - cmd.CommandText = "replace into land (UUID, RegionUUID, " + - "LocalLandID, Bitmap, Name, Description, " + - "OwnerUUID, IsGroupOwned, Area, AuctionID, " + - "Category, ClaimDate, ClaimPrice, GroupUUID, " + - "SalePrice, LandStatus, LandFlags, LandingType, " + - "MediaAutoScale, MediaTextureUUID, MediaURL, " + - "MusicURL, PassHours, PassPrice, SnapshotUUID, " + - "UserLocationX, UserLocationY, UserLocationZ, " + - "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, Dwell) values (" + - "?UUID, ?RegionUUID, " + - "?LocalLandID, ?Bitmap, ?Name, ?Description, " + - "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + - "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + - "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + - "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + - "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + - "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + - "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; - - FillLandCommand(cmd, parcel.landData, parcel.regionUUID); - - cmd.ExecuteNonQuery(); - - cmd.CommandText = "delete from landaccesslist where " + - "LandUUID = ?UUID"; - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; - - foreach (ParcelManager.ParcelAccessEntry entry in - parcel.landData.ParcelAccessList) + lock (m_Connection) { - FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); - cmd.ExecuteNonQuery(); + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "replace into land (UUID, RegionUUID, " + + "LocalLandID, Bitmap, Name, Description, " + + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + + "Category, ClaimDate, ClaimPrice, GroupUUID, " + + "SalePrice, LandStatus, LandFlags, LandingType, " + + "MediaAutoScale, MediaTextureUUID, MediaURL, " + + "MusicURL, PassHours, PassPrice, SnapshotUUID, " + + "UserLocationX, UserLocationY, UserLocationZ, " + + "UserLookAtX, UserLookAtY, UserLookAtZ, " + + "AuthbuyerID, OtherCleanTime, Dwell) values (" + + "?UUID, ?RegionUUID, " + + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + + "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + + "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + + "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + + "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; + + FillLandCommand(cmd, parcel.landData, parcel.regionUUID); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "delete from landaccesslist where " + + "LandUUID = ?UUID"; + + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in + parcel.landData.ParcelAccessList) + { + FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + } + cmd.Dispose(); } - cmd.Dispose(); - c.Close(); } public RegionSettings LoadRegionSettings(UUID regionUUID) { RegionSettings rs = null; - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select * from regionsettings where " + - "regionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("regionUUID", regionUUID); + cmd.CommandText = "select * from regionsettings where " + + "regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); - IDataReader reader = cmd.ExecuteReader(); + IDataReader reader = ExecuteReader(cmd); - try - { - if (reader.Read()) + try { - rs = BuildRegionSettings(reader); - rs.OnSave += StoreRegionSettings; + if (reader.Read()) + { + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; + } + else + { + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; + + StoreRegionSettings(rs); + } } - else + finally { - rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; - - StoreRegionSettings(rs); + reader.Close(); } + cmd.Dispose(); } - finally - { - reader.Close(); - } - cmd.Dispose(); - c.Close(); return rs; } public void StoreRegionSettings(RegionSettings rs) { - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); - - cmd.CommandText = "replace into regionsettings (regionUUID, " + - "block_terraform, block_fly, allow_damage, " + - "restrict_pushing, allow_land_resell, " + - "allow_land_join_divide, block_show_in_search, " + - "agent_limit, object_bonus, maturity, " + - "disable_scripts, disable_collisions, " + - "disable_physics, terrain_texture_1, " + - "terrain_texture_2, terrain_texture_3, " + - "terrain_texture_4, elevation_1_nw, " + - "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, "+ - "elevation_2_se, elevation_1_sw, "+ - "elevation_2_sw, water_height, " + - "terrain_raise_limit, terrain_lower_limit, " + - "use_estate_sun, fixed_sun, sun_position, " + - "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " + - "?BlockFly, ?AllowDamage, ?RestrictPushing, " + - "?AllowLandResell, ?AllowLandJoinDivide, " + - "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + - "?Maturity, ?DisableScripts, ?DisableCollisions, " + - "?DisablePhysics, ?TerrainTexture1, " + - "?TerrainTexture2, ?TerrainTexture3, " + - "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + - "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + - "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + - "?WaterHeight, ?TerrainRaiseLimit, " + - "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ)"; - - FillRegionSettingsCommand(cmd, rs); - - cmd.ExecuteNonQuery(); - cmd.Dispose(); - c.Close(); + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, "+ + "elevation_2_se, elevation_1_sw, "+ + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ)"; + + FillRegionSettingsCommand(cmd, rs); + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } } public List LoadLandObjects(UUID regionUUID) { List landData = new List(); - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); - - cmd.CommandText = "select * from land where " + - "RegionUUID = ?RegionUUID"; - - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionUUID)); - - IDataReader reader = cmd.ExecuteReader(); - - try - { - while (reader.Read()) - { - LandData newLand = BuildLandData(reader); - landData.Add(newLand); - } - } - finally + lock (m_Connection) { - reader.Close(); - } + MySqlCommand cmd = m_Connection.CreateCommand(); - foreach (LandData land in landData) - { - cmd.Parameters.Clear(); + cmd.CommandText = "select * from land where " + + "RegionUUID = ?RegionUUID"; - cmd.CommandText = "select * from landaccesslist " + - "where LandUUID = ?LandUUID"; + cmd.Parameters.AddWithValue("RegionUUID", + Util.ToRawUuidString(regionUUID)); - cmd.Parameters.AddWithValue("LandUUID", - Util.ToRawUuidString(land.GlobalID)); - - reader = cmd.ExecuteReader(); + IDataReader reader = ExecuteReader(cmd); try { while (reader.Read()) { - land.ParcelAccessList.Add(BuildLandAccessData(reader)); + LandData newLand = BuildLandData(reader); + landData.Add(newLand); } } finally { reader.Close(); } + + foreach (LandData land in landData) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "select * from landaccesslist " + + "where LandUUID = ?LandUUID"; + + cmd.Parameters.AddWithValue("LandUUID", + Util.ToRawUuidString(land.GlobalID)); + + reader = ExecuteReader(cmd); + + try + { + while (reader.Read()) + { + land.ParcelAccessList.Add(BuildLandAccessData(reader)); + } + } + finally + { + reader.Close(); + } + } + cmd.Dispose(); } - cmd.Dispose(); - c.Close(); return landData; } @@ -1379,42 +1419,41 @@ byte[] textureEntry = (byte[]) row["Texture"]; public void StorePrimInventory(UUID primID, ICollection items) { - RemoveItems(primID); - - MySqlConnection c = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - c.Open(); - - MySqlCommand cmd = c.CreateCommand(); - - if (items.Count == 0) - return; - - cmd.CommandText = "insert into primitems ("+ - "invType, assetType, name, "+ - "description, creationDate, nextPermissions, "+ - "currentPermissions, basePermissions, "+ - "everyonePermissions, groupPermissions, "+ - "flags, itemID, primID, assetID, "+ - "parentFolderID, creatorID, ownerID, "+ - "groupID, lastOwnerID) values (?invType, "+ - "?assetType, ?name, ?description, "+ - "?creationDate, ?nextPermissions, "+ - "?currentPermissions, ?basePermissions, "+ - "?everyonePermissions, ?groupPermissions, "+ - "?flags, ?itemID, ?primID, ?assetID, "+ - "?parentFolderID, ?creatorID, ?ownerID, "+ - "?groupID, ?lastOwnerID)"; - - foreach (TaskInventoryItem item in items) + lock (m_Connection) { - cmd.Parameters.Clear(); + RemoveItems(primID); + + MySqlCommand cmd = m_Connection.CreateCommand(); + + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems ("+ + "invType, assetType, name, "+ + "description, creationDate, nextPermissions, "+ + "currentPermissions, basePermissions, "+ + "everyonePermissions, groupPermissions, "+ + "flags, itemID, primID, assetID, "+ + "parentFolderID, creatorID, ownerID, "+ + "groupID, lastOwnerID) values (?invType, "+ + "?assetType, ?name, ?description, "+ + "?creationDate, ?nextPermissions, "+ + "?currentPermissions, ?basePermissions, "+ + "?everyonePermissions, ?groupPermissions, "+ + "?flags, ?itemID, ?primID, ?assetID, "+ + "?parentFolderID, ?creatorID, ?ownerID, "+ + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) + { + cmd.Parameters.Clear(); - FillItemCommand(cmd, item); + FillItemCommand(cmd, item); - cmd.ExecuteNonQuery(); + ExecuteNonQuery(cmd); + } + cmd.Dispose(); } - cmd.Dispose(); - c.Close(); } } } -- cgit v1.1 From 733faf9748bd675d2407d4969777c92549616eda Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 1 Dec 2008 19:08:58 +0000 Subject: Fix the terrain loader --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 73605f9..7efc375 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -527,7 +527,7 @@ namespace OpenSim.Data.MySQL cmd.Dispose(); } - return null; + return terrain; } public void RemoveLandObject(UUID globalID) -- cgit v1.1 From bf4ccf38582f21a718251f17579003525a6fd3c7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 2 Dec 2008 01:50:15 +0000 Subject: Catch all possible exceptions in the mysql module. It throws non-mysql exceptions as well. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 7efc375..53b561d 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -87,7 +87,7 @@ namespace OpenSim.Data.MySQL { r = c.ExecuteReader(); } - catch (MySqlException) + catch (Exception) { System.Threading.Thread.Sleep(500); @@ -120,7 +120,7 @@ namespace OpenSim.Data.MySQL { c.ExecuteNonQuery(); } - catch (MySqlException) + catch (Exception) { System.Threading.Thread.Sleep(500); -- cgit v1.1 From 26fd6c741f74b51f6bd090b4e6e5140d28936c2b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 2 Dec 2008 14:59:52 +0000 Subject: * Resolve http://opensimulator.org/mantis/view.php?id=2743 and http://opensimulator.org/mantis/view.php?id=2739 by no longer bothering to store or retrieve the local parentID in the region database * The original issue is that the now randomly generated local ids do not fit into the int parentID datatype * However, as far as I know it's actually pointless to store this local parent ID anyway (we already store the groupUUID), especially as we don't bother to store the localID (as opposed to UUID itself). * Conservatively, the actual column will be removed in a later commit --- OpenSim/Data/MySQL/MySQLRegionData.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 53b561d..8c49531 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -163,7 +163,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); cmd.CommandText = "replace into prims ("+ - "UUID, ParentID, CreationDate, "+ + "UUID, CreationDate, "+ "Name, Text, Description, "+ "SitName, TouchName, ObjectFlags, "+ "OwnerMask, NextOwnerMask, GroupMask, "+ @@ -196,7 +196,7 @@ namespace OpenSim.Data.MySQL "ColorR, ColorG, ColorB, ColorA, "+ "ParticleSystem, ClickAction, Material, "+ "CollisionSound, CollisionSoundVolume, "+ - "LinkNumber) values (" + "?UUID, ?ParentID, "+ + "LinkNumber) values (" + "?UUID, "+ "?CreationDate, ?Name, ?Text, "+ "?Description, ?SitName, ?TouchName, "+ "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ @@ -750,7 +750,6 @@ namespace OpenSim.Data.MySQL prim.UUID = new UUID((String) row["UUID"]); // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. - prim.ParentID = Convert.ToUInt32(row["ParentID"]); prim.CreationDate = Convert.ToInt32(row["CreationDate"]); prim.Name = (String) row["Name"]; // various text fields @@ -1067,7 +1066,7 @@ namespace OpenSim.Data.MySQL } /// - /// + /// Fill the prim command with prim values /// /// /// @@ -1077,7 +1076,6 @@ namespace OpenSim.Data.MySQL { cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID)); cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID)); - cmd.Parameters.AddWithValue("ParentID", prim.ParentID); cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); cmd.Parameters.AddWithValue("Name", prim.Name); cmd.Parameters.AddWithValue("SceneGroupID", Util.ToRawUuidString(sceneGroupID)); -- cgit v1.1 From a260466147b47de1d51539b5c23429440d94124f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 8 Dec 2008 16:29:48 +0000 Subject: fix an issue I found where primshapes weren't every being removed because of a logic error. attempt to speed up deletes a bit by batching up all the primitem deletes and primshape deletes into single delete statements. This removes the lock/release/lock/release/lock/release for loop. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 91 +++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 8c49531..4dc0685 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -300,20 +300,22 @@ namespace OpenSim.Data.MySQL reader.Close(); } - foreach (UUID uuid in uuids) - RemoveItems(uuid); - + // delete the main prims cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - - ExecuteNonQuery(cmd); - - cmd.CommandText = "delete from primshapes where UUID = ?UUID"; - ExecuteNonQuery(cmd); cmd.Dispose(); + + // there is no way this should be < 1 unless there is + // a very corrupt database, but in that case be extra + // safe anyway. + if (uuids.Count > 0) + { + RemoveShapes(uuids); + RemoveItems(uuids); + } } } - + /// /// Remove all persisted items of the given prim. /// The caller must acquire the necessrary synchronization locks @@ -335,6 +337,77 @@ namespace OpenSim.Data.MySQL } } + + /// + /// Remove all persisted shapes for a list of prims + /// The caller must acquire the necessrary synchronization locks + /// + /// the list of UUIDs + private void RemoveShapes(List uuids) + { + lock (m_Connection) + { + string sql = "delete from primshapes where "; + MySqlCommand cmd = m_Connection.CreateCommand(); + + for (int i = 0; i < uuids.Count; i++) + { + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(UUID = ?UUID" + i + ")"; + } + else + { + sql += "(UUID = ?UUID" + i + ") or "; + } + } + cmd.CommandText = sql; + + for (int i = 0; i < uuids.Count; i++) + { + cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); + } + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + + /// + /// Remove all persisted items for a list of prims + /// The caller must acquire the necessrary synchronization locks + /// + /// the list of UUIDs + private void RemoveItems(List uuids) + { + lock (m_Connection) + { + string sql = "delete from primitems where "; + MySqlCommand cmd = m_Connection.CreateCommand(); + + for (int i = 0; i < uuids.Count; i++) + { + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(PrimID = ?PrimID" + i + ")"; + } + else + { + sql += "(PrimID = ?PrimID" + i + ") or "; + } + } + cmd.CommandText = sql; + + for (int i = 0; i < uuids.Count; i++) + { + cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); + } + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + public List LoadObjects(UUID regionUUID) { UUID lastGroupID = UUID.Zero; -- cgit v1.1 From 444436db15909a91c2b1b2d4153032a13691440b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 8 Dec 2008 17:06:47 +0000 Subject: change a UUID cast to an actual new UUID call to be consistant with the rest of the assignments here. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 4dc0685..b8da7c3 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1049,7 +1049,7 @@ namespace OpenSim.Data.MySQL newData.Name = (String) row["Name"]; newData.Description = (String) row["Description"]; - newData.OwnerID = (UUID)(String)row["OwnerUUID"]; + newData.OwnerID = new UUID((String)row["OwnerUUID"]); newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); newData.Area = Convert.ToInt32(row["Area"]); newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented -- cgit v1.1 From fb49e010b781b33c6c7cc52f88aed0dcf6f8a721 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Mon, 22 Dec 2008 19:49:17 +0000 Subject: Update the MySQL connector to 5.2.5. Fixes Mantids#2673. Thanks for the hint, jhurliman. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4b51bda..23077f1 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -142,7 +142,7 @@ namespace OpenSim.Data.MySQL asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; asset.FullID = assetID; - asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false; + asset.Local = (bool)dbReader["local"]; asset.Name = (string) dbReader["name"]; asset.Type = (sbyte) dbReader["assetType"]; } -- cgit v1.1 From e64d9b66a9cb58d66c76cca2984801e2d056504c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 23 Dec 2008 20:41:52 +0000 Subject: * Fix http://opensimulator.org/mantis/view.php?id=2889 * Primshapes uuid wasn't being converted to raw (non-dashed) format before being used in primshapes delete command --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index b8da7c3..a06dbb3 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -365,7 +365,7 @@ namespace OpenSim.Data.MySQL for (int i = 0; i < uuids.Count; i++) { - cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); + cmd.Parameters.AddWithValue("UUID" + i, Util.ToRawUuidString(uuids[i])); } ExecuteNonQuery(cmd); @@ -1437,7 +1437,7 @@ namespace OpenSim.Data.MySQL s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); -byte[] textureEntry = (byte[]) row["Texture"]; + byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; s.ExtraParams = (byte[]) row["ExtraParams"]; -- cgit v1.1 From d8a2ad5cb5afd9bb16c4696ce841b846deef1190 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 5 Jan 2009 15:59:08 +0000 Subject: change the drop order to see if this affects unit test fails From: Sean Dague --- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index 5e6b7f9..6f95c6c 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -76,9 +76,9 @@ namespace OpenSim.Data.MySQL.Tests } if (database != null) { - database.ExecuteSql("drop table migrations"); database.ExecuteSql("drop table inventoryitems"); database.ExecuteSql("drop table inventoryfolders"); + database.ExecuteSql("drop table migrations"); } } } -- cgit v1.1 From 8d035b196df31ddb41e4917a757e83acdbb03d78 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 7 Jan 2009 18:46:27 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=2948 * This fixes adding and updating user profiles in MySQL on platforms that have a commas as a decimal separator * Thanks Tommil! --- OpenSim/Data/MySQL/MySQLGridData.cs | 12 +++--- OpenSim/Data/MySQL/MySQLManager.cs | 74 ++++++++++++++++++------------------- OpenSim/Data/MySQL/MySQLUserData.cs | 24 ++++++------ 3 files changed, 55 insertions(+), 55 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index da01ad3..437747b 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -245,7 +245,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?xmin"] = xmin.ToString(); param["?ymin"] = ymin.ToString(); param["?xmax"] = xmax.ToString(); @@ -294,7 +294,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; IDbCommand result = @@ -339,7 +339,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?handle"] = handle.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); @@ -374,7 +374,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); @@ -409,7 +409,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); // Add % because this is a like query. param["?regionName"] = regionName + "%"; // Order by statement will return shorter matches first. Only returns one record or no record. @@ -546,7 +546,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?x"] = x.ToString(); param["?y"] = y.ToString(); IDbCommand result = diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a54c020..f16795e 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -340,7 +340,7 @@ namespace OpenSim.Data.MySQL /// The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y /// The parameters - index so that @y is indexed as 'y' /// A MySQL DB Command - public IDbCommand Query(string sql, Dictionary parameters) + public IDbCommand Query(string sql, Dictionary parameters) { try { @@ -348,7 +348,7 @@ namespace OpenSim.Data.MySQL MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; - foreach (KeyValuePair param in parameters) + foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } @@ -714,7 +714,7 @@ namespace OpenSim.Data.MySQL string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?server"] = serverDaemon; parameters["?target"] = target; parameters["?method"] = methodCall; @@ -793,34 +793,34 @@ namespace OpenSim.Data.MySQL "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); parameters["?username"] = username; parameters["?lastname"] = lastname; parameters["?email"] = email; parameters["?passwordHash"] = passwordHash; parameters["?passwordSalt"] = passwordSalt; - parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegion"] = homeRegion; parameters["?homeRegionID"] = homeRegionID.ToString(); - parameters["?homeLocationX"] = homeLocX.ToString(); - parameters["?homeLocationY"] = homeLocY.ToString(); - parameters["?homeLocationZ"] = homeLocZ.ToString(); - parameters["?homeLookAtX"] = homeLookAtX.ToString(); - parameters["?homeLookAtY"] = homeLookAtY.ToString(); - parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); - parameters["?created"] = created.ToString(); - parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?homeLocationX"] = homeLocX; + parameters["?homeLocationY"] = homeLocY; + parameters["?homeLocationZ"] = homeLocZ; + parameters["?homeLookAtX"] = homeLookAtX; + parameters["?homeLookAtY"] = homeLookAtY; + parameters["?homeLookAtZ"] = homeLookAtZ; + parameters["?created"] = created; + parameters["?lastLogin"] = lastlogin; parameters["?userInventoryURI"] = inventoryURI; parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = canDoMask.ToString(); - parameters["?profileWantDoMask"] = wantDoMask.ToString(); + parameters["?profileCanDoMask"] = canDoMask; + parameters["?profileWantDoMask"] = wantDoMask; parameters["?profileAboutText"] = aboutText; parameters["?profileFirstText"] = firstText; parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); - parameters["?userFlags"] = userFlags.ToString(); - parameters["?godLevel"] = godLevel.ToString(); + parameters["?userFlags"] = userFlags; + parameters["?godLevel"] = godLevel; parameters["?customType"] = customType == null ? "" : customType; parameters["?partner"] = partner.ToString(); bool returnval = false; @@ -892,35 +892,35 @@ namespace OpenSim.Data.MySQL sql += "`customType` = ?customType , `partner` = ?partner , "; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?UUID"] = uuid.ToString(); parameters["?username"] = username; parameters["?lastname"] = lastname; parameters["?email"] = email; parameters["?passwordHash"] = passwordHash; parameters["?passwordSalt"] = passwordSalt; - parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegion"] = homeRegion; parameters["?homeRegionID"] = homeRegionID.ToString(); - parameters["?homeLocationX"] = homeLocX.ToString(); - parameters["?homeLocationY"] = homeLocY.ToString(); - parameters["?homeLocationZ"] = homeLocZ.ToString(); - parameters["?homeLookAtX"] = homeLookAtX.ToString(); - parameters["?homeLookAtY"] = homeLookAtY.ToString(); - parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); - parameters["?created"] = created.ToString(); - parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?homeLocationX"] = homeLocX; + parameters["?homeLocationY"] = homeLocY; + parameters["?homeLocationZ"] = homeLocZ; + parameters["?homeLookAtX"] = homeLookAtX; + parameters["?homeLookAtY"] = homeLookAtY; + parameters["?homeLookAtZ"] = homeLookAtZ; + parameters["?created"] = created; + parameters["?lastLogin"] = lastlogin; parameters["?userInventoryURI"] = inventoryURI; parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = canDoMask.ToString(); - parameters["?profileWantDoMask"] = wantDoMask.ToString(); + parameters["?profileCanDoMask"] = canDoMask; + parameters["?profileWantDoMask"] = wantDoMask; parameters["?profileAboutText"] = aboutText; parameters["?profileFirstText"] = firstText; parameters["?profileImage"] = profileImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString(); - parameters["?userFlags"] = userFlags.ToString(); - parameters["?godLevel"] = godLevel.ToString(); - parameters["?customType"] = customType == null ? "" : customType.ToString(); + parameters["?userFlags"] = userFlags; + parameters["?godLevel"] = godLevel; + parameters["?customType"] = customType == null ? "" : customType; parameters["?partner"] = partner.ToString(); bool returnval = false; @@ -993,7 +993,7 @@ namespace OpenSim.Data.MySQL sql += ";"; } - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?regionHandle"] = regiondata.regionHandle.ToString(); parameters["?regionName"] = regiondata.regionName.ToString(); @@ -1063,7 +1063,7 @@ namespace OpenSim.Data.MySQL string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); try { @@ -1102,7 +1102,7 @@ namespace OpenSim.Data.MySQL sql += "REPLACE INTO "; sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES "; sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);"; - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters["?UUID"] = agentdata.ProfileID.ToString(); parameters["?sessionID"] = agentdata.SessionID.ToString(); @@ -1114,8 +1114,8 @@ namespace OpenSim.Data.MySQL parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); parameters["?currentRegion"] = agentdata.Region.ToString(); parameters["?currentHandle"] = agentdata.Handle.ToString(); - parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString() + "," + (agentdata.Position.Y).ToString() + "," + (agentdata.Position.Z).ToString() + ">"; - parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString() + "," + (agentdata.LookAt.Y).ToString() + "," + (agentdata.LookAt.Z).ToString() + ">"; + parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString().Replace(",", ".") + "," + (agentdata.Position.Y).ToString().Replace(",", ".") + "," + (agentdata.Position.Z).ToString().Replace(",", ".") + ">"; + parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Y).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Z).ToString().Replace(",", ".") + ">"; bool returnval = false; diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 14d178b..f6a9af3 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -176,7 +176,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?first"] = user; param["?second"] = last; @@ -209,7 +209,7 @@ namespace OpenSim.Data.MySQL { int dtvalue = Util.UnixTimeSinceEpoch(); - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); @@ -251,7 +251,7 @@ namespace OpenSim.Data.MySQL public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); @@ -285,7 +285,7 @@ namespace OpenSim.Data.MySQL public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); @@ -318,7 +318,7 @@ namespace OpenSim.Data.MySQL { List Lfli = new List(); - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); @@ -373,7 +373,7 @@ namespace OpenSim.Data.MySQL { foreach (UUID uuid in uuids) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + @@ -419,7 +419,7 @@ namespace OpenSim.Data.MySQL querysplit = query.Split(' '); if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); @@ -461,7 +461,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; IDbCommand result = @@ -506,7 +506,7 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID"); try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); @@ -596,7 +596,7 @@ namespace OpenSim.Data.MySQL try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", @@ -744,7 +744,7 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance"); try { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); IDbCommand result = dbm.Manager.Query( @@ -825,7 +825,7 @@ namespace OpenSim.Data.MySQL public Hashtable GetUserAttachments(UUID agentID) { - Dictionary param = new Dictionary(); + Dictionary param = new Dictionary(); param["?uuid"] = agentID.ToString(); MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); -- cgit v1.1 From 7934094cf304a180e20201379fa2825570ad8ad3 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 14 Jan 2009 19:34:14 +0000 Subject: * Added MySQL Grid unit tests From: Arthur Rodrigo S Valadares --- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 OpenSim/Data/MySQL/Tests/MySQLGridTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs new file mode 100644 index 0000000..e6df085 --- /dev/null +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -0,0 +1,83 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Environment.Scenes; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLGridTest : BasicGridTest + { + public string file; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. + try + { + database = new MySQLManager(connect); + db = new MySQLGridData(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } + } + + [TestFixtureTearDown] + public void Cleanup() + { + if (db != null) + { + db.Dispose(); + } + // if a new table is added, it has to be dropped here + if (database != null) + { + database.ExecuteSql("drop table regions"); + } + } + } +} \ No newline at end of file -- cgit v1.1 From c5395feadd0af49cfdb21f31eae8180330c75c2b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 18 Jan 2009 23:31:13 +0000 Subject: Avoid an invalid cast on legacy data --- OpenSim/Data/MySQL/MySQLAssetData.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 23077f1..d4a7980 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -142,7 +142,14 @@ namespace OpenSim.Data.MySQL asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; asset.FullID = assetID; - asset.Local = (bool)dbReader["local"]; + try + { + asset.Local = (bool)dbReader["local"]; + } + catch (System.InvalidCastException) + { + asset.Local = false; + } asset.Name = (string) dbReader["name"]; asset.Type = (sbyte) dbReader["assetType"]; } -- cgit v1.1 From 0828c28501cfb14100d1270924ec77a8877ba94e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 19 Jan 2009 15:16:17 +0000 Subject: * Remove unused prims.ParentID field from SQLite and MySQL * Since this is a db change, as always I strongly recommend that you backup your database before updating to this revision * Haven't touched MSSQL in case I get it wrong - looking for some kind soul to take care of this. --- OpenSim/Data/MySQL/Resources/027_RegionStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/027_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/027_RegionStore.sql b/OpenSim/Data/MySQL/Resources/027_RegionStore.sql new file mode 100644 index 0000000..e1efab3 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/027_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE prims DROP COLUMN ParentID; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 7aa216d574897005c6d54e02e3e968e42d52f502 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 28 Jan 2009 01:55:45 +0000 Subject: Slight cleanup of docs, removing trailing whitespace. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index d4a7980..1e66618 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -45,7 +45,7 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private MySQLManager _dbConnection; - private long TicksToEpoch; + private long TicksToEpoch; #region IPlugin Members @@ -93,9 +93,8 @@ namespace OpenSim.Data.MySQL /// /// /// - /// connect string - /// Probably DEPRECATED and shouldn't be used - override public void Initialise() + /// DEPRECATED and shouldn't be used + public override void Initialise() { IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); @@ -109,7 +108,7 @@ namespace OpenSim.Data.MySQL } - override public void Dispose() { } + public override void Dispose() { } #region IAssetProviderPlugin Members @@ -257,7 +256,7 @@ namespace OpenSim.Data.MySQL _dbConnection.Reconnect(); } } - + } /// -- cgit v1.1 From 13f069b945b10ccdcb7ffd26392a0c9166914852 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 29 Jan 2009 20:08:04 +0000 Subject: * If an orphaned group is found in the mysql or mssql databases (i.e. there is no prim where UUID = SceneGroupID), then force one prim to have UUID = SceneGroupID. * A warning is posted about this on startup giving the location of the object * This should allow one class of persistently undeletable prims to be removed * This change should not cause any issues, but I still suggest that you backup your database beforehand * If this doesn't work for previously linked objects, then you could also try the workaround in http://opensimulator.org/mantis/view.php?id=3059 * This change has been made to mysql and mssql, but sqlite appears to work in a different way --- OpenSim/Data/MySQL/MySQLRegionData.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a06dbb3..e1ddb54 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -455,6 +455,20 @@ namespace OpenSim.Data.MySQL objects.Add(grp); lastGroupID = groupID; + + // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are + // recorded as the root prim (for which the UUID must equal the persisted group UUID). In + // this case, force the UUID to be the same as the group UUID so that at least these can be + // deleted (we need to change the UUID so that any other prims in the linkset can also be + // deleted). + if (prim.UUID != groupID && groupID != UUID.Zero) + { + m_log.WarnFormat( + "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", + prim.Name, prim.UUID, prim.GroupPosition, groupID); + + prim.UUID = groupID; + } grp = new SceneObjectGroup(prim); } @@ -484,7 +498,7 @@ namespace OpenSim.Data.MySQL foreach (SceneObjectPart part in prims) LoadItems(part); - m_log.DebugFormat("[DATABASE] Loaded {0} objects using {1} prims", objects.Count, prims.Count); + m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); return objects; } -- cgit v1.1 From f8e45e8e981bfd87f3765d7452046515e11a9345 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:03 +0000 Subject: Rename IAssetProviderPlugin to IAssetDataPlugin aligning with the other data plugins. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 1e66618..3ff2a1a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -110,7 +110,7 @@ namespace OpenSim.Data.MySQL public override void Dispose() { } - #region IAssetProviderPlugin Members + #region IAssetDataPlugin Members /// /// Fetch Asset from database -- cgit v1.1 From 0c03a48fb2060eda4d288e2d2ca4e650ce000b4b Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 4 Feb 2009 00:01:36 +0000 Subject: - add OpenSim.Framework.AssetMetadata class. AssetBase is now composed of it - trim trailing whitespace --- OpenSim/Data/MySQL/MySQLAssetData.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 3ff2a1a..823fa78 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -139,18 +139,18 @@ namespace OpenSim.Data.MySQL { asset = new AssetBase(); asset.Data = (byte[]) dbReader["data"]; - asset.Description = (string) dbReader["description"]; - asset.FullID = assetID; + asset.Metadata.Description = (string) dbReader["description"]; + asset.Metadata.FullID = assetID; try { - asset.Local = (bool)dbReader["local"]; + asset.Metadata.Local = (bool)dbReader["local"]; } catch (System.InvalidCastException) { - asset.Local = false; + asset.Metadata.Local = false; } - asset.Name = (string) dbReader["name"]; - asset.Type = (sbyte) dbReader["assetType"]; + asset.Metadata.Name = (string) dbReader["name"]; + asset.Metadata.Type = (sbyte) dbReader["assetType"]; } dbReader.Close(); cmd.Dispose(); @@ -178,8 +178,8 @@ namespace OpenSim.Data.MySQL { lock (_dbConnection) { - //m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); - if (ExistsAsset(asset.FullID)) + //m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.Metadata.FullID)); + if (ExistsAsset(asset.Metadata.FullID)) { //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); return; @@ -200,12 +200,12 @@ namespace OpenSim.Data.MySQL { // create unix epoch time int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); - cmd.Parameters.AddWithValue("?id", asset.FullID.ToString()); - cmd.Parameters.AddWithValue("?name", asset.Name); - cmd.Parameters.AddWithValue("?description", asset.Description); - cmd.Parameters.AddWithValue("?assetType", asset.Type); - cmd.Parameters.AddWithValue("?local", asset.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?id", asset.Metadata.ID); + cmd.Parameters.AddWithValue("?name", asset.Metadata.Name); + cmd.Parameters.AddWithValue("?description", asset.Metadata.Description); + cmd.Parameters.AddWithValue("?assetType", asset.Metadata.Type); + cmd.Parameters.AddWithValue("?local", asset.Metadata.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Metadata.Temporary); cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?access_time", now); cmd.Parameters.AddWithValue("?data", asset.Data); @@ -218,7 +218,7 @@ namespace OpenSim.Data.MySQL m_log.ErrorFormat( "[ASSETS DB]: " + "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + + Environment.NewLine + "Attempting reconnection", asset.Metadata.FullID, asset.Metadata.Name); _dbConnection.Reconnect(); } } @@ -241,7 +241,7 @@ namespace OpenSim.Data.MySQL { // create unix epoch time int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); - cmd.Parameters.AddWithValue("?id", asset.FullID.ToString()); + cmd.Parameters.AddWithValue("?id", asset.Metadata.ID); cmd.Parameters.AddWithValue("?access_time", now); cmd.ExecuteNonQuery(); cmd.Dispose(); @@ -252,7 +252,7 @@ namespace OpenSim.Data.MySQL m_log.ErrorFormat( "[ASSETS DB]: " + "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + + Environment.NewLine + "Attempting reconnection", asset.Metadata.FullID, asset.Metadata.Name); _dbConnection.Reconnect(); } } -- cgit v1.1 From 9b66108081a8c8cf79faaa6c541554091c40850e Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 6 Feb 2009 16:55:34 +0000 Subject: This changeset is the step 1 of 2 in refactoring OpenSim.Region.Environment into a "framework" part and a modules only part. This first changeset refactors OpenSim.Region.Environment.Scenes, OpenSim.Region.Environment.Interfaces, and OpenSim.Region.Interfaces into OpenSim.Region.Framework.{Interfaces,Scenes} leaving only region modules in OpenSim.Region.Environment. The next step will be to move region modules up from OpenSim.Region.Environment.Modules to OpenSim.Region.CoreModules and then sort out which modules are really core modules and which should move out to forge. I've been very careful to NOT BREAK anything. i hope i've succeeded. as this is the work of a whole week i hope i managed to keep track with the applied patches of the last week --- could any of you that did check in stuff have a look at whether it survived? thx! --- OpenSim/Data/MySQL/MySQLEstateData.cs | 4 ++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 57151b3..f811d84 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -35,8 +35,8 @@ using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; namespace OpenSim.Data.MySQL { diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e1ddb54..ab55ba5 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -36,8 +36,8 @@ using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; using OpenSim.Framework; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; namespace OpenSim.Data.MySQL { diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index 0419e21..0f7c9cd 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -33,7 +33,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenSim.Framework; using OpenSim.Data.Tests; using OpenSim.Data.MySQL; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Scenes; using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index e6df085..4638bca 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -33,7 +33,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenSim.Framework; using OpenSim.Data.Tests; using OpenSim.Data.MySQL; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Scenes; using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index 6f95c6c..8c7d820 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -33,7 +33,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenSim.Framework; using OpenSim.Data.Tests; using OpenSim.Data.MySQL; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Scenes; using OpenMetaverse; using log4net; diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index aed4cea..71e73c2 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -33,7 +33,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenSim.Framework; using OpenSim.Data.Tests; using OpenSim.Data.MySQL; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Scenes; using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs index c036f6c..8448dd7 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -33,7 +33,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenSim.Framework; using OpenSim.Data.Tests; using OpenSim.Data.MySQL; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Framework.Scenes; using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests -- cgit v1.1 From 29f54db90a07a51be5ca33f9edb972e1922f51a9 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 9 Feb 2009 22:07:27 +0000 Subject: Thank you kindly, TLaukkan (Timmil) for a patch that: * Fixed and added athursv's BasicEstateTest * Added MySQLEstateTest * Added SQLiteEstateTest --- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 99 +++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs new file mode 100644 index 0000000..17e71e1 --- /dev/null +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -0,0 +1,99 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLEstateTest : BasicEstateTest + { + public string file; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. + try + { + database = new MySQLManager(connect); + regionDb = new MySQLDataStore(); + regionDb.Initialise(connect); + db = new MySQLEstateStore(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } + } + + [TestFixtureTearDown] + public void Cleanup() + { + if (regionDb != null) + { + regionDb.Dispose(); + } + // if a new table is added, it has to be dropped here + if (database != null) + { + database.ExecuteSql("drop table migrations"); + database.ExecuteSql("drop table prims"); + database.ExecuteSql("drop table primshapes"); + database.ExecuteSql("drop table primitems"); + database.ExecuteSql("drop table terrain"); + database.ExecuteSql("drop table land"); + database.ExecuteSql("drop table landaccesslist"); + database.ExecuteSql("drop table regionban"); + database.ExecuteSql("drop table regionsettings"); + database.ExecuteSql("drop table estate_managers"); + database.ExecuteSql("drop table estate_groups"); + database.ExecuteSql("drop table estate_users"); + database.ExecuteSql("drop table estateban"); + database.ExecuteSql("drop table estate_settings"); + database.ExecuteSql("drop table estate_map"); + } + } + } +} -- cgit v1.1 From a3d14832af644ba228d13d7a62d4796c17911183 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 9 Feb 2009 22:49:05 +0000 Subject: Update svn properties, minor formatting cleanup. --- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 198 ++++++++++++++-------------- 1 file changed, 99 insertions(+), 99 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 17e71e1..bee3d04 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -1,99 +1,99 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.IO; -using System.Collections.Generic; -using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; -using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture] - public class MySQLEstateTest : BasicEstateTest - { - public string file; - public MySQLManager database; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - database = new MySQLManager(connect); - regionDb = new MySQLDataStore(); - regionDb.Initialise(connect); - db = new MySQLEstateStore(); - db.Initialise(connect); - } - catch (Exception e) - { - System.Console.WriteLine("Exception {0}", e); - Assert.Ignore(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - if (regionDb != null) - { - regionDb.Dispose(); - } - // if a new table is added, it has to be dropped here - if (database != null) - { - database.ExecuteSql("drop table migrations"); - database.ExecuteSql("drop table prims"); - database.ExecuteSql("drop table primshapes"); - database.ExecuteSql("drop table primitems"); - database.ExecuteSql("drop table terrain"); - database.ExecuteSql("drop table land"); - database.ExecuteSql("drop table landaccesslist"); - database.ExecuteSql("drop table regionban"); - database.ExecuteSql("drop table regionsettings"); - database.ExecuteSql("drop table estate_managers"); - database.ExecuteSql("drop table estate_groups"); - database.ExecuteSql("drop table estate_users"); - database.ExecuteSql("drop table estateban"); - database.ExecuteSql("drop table estate_settings"); - database.ExecuteSql("drop table estate_map"); - } - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenSim.Framework; +using OpenSim.Data.Tests; +using OpenSim.Data.MySQL; +using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL.Tests +{ + [TestFixture] + public class MySQLEstateTest : BasicEstateTest + { + public string file; + public MySQLManager database; + public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; + + [TestFixtureSetUp] + public void Init() + { + SuperInit(); + // If we manage to connect to the database with the user + // and password above it is our test database, and run + // these tests. If anything goes wrong, ignore these + // tests. + try + { + database = new MySQLManager(connect); + regionDb = new MySQLDataStore(); + regionDb.Initialise(connect); + db = new MySQLEstateStore(); + db.Initialise(connect); + } + catch (Exception e) + { + System.Console.WriteLine("Exception {0}", e); + Assert.Ignore(); + } + } + + [TestFixtureTearDown] + public void Cleanup() + { + if (regionDb != null) + { + regionDb.Dispose(); + } + // if a new table is added, it has to be dropped here + if (database != null) + { + database.ExecuteSql("drop table migrations"); + database.ExecuteSql("drop table prims"); + database.ExecuteSql("drop table primshapes"); + database.ExecuteSql("drop table primitems"); + database.ExecuteSql("drop table terrain"); + database.ExecuteSql("drop table land"); + database.ExecuteSql("drop table landaccesslist"); + database.ExecuteSql("drop table regionban"); + database.ExecuteSql("drop table regionsettings"); + database.ExecuteSql("drop table estate_managers"); + database.ExecuteSql("drop table estate_groups"); + database.ExecuteSql("drop table estate_users"); + database.ExecuteSql("drop table estateban"); + database.ExecuteSql("drop table estate_settings"); + database.ExecuteSql("drop table estate_map"); + } + } + } +} -- cgit v1.1 From 801da4346aeb3c08969c4845f5c595135a64470a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 12 Feb 2009 09:53:12 +0000 Subject: * optimized usings. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 12 +++++------- OpenSim/Data/MySQL/MySQLEstateData.cs | 11 ++++------- OpenSim/Data/MySQL/MySQLGridData.cs | 5 +++-- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLLogData.cs | 2 +- OpenSim/Data/MySQL/MySQLManager.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLRegionData.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLUserData.cs | 5 +++-- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 9 +-------- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 9 +-------- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 9 +-------- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 10 +--------- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 9 +-------- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 9 +-------- 14 files changed, 31 insertions(+), 77 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 823fa78..508e053 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -26,15 +26,13 @@ */ using System; -using System.Collections.Generic; using System.Data; using System.Reflection; -using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; +using OpenMetaverse; using OpenSim.Framework; - namespace OpenSim.Data.MySQL { /// @@ -62,7 +60,7 @@ namespace OpenSim.Data.MySQL /// connect string override public void Initialise(string connect) { - TicksToEpoch = new System.DateTime(1970,1,1).Ticks; + TicksToEpoch = new DateTime(1970,1,1).Ticks; // TODO: This will let you pass in the connect string in // the config, though someone will need to write that. @@ -145,7 +143,7 @@ namespace OpenSim.Data.MySQL { asset.Metadata.Local = (bool)dbReader["local"]; } - catch (System.InvalidCastException) + catch (InvalidCastException) { asset.Metadata.Local = false; } @@ -199,7 +197,7 @@ namespace OpenSim.Data.MySQL using (cmd) { // create unix epoch time - int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); + int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); cmd.Parameters.AddWithValue("?id", asset.Metadata.ID); cmd.Parameters.AddWithValue("?name", asset.Metadata.Name); cmd.Parameters.AddWithValue("?description", asset.Metadata.Description); @@ -240,7 +238,7 @@ namespace OpenSim.Data.MySQL using (cmd) { // create unix epoch time - int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); + int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); cmd.Parameters.AddWithValue("?id", asset.Metadata.ID); cmd.Parameters.AddWithValue("?access_time", now); cmd.ExecuteNonQuery(); diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index f811d84..5acbb9d 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -28,15 +28,12 @@ using System; using System.Collections.Generic; using System.Data; -using System.IO; using System.Reflection; -using System.Threading; -using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; namespace OpenSim.Data.MySQL { @@ -131,7 +128,7 @@ namespace OpenSim.Data.MySQL cmd.Dispose(); } - m_lastConnectionUse = System.DateTime.Now.Ticks; + m_lastConnectionUse = DateTime.Now.Ticks; m_log.DebugFormat( "[REGION DB]: Connection wait timeout {0} seconds", @@ -140,7 +137,7 @@ namespace OpenSim.Data.MySQL protected void CheckConnection() { - long timeNow = System.DateTime.Now.Ticks; + long timeNow = DateTime.Now.Ticks; if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) { @@ -185,7 +182,7 @@ namespace OpenSim.Data.MySQL else m_FieldMap[name].SetValue(es, false); } - else if (m_FieldMap[name].GetValue(es) is OpenMetaverse.UUID) + else if (m_FieldMap[name].GetValue(es) is UUID) { UUID uuid = UUID.Zero; diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 437747b..5c00330 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -29,8 +29,9 @@ using System; using System.Collections.Generic; using System.Data; using System.Reflection; -using OpenMetaverse; +using System.Threading; using log4net; +using OpenMetaverse; using OpenSim.Framework; namespace OpenSim.Data.MySQL @@ -78,7 +79,7 @@ namespace OpenSim.Data.MySQL if (lockedCons > m_maxConnections) { lockedCons = 0; - System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. + Thread.Sleep(1000); // Wait some time before searching them again. m_log.Debug( "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index efc781d..7d29061 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -28,9 +28,9 @@ using System; using System.Collections.Generic; using System.Reflection; -using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; +using OpenMetaverse; using OpenSim.Framework; namespace OpenSim.Data.MySQL diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index c02016c..13361af 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; -using System.Reflection; using System.Collections.Generic; +using System.Reflection; using log4net; using OpenSim.Framework; diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index f16795e..3bb6857 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -26,14 +26,14 @@ */ using System; -using System.Collections.Generic; using System.Collections; +using System.Collections.Generic; using System.Data; using System.IO; using System.Reflection; -using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; +using OpenMetaverse; using OpenSim.Framework; namespace OpenSim.Data.MySQL @@ -148,7 +148,7 @@ namespace OpenSim.Data.MySQL cmd.Dispose(); } - m_lastConnectionUse = System.DateTime.Now.Ticks; + m_lastConnectionUse = DateTime.Now.Ticks; m_log.DebugFormat( "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); @@ -161,7 +161,7 @@ namespace OpenSim.Data.MySQL { //m_log.Debug("[REGION DB]: Checking connection"); - long timeNow = System.DateTime.Now.Ticks; + long timeNow = DateTime.Now.Ticks; if (timeNow - m_lastConnectionUse > m_waitTimeout || dbcon.State != ConnectionState.Open) { m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ab55ba5..4b07ed6 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -28,13 +28,13 @@ using System; using System.Collections.Generic; using System.Data; +using System.Drawing; using System.IO; using System.Reflection; using System.Threading; -using System.Drawing; -using OpenMetaverse; using log4net; using MySql.Data.MySqlClient; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -89,7 +89,7 @@ namespace OpenSim.Data.MySQL } catch (Exception) { - System.Threading.Thread.Sleep(500); + Thread.Sleep(500); m_Connection.Close(); m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL } catch (Exception) { - System.Threading.Thread.Sleep(500); + Thread.Sleep(500); m_Connection.Close(); m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index f6a9af3..0f167b2 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -31,8 +31,9 @@ using System.Collections.Generic; using System.Data; using System.Reflection; using System.Text.RegularExpressions; -using OpenMetaverse; +using System.Threading; using log4net; +using OpenMetaverse; using OpenSim.Framework; namespace OpenSim.Data.MySQL @@ -93,7 +94,7 @@ namespace OpenSim.Data.MySQL if (lockedCons > m_maxConnections) { lockedCons = 0; - System.Threading.Thread.Sleep(1000); // Wait some time before searching them again. + Thread.Sleep(1000); // Wait some time before searching them again. m_log.Debug( "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); m_log.Debug("Current connections-in-use dump:"); diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index 0f7c9cd..d03e66c 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -26,15 +26,8 @@ */ using System; -using System.IO; -using System.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests { @@ -61,7 +54,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - System.Console.WriteLine("Exception {0}", e); + Console.WriteLine("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index bee3d04..f148385 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -26,15 +26,8 @@ */ using System; -using System.IO; -using System.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests { @@ -63,7 +56,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - System.Console.WriteLine("Exception {0}", e); + Console.WriteLine("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index 4638bca..953294f 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -26,15 +26,8 @@ */ using System; -using System.IO; -using System.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests { @@ -61,7 +54,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - System.Console.WriteLine("Exception {0}", e); + Console.WriteLine("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index 8c7d820..e03e38d 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -26,16 +26,8 @@ */ using System; -using System.IO; -using System.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; -using log4net; namespace OpenSim.Data.MySQL.Tests { @@ -62,7 +54,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - System.Console.WriteLine("Exception {0}", e); + Console.WriteLine("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index 71e73c2..5cce53b 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -26,15 +26,8 @@ */ using System; -using System.IO; -using System.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests { @@ -61,7 +54,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - System.Console.WriteLine("Exception {0}", e); + Console.WriteLine("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs index 8448dd7..b74617e 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -26,15 +26,8 @@ */ using System; -using System.IO; -using System.Collections.Generic; using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenSim.Framework; using OpenSim.Data.Tests; -using OpenSim.Data.MySQL; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; namespace OpenSim.Data.MySQL.Tests { @@ -61,7 +54,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - System.Console.WriteLine("Exception {0}", e); + Console.WriteLine("Exception {0}", e); Assert.Ignore(); } } -- cgit v1.1 From b3c0cea0246904d4833b29de8bfd9b2a58bcca2d Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:25:15 +0000 Subject: - add OpenSim.Grid.AssetServer.Plugins.OpenSim as a dependency for OpenSim.Data.*.addin.xml - remove OpenSim.Grid.NewAssetServer.exe from bin/OpenSim.Data.addin.xml - add prebuild.xml section for OpenSim.Grid.AssetServer.Plugins.OpenSim.dll --- OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml index 9e99547..9f583a2 100644 --- a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml +++ b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml @@ -4,6 +4,7 @@ + -- cgit v1.1 From 8d304725518424131fa42dce1515137e0bb1eada Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:25:25 +0000 Subject: Rename NewAssetServer AssetInventoryServer and fully qualify with OpenSim.Grid.AssetInventoryServer. --- OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml index 9f583a2..281e3af 100644 --- a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml +++ b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml @@ -4,7 +4,7 @@ - + -- cgit v1.1 From 9e88cef0330027baa008516073c6bd95a358456f Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:25:53 +0000 Subject: AssetInventoryServer plugins can't be a dependency for the OpenSim.Data.MySQL addin. --- OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml index 281e3af..9e99547 100644 --- a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml +++ b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml @@ -4,7 +4,6 @@ - -- cgit v1.1 From 76c0935ec744f2d230489398f879eb7f42b11d37 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 17 Feb 2009 01:36:44 +0000 Subject: - remove the Metadata property from AssetBase and return all previous properties as before - prefix private variables with m_ in AssetBase.cs - related to Mantis #3122, as mentioned in https://lists.berlios.de/pipermail/opensim-dev/2009-February/005088.html - all services will likely need to be upgraded after this commit --- OpenSim/Data/MySQL/MySQLAssetData.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 508e053..2211d4c 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -137,18 +137,18 @@ namespace OpenSim.Data.MySQL { asset = new AssetBase(); asset.Data = (byte[]) dbReader["data"]; - asset.Metadata.Description = (string) dbReader["description"]; - asset.Metadata.FullID = assetID; + asset.Description = (string) dbReader["description"]; + asset.FullID = assetID; try { - asset.Metadata.Local = (bool)dbReader["local"]; + asset.Local = (bool)dbReader["local"]; } catch (InvalidCastException) { - asset.Metadata.Local = false; + asset.Local = false; } - asset.Metadata.Name = (string) dbReader["name"]; - asset.Metadata.Type = (sbyte) dbReader["assetType"]; + asset.Name = (string) dbReader["name"]; + asset.Type = (sbyte) dbReader["assetType"]; } dbReader.Close(); cmd.Dispose(); @@ -176,8 +176,8 @@ namespace OpenSim.Data.MySQL { lock (_dbConnection) { - //m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.Metadata.FullID)); - if (ExistsAsset(asset.Metadata.FullID)) + //m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); + if (ExistsAsset(asset.FullID)) { //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); return; @@ -198,12 +198,12 @@ namespace OpenSim.Data.MySQL { // create unix epoch time int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); - cmd.Parameters.AddWithValue("?id", asset.Metadata.ID); - cmd.Parameters.AddWithValue("?name", asset.Metadata.Name); - cmd.Parameters.AddWithValue("?description", asset.Metadata.Description); - cmd.Parameters.AddWithValue("?assetType", asset.Metadata.Type); - cmd.Parameters.AddWithValue("?local", asset.Metadata.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Metadata.Temporary); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?name", asset.Name); + cmd.Parameters.AddWithValue("?description", asset.Description); + cmd.Parameters.AddWithValue("?assetType", asset.Type); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?access_time", now); cmd.Parameters.AddWithValue("?data", asset.Data); @@ -216,7 +216,7 @@ namespace OpenSim.Data.MySQL m_log.ErrorFormat( "[ASSETS DB]: " + "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.Metadata.FullID, asset.Metadata.Name); + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); _dbConnection.Reconnect(); } } @@ -239,7 +239,7 @@ namespace OpenSim.Data.MySQL { // create unix epoch time int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); - cmd.Parameters.AddWithValue("?id", asset.Metadata.ID); + cmd.Parameters.AddWithValue("?id", asset.ID); cmd.Parameters.AddWithValue("?access_time", now); cmd.ExecuteNonQuery(); cmd.Dispose(); @@ -250,7 +250,7 @@ namespace OpenSim.Data.MySQL m_log.ErrorFormat( "[ASSETS DB]: " + "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.Metadata.FullID, asset.Metadata.Name); + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); _dbConnection.Reconnect(); } } -- cgit v1.1 From 93465df5e3cdab1774216fbf3f741af03aa609f7 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 17 Feb 2009 14:12:57 +0000 Subject: * Moved the nifty MySQLEstateData connectionstring password-stripper out into the Util project --- OpenSim/Data/MySQL/MySQLEstateData.cs | 46 ++++++++++++----------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 5acbb9d..8e8c88f 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -58,31 +58,15 @@ namespace OpenSim.Data.MySQL { m_connectionString = connectionString; - int passPosition = 0; - int passEndPosition = 0; - string displayConnectionString = null; - try - { // hide the password in the connection string - passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); - passPosition = m_connectionString.IndexOf("=", passPosition); - if (passPosition < m_connectionString.Length) - passPosition += 1; - passEndPosition = m_connectionString.IndexOf(";", passPosition); - - displayConnectionString = m_connectionString.Substring(0, passPosition); - displayConnectionString += "***"; - displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); + { + m_log.Info("[REGION DB]: MySql - connecting: " + Util.GetDisplayConnectionString(m_connectionString)); } catch (Exception e) { m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); } - m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); - - //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); - m_connection = new MySqlConnection(m_connectionString); m_connection.Open(); @@ -159,7 +143,7 @@ namespace OpenSim.Data.MySQL EstateSettings es = new EstateSettings(); es.OnSave += StoreEstateSettings; - string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; + string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; CheckConnection(); @@ -206,7 +190,7 @@ namespace OpenSim.Data.MySQL names.Remove("EstateID"); - sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")"; + sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; cmd.CommandText = sql; cmd.Parameters.Clear(); @@ -216,13 +200,13 @@ namespace OpenSim.Data.MySQL if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?"+name, "1"); + cmd.Parameters.AddWithValue("?" + name, "1"); else - cmd.Parameters.AddWithValue("?"+name, "0"); + cmd.Parameters.AddWithValue("?" + name, "0"); } else { - cmd.Parameters.AddWithValue("?"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -255,7 +239,7 @@ namespace OpenSim.Data.MySQL // Munge and transfer the ban list // cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); try @@ -279,7 +263,7 @@ namespace OpenSim.Data.MySQL public void StoreEstateSettings(EstateSettings es) { - string sql = "replace into estate_settings ("+String.Join(",", FieldList)+") values ( ?"+String.Join(", ?", FieldList)+")"; + string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")"; CheckConnection(); @@ -292,13 +276,13 @@ namespace OpenSim.Data.MySQL if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?"+name, "1"); + cmd.Parameters.AddWithValue("?" + name, "1"); else - cmd.Parameters.AddWithValue("?"+name, "0"); + cmd.Parameters.AddWithValue("?" + name, "0"); } else { - cmd.Parameters.AddWithValue("?"+name, m_FieldMap[name].GetValue(es).ToString()); + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } } @@ -369,14 +353,14 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); - cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; + cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); - cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; + cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; foreach (UUID uuid in data) { @@ -396,7 +380,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = m_connection.CreateCommand(); - cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; + cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; cmd.Parameters.AddWithValue("?EstateID", EstateID); IDataReader r = cmd.ExecuteReader(); -- cgit v1.1 From c417a5b619eb85706a1782c5b0943cb8b28bd7a1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 17 Feb 2009 19:06:23 +0000 Subject: remove all the very old create and upgrade sql files, these were outdated by migrations 6 months ago. --- OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql | 24 ------------- OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql | 11 ------ .../MySQL/Resources/CreateAvatarAppearance.sql | 42 ---------------------- .../Data/MySQL/Resources/CreateFoldersTable.sql | 11 ------ OpenSim/Data/MySQL/Resources/CreateItemsTable.sql | 24 ------------- OpenSim/Data/MySQL/Resources/CreateLandTable.sql | 39 -------------------- OpenSim/Data/MySQL/Resources/CreateLogsTable.sql | 10 ------ .../Data/MySQL/Resources/CreateRegionsTable.sql | 32 ----------------- .../MySQL/Resources/CreateUserFriendsTable.sql | 11 ------ OpenSim/Data/MySQL/Resources/CreateUsersTable.sql | 35 ------------------ .../Resources/UpgradeFoldersTableToVersion2.sql | 4 --- .../Resources/UpgradeItemsTableToVersion2.sql | 9 ----- .../Resources/UpgradeItemsTableToVersion3.sql | 8 ----- .../MySQL/Resources/UpgradeLandTableToVersion2.sql | 3 -- .../Resources/UpgradeRegionsTableToVersion2.sql | 4 --- .../Resources/UpgradeRegionsTableToVersion3.sql | 18 ---------- .../Resources/UpgradeUsersTableToVersion2.sql | 3 -- 17 files changed, 288 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateItemsTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateLandTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateLogsTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/CreateUsersTable.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql delete mode 100644 OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql b/OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql deleted file mode 100644 index 3ef7bc9..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateAgentsTable.sql +++ /dev/null @@ -1,24 +0,0 @@ -SET FOREIGN_KEY_CHECKS=0; --- ---------------------------- --- Table structure for agents --- ---------------------------- -CREATE TABLE `agents` ( - `UUID` varchar(36) NOT NULL, - `sessionID` varchar(36) NOT NULL, - `secureSessionID` varchar(36) NOT NULL, - `agentIP` varchar(16) NOT NULL, - `agentPort` int(11) NOT NULL, - `agentOnline` tinyint(4) NOT NULL, - `loginTime` int(11) NOT NULL, - `logoutTime` int(11) NOT NULL, - `currentRegion` varchar(36) NOT NULL, - `currentHandle` bigint(20) unsigned NOT NULL, - `currentPos` varchar(64) NOT NULL, - PRIMARY KEY (`UUID`), - UNIQUE KEY `session` (`sessionID`), - UNIQUE KEY `ssession` (`secureSessionID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; - --- ---------------------------- --- Records --- ---------------------------- diff --git a/OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql b/OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql deleted file mode 100644 index 2c750fe..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateAssetsTable.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE `assets` ( - `id` binary(16) NOT NULL, - `name` varchar(64) NOT NULL, - `description` varchar(64) NOT NULL, - `assetType` tinyint(4) NOT NULL, - `invType` tinyint(4) NOT NULL, - `local` tinyint(1) NOT NULL, - `temporary` tinyint(1) NOT NULL, - `data` longblob NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql deleted file mode 100644 index 475c933..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql +++ /dev/null @@ -1,42 +0,0 @@ --- --- Create schema avatar_appearance --- - -DROP TABLE IF EXISTS `avatarappearance`; -CREATE TABLE `avatarappearance` ( - Owner char(36) NOT NULL, - Serial int(10) unsigned NOT NULL, - Visual_Params blob NOT NULL, - Texture blob NOT NULL, - Avatar_Height float NOT NULL, - Body_Item char(36) NOT NULL, - Body_Asset char(36) NOT NULL, - Skin_Item char(36) NOT NULL, - Skin_Asset char(36) NOT NULL, - Hair_Item char(36) NOT NULL, - Hair_Asset char(36) NOT NULL, - Eyes_Item char(36) NOT NULL, - Eyes_Asset char(36) NOT NULL, - Shirt_Item char(36) NOT NULL, - Shirt_Asset char(36) NOT NULL, - Pants_Item char(36) NOT NULL, - Pants_Asset char(36) NOT NULL, - Shoes_Item char(36) NOT NULL, - Shoes_Asset char(36) NOT NULL, - Socks_Item char(36) NOT NULL, - Socks_Asset char(36) NOT NULL, - Jacket_Item char(36) NOT NULL, - Jacket_Asset char(36) NOT NULL, - Gloves_Item char(36) NOT NULL, - Gloves_Asset char(36) NOT NULL, - Undershirt_Item char(36) NOT NULL, - Undershirt_Asset char(36) NOT NULL, - Underpants_Item char(36) NOT NULL, - Underpants_Asset char(36) NOT NULL, - Skirt_Item char(36) NOT NULL, - Skirt_Asset char(36) NOT NULL, - - - PRIMARY KEY (`Owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2'; - diff --git a/OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql b/OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql deleted file mode 100644 index b5bddde..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateFoldersTable.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE `inventoryfolders` ( - `folderID` varchar(36) NOT NULL default '', - `agentID` varchar(36) default NULL, - `parentFolderID` varchar(36) default NULL, - `folderName` varchar(64) default NULL, - `type` smallint NOT NULL default 0, - `version` int NOT NULL default 0, - PRIMARY KEY (`folderID`), - KEY `owner` (`agentID`), - KEY `parent` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; diff --git a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql b/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql deleted file mode 100644 index ffdbe17..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateItemsTable.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE `inventoryitems` ( - `inventoryID` varchar(36) NOT NULL default '', - `assetID` varchar(36) default NULL, - `assetType` int(11) default NULL, - `parentFolderID` varchar(36) default NULL, - `avatarID` varchar(36) default NULL, - `inventoryName` varchar(64) default NULL, - `inventoryDescription` varchar(128) default NULL, - `inventoryNextPermissions` int(10) unsigned default NULL, - `inventoryCurrentPermissions` int(10) unsigned default NULL, - `invType` int(11) default NULL, - `creatorID` varchar(36) default NULL, - `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, - `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, - `salePrice` int(11) NOT NULL default 0, - `saleType` tinyint(4) NOT NULL default 0, - `creationDate` int(11) NOT NULL default 0, - `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - `groupOwned` tinyint(4) NOT NULL default 0, - `flags` int(11) unsigned NOT NULL default 0, - PRIMARY KEY (`inventoryID`), - KEY `owner` (`avatarID`), - KEY `folder` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/CreateLandTable.sql b/OpenSim/Data/MySQL/Resources/CreateLandTable.sql deleted file mode 100644 index 6c7254a..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateLandTable.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE `land` - ( - `UUID` varchar (255) NOT NULL, - `RegionUUID` varchar (255) DEFAULT NULL , - `LocalLandID` int (11) DEFAULT NULL , - `Bitmap` longblob, - `Name` varchar (255) DEFAULT NULL , - `Description` varchar (255) DEFAULT NULL , - `OwnerUUID` varchar (255) DEFAULT NULL , - `IsGroupOwned` int (11) DEFAULT NULL , - `Area` int (11) DEFAULT NULL , - `AuctionID` int (11) DEFAULT NULL , - `Category` int (11) DEFAULT NULL , - `ClaimDate` int (11) DEFAULT NULL , - `ClaimPrice` int (11) DEFAULT NULL , - `GroupUUID` varchar (255) DEFAULT NULL , - `SalePrice` int (11) DEFAULT NULL , - `LandStatus` int (11) DEFAULT NULL , - `LandFlags` int (11) DEFAULT NULL , - `LandingType` int (11) DEFAULT NULL , - `MediaAutoScale` int (11) DEFAULT NULL , - `MediaTextureUUID` varchar (255) DEFAULT NULL , - `MediaURL` varchar (255) DEFAULT NULL , - `MusicURL` varchar (255) DEFAULT NULL , - `PassHours` float DEFAULT NULL , - `PassPrice` int (11) DEFAULT NULL , - `SnapshotUUID` varchar (255) DEFAULT NULL , - `UserLocationX` float DEFAULT NULL , - `UserLocationY` float DEFAULT NULL , - `UserLocationZ` float DEFAULT NULL , - `UserLookAtX` float DEFAULT NULL , - `UserLookAtY` float DEFAULT NULL , - `UserLookAtZ` float DEFAULT NULL , - `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, - - PRIMARY KEY (`UUID`) - ) - ENGINE=INNODB - DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql b/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql deleted file mode 100644 index 53dcd31..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateLogsTable.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `logs` ( - `logID` int(10) unsigned NOT NULL auto_increment, - `target` varchar(36) default NULL, - `server` varchar(64) default NULL, - `method` varchar(64) default NULL, - `arguments` varchar(255) default NULL, - `priority` int(11) default NULL, - `message` text, - PRIMARY KEY (`logID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 diff --git a/OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql b/OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql deleted file mode 100644 index cb0f9bd..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateRegionsTable.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE `regions` ( - `uuid` varchar(36) NOT NULL, - `regionHandle` bigint(20) unsigned NOT NULL, - `regionName` varchar(32) default NULL, - `regionRecvKey` varchar(128) default NULL, - `regionSendKey` varchar(128) default NULL, - `regionSecret` varchar(128) default NULL, - `regionDataURI` varchar(255) default NULL, - `serverIP` varchar(64) default NULL, - `serverPort` int(10) unsigned default NULL, - `serverURI` varchar(255) default NULL, - `locX` int(10) unsigned default NULL, - `locY` int(10) unsigned default NULL, - `locZ` int(10) unsigned default NULL, - `eastOverrideHandle` bigint(20) unsigned default NULL, - `westOverrideHandle` bigint(20) unsigned default NULL, - `southOverrideHandle` bigint(20) unsigned default NULL, - `northOverrideHandle` bigint(20) unsigned default NULL, - `regionAssetURI` varchar(255) default NULL, - `regionAssetRecvKey` varchar(128) default NULL, - `regionAssetSendKey` varchar(128) default NULL, - `regionUserURI` varchar(255) default NULL, - `regionUserRecvKey` varchar(128) default NULL, - `regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL, - `serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL, - `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, - `originUUID` varchar(36), - PRIMARY KEY (`uuid`), - KEY `regionName` (`regionName`), - KEY `regionHandle` (`regionHandle`), - KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql b/OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql deleted file mode 100644 index 8480d48..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateUserFriendsTable.sql +++ /dev/null @@ -1,11 +0,0 @@ -SET FOREIGN_KEY_CHECKS=0; --- ---------------------------- --- Table structure for users --- ---------------------------- -CREATE TABLE `userfriends` ( - `ownerID` VARCHAR(37) NOT NULL, - `friendID` VARCHAR(37) NOT NULL, - `friendPerms` INT NOT NULL, - `datetimestamp` INT NOT NULL, - UNIQUE KEY (`ownerID`, `friendID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/CreateUsersTable.sql b/OpenSim/Data/MySQL/Resources/CreateUsersTable.sql deleted file mode 100644 index d9e8ae2..0000000 --- a/OpenSim/Data/MySQL/Resources/CreateUsersTable.sql +++ /dev/null @@ -1,35 +0,0 @@ -SET FOREIGN_KEY_CHECKS=0; --- ---------------------------- --- Table structure for users --- ---------------------------- -CREATE TABLE `users` ( - `UUID` varchar(36) NOT NULL default '', - `username` varchar(32) NOT NULL, - `lastname` varchar(32) NOT NULL, - `passwordHash` varchar(32) NOT NULL, - `passwordSalt` varchar(32) NOT NULL, - `homeRegion` bigint(20) unsigned default NULL, - `homeLocationX` float default NULL, - `homeLocationY` float default NULL, - `homeLocationZ` float default NULL, - `homeLookAtX` float default NULL, - `homeLookAtY` float default NULL, - `homeLookAtZ` float default NULL, - `created` int(11) NOT NULL, - `lastLogin` int(11) NOT NULL, - `userInventoryURI` varchar(255) default NULL, - `userAssetURI` varchar(255) default NULL, - `profileCanDoMask` int(10) unsigned default NULL, - `profileWantDoMask` int(10) unsigned default NULL, - `profileAboutText` text, - `profileFirstText` text, - `profileImage` varchar(36) default NULL, - `profileFirstImage` varchar(36) default NULL, - `webLoginKey` varchar(36) default NULL, - PRIMARY KEY (`UUID`), - UNIQUE KEY `usernames` (`username`,`lastname`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2'; - --- ---------------------------- --- Records --- ---------------------------- diff --git a/OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql deleted file mode 100644 index b5a7964..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeFoldersTableToVersion2.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `inventoryfolders` - ADD COLUMN `type` smallint NOT NULL default 0, - ADD COLUMN `version` int NOT NULL default 0, -COMMENT='Rev. 2'; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql deleted file mode 100644 index d1ef504..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion2.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `inventoryitems` - CHANGE COLUMN `type` `assetType` int(11) default NULL, - ADD COLUMN `invType` int(11) default NULL, - ADD COLUMN `creatorID` varchar(36) default NULL, - ADD COLUMN `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, - ADD COLUMN `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, -COMMENT='Rev. 2'; - -UPDATE `inventoryitems` SET invType=assetType; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql b/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql deleted file mode 100644 index b4108ab..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeItemsTableToVersion3.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE `inventoryitems` - ADD COLUMN `salePrice` int(11) NOT NULL default 0, - ADD COLUMN `saleType` tinyint(4) NOT NULL default 0, - ADD COLUMN `creationDate` int(11) NOT NULL default 0, - ADD COLUMN `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - ADD COLUMN `groupOwned` tinyint(4) NOT NULL default 0, - ADD COLUMN `flags` int(11) unsigned NOT NULL default 0, -COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql deleted file mode 100644 index c5c55f1..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeLandTableToVersion2.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `land` - ADD COLUMN `AuthbuyerID` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, -COMMENT='Rev. 2'; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql deleted file mode 100644 index 034b755..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion2.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `regions` - ADD COLUMN `originUUID` varchar(36), -COMMENT='Rev. 2'; -UPDATE `regions` SET originUUID=uuid; diff --git a/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql b/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql deleted file mode 100644 index b48afec..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeRegionsTableToVersion3.sql +++ /dev/null @@ -1,18 +0,0 @@ -DROP PROCEDURE IF EXISTS upgraderegions3; - -create procedure upgraderegions3() -BEGIN -DECLARE db_name varchar(64); -select database() into db_name; -IF ((select count(*) from information_schema.columns where table_name='regions' and column_name='owner_uuid' and table_schema=db_name) > 0) -THEN - ALTER TABLE `regions`, COMMENT='Rev. 3'; -ELSE - ALTER TABLE `regions` - ADD COLUMN `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null after serverRemotingPort, COMMENT='Rev. 3'; -END IF; -END; - -call upgraderegions3(); - - diff --git a/OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql b/OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql deleted file mode 100644 index dd21a66..0000000 --- a/OpenSim/Data/MySQL/Resources/UpgradeUsersTableToVersion2.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `users` - ADD COLUMN `webLoginKey` varchar(36) default '00000000-0000-0000-0000-000000000000' NOT NULL, -COMMENT='Rev. 2'; \ No newline at end of file -- cgit v1.1 From 8d23d97084394202f46a377ff4e1a5d160c21c98 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 18 Feb 2009 12:56:28 +0000 Subject: remove legacy pre-migration code for mysql grid adapter, who knew this was still in there. --- OpenSim/Data/MySQL/MySQLGridData.cs | 55 ------------------------------------- 1 file changed, 55 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 5c00330..75901b2 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -148,64 +148,9 @@ namespace OpenSim.Data.MySQL // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; Migration m = new Migration(database.Connection, assem, "GridStore"); - - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m); - m.Update(); } - #region Test and initialization code - - /// - /// Ensure that the user related tables exists and are at the latest version - /// - private void TestTables(Migration m) - { - // we already have migrations, get out of here - if (m.Version > 0) - return; - - Dictionary tableList = new Dictionary(); - - tableList["regions"] = null; - database.GetTableVersion(tableList); - - UpgradeRegionsTable(tableList["regions"]); - - // we have tables, but not a migration model yet - if (m.Version == 0) - m.Version = 1; - } - - /// - /// Create or upgrade the table if necessary - /// - /// A null indicates that the table does not - /// currently exist - private void UpgradeRegionsTable(string oldVersion) - { - // null as the version, indicates that the table didn't exist - if (oldVersion == null) - { - database.ExecuteResourceSql("CreateRegionsTable.sql"); - return; - } - if (oldVersion.Contains("Rev. 1")) - { - database.ExecuteResourceSql("UpgradeRegionsTableToVersion2.sql"); - return; - } - if (oldVersion.Contains("Rev. 2")) - { - database.ExecuteResourceSql("UpgradeRegionsTableToVersion3.sql"); - return; - } - } - - #endregion - /// /// Shuts down the grid interface /// -- cgit v1.1 From 2d7c15c5606a3349eb38c60866ff48b8c01827a0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 18 Feb 2009 18:48:59 +0000 Subject: Fix estate ban list persistence in MySQL and reenable tests --- OpenSim/Data/MySQL/MySQLEstateData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 8e8c88f..0db624d 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -335,7 +335,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )"; + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; foreach (EstateBan b in es.EstateBans) { -- cgit v1.1 From 2e095f5727b2bd22ccf06f940ec191bed4fc8820 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 20 Feb 2009 16:47:31 +0000 Subject: * Upped VersionInfo to 0.6.3 and in the process, changed assemblyinfo to 0.6.3.* to better track down dll ref and overwrite problems. --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index b3e08a3..95deefe 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -35,9 +35,9 @@ using System.Runtime.InteropServices; [assembly : AssemblyTitle("OpenSim.Data.MySQL")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] -[assembly : AssemblyCompany("")] +[assembly : AssemblyCompany("http://opensimulator.org")] [assembly : AssemblyProduct("OpenSim.Data.MySQL")] -[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyVersion("0.6.3.*")] [assembly : AssemblyFileVersion("1.0.0.0")] -- cgit v1.1 From 1cadad9ec62c54fe8ebde8a895817bd980fed975 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sat, 21 Feb 2009 09:39:33 +0000 Subject: * Applied a patch that: Added estate ban table to migration scripts and nhibernate mapping. Refactored property getters and setters for estate ban object to support NHibernate. * Added estate ban table to migration scripts of all supported databases. * Added nhibernate mapping for EstateBans property of EstateSettings * Refactored property accessors for EstateBan object. * Added comments for EstateBan properties. * Ensured that NHibernate tests pass with NUnitGUI. * Ensured that nant test target passes. This fixes mantis #3210. Thank you, tlaukkan! --- OpenSim/Data/MySQL/MySQLEstateData.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 0db624d..133ee7a 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -314,9 +314,9 @@ namespace OpenSim.Data.MySQL UUID uuid = new UUID(); UUID.TryParse(r["bannedUUID"].ToString(), out uuid); - eb.bannedUUID = uuid; - eb.bannedIP = "0.0.0.0"; - eb.bannedIPHostMask = "0.0.0.0"; + eb.BannedUserID = uuid; + eb.BannedHostAddress = "0.0.0.0"; + eb.BannedHostIPMask = "0.0.0.0"; es.AddBan(eb); } r.Close(); @@ -340,7 +340,7 @@ namespace OpenSim.Data.MySQL foreach (EstateBan b in es.EstateBans) { cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?bannedUUID", b.bannedUUID.ToString()); + cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); -- cgit v1.1 From 8f55b9d735fbc975ce7a4b54e972c17ffbfb1f49 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 22 Feb 2009 20:52:55 +0000 Subject: Mantis#3218. Thank you kindly, TLaukkan (Tommil) for a patch that: * Added log4net dependency to physxplugin in prebuild.xml. * Added missing m_log fields to classes. * Replaced Console.WriteLine with appropriate m_log.Xxxx * Tested that nant test target runs succesfully. * Tested that local opensim sandbox starts up without errors. --- OpenSim/Data/MySQL/MySQLManager.cs | 2 -- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 7 +++++-- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 5 ++++- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 8 ++++++-- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 5 ++++- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 7 +++++-- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 7 +++++-- 7 files changed, 29 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 3bb6857..2f14f16 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -1030,7 +1030,6 @@ namespace OpenSim.Data.MySQL { IDbCommand result = Query(sql, parameters); - //Console.WriteLine(result.CommandText); // int x; // if ((x = result.ExecuteNonQuery()) > 0) // { @@ -1123,7 +1122,6 @@ namespace OpenSim.Data.MySQL { IDbCommand result = Query(sql, parameters); - //Console.WriteLine(result.CommandText); // int x; // if ((x = result.ExecuteNonQuery()) > 0) // { diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index d03e66c..514e04e 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -28,12 +28,15 @@ using System; using NUnit.Framework; using OpenSim.Data.Tests; +using log4net; +using System.Reflection; namespace OpenSim.Data.MySQL.Tests { [TestFixture] public class MySQLAssetTest : BasicAssetTest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; @@ -54,7 +57,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - Console.WriteLine("Exception {0}", e); + m_log.Error(e.ToString()); Assert.Ignore(); } } @@ -73,4 +76,4 @@ namespace OpenSim.Data.MySQL.Tests } } } -} \ No newline at end of file +} diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index f148385..79fcc2d 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -28,12 +28,15 @@ using System; using NUnit.Framework; using OpenSim.Data.Tests; +using log4net; +using System.Reflection; namespace OpenSim.Data.MySQL.Tests { [TestFixture] public class MySQLEstateTest : BasicEstateTest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; @@ -56,7 +59,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - Console.WriteLine("Exception {0}", e); + m_log.Error("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index 953294f..fd71022 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -28,12 +28,16 @@ using System; using NUnit.Framework; using OpenSim.Data.Tests; +using log4net; +using System.Reflection; namespace OpenSim.Data.MySQL.Tests { [TestFixture] public class MySQLGridTest : BasicGridTest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public string file; public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; @@ -54,7 +58,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - Console.WriteLine("Exception {0}", e); + m_log.Error("Exception {0}", e); Assert.Ignore(); } } @@ -73,4 +77,4 @@ namespace OpenSim.Data.MySQL.Tests } } } -} \ No newline at end of file +} diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index e03e38d..c7799e5 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -28,12 +28,15 @@ using System; using NUnit.Framework; using OpenSim.Data.Tests; +using log4net; +using System.Reflection; namespace OpenSim.Data.MySQL.Tests { [TestFixture] public class MySQLInventoryTest : BasicInventoryTest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; @@ -54,7 +57,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - Console.WriteLine("Exception {0}", e); + m_log.Error("Exception {0}", e); Assert.Ignore(); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index 5cce53b..77964d3 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -28,12 +28,15 @@ using System; using NUnit.Framework; using OpenSim.Data.Tests; +using log4net; +using System.Reflection; namespace OpenSim.Data.MySQL.Tests { [TestFixture] public class MySQLRegionTest : BasicRegionTest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; @@ -54,7 +57,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - Console.WriteLine("Exception {0}", e); + m_log.Error("Exception {0}", e); Assert.Ignore(); } } @@ -87,4 +90,4 @@ namespace OpenSim.Data.MySQL.Tests } } } -} \ No newline at end of file +} diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs index b74617e..449ce4a 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -28,12 +28,15 @@ using System; using NUnit.Framework; using OpenSim.Data.Tests; +using log4net; +using System.Reflection; namespace OpenSim.Data.MySQL.Tests { [TestFixture] public class MySQLUserTest : BasicUserTest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; @@ -54,7 +57,7 @@ namespace OpenSim.Data.MySQL.Tests } catch (Exception e) { - Console.WriteLine("Exception {0}", e); + m_log.Error("Exception {0}", e); Assert.Ignore(); } } @@ -78,4 +81,4 @@ namespace OpenSim.Data.MySQL.Tests } } } -} \ No newline at end of file +} -- cgit v1.1 From 41c883ea47105d04087fb173047b6cd7e17be40d Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 25 Feb 2009 11:01:38 +0000 Subject: * Refactored SOP.FolderID weirdness by removing calls to empty setter. YEs, I do realize the setter has to be there for legacy reasons, but since the calls will never acually DO anyhting, I'm removing them. * So, SOP.FolderID is actually a cruft field that should be removed. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 4b07ed6..e39b185 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -441,10 +441,6 @@ namespace OpenSim.Data.MySQL else prim.Shape = BuildShape(reader); - prim.FolderID = prim.UUID; // A relic from when we - // we thought prims contained - // folder objects. In - // reality, prim == folder prims.Add(prim); UUID groupID = new UUID(reader["SceneGroupID"].ToString()); -- cgit v1.1 From a2f07ecd2e248966957a8ea70d772276359b02e8 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 9 Mar 2009 07:29:34 +0000 Subject: Implemented FetchAssetMetadataSet in DB backends. This method fetches metadata for a subset of the entries in the assets database. This functionality is used in the ForEach calls in the asset storage providers in AssetInventoryServer. With this implemented, frontends such as the BrowseFrontend should now work. - MySQL: implemented, sanity tested - SQLite: implemented, sanity tested - MSSQL: implemented, not tested - NHibernate: not implemented --- OpenSim/Data/MySQL/MySQLAssetData.cs | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 2211d4c..466f5db 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -28,6 +28,7 @@ using System; using System.Data; using System.Reflection; +using System.Collections.Generic; using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; @@ -311,6 +312,56 @@ namespace OpenSim.Data.MySQL return assetExists; } + /// + /// Returns a list of AssetMetadata objects. The list is a subset of + /// the entire data set offset by containing + /// elements. + /// + /// The number of results to discard from the total data set. + /// The number of rows the returned list should contain. + /// A list of AssetMetadata objects. + public override List FetchAssetMetadataSet(int start, int count) + { + List retList = new List(count); + + lock (_dbConnection) + { + _dbConnection.CheckConnection(); + + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection); + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader()) + { + while (dbReader.Read()) + { + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string) dbReader["name"]; + metadata.Description = (string) dbReader["description"]; + metadata.Type = (sbyte) dbReader["assetType"]; + metadata.Temporary = (bool) dbReader["temporary"]; // Not sure if this is correct. + metadata.FullID = new UUID((string) dbReader["id"]); + + // Current SHA1s are not stored/computed. + metadata.SHA1 = new byte[] {}; + + retList.Add(metadata); + } + } + } + catch (Exception e) + { + m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection"); + _dbConnection.Reconnect(); + } + } + + return retList; + } + #endregion /// -- cgit v1.1 From 1121a214b9258487dae0d84dad1a0b495d2f80bd Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 21 Mar 2009 17:46:58 +0000 Subject: Add a QueryItem method to the inventory subsystem. Currently implemented for MySQL only, stubs for the others. This allows updating the cache with a single item from the database. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 7d29061..1a6f068 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -539,6 +539,11 @@ namespace OpenSim.Data.MySQL } } + public InventoryItemBase queryInventoryItem(UUID itemID) + { + return getInventoryItem(itemID); + } + /// /// Creates a new inventory folder /// -- cgit v1.1 From 9b82b52096fd1b44aa80e4c6d673d1646b616052 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 22 Mar 2009 16:12:48 +0000 Subject: MYSQL Only: Make items given while offline appear in inventory without the need to clear cache. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 1a6f068..2f26cdf 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -497,6 +497,15 @@ namespace OpenSim.Data.MySQL } result.Dispose(); + + result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", database.Connection); + result.Parameters.AddWithValue("?folderID", item.Folder.ToString +()); + lock (database) + { + result.ExecuteNonQuery(); + } + result.Dispose(); } catch (MySqlException e) { -- cgit v1.1 From 412112acbafa6e1f111b12007fd3a81728d0b2f5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 23 Mar 2009 00:11:34 +0000 Subject: Committing partial work on passing folders across instances. This may crash. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 2f26cdf..a5312b5 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -553,6 +553,11 @@ namespace OpenSim.Data.MySQL return getInventoryItem(itemID); } + public InventoryFolderBase queryInventoryFolder(UUID folderID) + { + return getInventoryFolder(folderID); + } + /// /// Creates a new inventory folder /// -- cgit v1.1 From 52c482a7a7b297715cbcd7460edb1ad07d7a06c6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 27 Mar 2009 22:13:09 +0000 Subject: * This updates LibOMV to the current release 0.6.0 on March 19 2009 * Important: HttpServer.dll was changed to HttpServer_OpenSim.dll so that the HttpServer references do not conflict if you've copied the OpenMetaverse.Http.dll and requirements to the OpenSimulator bin folder. This means that if you reference HttpServer.dll in any projects, you will need to change the reference to HttpServer_OpenSim.dll. It still uses the Same HttpServer namespace though. --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 2f14f16..ad022a5 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -1171,7 +1171,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); cmd.Parameters.AddWithValue("?serial", appearance.Serial); cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); - cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes()); + cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); -- cgit v1.1 From 958d764172fcbaa5d3a33b787b01426caa300a8a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 1 Apr 2009 19:44:46 +0000 Subject: * Upped trunk version number to 0.6.4 as we just tagged 0.6.4-release --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 95deefe..986a583 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.3.*")] +[assembly : AssemblyVersion("0.6.4.*")] [assembly : AssemblyFileVersion("1.0.0.0")] -- cgit v1.1 From 97fa525f4e6252031f5276193c4ca8fcac9e59bd Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sun, 5 Apr 2009 17:07:50 +0000 Subject: Adding migrations for MySQL and SQLite for removing the "old" cloud image. The new one already in the Library will be reinserted automatically. Fixes Mantis #964 --- OpenSim/Data/MySQL/Resources/006_AssetStore.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 OpenSim/Data/MySQL/Resources/006_AssetStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/006_AssetStore.sql b/OpenSim/Data/MySQL/Resources/006_AssetStore.sql new file mode 100644 index 0000000..3104353 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/006_AssetStore.sql @@ -0,0 +1 @@ +DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621' -- cgit v1.1 From f3c7298fc5bdb35e8a293c9aee4134c8e8fe2856 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 8 Apr 2009 17:50:57 +0000 Subject: * Make it possible to store creator strings in user inventory items as well as UUIDs * All existing functionality should be unaffected. * Database schemas have not been changed. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index a5312b5..7092096 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -306,22 +306,20 @@ namespace OpenSim.Data.MySQL try { InventoryItemBase item = new InventoryItemBase(); + item.CreatorId = (string)reader["creatorID"]; + // Be a bit safer in parsing these because the // database doesn't enforce them to be not null, and // the inventory still works if these are weird in the // db - UUID Owner = UUID.Zero; - UUID Creator = UUID.Zero; UUID GroupID = UUID.Zero; UUID.TryParse((string)reader["avatarID"], out Owner); - UUID.TryParse((string)reader["creatorID"], out Creator); UUID.TryParse((string)reader["groupID"], out GroupID); - item.Owner = Owner; - item.Creator = Creator; + item.Owner = Owner; item.GroupID = GroupID; - // Rest of the parsing. If these UUID's fail, we're dead anyway + // Rest of the parsing. If these UUID's fail, we're dead anyway item.ID = new UUID((string) reader["inventoryID"]); item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; @@ -480,7 +478,7 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.CurrentPermissions.ToString()); result.Parameters.AddWithValue("?invType", item.InvType); - result.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); + result.Parameters.AddWithValue("?creatorID", item.CreatorId); result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); -- cgit v1.1 From a707fa7bea7deff8adf445bbf2bbd8cff19fcbcf Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 9 Apr 2009 06:42:15 +0000 Subject: * Added custom DatabaseTestAttribute to help separating unit tests from component tests. --- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index 514e04e..ff324e7 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -33,7 +33,7 @@ using System.Reflection; namespace OpenSim.Data.MySQL.Tests { - [TestFixture] + [TestFixture, DatabaseTest] public class MySQLAssetTest : BasicAssetTest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From ed33878a0fb549acc52f0d31bb9de02e82cb2b0d Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 9 Apr 2009 07:11:49 +0000 Subject: * tagged some more database tests as such --- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 79fcc2d..a2f0a4c 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -33,7 +33,7 @@ using System.Reflection; namespace OpenSim.Data.MySQL.Tests { - [TestFixture] + [TestFixture, DatabaseTest] public class MySQLEstateTest : BasicEstateTest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index fd71022..a1b973a 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -33,7 +33,7 @@ using System.Reflection; namespace OpenSim.Data.MySQL.Tests { - [TestFixture] + [TestFixture, DatabaseTest] public class MySQLGridTest : BasicGridTest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index c7799e5..298b4fc 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -33,7 +33,7 @@ using System.Reflection; namespace OpenSim.Data.MySQL.Tests { - [TestFixture] + [TestFixture, DatabaseTest] public class MySQLInventoryTest : BasicInventoryTest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index 77964d3..ff64e59 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -33,7 +33,7 @@ using System.Reflection; namespace OpenSim.Data.MySQL.Tests { - [TestFixture] + [TestFixture, DatabaseTest] public class MySQLRegionTest : BasicRegionTest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs index 449ce4a..920fcf1 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -33,7 +33,7 @@ using System.Reflection; namespace OpenSim.Data.MySQL.Tests { - [TestFixture] + [TestFixture, DatabaseTest] public class MySQLUserTest : BasicUserTest { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 5572a00295e36e3ee455a4eef9879c4685f3589d Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 9 Apr 2009 16:40:02 +0000 Subject: * Moved the DatabaseTestAttribute to Test.Common, and thus included ref to that in all db tests. *phew* --- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 1 + OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 1 + OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 1 + OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 1 + OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 1 + OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 1 + 6 files changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index ff324e7..fd6f508 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -30,6 +30,7 @@ using NUnit.Framework; using OpenSim.Data.Tests; using log4net; using System.Reflection; +using OpenSim.Tests.Common; namespace OpenSim.Data.MySQL.Tests { diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index a2f0a4c..1f44b4b 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -30,6 +30,7 @@ using NUnit.Framework; using OpenSim.Data.Tests; using log4net; using System.Reflection; +using OpenSim.Tests.Common; namespace OpenSim.Data.MySQL.Tests { diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index a1b973a..23512dc 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -30,6 +30,7 @@ using NUnit.Framework; using OpenSim.Data.Tests; using log4net; using System.Reflection; +using OpenSim.Tests.Common; namespace OpenSim.Data.MySQL.Tests { diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index 298b4fc..f539359 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -30,6 +30,7 @@ using NUnit.Framework; using OpenSim.Data.Tests; using log4net; using System.Reflection; +using OpenSim.Tests.Common; namespace OpenSim.Data.MySQL.Tests { diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index ff64e59..294a80e 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -30,6 +30,7 @@ using NUnit.Framework; using OpenSim.Data.Tests; using log4net; using System.Reflection; +using OpenSim.Tests.Common; namespace OpenSim.Data.MySQL.Tests { diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs index 920fcf1..3da06c8 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -30,6 +30,7 @@ using NUnit.Framework; using OpenSim.Data.Tests; using log4net; using System.Reflection; +using OpenSim.Tests.Common; namespace OpenSim.Data.MySQL.Tests { -- cgit v1.1 From 39c63029727f895d72eb5b4ebbf6a8f5a002201d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 9 Apr 2009 18:17:52 +0000 Subject: * Improve inventory uuid conversions to make sure that we aren't converting anything that already contains a - * Among other things, this means that if a migration is interrupted, it can simply be retried --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 466f5db..20b2673 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -177,7 +177,7 @@ namespace OpenSim.Data.MySQL { lock (_dbConnection) { - //m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); + //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID); if (ExistsAsset(asset.FullID)) { //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); -- cgit v1.1 From 29355de6ee01b1f44f32ea45b9c06f636ae9a241 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 13 Apr 2009 20:04:18 +0000 Subject: * Some more experimental work on distributed assets. Nothing hotwired yet. * Introduced preprocess step in FetchAsset (Might revert this later) * Some minor CCC * Added actual implementation of GetUserProfile( uri ) and the corresponding handler to OGS1. * Introduced non-functioning GetUserUri( userProfile) awaiting user server wireup (this might move elsewhere) --- OpenSim/Data/MySQL/MySQLAssetData.cs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 20b2673..cc16389 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -109,6 +109,24 @@ namespace OpenSim.Data.MySQL public override void Dispose() { } + /// + /// Database provider version + /// + override public string Version + { + get { return _dbConnection.getVersion(); } + } + + /// + /// The name of this DB provider + /// + override public string Name + { + get { return "MySQL Asset storage engine"; } + } + + #endregion + #region IAssetDataPlugin Members /// @@ -117,7 +135,7 @@ namespace OpenSim.Data.MySQL /// Asset UUID to fetch /// Return the asset /// On failure : throw an exception and attempt to reconnect to database - override public AssetBase FetchAsset(UUID assetID) + override protected AssetBase FetchStoredAsset(UUID assetID) { AssetBase asset = null; lock (_dbConnection) @@ -364,22 +382,6 @@ namespace OpenSim.Data.MySQL #endregion - /// - /// Database provider version - /// - override public string Version - { - get { return _dbConnection.getVersion(); } - } - /// - /// The name of this DB provider - /// - override public string Name - { - get { return "MySQL Asset storage engine"; } - } - - #endregion } } -- cgit v1.1 From 45b90ceef1b73994f729275eae112870ff34cb64 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 22 Apr 2009 19:00:40 +0000 Subject: ensure we've got a clean data environment prior to running the region tests --- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index 294a80e..e3f9413 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -53,6 +53,9 @@ namespace OpenSim.Data.MySQL.Tests try { database = new MySQLManager(connect); + // this is important in case a previous run ended badly + ClearDB(database); + db = new MySQLDataStore(); db.Initialise(connect); } @@ -70,24 +73,28 @@ namespace OpenSim.Data.MySQL.Tests { db.Dispose(); } - // if a new table is added, it has to be dropped here - if (database != null) + ClearDB(database); + } + + private void ClearDB(MySQLManager manager) + { + if (manager != null) { - database.ExecuteSql("drop table migrations"); - database.ExecuteSql("drop table prims"); - database.ExecuteSql("drop table primshapes"); - database.ExecuteSql("drop table primitems"); - database.ExecuteSql("drop table terrain"); - database.ExecuteSql("drop table land"); - database.ExecuteSql("drop table landaccesslist"); - database.ExecuteSql("drop table regionban"); - database.ExecuteSql("drop table regionsettings"); - database.ExecuteSql("drop table estate_managers"); - database.ExecuteSql("drop table estate_groups"); - database.ExecuteSql("drop table estate_users"); - database.ExecuteSql("drop table estateban"); - database.ExecuteSql("drop table estate_settings"); - database.ExecuteSql("drop table estate_map"); + manager.ExecuteSql("drop table migrations"); + manager.ExecuteSql("drop table prims"); + manager.ExecuteSql("drop table primshapes"); + manager.ExecuteSql("drop table primitems"); + manager.ExecuteSql("drop table terrain"); + manager.ExecuteSql("drop table land"); + manager.ExecuteSql("drop table landaccesslist"); + manager.ExecuteSql("drop table regionban"); + manager.ExecuteSql("drop table regionsettings"); + manager.ExecuteSql("drop table estate_managers"); + manager.ExecuteSql("drop table estate_groups"); + manager.ExecuteSql("drop table estate_users"); + manager.ExecuteSql("drop table estateban"); + manager.ExecuteSql("drop table estate_settings"); + manager.ExecuteSql("drop table estate_map"); } } } -- cgit v1.1 From b0ac6cd0e0bea641d652cb9ef8b8167bafcadee5 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 22 Apr 2009 19:11:54 +0000 Subject: add cleardb to estate tests --- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 40 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 1f44b4b..8659aa2 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -53,6 +53,9 @@ namespace OpenSim.Data.MySQL.Tests try { database = new MySQLManager(connect); + // clear db incase to ensure we are in a clean state + ClearDB(database); + regionDb = new MySQLDataStore(); regionDb.Initialise(connect); db = new MySQLEstateStore(); @@ -72,24 +75,29 @@ namespace OpenSim.Data.MySQL.Tests { regionDb.Dispose(); } + ClearDB(database); + } + + private void ClearDB(MySQLManager manager) + { // if a new table is added, it has to be dropped here - if (database != null) + if (manager != null) { - database.ExecuteSql("drop table migrations"); - database.ExecuteSql("drop table prims"); - database.ExecuteSql("drop table primshapes"); - database.ExecuteSql("drop table primitems"); - database.ExecuteSql("drop table terrain"); - database.ExecuteSql("drop table land"); - database.ExecuteSql("drop table landaccesslist"); - database.ExecuteSql("drop table regionban"); - database.ExecuteSql("drop table regionsettings"); - database.ExecuteSql("drop table estate_managers"); - database.ExecuteSql("drop table estate_groups"); - database.ExecuteSql("drop table estate_users"); - database.ExecuteSql("drop table estateban"); - database.ExecuteSql("drop table estate_settings"); - database.ExecuteSql("drop table estate_map"); + manager.ExecuteSql("drop table migrations"); + manager.ExecuteSql("drop table prims"); + manager.ExecuteSql("drop table primshapes"); + manager.ExecuteSql("drop table primitems"); + manager.ExecuteSql("drop table terrain"); + manager.ExecuteSql("drop table land"); + manager.ExecuteSql("drop table landaccesslist"); + manager.ExecuteSql("drop table regionban"); + manager.ExecuteSql("drop table regionsettings"); + manager.ExecuteSql("drop table estate_managers"); + manager.ExecuteSql("drop table estate_groups"); + manager.ExecuteSql("drop table estate_users"); + manager.ExecuteSql("drop table estateban"); + manager.ExecuteSql("drop table estate_settings"); + manager.ExecuteSql("drop table estate_map"); } } } -- cgit v1.1 From e0160e56409720045b09b250fd40424fea4fd42a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 22 Apr 2009 19:23:38 +0000 Subject: add if exists to the drop table --- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 30 ++++++++++++++--------------- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 30 ++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 8659aa2..148d910 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -83,21 +83,21 @@ namespace OpenSim.Data.MySQL.Tests // if a new table is added, it has to be dropped here if (manager != null) { - manager.ExecuteSql("drop table migrations"); - manager.ExecuteSql("drop table prims"); - manager.ExecuteSql("drop table primshapes"); - manager.ExecuteSql("drop table primitems"); - manager.ExecuteSql("drop table terrain"); - manager.ExecuteSql("drop table land"); - manager.ExecuteSql("drop table landaccesslist"); - manager.ExecuteSql("drop table regionban"); - manager.ExecuteSql("drop table regionsettings"); - manager.ExecuteSql("drop table estate_managers"); - manager.ExecuteSql("drop table estate_groups"); - manager.ExecuteSql("drop table estate_users"); - manager.ExecuteSql("drop table estateban"); - manager.ExecuteSql("drop table estate_settings"); - manager.ExecuteSql("drop table estate_map"); + manager.ExecuteSql("drop table if exists migrations"); + manager.ExecuteSql("drop table if exists prims"); + manager.ExecuteSql("drop table if exists primshapes"); + manager.ExecuteSql("drop table if exists primitems"); + manager.ExecuteSql("drop table if exists terrain"); + manager.ExecuteSql("drop table if exists land"); + manager.ExecuteSql("drop table if exists landaccesslist"); + manager.ExecuteSql("drop table if exists regionban"); + manager.ExecuteSql("drop table if exists regionsettings"); + manager.ExecuteSql("drop table if exists estate_managers"); + manager.ExecuteSql("drop table if exists estate_groups"); + manager.ExecuteSql("drop table if exists estate_users"); + manager.ExecuteSql("drop table if exists estateban"); + manager.ExecuteSql("drop table if exists estate_settings"); + manager.ExecuteSql("drop table if exists estate_map"); } } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index e3f9413..b8fac69 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -80,21 +80,21 @@ namespace OpenSim.Data.MySQL.Tests { if (manager != null) { - manager.ExecuteSql("drop table migrations"); - manager.ExecuteSql("drop table prims"); - manager.ExecuteSql("drop table primshapes"); - manager.ExecuteSql("drop table primitems"); - manager.ExecuteSql("drop table terrain"); - manager.ExecuteSql("drop table land"); - manager.ExecuteSql("drop table landaccesslist"); - manager.ExecuteSql("drop table regionban"); - manager.ExecuteSql("drop table regionsettings"); - manager.ExecuteSql("drop table estate_managers"); - manager.ExecuteSql("drop table estate_groups"); - manager.ExecuteSql("drop table estate_users"); - manager.ExecuteSql("drop table estateban"); - manager.ExecuteSql("drop table estate_settings"); - manager.ExecuteSql("drop table estate_map"); + manager.ExecuteSql("drop table if exists migrations"); + manager.ExecuteSql("drop table if exists prims"); + manager.ExecuteSql("drop table if exists primshapes"); + manager.ExecuteSql("drop table if exists primitems"); + manager.ExecuteSql("drop table if exists terrain"); + manager.ExecuteSql("drop table if exists land"); + manager.ExecuteSql("drop table if exists landaccesslist"); + manager.ExecuteSql("drop table if exists regionban"); + manager.ExecuteSql("drop table if exists regionsettings"); + manager.ExecuteSql("drop table if exists estate_managers"); + manager.ExecuteSql("drop table if exists estate_groups"); + manager.ExecuteSql("drop table if exists estate_users"); + manager.ExecuteSql("drop table if exists estateban"); + manager.ExecuteSql("drop table if exists estate_settings"); + manager.ExecuteSql("drop table if exists estate_map"); } } } -- cgit v1.1 From 2284c8509f29b8766794f6482839cd9bc5e9f300 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 7 May 2009 14:20:32 +0000 Subject: * Consistently used dashed uuid format for mysql region data, as is done for all other tables * This revision contains a mysql data migration. Please backup your mysql region database as a precaution before using this code. * I also advise that you do a runprebuild[.sh|.bat] and a clean build ("nant clean build" if you're using the command line). * This change is needed for future id schemes --- OpenSim/Data/MySQL/MySQLRegionData.cs | 55 ++++++++--------- OpenSim/Data/MySQL/Resources/028_RegionStore.sql | 79 ++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 29 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/028_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e39b185..b13813f 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -282,7 +282,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "select UUID from prims where "+ "SceneGroupID= ?UUID"; - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(obj)); + cmd.Parameters.AddWithValue("UUID", obj.ToString()); List uuids = new List(); @@ -365,7 +365,7 @@ namespace OpenSim.Data.MySQL for (int i = 0; i < uuids.Count; i++) { - cmd.Parameters.AddWithValue("UUID" + i, Util.ToRawUuidString(uuids[i])); + cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); } ExecuteNonQuery(cmd); @@ -426,8 +426,7 @@ namespace OpenSim.Data.MySQL "where RegionUUID = ?RegionUUID " + "order by SceneGroupID asc, sort asc, LinkNumber asc"; - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionUUID)); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); IDataReader reader = ExecuteReader(cmd); @@ -549,8 +548,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "delete from terrain where " + "RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionID)); + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); ExecuteNonQuery(cmd); @@ -576,7 +574,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "select RegionUUID, Revision, Heightfield " + "from terrain where RegionUUID = ?RegionUUID "+ "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID)); + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); IDataReader reader = ExecuteReader(cmd); @@ -621,7 +619,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "delete from land where UUID = ?UUID"; - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID)); + cmd.Parameters.AddWithValue("UUID", globalID.ToString()); ExecuteNonQuery(cmd); cmd.Dispose(); @@ -775,8 +773,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "select * from land where " + "RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", - Util.ToRawUuidString(regionUUID)); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); IDataReader reader = ExecuteReader(cmd); @@ -800,8 +797,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "select * from landaccesslist " + "where LandUUID = ?LandUUID"; - cmd.Parameters.AddWithValue("LandUUID", - Util.ToRawUuidString(land.GlobalID)); + cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); reader = ExecuteReader(cmd); @@ -1157,11 +1153,11 @@ namespace OpenSim.Data.MySQL /// private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) { - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID)); - cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID)); + cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); cmd.Parameters.AddWithValue("Name", prim.Name); - cmd.Parameters.AddWithValue("SceneGroupID", Util.ToRawUuidString(sceneGroupID)); + cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString()); // the UUID of the root part for this SceneObjectGroup // various text fields cmd.Parameters.AddWithValue("Text", prim.Text); @@ -1174,10 +1170,10 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("TouchName", prim.TouchName); // permissions cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags); - cmd.Parameters.AddWithValue("CreatorID", Util.ToRawUuidString(prim.CreatorID)); - cmd.Parameters.AddWithValue("OwnerID", Util.ToRawUuidString(prim.OwnerID)); - cmd.Parameters.AddWithValue("GroupID", Util.ToRawUuidString(prim.GroupID)); - cmd.Parameters.AddWithValue("LastOwnerID", Util.ToRawUuidString(prim.LastOwnerID)); + cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); + cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); + cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); + cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); @@ -1361,8 +1357,8 @@ namespace OpenSim.Data.MySQL /// private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID) { - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(land.GlobalID)); - cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID)); + cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString()); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); cmd.Parameters.AddWithValue("LocalLandID", land.LocalID); // Bitmap is a byte[512] @@ -1370,25 +1366,25 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Name", land.Name); cmd.Parameters.AddWithValue("Description", land.Description); - cmd.Parameters.AddWithValue("OwnerUUID", Util.ToRawUuidString(land.OwnerID)); + cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString()); cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned); cmd.Parameters.AddWithValue("Area", land.Area); cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate); cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice); - cmd.Parameters.AddWithValue("GroupUUID", Util.ToRawUuidString(land.GroupID)); + cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString()); cmd.Parameters.AddWithValue("SalePrice", land.SalePrice); cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus cmd.Parameters.AddWithValue("LandFlags", land.Flags); cmd.Parameters.AddWithValue("LandingType", land.LandingType); cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale); - cmd.Parameters.AddWithValue("MediaTextureUUID", Util.ToRawUuidString(land.MediaID)); + cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString()); cmd.Parameters.AddWithValue("MediaURL", land.MediaURL); cmd.Parameters.AddWithValue("MusicURL", land.MusicURL); cmd.Parameters.AddWithValue("PassHours", land.PassHours); cmd.Parameters.AddWithValue("PassPrice", land.PassPrice); - cmd.Parameters.AddWithValue("SnapshotUUID", Util.ToRawUuidString(land.SnapshotID)); + cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString()); cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X); cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y); cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z); @@ -1408,8 +1404,8 @@ namespace OpenSim.Data.MySQL /// private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) { - cmd.Parameters.AddWithValue("LandUUID", Util.ToRawUuidString(parcelID)); - cmd.Parameters.AddWithValue("AccessUUID", Util.ToRawUuidString(entry.AgentID)); + cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); + cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); cmd.Parameters.AddWithValue("Flags", entry.Flags); } @@ -1465,7 +1461,7 @@ namespace OpenSim.Data.MySQL private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim) { PrimitiveBaseShape s = prim.Shape; - cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID)); + cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); // shape is an enum cmd.Parameters.AddWithValue("Shape", 0); // vectors @@ -1533,8 +1529,9 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + cmd.Dispose(); } } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/028_RegionStore.sql b/OpenSim/Data/MySQL/Resources/028_RegionStore.sql new file mode 100644 index 0000000..078394f --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/028_RegionStore.sql @@ -0,0 +1,79 @@ +BEGIN; + +update terrain + set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) + where RegionUUID not like '%-%'; + + +update landaccesslist + set LandUUID = concat(substr(LandUUID, 1, 8), "-", substr(LandUUID, 9, 4), "-", substr(LandUUID, 13, 4), "-", substr(LandUUID, 17, 4), "-", substr(LandUUID, 21, 12)) + where LandUUID not like '%-%'; + +update landaccesslist + set AccessUUID = concat(substr(AccessUUID, 1, 8), "-", substr(AccessUUID, 9, 4), "-", substr(AccessUUID, 13, 4), "-", substr(AccessUUID, 17, 4), "-", substr(AccessUUID, 21, 12)) + where AccessUUID not like '%-%'; + + +update prims + set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) + where UUID not like '%-%'; + +update prims + set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) + where RegionUUID not like '%-%'; + +update prims + set SceneGroupID = concat(substr(SceneGroupID, 1, 8), "-", substr(SceneGroupID, 9, 4), "-", substr(SceneGroupID, 13, 4), "-", substr(SceneGroupID, 17, 4), "-", substr(SceneGroupID, 21, 12)) + where SceneGroupID not like '%-%'; + +update prims + set CreatorID = concat(substr(CreatorID, 1, 8), "-", substr(CreatorID, 9, 4), "-", substr(CreatorID, 13, 4), "-", substr(CreatorID, 17, 4), "-", substr(CreatorID, 21, 12)) + where CreatorID not like '%-%'; + +update prims + set OwnerID = concat(substr(OwnerID, 1, 8), "-", substr(OwnerID, 9, 4), "-", substr(OwnerID, 13, 4), "-", substr(OwnerID, 17, 4), "-", substr(OwnerID, 21, 12)) + where OwnerID not like '%-%'; + +update prims + set GroupID = concat(substr(GroupID, 1, 8), "-", substr(GroupID, 9, 4), "-", substr(GroupID, 13, 4), "-", substr(GroupID, 17, 4), "-", substr(GroupID, 21, 12)) + where GroupID not like '%-%'; + +update prims + set LastOwnerID = concat(substr(LastOwnerID, 1, 8), "-", substr(LastOwnerID, 9, 4), "-", substr(LastOwnerID, 13, 4), "-", substr(LastOwnerID, 17, 4), "-", substr(LastOwnerID, 21, 12)) + where LastOwnerID not like '%-%'; + + +update primshapes + set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) + where UUID not like '%-%'; + + +update land + set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) + where UUID not like '%-%'; + +update land + set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) + where RegionUUID not like '%-%'; + +update land + set OwnerUUID = concat(substr(OwnerUUID, 1, 8), "-", substr(OwnerUUID, 9, 4), "-", substr(OwnerUUID, 13, 4), "-", substr(OwnerUUID, 17, 4), "-", substr(OwnerUUID, 21, 12)) + where OwnerUUID not like '%-%'; + +update land + set GroupUUID = concat(substr(GroupUUID, 1, 8), "-", substr(GroupUUID, 9, 4), "-", substr(GroupUUID, 13, 4), "-", substr(GroupUUID, 17, 4), "-", substr(GroupUUID, 21, 12)) + where GroupUUID not like '%-%'; + +update land + set MediaTextureUUID = concat(substr(MediaTextureUUID, 1, 8), "-", substr(MediaTextureUUID, 9, 4), "-", substr(MediaTextureUUID, 13, 4), "-", substr(MediaTextureUUID, 17, 4), "-", substr(MediaTextureUUID, 21, 12)) + where MediaTextureUUID not like '%-%'; + +update land + set SnapshotUUID = concat(substr(SnapshotUUID, 1, 8), "-", substr(SnapshotUUID, 9, 4), "-", substr(SnapshotUUID, 13, 4), "-", substr(SnapshotUUID, 17, 4), "-", substr(SnapshotUUID, 21, 12)) + where SnapshotUUID not like '%-%'; + +update land + set AuthbuyerID = concat(substr(AuthbuyerID, 1, 8), "-", substr(AuthbuyerID, 9, 4), "-", substr(AuthbuyerID, 13, 4), "-", substr(AuthbuyerID, 17, 4), "-", substr(AuthbuyerID, 21, 12)) + where AuthbuyerID not like '%-%'; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 3485b2b1c3d7acf56ce3d7d1d3498c2d19567038 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 8 May 2009 12:28:22 +0000 Subject: now that creatorID is no longer a strict UUID, and the column can still be NULL, we lost protection from NULL strings. This puts some protection in for that case. This may address many of the inventory issues that are being seen intermitently. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 7092096..66e13a9 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -306,7 +306,16 @@ namespace OpenSim.Data.MySQL try { InventoryItemBase item = new InventoryItemBase(); - item.CreatorId = (string)reader["creatorID"]; + + // TODO: this is to handle a case where NULLs creep in there, which we are not sure is indemic to the system, or legacy. It would be nice to live fix these. + if (reader["creatorID"] == null) + { + item.CreatorId = UUID.Zero.ToString(); + } + else + { + item.CreatorId = (string)reader["creatorID"]; + } // Be a bit safer in parsing these because the // database doesn't enforce them to be not null, and -- cgit v1.1 From 51a9c91909897f37c085afc0d1d62e120e9be31f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 8 May 2009 14:16:07 +0000 Subject: WARNING: contains migration Since creatorID is no longer treated as a UUID type in the code from the database we need to make sure that it isn't null in the database. This updates all empty string and null values for this column to the Zero UUID, and makes the column a not null definition with a default fo the Zero UUID. --- OpenSim/Data/MySQL/Resources/004_InventoryStore.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/004_InventoryStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/004_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/004_InventoryStore.sql new file mode 100644 index 0000000..c45f773 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_InventoryStore.sql @@ -0,0 +1,7 @@ +BEGIN; + +update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID is NULL; +update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID = ''; +alter table inventoryitems modify column creatorID varchar(36) not NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; -- cgit v1.1 From c1d680b6c3a5e3dc11cd1e7cc9b74d3d81317eee Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 12 May 2009 03:30:37 +0000 Subject: Thank you kindly, Patnad, for a patch that: This is to handle the changes in the v1.23 viewer of LL regarding the adult rating. With this patch a region can be changed to the adult rating from LL viewer v1.23 and above. --- OpenSim/Data/MySQL/MySQLManager.cs | 6 ++++-- OpenSim/Data/MySQL/Resources/002_GridStore.sql | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/002_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index ad022a5..139d57f 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -436,6 +436,7 @@ namespace OpenSim.Data.MySQL // World Map Addition UUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); UUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); + retval.maturity = Convert.ToUInt32(reader["access"]); } else { @@ -976,13 +977,13 @@ namespace OpenSim.Data.MySQL // server for the UUID of the region's owner (master avatar). It consists of the addition of the column and value to the relevant sql, // as well as the related parameterization sql += - "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID) VALUES "; + "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID, access) VALUES "; sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; sql += - "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid, ?originUUID)"; + "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid, ?originUUID, ?access)"; if (GRID_ONLY_UPDATE_NECESSARY_DATA) { @@ -1023,6 +1024,7 @@ namespace OpenSim.Data.MySQL parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString(); parameters["?owner_uuid"] = regiondata.owner_uuid.ToString(); parameters["?originUUID"] = regiondata.originUUID.ToString(); + parameters["?access"] = regiondata.maturity.ToString(); bool returnval = false; diff --git a/OpenSim/Data/MySQL/Resources/002_GridStore.sql b/OpenSim/Data/MySQL/Resources/002_GridStore.sql new file mode 100644 index 0000000..bda43d0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_GridStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE regions add column access integer unsigned default 1; + +COMMIT; -- cgit v1.1 From 5cfd84c92427658d88c4b36e1470744babd3d54d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 17 May 2009 10:26:00 +0000 Subject: Update svn properties. --- OpenSim/Data/MySQL/Resources/002_GridStore.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_GridStore.sql b/OpenSim/Data/MySQL/Resources/002_GridStore.sql index bda43d0..35b9be1 100644 --- a/OpenSim/Data/MySQL/Resources/002_GridStore.sql +++ b/OpenSim/Data/MySQL/Resources/002_GridStore.sql @@ -1,5 +1,5 @@ -BEGIN; - -ALTER TABLE regions add column access integer unsigned default 1; - -COMMIT; +BEGIN; + +ALTER TABLE regions add column access integer unsigned default 1; + +COMMIT; -- cgit v1.1 From 0bff818d39617f9aa1a8146fc2ad9bc15efb4698 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 25 May 2009 11:26:36 +0000 Subject: From: Chris Yeoh The attached patch implements llPassTouches. It has been added to the export/import XML along with the flag for AllowedInventoryDrop. The MySQL backend has been updated as well, though I haven't done one of those before so could do with a check. I added the migration mysql file as well. The other data backends need updating as well. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index b13813f..8a24fec 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -196,6 +196,7 @@ namespace OpenSim.Data.MySQL "ColorR, ColorG, ColorB, ColorA, "+ "ParticleSystem, ClickAction, Material, "+ "CollisionSound, CollisionSoundVolume, "+ + "PassTouches, "+ "LinkNumber) values (" + "?UUID, "+ "?CreationDate, ?Name, ?Text, "+ "?Description, ?SitName, ?TouchName, "+ @@ -227,7 +228,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, "+ "?ColorB, ?ColorA, ?ParticleSystem, "+ "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?LinkNumber)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -950,6 +951,9 @@ namespace OpenSim.Data.MySQL prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); + + if (Convert.ToInt16(row["PassTouches"]) != 0) + prim.PassTouches = true; prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); return prim; @@ -1272,6 +1276,12 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); + + if (prim.PassTouches) + cmd.Parameters.AddWithValue("PassTouches", 1); + else + cmd.Parameters.AddWithValue("PassTouches", 0); + cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); } @@ -1534,4 +1544,4 @@ namespace OpenSim.Data.MySQL } } } -} \ No newline at end of file +} -- cgit v1.1 From c18c1f6c7ce8fc17923b6ff847589191fd95c847 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 25 May 2009 11:32:31 +0000 Subject: Revert "From: Chris Yeoh " This reverts r9666. for some reason the mysql update does not work. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 8a24fec..b13813f 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -196,7 +196,6 @@ namespace OpenSim.Data.MySQL "ColorR, ColorG, ColorB, ColorA, "+ "ParticleSystem, ClickAction, Material, "+ "CollisionSound, CollisionSoundVolume, "+ - "PassTouches, "+ "LinkNumber) values (" + "?UUID, "+ "?CreationDate, ?Name, ?Text, "+ "?Description, ?SitName, ?TouchName, "+ @@ -228,7 +227,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, "+ "?ColorB, ?ColorA, ?ParticleSystem, "+ "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; + "?CollisionSoundVolume, ?LinkNumber)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -951,9 +950,6 @@ namespace OpenSim.Data.MySQL prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); - - if (Convert.ToInt16(row["PassTouches"]) != 0) - prim.PassTouches = true; prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); return prim; @@ -1276,12 +1272,6 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); - - if (prim.PassTouches) - cmd.Parameters.AddWithValue("PassTouches", 1); - else - cmd.Parameters.AddWithValue("PassTouches", 0); - cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); } @@ -1544,4 +1534,4 @@ namespace OpenSim.Data.MySQL } } } -} +} \ No newline at end of file -- cgit v1.1 From ba360ede8b876c5c1b99b4f172eb5d254a1c6f5a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 25 May 2009 11:43:56 +0000 Subject: * Upped version number to 0.6.5 --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 986a583..b494042 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.4.*")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From 901fdca13b8b6617ceabc4766c684799f4f8739b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 27 May 2009 18:01:06 +0000 Subject: From: Chris Yeoh The attached patch implements llPassTouches. It has been added to the export/import XML along with the flag for AllowedInventoryDrop. The MySQL backend has been updated as well, though I haven't done one of those before so could do with a check. I added the migration mysql file as well. The other data backends need updating as well. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 14 ++++++++++++-- OpenSim/Data/MySQL/Resources/029_RegionStore.sql | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/029_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index b13813f..8a24fec 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -196,6 +196,7 @@ namespace OpenSim.Data.MySQL "ColorR, ColorG, ColorB, ColorA, "+ "ParticleSystem, ClickAction, Material, "+ "CollisionSound, CollisionSoundVolume, "+ + "PassTouches, "+ "LinkNumber) values (" + "?UUID, "+ "?CreationDate, ?Name, ?Text, "+ "?Description, ?SitName, ?TouchName, "+ @@ -227,7 +228,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, "+ "?ColorB, ?ColorA, ?ParticleSystem, "+ "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?LinkNumber)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -950,6 +951,9 @@ namespace OpenSim.Data.MySQL prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); + + if (Convert.ToInt16(row["PassTouches"]) != 0) + prim.PassTouches = true; prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); return prim; @@ -1272,6 +1276,12 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); + + if (prim.PassTouches) + cmd.Parameters.AddWithValue("PassTouches", 1); + else + cmd.Parameters.AddWithValue("PassTouches", 0); + cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); } @@ -1534,4 +1544,4 @@ namespace OpenSim.Data.MySQL } } } -} \ No newline at end of file +} diff --git a/OpenSim/Data/MySQL/Resources/029_RegionStore.sql b/OpenSim/Data/MySQL/Resources/029_RegionStore.sql new file mode 100644 index 0000000..b5962a2 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/029_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE prims ADD COLUMN PassTouches tinyint not null default 0; + +COMMIT; -- cgit v1.1 From 840de6c036570d559ec6924cd8405d3f34a99fdd Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 1 Jun 2009 06:37:14 +0000 Subject: Minor: Change OpenSim to OpenSimulator in older copyright headers and LICENSE.txt. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLEstateData.cs | 2 +- OpenSim/Data/MySQL/MySQLGridData.cs | 2 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLLogData.cs | 2 +- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 2 +- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index cc16389..c22f645 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 133ee7a..e8694fc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 75901b2..0a5800b 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 66e13a9..e48f26a 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 13361af..8f67eeb 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 139d57f..a6cce57 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 8a24fec..7038396 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 0f167b2..537ef6c 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index b494042..c28829c 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index fd6f508..e1d3f81 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 148d910..48486b1 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index 23512dc..7c36375 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index f539359..23c1ec5 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index b8fac69..0dc8b7d 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs index 3da06c8..cf8139a 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * -- cgit v1.1 From 717fd3b5b91f54113ef554799f124275d5489ea1 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 3 Jun 2009 12:48:04 +0000 Subject: From: Chris Yeoh This patch adds oar file date and time (UTC) meta data to an oar file when it is created. It also adds a unique ID, though this id does not in anyway identify the machine that the oar file was created on. When an oar file with this meta data is loaded this extra information is saved with the region settings and available via LSL through: - osLoadedCreationDate() - osLoadedCreationTime() - osLoadedCreationID() If there is no meta data these fields will be blank. Subsequent oar file loads will erase the information for the previous oar file load. Persistence has only been implemented for MySQL, the other backends need updating. Overall this allows us to much more easily identify the specific version of software that clients are using. Its very straightforward to edit the oar file to change the ID string to be something more human friendly. Included in the patch is a new file OpenSim/Data/MySQL/Resources/030_RegionStore.sql required for the MySQL DB migration. btw I had a chat with justincc about this a few weeks ago since he wrote the oar file import/export and he sounded happy to accept something that included date/time information but didn't want anything that would silently leak private information like machine names. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 26 ++++++++++++++++++++++-- OpenSim/Data/MySQL/Resources/030_RegionStore.sql | 7 +++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/030_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 7038396..72c089e 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -741,7 +741,8 @@ namespace OpenSim.Data.MySQL "terrain_raise_limit, terrain_lower_limit, " + "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " + + "sunvectorz, loaded_creation_date, loaded_creation_time, " + + "loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + @@ -754,12 +755,14 @@ namespace OpenSim.Data.MySQL "?WaterHeight, ?TerrainRaiseLimit, " + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ)"; + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + + "?LoadedCreationDate, ?LoadedCreationTime, ?LoadedCreationID)"; FillRegionSettingsCommand(cmd, rs); ExecuteNonQuery(cmd); cmd.Dispose(); + } } @@ -1039,6 +1042,21 @@ namespace OpenSim.Data.MySQL newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new UUID((String) row["covenant"]); + if (row["loaded_creation_date"] is DBNull) + newSettings.LoadedCreationDate = ""; + else + newSettings.LoadedCreationDate = (String) row["loaded_creation_date"]; + + if (row["loaded_creation_time"] is DBNull) + newSettings.LoadedCreationTime = ""; + else + newSettings.LoadedCreationTime = (String) row["loaded_creation_time"]; + + if (row["loaded_creation_id"] is DBNull) + newSettings.LoadedCreationID = ""; + else + newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; + return newSettings; } @@ -1357,6 +1375,10 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); + cmd.Parameters.AddWithValue("LoadedCreationDate", settings.LoadedCreationDate); + cmd.Parameters.AddWithValue("LoadedCreationTime", settings.LoadedCreationTime); + cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); + } /// diff --git a/OpenSim/Data/MySQL/Resources/030_RegionStore.sql b/OpenSim/Data/MySQL/Resources/030_RegionStore.sql new file mode 100644 index 0000000..dfdcf6d --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/030_RegionStore.sql @@ -0,0 +1,7 @@ +BEGIN; + +ALTER TABLE regionsettings ADD COLUMN loaded_creation_date varchar(20) default NULL; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_time varchar(20) default NULL; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_id varchar(64) default NULL; + +COMMIT; -- cgit v1.1 From 3dc2010da6412941bfbcdb29007b12a8f37b7bef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 29 Jun 2009 15:05:12 +0000 Subject: From: Chris Yeoh Attached is a patch that changes the oar file saving of creation date/time to an integer instead of a string. I did this after justincc emailed me saying there is a problem with internationalisation doing it the old way and I said I'd fix it. Its been tested with MySQL and I've made the changes for MSSQL but that hasn't been well tested. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 17 ++++------------- OpenSim/Data/MySQL/Resources/031_RegionStore.sql | 7 +++++++ 2 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/031_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 72c089e..a72ae45 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -741,7 +741,7 @@ namespace OpenSim.Data.MySQL "terrain_raise_limit, terrain_lower_limit, " + "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz, loaded_creation_date, loaded_creation_time, " + + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + @@ -756,7 +756,7 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDate, ?LoadedCreationTime, ?LoadedCreationID)"; + "?LoadedCreationDateTime, ?LoadedCreationID)"; FillRegionSettingsCommand(cmd, rs); @@ -1042,15 +1042,7 @@ namespace OpenSim.Data.MySQL newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new UUID((String) row["covenant"]); - if (row["loaded_creation_date"] is DBNull) - newSettings.LoadedCreationDate = ""; - else - newSettings.LoadedCreationDate = (String) row["loaded_creation_date"]; - - if (row["loaded_creation_time"] is DBNull) - newSettings.LoadedCreationTime = ""; - else - newSettings.LoadedCreationTime = (String) row["loaded_creation_time"]; + newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); if (row["loaded_creation_id"] is DBNull) newSettings.LoadedCreationID = ""; @@ -1375,8 +1367,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); - cmd.Parameters.AddWithValue("LoadedCreationDate", settings.LoadedCreationDate); - cmd.Parameters.AddWithValue("LoadedCreationTime", settings.LoadedCreationTime); + cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDate); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); } diff --git a/OpenSim/Data/MySQL/Resources/031_RegionStore.sql b/OpenSim/Data/MySQL/Resources/031_RegionStore.sql new file mode 100644 index 0000000..d069296 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/031_RegionStore.sql @@ -0,0 +1,7 @@ +BEGIN; + +ALTER TABLE regionsettings DROP COLUMN loaded_creation_date; +ALTER TABLE regionsettings DROP COLUMN loaded_creation_time; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT NULL default 0; + +COMMIT; -- cgit v1.1 From fe21189aa477fe3e8f209050533c90f75740c365 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 30 Jun 2009 13:50:12 +0000 Subject: From: Chris Yeoh Ooops, sorry there was a bug in the patch and causes an exception on some system (I think it only happens on windows since it didn't occur during my testin). I've attached a one liner which fixes the problem. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a72ae45..fafba16 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1367,7 +1367,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); - cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDate); + cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); } -- cgit v1.1 From c3bb9ec42ccc86d55055494bad31835a0fae00d2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 24 Jul 2009 20:01:17 +0000 Subject: * Apply asset and inventory name and description bound checks to MySQL --- OpenSim/Data/MySQL/MySQLAssetData.cs | 18 ++++++++++++++++-- OpenSim/Data/MySQL/MySQLInventoryData.cs | 27 ++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index c22f645..26cdd06 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -210,6 +210,20 @@ namespace OpenSim.Data.MySQL "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", _dbConnection.Connection); + string assetName = asset.Name; + if (asset.Name.Length > 64) + { + assetName = asset.Name.Substring(0, 64); + m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + } + + string assetDescription = asset.Description; + if (asset.Description.Length > 64) + { + assetDescription = asset.Description.Substring(0, 64); + m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + } + // need to ensure we dispose try { @@ -218,8 +232,8 @@ namespace OpenSim.Data.MySQL // create unix epoch time int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?name", asset.Name); - cmd.Parameters.AddWithValue("?description", asset.Description); + cmd.Parameters.AddWithValue("?name", assetName); + cmd.Parameters.AddWithValue("?description", assetDescription); cmd.Parameters.AddWithValue("?assetType", asset.Type); cmd.Parameters.AddWithValue("?local", asset.Local); cmd.Parameters.AddWithValue("?temporary", asset.Temporary); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index e48f26a..a4b8663 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -471,6 +471,20 @@ namespace OpenSim.Data.MySQL + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" + ", ?groupID, ?groupOwned, ?flags)"; + string itemName = item.Name; + if (item.Name.Length > 64) + { + itemName = item.Name.Substring(0, 64); + m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length + " to " + itemName.Length + " characters on add item"); + } + + string itemDesc = item.Description; + if (item.Description.Length > 128) + { + itemDesc = item.Description.Substring(0, 128); + m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length + " to " + itemDesc.Length + " characters on add item"); + } + try { database.CheckConnection(); @@ -481,8 +495,8 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); - result.Parameters.AddWithValue("?inventoryName", item.Name); - result.Parameters.AddWithValue("?inventoryDescription", item.Description); + result.Parameters.AddWithValue("?inventoryName", itemName); + result.Parameters.AddWithValue("?inventoryDescription", itemDesc); result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.CurrentPermissions.ToString()); @@ -575,13 +589,20 @@ namespace OpenSim.Data.MySQL "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; + string folderName = folder.Name; + if (folderName.Length > 64) + { + folderName = folderName.Substring(0, 64); + m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder"); + } + database.CheckConnection(); MySqlCommand cmd = new MySqlCommand(sql, database.Connection); cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); - cmd.Parameters.AddWithValue("?folderName", folder.Name); + cmd.Parameters.AddWithValue("?folderName", folderName); cmd.Parameters.AddWithValue("?type", (short) folder.Type); cmd.Parameters.AddWithValue("?version", folder.Version); -- cgit v1.1 From 64bd9a335444379ebe1cad8e34d5b5953a76f671 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 25 Jul 2009 15:49:10 +0000 Subject: * Updates libOMV to version 0.7.0 * Uses mantis #3811 as a base (thanks jhuliman) with changes. * E-mail regarding interface changes sent to the opensim-dev list * Archive: https://lists.berlios.de/pipermail/opensim-dev/2009-July/007219.html --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index fafba16..09564de 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1073,13 +1073,13 @@ namespace OpenSim.Data.MySQL newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); newData.Area = Convert.ToInt32(row["Area"]); newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented - newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); newData.GroupID = new UUID((String) row["GroupUUID"]); newData.SalePrice = Convert.ToInt32(row["SalePrice"]); - newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus newData.Flags = Convert.ToUInt32(row["LandFlags"]); newData.LandingType = Convert.ToByte(row["LandingType"]); -- cgit v1.1 From c8a68fb3fbac0d99b53a62bb062232c0d5695d3c Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 7 Aug 2009 18:40:56 -0400 Subject: * Remove hard coded 256 limitations from various places. There's no more 256m limitation within the OpenSimulator framework, however, the LLClient ClientView does not support regions larger then 256 meters so, if you try and make your region larger by setting Constants.RegionSize = 512; in OpenSim.Framework.Constants.cs, the terrain will not display on clients using the LLUDP protocol --- OpenSim/Data/MySQL/MySQLRegionData.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 09564de..2166845 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -583,16 +583,16 @@ namespace OpenSim.Data.MySQL { while (reader.Read()) { - terrain = new double[256,256]; + terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; terrain.Initialize(); MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); int rev = 0; BinaryReader br = new BinaryReader(mstr); - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { terrain[x, y] = br.ReadDouble(); } @@ -1141,12 +1141,12 @@ namespace OpenSim.Data.MySQL /// private static Array SerializeTerrain(double[,] val) { - MemoryStream str = new MemoryStream(65536*sizeof (double)); + MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) + for (int x = 0; x < (int)Constants.RegionSize; x++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { double height = val[x, y]; if (height == 0.0) -- cgit v1.1 From 23d478f2fa06d1dedabfb24cf6ff763b586173ce Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 9 Aug 2009 02:01:21 -0500 Subject: Adding in Reflection-based testing, to ensure that all properties are covered. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 1 + OpenSim/Data/MySQL/MySQLInventoryData.cs | 11 ++++++----- OpenSim/Data/MySQL/MySQLRegionData.cs | 17 ++++++++++------- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 8 ++++++++ OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 12 +++++++++--- 5 files changed, 34 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 26cdd06..5d87649 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -168,6 +168,7 @@ namespace OpenSim.Data.MySQL } asset.Name = (string) dbReader["name"]; asset.Type = (sbyte) dbReader["assetType"]; + asset.Temporary = (bool)dbReader["temporary"]; } dbReader.Close(); cmd.Dispose(); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index a4b8663..121ef7a 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -342,7 +342,7 @@ namespace OpenSim.Data.MySQL item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; item.GroupPermissions = (uint) reader["inventoryGroupPermissions"]; item.SalePrice = (int) reader["salePrice"]; - item.SaleType = Convert.ToByte(reader["saleType"]); + item.SaleType = unchecked((byte)(Convert.ToSByte(reader["saleType"]))); item.CreationDate = (int) reader["creationDate"]; item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); item.Flags = (uint) reader["flags"]; @@ -423,7 +423,7 @@ namespace OpenSim.Data.MySQL /// /// Returns a specified inventory folder /// - /// The folder to return + /// The folder to return /// A folder class public InventoryFolderBase getInventoryFolder(UUID folderID) { @@ -438,8 +438,9 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?uuid", folderID.ToString()); MySqlDataReader reader = result.ExecuteReader(); - reader.Read(); - InventoryFolderBase folder = readInventoryFolder(reader); + InventoryFolderBase folder = null; + if(reader.Read()) + folder = readInventoryFolder(reader); reader.Close(); result.Dispose(); @@ -506,7 +507,7 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); result.Parameters.AddWithValue("?salePrice", item.SalePrice); - result.Parameters.AddWithValue("?saleType", item.SaleType); + result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); result.Parameters.AddWithValue("?creationDate", item.CreationDate); result.Parameters.AddWithValue("?groupID", item.GroupID); result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 2166845..9c2ee4a 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -834,7 +834,10 @@ namespace OpenSim.Data.MySQL // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - prim.Name = (String) row["Name"]; + if (row["Name"] != DBNull.Value) + prim.Name = (String)row["Name"]; + else + prim.Name = string.Empty; // various text fields prim.Text = (String) row["Text"]; prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), @@ -945,12 +948,12 @@ namespace OpenSim.Data.MySQL prim.DIE_AT_EDGE = true; prim.SalePrice = Convert.ToInt32(row["SalePrice"]); - prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); + prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"])); - prim.Material = Convert.ToByte(row["Material"]); + prim.Material = unchecked((byte)Convert.ToSByte(row["Material"])); if (!(row["ClickAction"] is DBNull)) - prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]); + prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"])); prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); @@ -1277,12 +1280,12 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("DieAtEdge", 0); cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); - cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType)); + cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType))); byte clickAction = prim.ClickAction; - cmd.Parameters.AddWithValue("ClickAction", clickAction); + cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction))); - cmd.Parameters.AddWithValue("Material", prim.Material); + cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material))); cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index 7c36375..d1d5c2a 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -62,11 +62,18 @@ namespace OpenSim.Data.MySQL.Tests m_log.Error("Exception {0}", e); Assert.Ignore(); } + + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration(database.Connection, assem, "GridStore"); + + m.Update(); } [TestFixtureTearDown] public void Cleanup() { + m_log.Warn("Cleaning up."); if (db != null) { db.Dispose(); @@ -74,6 +81,7 @@ namespace OpenSim.Data.MySQL.Tests // if a new table is added, it has to be dropped here if (database != null) { + database.ExecuteSql("drop table migrations"); database.ExecuteSql("drop table regions"); } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index 23c1ec5..a3a32dc 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -53,6 +53,7 @@ namespace OpenSim.Data.MySQL.Tests try { database = new MySQLManager(connect); + DropTables(); db = new MySQLInventoryData(); db.Initialise(connect); } @@ -72,10 +73,15 @@ namespace OpenSim.Data.MySQL.Tests } if (database != null) { - database.ExecuteSql("drop table inventoryitems"); - database.ExecuteSql("drop table inventoryfolders"); - database.ExecuteSql("drop table migrations"); + DropTables(); } } + + private void DropTables() + { + database.ExecuteSql("drop table IF EXISTS inventoryitems"); + database.ExecuteSql("drop table IF EXISTS inventoryfolders"); + database.ExecuteSql("drop table IF EXISTS migrations"); + } } } -- cgit v1.1 From d2e5380cb2325ad42917c528c52a8ad42ec0176f Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sat, 15 Aug 2009 10:54:48 -0500 Subject: * Fixed MySQL/MySQLAssetData.cs to properly do updates * Removed an extra parameter from MySQL/MySQLInventoryData.cs * Fixed a bug in SQLite/SQLiteAssetData.cs that was causing a NRE when updating an asset. * Improved the BasicAssetTest.cs to do full create/update/get testing * Improved the BasicInventoryTest.cs to do full create/update/get of both a folder and an item * Moved the null ref tests to the start of the PropertyCompareConstraint.cs, so that it doesn't throw when passing in a null item --- OpenSim/Data/MySQL/MySQLAssetData.cs | 9 +-------- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 5d87649..0865083 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -196,18 +196,11 @@ namespace OpenSim.Data.MySQL { lock (_dbConnection) { - //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID); - if (ExistsAsset(asset.FullID)) - { - //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); - return; - } - _dbConnection.CheckConnection(); MySqlCommand cmd = new MySqlCommand( - "insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", _dbConnection.Connection); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 121ef7a..849c246 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -604,7 +604,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); cmd.Parameters.AddWithValue("?folderName", folderName); - cmd.Parameters.AddWithValue("?type", (short) folder.Type); + cmd.Parameters.AddWithValue("?type", folder.Type); cmd.Parameters.AddWithValue("?version", folder.Version); try -- cgit v1.1 From 82c888fc6c103ec345bf656cd469f4260b678bcb Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 17 Aug 2009 10:29:06 +0900 Subject: Add copyright headers. Formatting cleanup. Fix a compiler warning. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 849c246..4521a0f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -439,7 +439,7 @@ namespace OpenSim.Data.MySQL MySqlDataReader reader = result.ExecuteReader(); InventoryFolderBase folder = null; - if(reader.Read()) + if (reader.Read()) folder = readInventoryFolder(reader); reader.Close(); result.Dispose(); -- cgit v1.1 From f1287cc7af7da26910c5cba456a8c35b6454d815 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 16 Aug 2009 18:54:20 -0500 Subject: * Switching IAssetData to follow the new naming schema, removing the separate insert and update methods. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 0865083..1b4377a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -135,7 +135,7 @@ namespace OpenSim.Data.MySQL /// Asset UUID to fetch /// Return the asset /// On failure : throw an exception and attempt to reconnect to database - override protected AssetBase FetchStoredAsset(UUID assetID) + override public AssetBase GetAsset(UUID assetID) { AssetBase asset = null; lock (_dbConnection) @@ -192,7 +192,7 @@ namespace OpenSim.Data.MySQL /// /// Asset UUID to create /// On failure : Throw an exception and attempt to reconnect to database - override public void CreateAsset(AssetBase asset) + override public void StoreAsset(AssetBase asset) { lock (_dbConnection) { @@ -285,15 +285,6 @@ namespace OpenSim.Data.MySQL } /// - /// Update a asset in database, see - /// - /// Asset UUID to update - override public void UpdateAsset(AssetBase asset) - { - CreateAsset(asset); - } - - /// /// check if the asset UUID exist in database /// /// The asset UUID -- cgit v1.1 From b1853d9f265fb32cf51d65fdcf2d5b4741911f00 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 16 Aug 2009 23:25:12 -0500 Subject: Fixing a spot I missed in assets. Switching Grid to the new naming schema with Store/Get --- OpenSim/Data/MySQL/MySQLGridData.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 0a5800b..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -391,7 +391,7 @@ namespace OpenSim.Data.MySQL /// /// The profile to add /// Successful? - override public DataResponse AddProfile(RegionProfileData profile) + override public DataResponse StoreProfile(RegionProfileData profile) { MySQLSuperManager dbm = GetLockedConnection(); try { @@ -408,17 +408,6 @@ namespace OpenSim.Data.MySQL } /// - /// Update a sim profile - /// - /// The profile to update - /// Sucessful? - /// Same as AddProfile - override public DataResponse UpdateProfile(RegionProfileData profile) - { - return AddProfile(profile); - } - - /// /// Deletes a sim profile from the database /// /// the sim UUID -- cgit v1.1 From 604ef5ba799c4ac6af4a965ede726faf42916ad6 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Fri, 21 Aug 2009 17:48:45 -0300 Subject: Fix issue where conversion of temporary boolean variable fails on MySQL --- OpenSim/Data/MySQL/MySQLAssetData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 1b4377a..66c34fe 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -168,7 +168,7 @@ namespace OpenSim.Data.MySQL } asset.Name = (string) dbReader["name"]; asset.Type = (sbyte) dbReader["assetType"]; - asset.Temporary = (bool)dbReader["temporary"]; + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } dbReader.Close(); cmd.Dispose(); @@ -359,7 +359,7 @@ namespace OpenSim.Data.MySQL metadata.Name = (string) dbReader["name"]; metadata.Description = (string) dbReader["description"]; metadata.Type = (sbyte) dbReader["assetType"]; - metadata.Temporary = (bool) dbReader["temporary"]; // Not sure if this is correct. + metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. metadata.FullID = new UUID((string) dbReader["id"]); // Current SHA1s are not stored/computed. -- cgit v1.1 From f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Sep 2009 03:33:31 +0100 Subject: Thank you, dslake, for a set of patches to improve OpenSim startup and idle performance. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 49 ++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 9c2ee4a..4a16a70 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -412,8 +412,8 @@ namespace OpenSim.Data.MySQL public List LoadObjects(UUID regionUUID) { UUID lastGroupID = UUID.Zero; - List objects = new List(); - List prims = new List(); + Dictionary objects = new Dictionary(); + Dictionary prims = new Dictionary(); SceneObjectGroup grp = null; lock (m_Connection) @@ -441,14 +441,14 @@ namespace OpenSim.Data.MySQL else prim.Shape = BuildShape(reader); - prims.Add(prim); + prims[prim.UUID] = prim; UUID groupID = new UUID(reader["SceneGroupID"].ToString()); if (groupID != lastGroupID) // New SOG { if (grp != null) - objects.Add(grp); + objects[grp.UUID] = grp; lastGroupID = groupID; @@ -487,16 +487,47 @@ namespace OpenSim.Data.MySQL } if (grp != null) - objects.Add(grp); + objects[grp.UUID] = grp; cmd.Dispose(); } - foreach (SceneObjectPart part in prims) - LoadItems(part); + // Instead of attempting to LoadItems on every prim, + // most of which probably have no items... get a + // list from DB of all prims which have items and + // LoadItems only on those + List primsWithInventory = new List(); + lock (m_Connection) + { + MySqlCommand itemCmd = m_Connection.CreateCommand(); + itemCmd.CommandText = "select distinct primID from primitems"; + IDataReader itemReader = ExecuteReader(itemCmd); + try + { + while (itemReader.Read()) + { + if (!(itemReader["primID"] is DBNull)) + { + UUID primID = new UUID(itemReader["primID"].ToString()); + if (prims.ContainsKey(primID)) + { + primsWithInventory.Add(prims[primID]); + } + } + } + } + finally + { + itemReader.Close(); + } + itemCmd.Dispose(); + } + foreach (SceneObjectPart prim in primsWithInventory) + { + LoadItems(prim); + } m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); - - return objects; + return new List(objects.Values); } /// -- cgit v1.1 From 90262d40929ab0bdf6888861608a0e712b793f48 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 00:23:26 +0100 Subject: Add the user authentication data adapter. This is meant to use a new table schema, but can read the old ones for compatibility. It should not be used to write to the old tables unless you know what you're doing! This is untested and will probably not work. --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 146 ++++++++++++++++++++++++++ OpenSim/Data/MySQL/MySQLFramework.cs | 115 ++++++++++++++++++++ 2 files changed, 261 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLAuthenticationData.cs create mode 100644 OpenSim/Data/MySQL/MySQLFramework.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs new file mode 100644 index 0000000..625d3b1 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -0,0 +1,146 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData + { + private string m_Realm; + private DataTable m_SchemaTable = null; + + public MySqlAuthenticationData(string connectionString, string realm) + : base(connectionString) + { + m_Realm = realm; + } + + public AuthenticationData Get(UUID principalID) + { + AuthenticationData ret = new AuthenticationData(); + ret.Data = new Dictionary(); + + MySqlCommand cmd = new MySqlCommand( + "select * from `"+m_Realm+"` where UUID = ?principalID" + ); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) + { + ret.PrincipalID = principalID; + + if (m_SchemaTable == null) + m_SchemaTable = result.GetSchemaTable(); + + foreach (DataColumn c in m_SchemaTable.Columns) + { + if (c.ColumnName == "UUID") + continue; + + ret.Data[c.ColumnName] = result[c.ColumnName].ToString(); + } + + result.Close(); + CloseReaderCommand(cmd); + + return ret; + } + + result.Close(); + CloseReaderCommand(cmd); + + return null; + } + + public bool Store(AuthenticationData data) + { + if (data.Data.ContainsKey("UUID")) + data.Data.Remove("UUID"); + + string[] fields = new List(data.Data.Keys).ToArray(); + + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) + { + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; + + first = false; + + cmd.Parameters.AddWithValue(field, data.Data[field]); + } + + update += " where UUID = ?principalID"; + + cmd.CommandText = update; + cmd.Parameters.AddWithValue("UUID", data.PrincipalID.ToString()); + + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`UUID`, `" + + String.Join("`, `", fields) + + "`) values ( ?UUID, ?" + String.Join(", ?", fields) + ")"; + + if (ExecuteNonQuery(cmd) < 0) + { + cmd.Dispose(); + return false; + } + } + + cmd.Dispose(); + + return true; + } + + public bool SetDataItem(UUID principalID, string item, string value) + { + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); + + + cmd.Parameters.AddWithValue(item, value); + cmd.Parameters.AddWithValue("UUID", principalID.ToString()); + + return false; + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs new file mode 100644 index 0000000..f2b31c4 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// + /// A database interface class to a user profile storage system + /// + public class MySqlFramework + { + protected MySqlConnection m_Connection; + + protected MySqlFramework(string connectionString) + { + m_Connection = new MySqlConnection(connectionString); + + m_Connection.Open(); + } + + ////////////////////////////////////////////////////////////// + // + // All non queries are funneled through one connection + // to increase performance a little + // + protected int ExecuteNonQuery(MySqlCommand cmd) + { + lock (m_Connection) + { + cmd.Connection = m_Connection; + + bool errorSeen = false; + + while (true) + { + try + { + return cmd.ExecuteNonQuery(); + } + catch (MySqlException e) + { + if (errorSeen) + throw; + + // This is "Server has gone away" and "Server lost" + // + if (e.Number == 2006 || e.Number == 2013) + { + errorSeen = true; + + m_Connection.Close(); + MySqlConnection newConnection = (MySqlConnection) + ((ICloneable)m_Connection).Clone(); + m_Connection.Dispose(); + m_Connection = newConnection; + m_Connection.Open(); + + cmd.Connection = m_Connection; + } + } + } + } + } + + protected IDataReader ExecuteReader(MySqlCommand cmd) + { + MySqlConnection newConnection = (MySqlConnection) + ((ICloneable)m_Connection).Clone(); + + newConnection.Open(); + + cmd.Connection = newConnection; + + return cmd.ExecuteReader(); + } + + protected void CloseReaderCommand(MySqlCommand cmd) + { + cmd.Connection.Close(); + cmd.Connection.Dispose(); + cmd.Dispose(); + } + } +} -- cgit v1.1 From c9a24ece546fb20977d27abef736cd5e45d976e2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 03:13:32 +0100 Subject: More work on new authentication service --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 35 ++++++++++++++++++--------- OpenSim/Data/MySQL/MySQLFramework.cs | 8 ++++++ 2 files changed, 31 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 625d3b1..19575ec 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData { private string m_Realm; - private DataTable m_SchemaTable = null; + private List m_ColumnNames = null; public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) @@ -63,15 +63,21 @@ namespace OpenSim.Data.MySQL { ret.PrincipalID = principalID; - if (m_SchemaTable == null) - m_SchemaTable = result.GetSchemaTable(); + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } - foreach (DataColumn c in m_SchemaTable.Columns) + foreach (string s in m_ColumnNames) { - if (c.ColumnName == "UUID") + if (s == "UUID") continue; - ret.Data[c.ColumnName] = result[c.ColumnName].ToString(); + ret.Data[s] = result[s].ToString(); } result.Close(); @@ -105,21 +111,23 @@ namespace OpenSim.Data.MySQL first = false; - cmd.Parameters.AddWithValue(field, data.Data[field]); + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); } update += " where UUID = ?principalID"; cmd.CommandText = update; - cmd.Parameters.AddWithValue("UUID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); if (ExecuteNonQuery(cmd) < 1) { string insert = "insert into `" + m_Realm + "` (`UUID`, `" + String.Join("`, `", fields) + - "`) values ( ?UUID, ?" + String.Join(", ?", fields) + ")"; + "`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")"; - if (ExecuteNonQuery(cmd) < 0) + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) { cmd.Dispose(); return false; @@ -137,8 +145,11 @@ namespace OpenSim.Data.MySQL "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - cmd.Parameters.AddWithValue(item, value); - cmd.Parameters.AddWithValue("UUID", principalID.ToString()); + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f2b31c4..6c73249 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -70,6 +70,7 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { +Console.WriteLine(e.ToString()); if (errorSeen) throw; @@ -88,6 +89,13 @@ namespace OpenSim.Data.MySQL cmd.Connection = m_Connection; } + else + throw; + } + catch (Exception e) + { +Console.WriteLine(e.ToString()); + return 0; } } } -- cgit v1.1 From ac40c7a74c15e0f61ba5bfcb4c6a6fb39993a87c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 07:48:09 +0100 Subject: Fully implement unencrypted auth token operations --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 19575ec..1ee64ce 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -39,6 +39,7 @@ namespace OpenSim.Data.MySQL { private string m_Realm; private List m_ColumnNames = null; + private int m_LastExpire = 0; public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) @@ -153,5 +154,56 @@ namespace OpenSim.Data.MySQL return false; } + + public bool SetToken(UUID principalID, string token, int lifetime) + { + if (System.Environment.TickCount - m_LastExpire > 30000) + DoExpire(); + + MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"); + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?token", token); + cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + { + cmd.Dispose(); + return true; + } + + cmd.Dispose(); + return false; + } + + public bool CheckToken(UUID principalID, string token, int lifetime) + { + if (System.Environment.TickCount - m_LastExpire > 30000) + DoExpire(); + + MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"); + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?token", token); + cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + { + cmd.Dispose(); + return true; + } + + cmd.Dispose(); + + return false; + } + + private void DoExpire() + { + MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"); + ExecuteNonQuery(cmd); + + cmd.Dispose(); + + m_LastExpire = System.Environment.TickCount; + } } } -- cgit v1.1 From 67f803c919324f49e21279faa43c9578b625529e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 08:10:05 +0100 Subject: Add the new AuthStore to migrations. Update OpenSim.Server.ini --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 3 +++ OpenSim/Data/MySQL/Resources/001_AuthStore.sql | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_AuthStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 1ee64ce..afd59bd 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -45,6 +45,9 @@ namespace OpenSim.Data.MySQL : base(connectionString) { m_Realm = realm; + + Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); + m.Update(); } public AuthenticationData Get(UUID principalID) diff --git a/OpenSim/Data/MySQL/Resources/001_AuthStore.sql b/OpenSim/Data/MySQL/Resources/001_AuthStore.sql new file mode 100644 index 0000000..c7e16fb --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_AuthStore.sql @@ -0,0 +1,21 @@ +begin; + +CREATE TABLE `auth` ( + `UUID` char(36) NOT NULL, + `passwordHash` char(32) NOT NULL default '', + `passwordSalt` char(32) NOT NULL default '', + `webLoginKey` varchar(255) NOT NULL default '', + PRIMARY KEY (`UUID`) +) ENGINE=InnoDB; + +CREATE TABLE `tokens` ( + `UUID` char(36) NOT NULL, + `token` varchar(255) NOT NULL, + `validity` datetime NOT NULL, + UNIQUE KEY `uuid_token` (`UUID`,`token`), + KEY `UUID` (`UUID`), + KEY `token` (`token`), + KEY `validity` (`validity`) +) ENGINE=InnoDB; + +commit; -- cgit v1.1 From 2a8f66b221e93fb2d693c1c273c2dee85439f835 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Sep 2009 04:28:42 +0100 Subject: Revising the user account data interfaces. No user functionality yet --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 180 +++++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/008_UserStore.sql | 5 + 2 files changed, 185 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLUserAccountData.cs create mode 100644 OpenSim/Data/MySQL/Resources/008_UserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs new file mode 100644 index 0000000..39d60ca --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -0,0 +1,180 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySqlUserAccountData : MySqlFramework, IUserAccountData + { + private string m_Realm; + private List m_ColumnNames = null; + private int m_LastExpire = 0; + + public MySqlUserAccountData(string connectionString, string realm) + : base(connectionString) + { + m_Realm = realm; + + Migration m = new Migration(m_Connection, GetType().Assembly, "UserStore"); + m.Update(); + } + + public List Query(UUID principalID, UUID scopeID, string query) + { + return null; + } + + public UserAccountData Get(UUID principalID, UUID scopeID) + { + UserAccountData ret = new UserAccountData(); + ret.Data = new Dictionary(); + + string command = "select * from `"+m_Realm+"` where UUID = ?principalID"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; + + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) + { + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + result.Close(); + CloseReaderCommand(cmd); + + return ret; + } + + result.Close(); + CloseReaderCommand(cmd); + + return null; + } + + public bool Store(UserAccountData data) + { + if (data.Data.ContainsKey("UUID")) + data.Data.Remove("UUID"); + if (data.Data.ContainsKey("ScopeID")) + data.Data.Remove("ScopeID"); + + string[] fields = new List(data.Data.Keys).ToArray(); + + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) + { + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; + + first = false; + + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } + + update += " where UUID = ?principalID"; + + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; + + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values ( ?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; + } + } + + cmd.Dispose(); + + return true; + } + + public bool SetDataItem(UUID principalID, string item, string value) + { + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); + + + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; + + return false; + } + } +} diff --git a/OpenSim/Data/MySQL/Resources/008_UserStore.sql b/OpenSim/Data/MySQL/Resources/008_UserStore.sql new file mode 100644 index 0000000..4500bd5 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/008_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE users add scopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; -- cgit v1.1 From 90a4d4f9f93eda3d707292c9619aecc765edada8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 16 Sep 2009 17:52:16 +0100 Subject: Adding the MySQL RegionData service. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 1594 ++++++++++++++++++++++++++ OpenSim/Data/MySQL/MySQLRegionData.cs | 1615 +++------------------------ 2 files changed, 1738 insertions(+), 1471 deletions(-) create mode 100644 OpenSim/Data/MySQL/MySQLLegacyRegionData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs new file mode 100644 index 0000000..4a16a70 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -0,0 +1,1594 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Threading; +using log4net; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for the Region Server + /// + public class MySQLDataStore : IRegionDataStore + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ConnectionString; + + private MySqlConnection m_Connection = null; + + public void Initialise(string connectionString) + { + m_ConnectionString = connectionString; + + m_Connection = new MySqlConnection(m_ConnectionString); + + m_Connection.Open(); + + // Apply new Migrations + // + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_Connection, assem, "RegionStore"); + m.Update(); + + // Clean dropped attachments + // + MySqlCommand cmd = m_Connection.CreateCommand(); + cmd.CommandText = "delete from prims, primshapes using prims " + + "left join primshapes on prims.uuid = primshapes.uuid " + + "where PCode = 9 and State <> 0"; + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + + private IDataReader ExecuteReader(MySqlCommand c) + { + IDataReader r = null; + bool errorSeen = false; + + while (true) + { + try + { + r = c.ExecuteReader(); + } + catch (Exception) + { + Thread.Sleep(500); + + m_Connection.Close(); + m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + m_Connection.Open(); + c.Connection = m_Connection; + + if (!errorSeen) + { + errorSeen = true; + continue; + } + throw; + } + + break; + } + + return r; + } + + private void ExecuteNonQuery(MySqlCommand c) + { + bool errorSeen = false; + + while (true) + { + try + { + c.ExecuteNonQuery(); + } + catch (Exception) + { + Thread.Sleep(500); + + m_Connection.Close(); + m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + m_Connection.Open(); + c.Connection = m_Connection; + + if (!errorSeen) + { + errorSeen = true; + continue; + } + throw; + } + + break; + } + } + + public void Dispose() {} + + public void StoreObject(SceneObjectGroup obj, UUID regionUUID) + { + uint flags = obj.RootPart.GetEffectiveObjectFlags(); + + // Eligibility check + // + if ((flags & (uint)PrimFlags.Temporary) != 0) + return; + if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) + return; + + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + foreach (SceneObjectPart prim in obj.Children.Values) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims ("+ + "UUID, CreationDate, "+ + "Name, Text, Description, "+ + "SitName, TouchName, ObjectFlags, "+ + "OwnerMask, NextOwnerMask, GroupMask, "+ + "EveryoneMask, BaseMask, PositionX, "+ + "PositionY, PositionZ, GroupPositionX, "+ + "GroupPositionY, GroupPositionZ, VelocityX, "+ + "VelocityY, VelocityZ, AngularVelocityX, "+ + "AngularVelocityY, AngularVelocityZ, "+ + "AccelerationX, AccelerationY, "+ + "AccelerationZ, RotationX, "+ + "RotationY, RotationZ, "+ + "RotationW, SitTargetOffsetX, "+ + "SitTargetOffsetY, SitTargetOffsetZ, "+ + "SitTargetOrientW, SitTargetOrientX, "+ + "SitTargetOrientY, SitTargetOrientZ, "+ + "RegionUUID, CreatorID, "+ + "OwnerID, GroupID, "+ + "LastOwnerID, SceneGroupID, "+ + "PayPrice, PayButton1, "+ + "PayButton2, PayButton3, "+ + "PayButton4, LoopedSound, "+ + "LoopedSoundGain, TextureAnimation, "+ + "OmegaX, OmegaY, OmegaZ, "+ + "CameraEyeOffsetX, CameraEyeOffsetY, "+ + "CameraEyeOffsetZ, CameraAtOffsetX, "+ + "CameraAtOffsetY, CameraAtOffsetZ, "+ + "ForceMouselook, ScriptAccessPin, "+ + "AllowedDrop, DieAtEdge, "+ + "SalePrice, SaleType, "+ + "ColorR, ColorG, ColorB, ColorA, "+ + "ParticleSystem, ClickAction, Material, "+ + "CollisionSound, CollisionSoundVolume, "+ + "PassTouches, "+ + "LinkNumber) values (" + "?UUID, "+ + "?CreationDate, ?Name, ?Text, "+ + "?Description, ?SitName, ?TouchName, "+ + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ + "?GroupMask, ?EveryoneMask, ?BaseMask, "+ + "?PositionX, ?PositionY, ?PositionZ, "+ + "?GroupPositionX, ?GroupPositionY, "+ + "?GroupPositionZ, ?VelocityX, "+ + "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ + "?AngularVelocityY, ?AngularVelocityZ, "+ + "?AccelerationX, ?AccelerationY, "+ + "?AccelerationZ, ?RotationX, "+ + "?RotationY, ?RotationZ, "+ + "?RotationW, ?SitTargetOffsetX, "+ + "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ + "?SitTargetOrientW, ?SitTargetOrientX, "+ + "?SitTargetOrientY, ?SitTargetOrientZ, "+ + "?RegionUUID, ?CreatorID, ?OwnerID, "+ + "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ + "?PayPrice, ?PayButton1, ?PayButton2, "+ + "?PayButton3, ?PayButton4, ?LoopedSound, "+ + "?LoopedSoundGain, ?TextureAnimation, "+ + "?OmegaX, ?OmegaY, ?OmegaZ, "+ + "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ + "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ + "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ + "?ForceMouselook, ?ScriptAccessPin, "+ + "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ + "?SaleType, ?ColorR, ?ColorG, "+ + "?ColorB, ?ColorA, ?ParticleSystem, "+ + "?ClickAction, ?Material, ?CollisionSound, "+ + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes ("+ + "UUID, Shape, ScaleX, ScaleY, "+ + "ScaleZ, PCode, PathBegin, PathEnd, "+ + "PathScaleX, PathScaleY, PathShearX, "+ + "PathShearY, PathSkew, PathCurve, "+ + "PathRadiusOffset, PathRevolutions, "+ + "PathTaperX, PathTaperY, PathTwist, "+ + "PathTwistBegin, ProfileBegin, ProfileEnd, "+ + "ProfileCurve, ProfileHollow, Texture, "+ + "ExtraParams, State) values (?UUID, "+ + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ + "?PCode, ?PathBegin, ?PathEnd, "+ + "?PathScaleX, ?PathScaleY, "+ + "?PathShearX, ?PathShearY, "+ + "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ + "?PathRevolutions, ?PathTaperX, "+ + "?PathTaperY, ?PathTwist, "+ + "?PathTwistBegin, ?ProfileBegin, "+ + "?ProfileEnd, ?ProfileCurve, "+ + "?ProfileHollow, ?Texture, ?ExtraParams, "+ + "?State)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); + } + cmd.Dispose(); + } + } + + public void RemoveObject(UUID obj, UUID regionUUID) + { + // Formerly, this used to check the region UUID. + // That makes no sense, as we remove the contents of a prim + // unconditionally, but the prim dependent on the region ID. + // So, we would destroy an object and cause hard to detect + // issues if we delete the contents only. Deleting it all may + // cause the loss of a prim, but is cleaner. + // It's also faster because it uses the primary key. + // + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "select UUID from prims where "+ + "SceneGroupID= ?UUID"; + + cmd.Parameters.AddWithValue("UUID", obj.ToString()); + + List uuids = new List(); + + IDataReader reader = ExecuteReader(cmd); + + try + { + while (reader.Read()) + { + uuids.Add(new UUID(reader["UUID"].ToString())); + } + } + finally + { + reader.Close(); + } + + // delete the main prims + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + ExecuteNonQuery(cmd); + cmd.Dispose(); + + // there is no way this should be < 1 unless there is + // a very corrupt database, but in that case be extra + // safe anyway. + if (uuids.Count > 0) + { + RemoveShapes(uuids); + RemoveItems(uuids); + } + } + } + + /// + /// Remove all persisted items of the given prim. + /// The caller must acquire the necessrary synchronization locks + /// + /// the Item UUID + private void RemoveItems(UUID uuid) + { + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "delete from primitems where " + + "PrimID = ?PrimID"; + + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + + + /// + /// Remove all persisted shapes for a list of prims + /// The caller must acquire the necessrary synchronization locks + /// + /// the list of UUIDs + private void RemoveShapes(List uuids) + { + lock (m_Connection) + { + string sql = "delete from primshapes where "; + MySqlCommand cmd = m_Connection.CreateCommand(); + + for (int i = 0; i < uuids.Count; i++) + { + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(UUID = ?UUID" + i + ")"; + } + else + { + sql += "(UUID = ?UUID" + i + ") or "; + } + } + cmd.CommandText = sql; + + for (int i = 0; i < uuids.Count; i++) + { + cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); + } + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + + /// + /// Remove all persisted items for a list of prims + /// The caller must acquire the necessrary synchronization locks + /// + /// the list of UUIDs + private void RemoveItems(List uuids) + { + lock (m_Connection) + { + string sql = "delete from primitems where "; + MySqlCommand cmd = m_Connection.CreateCommand(); + + for (int i = 0; i < uuids.Count; i++) + { + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(PrimID = ?PrimID" + i + ")"; + } + else + { + sql += "(PrimID = ?PrimID" + i + ") or "; + } + } + cmd.CommandText = sql; + + for (int i = 0; i < uuids.Count; i++) + { + cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); + } + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + + public List LoadObjects(UUID regionUUID) + { + UUID lastGroupID = UUID.Zero; + Dictionary objects = new Dictionary(); + Dictionary prims = new Dictionary(); + SceneObjectGroup grp = null; + + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "select *, " + + "case when prims.UUID = SceneGroupID " + + "then 0 else 1 end as sort from prims " + + "left join primshapes on prims.UUID = primshapes.UUID "+ + "where RegionUUID = ?RegionUUID " + + "order by SceneGroupID asc, sort asc, LinkNumber asc"; + + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + + IDataReader reader = ExecuteReader(cmd); + + try + { + while (reader.Read()) + { + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); + + prims[prim.UUID] = prim; + + UUID groupID = new UUID(reader["SceneGroupID"].ToString()); + + if (groupID != lastGroupID) // New SOG + { + if (grp != null) + objects[grp.UUID] = grp; + + lastGroupID = groupID; + + // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are + // recorded as the root prim (for which the UUID must equal the persisted group UUID). In + // this case, force the UUID to be the same as the group UUID so that at least these can be + // deleted (we need to change the UUID so that any other prims in the linkset can also be + // deleted). + if (prim.UUID != groupID && groupID != UUID.Zero) + { + m_log.WarnFormat( + "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", + prim.Name, prim.UUID, prim.GroupPosition, groupID); + + prim.UUID = groupID; + } + + grp = new SceneObjectGroup(prim); + } + else + { + // Black magic to preserve link numbers + // + int link = prim.LinkNum; + + grp.AddPart(prim); + + if (link != 0) + prim.LinkNum = link; + } + } + } + finally + { + reader.Close(); + } + + if (grp != null) + objects[grp.UUID] = grp; + cmd.Dispose(); + } + + // Instead of attempting to LoadItems on every prim, + // most of which probably have no items... get a + // list from DB of all prims which have items and + // LoadItems only on those + List primsWithInventory = new List(); + lock (m_Connection) + { + MySqlCommand itemCmd = m_Connection.CreateCommand(); + itemCmd.CommandText = "select distinct primID from primitems"; + IDataReader itemReader = ExecuteReader(itemCmd); + try + { + while (itemReader.Read()) + { + if (!(itemReader["primID"] is DBNull)) + { + UUID primID = new UUID(itemReader["primID"].ToString()); + if (prims.ContainsKey(primID)) + { + primsWithInventory.Add(prims[primID]); + } + } + } + } + finally + { + itemReader.Close(); + } + itemCmd.Dispose(); + } + + foreach (SceneObjectPart prim in primsWithInventory) + { + LoadItems(prim); + } + m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); + return new List(objects.Values); + } + + /// + /// Load in a prim's persisted inventory. + /// + /// The prim + private void LoadItems(SceneObjectPart prim) + { + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "select * from primitems where "+ + "PrimID = ?PrimID"; + + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + + IDataReader reader = ExecuteReader(cmd); + List inventory = + new List(); + + try + { + while (reader.Read()) + { + TaskInventoryItem item = BuildItem(reader); + + item.ParentID = prim.UUID; // Values in database are + // often wrong + inventory.Add(item); + } + } + finally + { + reader.Close(); + } + + cmd.Dispose(); + prim.Inventory.RestoreInventoryItems(inventory); + } + } + + public void StoreTerrain(double[,] ter, UUID regionID) + { + m_log.Info("[REGION DB]: Storing terrain"); + + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "delete from terrain where " + + "RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "insert into terrain (RegionUUID, " + + "Revision, Heightfield) values (?RegionUUID, " + + "1, ?Heightfield)"; + + cmd.Parameters.AddWithValue("Heightfield", + SerializeTerrain(ter)); + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + + public double[,] LoadTerrain(UUID regionID) + { + double[,] terrain = null; + + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID "+ + "order by Revision desc limit 1"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + IDataReader reader = ExecuteReader(cmd); + + try + { + while (reader.Read()) + { + terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; + terrain.Initialize(); + + MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); + int rev = 0; + + BinaryReader br = new BinaryReader(mstr); + for (int x = 0; x < (int)Constants.RegionSize; x++) + { + for (int y = 0; y < (int)Constants.RegionSize; y++) + { + terrain[x, y] = br.ReadDouble(); + } + rev = Convert.ToInt32(reader["Revision"]); + } + m_log.InfoFormat("[REGION DB]: Loaded terrain " + + "revision r{0}", rev); + } + } + finally + { + reader.Close(); + } + cmd.Dispose(); + } + + return terrain; + } + + public void RemoveLandObject(UUID globalID) + { + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "delete from land where UUID = ?UUID"; + + cmd.Parameters.AddWithValue("UUID", globalID.ToString()); + + ExecuteNonQuery(cmd); + cmd.Dispose(); + } + } + + public void StoreLandObject(ILandObject parcel) + { + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "replace into land (UUID, RegionUUID, " + + "LocalLandID, Bitmap, Name, Description, " + + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + + "Category, ClaimDate, ClaimPrice, GroupUUID, " + + "SalePrice, LandStatus, LandFlags, LandingType, " + + "MediaAutoScale, MediaTextureUUID, MediaURL, " + + "MusicURL, PassHours, PassPrice, SnapshotUUID, " + + "UserLocationX, UserLocationY, UserLocationZ, " + + "UserLookAtX, UserLookAtY, UserLookAtZ, " + + "AuthbuyerID, OtherCleanTime, Dwell) values (" + + "?UUID, ?RegionUUID, " + + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + + "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + + "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + + "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + + "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; + + FillLandCommand(cmd, parcel.landData, parcel.regionUUID); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "delete from landaccesslist where " + + "LandUUID = ?UUID"; + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in + parcel.landData.ParcelAccessList) + { + FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + } + cmd.Dispose(); + } + } + + public RegionSettings LoadRegionSettings(UUID regionUUID) + { + RegionSettings rs = null; + + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "select * from regionsettings where " + + "regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); + + IDataReader reader = ExecuteReader(cmd); + + try + { + if (reader.Read()) + { + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; + } + else + { + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; + + StoreRegionSettings(rs); + } + } + finally + { + reader.Close(); + } + cmd.Dispose(); + } + + return rs; + } + + public void StoreRegionSettings(RegionSettings rs) + { + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, "+ + "elevation_2_se, elevation_1_sw, "+ + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz, loaded_creation_datetime, " + + "loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + + "?LoadedCreationDateTime, ?LoadedCreationID)"; + + FillRegionSettingsCommand(cmd, rs); + + ExecuteNonQuery(cmd); + cmd.Dispose(); + + } + } + + public List LoadLandObjects(UUID regionUUID) + { + List landData = new List(); + + lock (m_Connection) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = "select * from land where " + + "RegionUUID = ?RegionUUID"; + + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + + IDataReader reader = ExecuteReader(cmd); + + try + { + while (reader.Read()) + { + LandData newLand = BuildLandData(reader); + landData.Add(newLand); + } + } + finally + { + reader.Close(); + } + + foreach (LandData land in landData) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "select * from landaccesslist " + + "where LandUUID = ?LandUUID"; + + cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); + + reader = ExecuteReader(cmd); + + try + { + while (reader.Read()) + { + land.ParcelAccessList.Add(BuildLandAccessData(reader)); + } + } + finally + { + reader.Close(); + } + } + cmd.Dispose(); + } + + return landData; + } + + public void Shutdown() + { + } + + private SceneObjectPart BuildPrim(IDataReader row) + { + SceneObjectPart prim = new SceneObjectPart(); + prim.UUID = new UUID((String) row["UUID"]); + // explicit conversion of integers is required, which sort + // of sucks. No idea if there is a shortcut here or not. + prim.CreationDate = Convert.ToInt32(row["CreationDate"]); + if (row["Name"] != DBNull.Value) + prim.Name = (String)row["Name"]; + else + prim.Name = string.Empty; + // various text fields + prim.Text = (String) row["Text"]; + prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), + Convert.ToInt32(row["ColorR"]), + Convert.ToInt32(row["ColorG"]), + Convert.ToInt32(row["ColorB"])); + prim.Description = (String) row["Description"]; + prim.SitName = (String) row["SitName"]; + prim.TouchName = (String) row["TouchName"]; + // permissions + prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); + prim.CreatorID = new UUID((String) row["CreatorID"]); + prim.OwnerID = new UUID((String) row["OwnerID"]); + prim.GroupID = new UUID((String) row["GroupID"]); + prim.LastOwnerID = new UUID((String) row["LastOwnerID"]); + prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); + prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); + prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); + prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); + prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); + // vectors + prim.OffsetPosition = new Vector3( + Convert.ToSingle(row["PositionX"]), + Convert.ToSingle(row["PositionY"]), + Convert.ToSingle(row["PositionZ"]) + ); + prim.GroupPosition = new Vector3( + Convert.ToSingle(row["GroupPositionX"]), + Convert.ToSingle(row["GroupPositionY"]), + Convert.ToSingle(row["GroupPositionZ"]) + ); + prim.Velocity = new Vector3( + Convert.ToSingle(row["VelocityX"]), + Convert.ToSingle(row["VelocityY"]), + Convert.ToSingle(row["VelocityZ"]) + ); + prim.AngularVelocity = new Vector3( + Convert.ToSingle(row["AngularVelocityX"]), + Convert.ToSingle(row["AngularVelocityY"]), + Convert.ToSingle(row["AngularVelocityZ"]) + ); + prim.Acceleration = new Vector3( + Convert.ToSingle(row["AccelerationX"]), + Convert.ToSingle(row["AccelerationY"]), + Convert.ToSingle(row["AccelerationZ"]) + ); + // quaternions + prim.RotationOffset = new Quaternion( + Convert.ToSingle(row["RotationX"]), + Convert.ToSingle(row["RotationY"]), + Convert.ToSingle(row["RotationZ"]), + Convert.ToSingle(row["RotationW"]) + ); + prim.SitTargetPositionLL = new Vector3( + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"]) + ); + prim.SitTargetOrientationLL = new Quaternion( + Convert.ToSingle(row["SitTargetOrientX"]), + Convert.ToSingle(row["SitTargetOrientY"]), + Convert.ToSingle(row["SitTargetOrientZ"]), + Convert.ToSingle(row["SitTargetOrientW"]) + ); + + prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]); + prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]); + prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]); + prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); + prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); + + prim.Sound = new UUID(row["LoopedSound"].ToString()); + prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); + prim.SoundFlags = 1; // If it's persisted at all, it's looped + + if (!(row["TextureAnimation"] is DBNull)) + prim.TextureAnimation = (Byte[])row["TextureAnimation"]; + if (!(row["ParticleSystem"] is DBNull)) + prim.ParticleSystem = (Byte[])row["ParticleSystem"]; + + prim.RotationalVelocity = new Vector3( + Convert.ToSingle(row["OmegaX"]), + Convert.ToSingle(row["OmegaY"]), + Convert.ToSingle(row["OmegaZ"]) + ); + + prim.SetCameraEyeOffset(new Vector3( + Convert.ToSingle(row["CameraEyeOffsetX"]), + Convert.ToSingle(row["CameraEyeOffsetY"]), + Convert.ToSingle(row["CameraEyeOffsetZ"]) + )); + + prim.SetCameraAtOffset(new Vector3( + Convert.ToSingle(row["CameraAtOffsetX"]), + Convert.ToSingle(row["CameraAtOffsetY"]), + Convert.ToSingle(row["CameraAtOffsetZ"]) + )); + + if (Convert.ToInt16(row["ForceMouselook"]) != 0) + prim.SetForceMouselook(true); + + prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]); + + if (Convert.ToInt16(row["AllowedDrop"]) != 0) + prim.AllowedDrop = true; + + if (Convert.ToInt16(row["DieAtEdge"]) != 0) + prim.DIE_AT_EDGE = true; + + prim.SalePrice = Convert.ToInt32(row["SalePrice"]); + prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"])); + + prim.Material = unchecked((byte)Convert.ToSByte(row["Material"])); + + if (!(row["ClickAction"] is DBNull)) + prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"])); + + prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); + prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); + + if (Convert.ToInt16(row["PassTouches"]) != 0) + prim.PassTouches = true; + prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); + + return prim; + } + + + /// + /// Build a prim inventory item from the persisted data. + /// + /// + /// + private static TaskInventoryItem BuildItem(IDataReader row) + { + TaskInventoryItem taskItem = new TaskInventoryItem(); + + taskItem.ItemID = new UUID((String)row["itemID"]); + taskItem.ParentPartID = new UUID((String)row["primID"]); + taskItem.AssetID = new UUID((String)row["assetID"]); + taskItem.ParentID = new UUID((String)row["parentFolderID"]); + + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); + + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorID = new UUID((String)row["creatorID"]); + taskItem.OwnerID = new UUID((String)row["ownerID"]); + taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]); + taskItem.GroupID = new UUID((String)row["groupID"]); + + taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); + taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); + taskItem.Flags = Convert.ToUInt32(row["flags"]); + + return taskItem; + } + + private static RegionSettings BuildRegionSettings(IDataReader row) + { + RegionSettings newSettings = new RegionSettings(); + + newSettings.RegionUUID = new UUID((string) row["regionUUID"]); + newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); + newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); + newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); + newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); + newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); + newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); + newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); + newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); + newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); + newSettings.Maturity = Convert.ToInt32(row["maturity"]); + newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); + newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); + newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); + newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]); + newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]); + newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]); + newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]); + newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); + newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); + newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); + newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); + newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); + newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); + newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); + newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); + newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); + newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); + newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); + newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); + newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); + newSettings.SunVector = new Vector3 ( + Convert.ToSingle(row["sunvectorx"]), + Convert.ToSingle(row["sunvectory"]), + Convert.ToSingle(row["sunvectorz"]) + ); + newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); + newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); + newSettings.Covenant = new UUID((String) row["covenant"]); + + newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); + + if (row["loaded_creation_id"] is DBNull) + newSettings.LoadedCreationID = ""; + else + newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; + + return newSettings; + } + + /// + /// + /// + /// + /// + private static LandData BuildLandData(IDataReader row) + { + LandData newData = new LandData(); + + newData.GlobalID = new UUID((String) row["UUID"]); + newData.LocalID = Convert.ToInt32(row["LocalLandID"]); + + // Bitmap is a byte[512] + newData.Bitmap = (Byte[]) row["Bitmap"]; + + newData.Name = (String) row["Name"]; + newData.Description = (String) row["Description"]; + newData.OwnerID = new UUID((String)row["OwnerUUID"]); + newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); + newData.Area = Convert.ToInt32(row["Area"]); + newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented + newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory + newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); + newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.GroupID = new UUID((String) row["GroupUUID"]); + newData.SalePrice = Convert.ToInt32(row["SalePrice"]); + newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus + newData.Flags = Convert.ToUInt32(row["LandFlags"]); + newData.LandingType = Convert.ToByte(row["LandingType"]); + newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); + newData.MediaID = new UUID((String) row["MediaTextureUUID"]); + newData.MediaURL = (String) row["MediaURL"]; + newData.MusicURL = (String) row["MusicURL"]; + newData.PassHours = Convert.ToSingle(row["PassHours"]); + newData.PassPrice = Convert.ToInt32(row["PassPrice"]); + UUID authedbuyer = UUID.Zero; + UUID snapshotID = UUID.Zero; + + UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); + UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); + newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); + newData.Dwell = Convert.ToInt32(row["Dwell"]); + + newData.AuthBuyerID = authedbuyer; + newData.SnapshotID = snapshotID; + try + { + newData.UserLocation = + new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.UserLookAt = + new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); + } + catch (InvalidCastException) + { + newData.UserLocation = Vector3.Zero; + newData.UserLookAt = Vector3.Zero; + m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); + } + + newData.ParcelAccessList = new List(); + + return newData; + } + + /// + /// + /// + /// + /// + private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = new UUID((string) row["AccessUUID"]); + entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); + entry.Time = new DateTime(); + return entry; + } + + /// + /// + /// + /// + /// + private static Array SerializeTerrain(double[,] val) + { + MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); + BinaryWriter bw = new BinaryWriter(str); + + // TODO: COMPATIBILITY - Add byte-order conversions + for (int x = 0; x < (int)Constants.RegionSize; x++) + for (int y = 0; y < (int)Constants.RegionSize; y++) + { + double height = val[x, y]; + if (height == 0.0) + height = double.Epsilon; + + bw.Write(height); + } + + return str.ToArray(); + } + + /// + /// Fill the prim command with prim values + /// + /// + /// + /// + /// + private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) + { + cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); + cmd.Parameters.AddWithValue("Name", prim.Name); + cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString()); + // the UUID of the root part for this SceneObjectGroup + // various text fields + cmd.Parameters.AddWithValue("Text", prim.Text); + cmd.Parameters.AddWithValue("ColorR", prim.Color.R); + cmd.Parameters.AddWithValue("ColorG", prim.Color.G); + cmd.Parameters.AddWithValue("ColorB", prim.Color.B); + cmd.Parameters.AddWithValue("ColorA", prim.Color.A); + cmd.Parameters.AddWithValue("Description", prim.Description); + cmd.Parameters.AddWithValue("SitName", prim.SitName); + cmd.Parameters.AddWithValue("TouchName", prim.TouchName); + // permissions + cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags); + cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); + cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); + cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); + cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); + cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); + cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); + cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); + cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask); + cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask); + // vectors + cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X); + cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y); + cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z); + cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X); + cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y); + cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z); + cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X); + cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y); + cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z); + cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z); + cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X); + cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y); + cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z); + // quaternions + cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X); + cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y); + cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z); + cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W); + + // Sit target + Vector3 sitTargetPos = prim.SitTargetPositionLL; + cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X); + cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y); + cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z); + + Quaternion sitTargetOrient = prim.SitTargetOrientationLL; + cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W); + cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X); + cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y); + cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z); + + cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]); + cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]); + cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]); + cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]); + cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]); + + if ((prim.SoundFlags & 1) != 0) // Looped + { + cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString()); + cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain); + } + else + { + cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero); + cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f); + } + + cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); + cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); + + cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); + cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); + cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); + + cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); + cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); + cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z); + + cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X); + cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y); + cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z); + + if (prim.GetForceMouselook()) + cmd.Parameters.AddWithValue("ForceMouselook", 1); + else + cmd.Parameters.AddWithValue("ForceMouselook", 0); + + cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin); + + if (prim.AllowedDrop) + cmd.Parameters.AddWithValue("AllowedDrop", 1); + else + cmd.Parameters.AddWithValue("AllowedDrop", 0); + + if (prim.DIE_AT_EDGE) + cmd.Parameters.AddWithValue("DieAtEdge", 1); + else + cmd.Parameters.AddWithValue("DieAtEdge", 0); + + cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); + cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType))); + + byte clickAction = prim.ClickAction; + cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction))); + + cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material))); + + cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); + cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); + + if (prim.PassTouches) + cmd.Parameters.AddWithValue("PassTouches", 1); + else + cmd.Parameters.AddWithValue("PassTouches", 0); + + cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); + } + + /// + /// + /// + /// + /// + private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem) + { + cmd.Parameters.AddWithValue("itemID", taskItem.ItemID); + cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID); + cmd.Parameters.AddWithValue("assetID", taskItem.AssetID); + cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID); + + cmd.Parameters.AddWithValue("invType", taskItem.InvType); + cmd.Parameters.AddWithValue("assetType", taskItem.Type); + + cmd.Parameters.AddWithValue("name", taskItem.Name); + cmd.Parameters.AddWithValue("description", taskItem.Description); + cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate); + cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID); + cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID); + cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID); + cmd.Parameters.AddWithValue("groupID", taskItem.GroupID); + cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions); + cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions); + cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions); + cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions); + cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions); + cmd.Parameters.AddWithValue("flags", taskItem.Flags); + } + + /// + /// + /// + private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings) + { + cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform); + cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly); + cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage); + cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing); + cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell); + cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide); + cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch); + cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit); + cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus); + cmd.Parameters.AddWithValue("Maturity", settings.Maturity); + cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts); + cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions); + cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics); + cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString()); + cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW); + cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW); + cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE); + cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE); + cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE); + cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE); + cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW); + cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW); + cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight); + cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit); + cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit); + cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun); + cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox); + cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X); + cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y); + cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z); + cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); + cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); + cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); + cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); + cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); + + } + + /// + /// + /// + /// + /// + /// + private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID) + { + cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString()); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + cmd.Parameters.AddWithValue("LocalLandID", land.LocalID); + + // Bitmap is a byte[512] + cmd.Parameters.AddWithValue("Bitmap", land.Bitmap); + + cmd.Parameters.AddWithValue("Name", land.Name); + cmd.Parameters.AddWithValue("Description", land.Description); + cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString()); + cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned); + cmd.Parameters.AddWithValue("Area", land.Area); + cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented + cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory + cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate); + cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice); + cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString()); + cmd.Parameters.AddWithValue("SalePrice", land.SalePrice); + cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus + cmd.Parameters.AddWithValue("LandFlags", land.Flags); + cmd.Parameters.AddWithValue("LandingType", land.LandingType); + cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale); + cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString()); + cmd.Parameters.AddWithValue("MediaURL", land.MediaURL); + cmd.Parameters.AddWithValue("MusicURL", land.MusicURL); + cmd.Parameters.AddWithValue("PassHours", land.PassHours); + cmd.Parameters.AddWithValue("PassPrice", land.PassPrice); + cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString()); + cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X); + cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y); + cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z); + cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X); + cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y); + cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); + cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); + cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); + cmd.Parameters.AddWithValue("Dwell", land.Dwell); + } + + /// + /// + /// + /// + /// + /// + private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) + { + cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); + cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); + cmd.Parameters.AddWithValue("Flags", entry.Flags); + } + + /// + /// + /// + /// + /// + private PrimitiveBaseShape BuildShape(IDataReader row) + { + PrimitiveBaseShape s = new PrimitiveBaseShape(); + s.Scale = new Vector3( + Convert.ToSingle(row["ScaleX"]), + Convert.ToSingle(row["ScaleY"]), + Convert.ToSingle(row["ScaleZ"]) + ); + // paths + s.PCode = Convert.ToByte(row["PCode"]); + s.PathBegin = Convert.ToUInt16(row["PathBegin"]); + s.PathEnd = Convert.ToUInt16(row["PathEnd"]); + s.PathScaleX = Convert.ToByte(row["PathScaleX"]); + s.PathScaleY = Convert.ToByte(row["PathScaleY"]); + s.PathShearX = Convert.ToByte(row["PathShearX"]); + s.PathShearY = Convert.ToByte(row["PathShearY"]); + s.PathSkew = Convert.ToSByte(row["PathSkew"]); + s.PathCurve = Convert.ToByte(row["PathCurve"]); + s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); + s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); + s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); + s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); + s.PathTwist = Convert.ToSByte(row["PathTwist"]); + s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); + // profile + s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); + s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); + s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); + s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); + byte[] textureEntry = (byte[]) row["Texture"]; + s.TextureEntry = textureEntry; + + s.ExtraParams = (byte[]) row["ExtraParams"]; + + s.State = Convert.ToByte(row["State"]); + + return s; + } + + /// + /// + /// + /// + /// + private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim) + { + PrimitiveBaseShape s = prim.Shape; + cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); + // shape is an enum + cmd.Parameters.AddWithValue("Shape", 0); + // vectors + cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X); + cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y); + cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z); + // paths + cmd.Parameters.AddWithValue("PCode", s.PCode); + cmd.Parameters.AddWithValue("PathBegin", s.PathBegin); + cmd.Parameters.AddWithValue("PathEnd", s.PathEnd); + cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX); + cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY); + cmd.Parameters.AddWithValue("PathShearX", s.PathShearX); + cmd.Parameters.AddWithValue("PathShearY", s.PathShearY); + cmd.Parameters.AddWithValue("PathSkew", s.PathSkew); + cmd.Parameters.AddWithValue("PathCurve", s.PathCurve); + cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset); + cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions); + cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX); + cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY); + cmd.Parameters.AddWithValue("PathTwist", s.PathTwist); + cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin); + // profile + cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin); + cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd); + cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve); + cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow); + cmd.Parameters.AddWithValue("Texture", s.TextureEntry); + cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); + cmd.Parameters.AddWithValue("State", s.State); + } + + public void StorePrimInventory(UUID primID, ICollection items) + { + lock (m_Connection) + { + RemoveItems(primID); + + MySqlCommand cmd = m_Connection.CreateCommand(); + + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems ("+ + "invType, assetType, name, "+ + "description, creationDate, nextPermissions, "+ + "currentPermissions, basePermissions, "+ + "everyonePermissions, groupPermissions, "+ + "flags, itemID, primID, assetID, "+ + "parentFolderID, creatorID, ownerID, "+ + "groupID, lastOwnerID) values (?invType, "+ + "?assetType, ?name, ?description, "+ + "?creationDate, ?nextPermissions, "+ + "?currentPermissions, ?basePermissions, "+ + "?everyonePermissions, ?groupPermissions, "+ + "?flags, ?itemID, ?primID, ?assetID, "+ + "?parentFolderID, ?creatorID, ?ownerID, "+ + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) + { + cmd.Parameters.Clear(); + + FillItemCommand(cmd, item); + + ExecuteNonQuery(cmd); + } + + cmd.Dispose(); + } + } + } +} diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 4a16a70..ced26a4 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -26,1569 +26,242 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Data; -using System.Drawing; -using System.IO; -using System.Reflection; -using System.Threading; -using log4net; -using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; +using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL { - /// - /// A MySQL Interface for the Region Server - /// - public class MySQLDataStore : IRegionDataStore + public class MySqlRegionData : MySqlFramework, IRegionData { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string m_ConnectionString; + private string m_Realm; + private List m_ColumnNames = null; + private int m_LastExpire = 0; - private MySqlConnection m_Connection = null; - - public void Initialise(string connectionString) + public MySqlRegionData(string connectionString, string realm) + : base(connectionString) { - m_ConnectionString = connectionString; - - m_Connection = new MySqlConnection(m_ConnectionString); + m_Realm = realm; - m_Connection.Open(); - - // Apply new Migrations - // - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_Connection, assem, "RegionStore"); + Migration m = new Migration(m_Connection, GetType().Assembly, "GridStore"); m.Update(); - - // Clean dropped attachments - // - MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "delete from prims, primshapes using prims " + - "left join primshapes on prims.uuid = primshapes.uuid " + - "where PCode = 9 and State <> 0"; - ExecuteNonQuery(cmd); - cmd.Dispose(); } - private IDataReader ExecuteReader(MySqlCommand c) + public List Get(string regionName, UUID scopeID) { - IDataReader r = null; - bool errorSeen = false; + string command = "select * from `"+m_Realm+"` where regionName like ?regionName"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; - while (true) - { - try - { - r = c.ExecuteReader(); - } - catch (Exception) - { - Thread.Sleep(500); - - m_Connection.Close(); - m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - m_Connection.Open(); - c.Connection = m_Connection; + MySqlCommand cmd = new MySqlCommand(command); - if (!errorSeen) - { - errorSeen = true; - continue; - } - throw; - } + cmd.Parameters.AddWithValue("?regionName", regionName); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - break; - } - - return r; + return RunCommand(cmd); } - private void ExecuteNonQuery(MySqlCommand c) + public RegionData Get(int posX, int posY, UUID scopeID) { - bool errorSeen = false; + string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; - while (true) - { - try - { - c.ExecuteNonQuery(); - } - catch (Exception) - { - Thread.Sleep(500); + MySqlCommand cmd = new MySqlCommand(command); - m_Connection.Close(); - m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - m_Connection.Open(); - c.Connection = m_Connection; + cmd.Parameters.AddWithValue("?posX", posX.ToString()); + cmd.Parameters.AddWithValue("?posY", posY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - if (!errorSeen) - { - errorSeen = true; - continue; - } - throw; - } + List ret = RunCommand(cmd); + if (ret == null) + return null; - break; - } + return ret[0]; } - public void Dispose() {} - - public void StoreObject(SceneObjectGroup obj, UUID regionUUID) + public RegionData Get(UUID regionID, UUID scopeID) { - uint flags = obj.RootPart.GetEffectiveObjectFlags(); - - // Eligibility check - // - if ((flags & (uint)PrimFlags.Temporary) != 0) - return; - if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) - return; - - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + string command = "select * from `"+m_Realm+"` where uuid = ?regionID"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; - foreach (SceneObjectPart prim in obj.Children.Values) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims ("+ - "UUID, CreationDate, "+ - "Name, Text, Description, "+ - "SitName, TouchName, ObjectFlags, "+ - "OwnerMask, NextOwnerMask, GroupMask, "+ - "EveryoneMask, BaseMask, PositionX, "+ - "PositionY, PositionZ, GroupPositionX, "+ - "GroupPositionY, GroupPositionZ, VelocityX, "+ - "VelocityY, VelocityZ, AngularVelocityX, "+ - "AngularVelocityY, AngularVelocityZ, "+ - "AccelerationX, AccelerationY, "+ - "AccelerationZ, RotationX, "+ - "RotationY, RotationZ, "+ - "RotationW, SitTargetOffsetX, "+ - "SitTargetOffsetY, SitTargetOffsetZ, "+ - "SitTargetOrientW, SitTargetOrientX, "+ - "SitTargetOrientY, SitTargetOrientZ, "+ - "RegionUUID, CreatorID, "+ - "OwnerID, GroupID, "+ - "LastOwnerID, SceneGroupID, "+ - "PayPrice, PayButton1, "+ - "PayButton2, PayButton3, "+ - "PayButton4, LoopedSound, "+ - "LoopedSoundGain, TextureAnimation, "+ - "OmegaX, OmegaY, OmegaZ, "+ - "CameraEyeOffsetX, CameraEyeOffsetY, "+ - "CameraEyeOffsetZ, CameraAtOffsetX, "+ - "CameraAtOffsetY, CameraAtOffsetZ, "+ - "ForceMouselook, ScriptAccessPin, "+ - "AllowedDrop, DieAtEdge, "+ - "SalePrice, SaleType, "+ - "ColorR, ColorG, ColorB, ColorA, "+ - "ParticleSystem, ClickAction, Material, "+ - "CollisionSound, CollisionSoundVolume, "+ - "PassTouches, "+ - "LinkNumber) values (" + "?UUID, "+ - "?CreationDate, ?Name, ?Text, "+ - "?Description, ?SitName, ?TouchName, "+ - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ - "?GroupMask, ?EveryoneMask, ?BaseMask, "+ - "?PositionX, ?PositionY, ?PositionZ, "+ - "?GroupPositionX, ?GroupPositionY, "+ - "?GroupPositionZ, ?VelocityX, "+ - "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ - "?AngularVelocityY, ?AngularVelocityZ, "+ - "?AccelerationX, ?AccelerationY, "+ - "?AccelerationZ, ?RotationX, "+ - "?RotationY, ?RotationZ, "+ - "?RotationW, ?SitTargetOffsetX, "+ - "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ - "?SitTargetOrientW, ?SitTargetOrientX, "+ - "?SitTargetOrientY, ?SitTargetOrientZ, "+ - "?RegionUUID, ?CreatorID, ?OwnerID, "+ - "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ - "?PayPrice, ?PayButton1, ?PayButton2, "+ - "?PayButton3, ?PayButton4, ?LoopedSound, "+ - "?LoopedSoundGain, ?TextureAnimation, "+ - "?OmegaX, ?OmegaY, ?OmegaZ, "+ - "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ - "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ - "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ - "?ForceMouselook, ?ScriptAccessPin, "+ - "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ - "?SaleType, ?ColorR, ?ColorG, "+ - "?ColorB, ?ColorA, ?ParticleSystem, "+ - "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); + MySqlCommand cmd = new MySqlCommand(command); - cmd.CommandText = "replace into primshapes ("+ - "UUID, Shape, ScaleX, ScaleY, "+ - "ScaleZ, PCode, PathBegin, PathEnd, "+ - "PathScaleX, PathScaleY, PathShearX, "+ - "PathShearY, PathSkew, PathCurve, "+ - "PathRadiusOffset, PathRevolutions, "+ - "PathTaperX, PathTaperY, PathTwist, "+ - "PathTwistBegin, ProfileBegin, ProfileEnd, "+ - "ProfileCurve, ProfileHollow, Texture, "+ - "ExtraParams, State) values (?UUID, "+ - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ - "?PCode, ?PathBegin, ?PathEnd, "+ - "?PathScaleX, ?PathScaleY, "+ - "?PathShearX, ?PathShearY, "+ - "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ - "?PathRevolutions, ?PathTaperX, "+ - "?PathTaperY, ?PathTwist, "+ - "?PathTwistBegin, ?ProfileBegin, "+ - "?ProfileEnd, ?ProfileCurve, "+ - "?ProfileHollow, ?Texture, ?ExtraParams, "+ - "?State)"; + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - FillShapeCommand(cmd, prim); + List ret = RunCommand(cmd); + if (ret == null) + return null; - ExecuteNonQuery(cmd); - } - cmd.Dispose(); - } + return ret[0]; } - public void RemoveObject(UUID obj, UUID regionUUID) + public List Get(int startX, int startY, int endX, int endY, UUID scopeID) { - // Formerly, this used to check the region UUID. - // That makes no sense, as we remove the contents of a prim - // unconditionally, but the prim dependent on the region ID. - // So, we would destroy an object and cause hard to detect - // issues if we delete the contents only. Deleting it all may - // cause the loss of a prim, but is cleaner. - // It's also faster because it uses the primary key. - // - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select UUID from prims where "+ - "SceneGroupID= ?UUID"; + string command = "select * from `"+m_Realm+"` where locX between ?startX and ?endX and locY between ?startY and ?endY"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; - cmd.Parameters.AddWithValue("UUID", obj.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - List uuids = new List(); + cmd.Parameters.AddWithValue("?startX", startX.ToString()); + cmd.Parameters.AddWithValue("?startY", startY.ToString()); + cmd.Parameters.AddWithValue("?endX", endX.ToString()); + cmd.Parameters.AddWithValue("?endY", endY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - IDataReader reader = ExecuteReader(cmd); - - try - { - while (reader.Read()) - { - uuids.Add(new UUID(reader["UUID"].ToString())); - } - } - finally - { - reader.Close(); - } - - // delete the main prims - cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - ExecuteNonQuery(cmd); - cmd.Dispose(); - - // there is no way this should be < 1 unless there is - // a very corrupt database, but in that case be extra - // safe anyway. - if (uuids.Count > 0) - { - RemoveShapes(uuids); - RemoveItems(uuids); - } - } + return RunCommand(cmd); } - /// - /// Remove all persisted items of the given prim. - /// The caller must acquire the necessrary synchronization locks - /// - /// the Item UUID - private void RemoveItems(UUID uuid) + public List RunCommand(MySqlCommand cmd) { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "delete from primitems where " + - "PrimID = ?PrimID"; - - cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + List retList = new List(); - ExecuteNonQuery(cmd); - cmd.Dispose(); - } - } + IDataReader result = ExecuteReader(cmd); - - /// - /// Remove all persisted shapes for a list of prims - /// The caller must acquire the necessrary synchronization locks - /// - /// the list of UUIDs - private void RemoveShapes(List uuids) - { - lock (m_Connection) + while (result.Read()) { - string sql = "delete from primshapes where "; - MySqlCommand cmd = m_Connection.CreateCommand(); - - for (int i = 0; i < uuids.Count; i++) + RegionData ret = new RegionData(); + ret.Data = new Dictionary(); + + UUID regionID; + UUID.TryParse(result["uuid"].ToString(), out regionID); + ret.RegionID = regionID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + ret.RegionName = result["regionName"].ToString(); + ret.posX = Convert.ToInt32(result["locX"]); + ret.posY = Convert.ToInt32(result["locY"]); + + if (m_ColumnNames == null) { - if ((i + 1) == uuids.Count) - {// end of the list - sql += "(UUID = ?UUID" + i + ")"; - } - else - { - sql += "(UUID = ?UUID" + i + ") or "; - } - } - cmd.CommandText = sql; + m_ColumnNames = new List(); - for (int i = 0; i < uuids.Count; i++) - { - cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } - ExecuteNonQuery(cmd); - cmd.Dispose(); - } - } - - /// - /// Remove all persisted items for a list of prims - /// The caller must acquire the necessrary synchronization locks - /// - /// the list of UUIDs - private void RemoveItems(List uuids) - { - lock (m_Connection) - { - string sql = "delete from primitems where "; - MySqlCommand cmd = m_Connection.CreateCommand(); - - for (int i = 0; i < uuids.Count; i++) + foreach (string s in m_ColumnNames) { - if ((i + 1) == uuids.Count) - {// end of the list - sql += "(PrimID = ?PrimID" + i + ")"; - } - else - { - sql += "(PrimID = ?PrimID" + i + ") or "; - } - } - cmd.CommandText = sql; - - for (int i = 0; i < uuids.Count; i++) - { - cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); - } - - ExecuteNonQuery(cmd); - cmd.Dispose(); - } - } - - public List LoadObjects(UUID regionUUID) - { - UUID lastGroupID = UUID.Zero; - Dictionary objects = new Dictionary(); - Dictionary prims = new Dictionary(); - SceneObjectGroup grp = null; - - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select *, " + - "case when prims.UUID = SceneGroupID " + - "then 0 else 1 end as sort from prims " + - "left join primshapes on prims.UUID = primshapes.UUID "+ - "where RegionUUID = ?RegionUUID " + - "order by SceneGroupID asc, sort asc, LinkNumber asc"; - - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - - try - { - while (reader.Read()) - { - SceneObjectPart prim = BuildPrim(reader); - if (reader["Shape"] is DBNull) - prim.Shape = PrimitiveBaseShape.Default; - else - prim.Shape = BuildShape(reader); - - prims[prim.UUID] = prim; - - UUID groupID = new UUID(reader["SceneGroupID"].ToString()); - - if (groupID != lastGroupID) // New SOG - { - if (grp != null) - objects[grp.UUID] = grp; - - lastGroupID = groupID; - - // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are - // recorded as the root prim (for which the UUID must equal the persisted group UUID). In - // this case, force the UUID to be the same as the group UUID so that at least these can be - // deleted (we need to change the UUID so that any other prims in the linkset can also be - // deleted). - if (prim.UUID != groupID && groupID != UUID.Zero) - { - m_log.WarnFormat( - "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", - prim.Name, prim.UUID, prim.GroupPosition, groupID); - - prim.UUID = groupID; - } - - grp = new SceneObjectGroup(prim); - } - else - { - // Black magic to preserve link numbers - // - int link = prim.LinkNum; - - grp.AddPart(prim); + if (s == "uuid") + continue; + if (s == "ScopeID") + continue; + if (s == "regionName") + continue; + if (s == "locX") + continue; + if (s == "locY") + continue; - if (link != 0) - prim.LinkNum = link; - } - } - } - finally - { - reader.Close(); + ret.Data[s] = result[s].ToString(); } - if (grp != null) - objects[grp.UUID] = grp; - cmd.Dispose(); + retList.Add(ret); } - // Instead of attempting to LoadItems on every prim, - // most of which probably have no items... get a - // list from DB of all prims which have items and - // LoadItems only on those - List primsWithInventory = new List(); - lock (m_Connection) - { - MySqlCommand itemCmd = m_Connection.CreateCommand(); - itemCmd.CommandText = "select distinct primID from primitems"; - IDataReader itemReader = ExecuteReader(itemCmd); - try - { - while (itemReader.Read()) - { - if (!(itemReader["primID"] is DBNull)) - { - UUID primID = new UUID(itemReader["primID"].ToString()); - if (prims.ContainsKey(primID)) - { - primsWithInventory.Add(prims[primID]); - } - } - } - } - finally - { - itemReader.Close(); - } - itemCmd.Dispose(); - } - - foreach (SceneObjectPart prim in primsWithInventory) - { - LoadItems(prim); - } - m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); - return new List(objects.Values); - } - - /// - /// Load in a prim's persisted inventory. - /// - /// The prim - private void LoadItems(SceneObjectPart prim) - { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); + result.Close(); + CloseReaderCommand(cmd); - cmd.CommandText = "select * from primitems where "+ - "PrimID = ?PrimID"; + if (retList.Count > 0) + return retList; - cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - List inventory = - new List(); - - try - { - while (reader.Read()) - { - TaskInventoryItem item = BuildItem(reader); - - item.ParentID = prim.UUID; // Values in database are - // often wrong - inventory.Add(item); - } - } - finally - { - reader.Close(); - } - - cmd.Dispose(); - prim.Inventory.RestoreInventoryItems(inventory); - } + return null; } - public void StoreTerrain(double[,] ter, UUID regionID) + public bool Store(RegionData data) { - m_log.Info("[REGION DB]: Storing terrain"); + if (data.Data.ContainsKey("uuid")) + data.Data.Remove("uuid"); + if (data.Data.ContainsKey("ScopeID")) + data.Data.Remove("ScopeID"); + if (data.Data.ContainsKey("regionName")) + data.Data.Remove("regionName"); + if (data.Data.ContainsKey("posX")) + data.Data.Remove("posX"); + if (data.Data.ContainsKey("posY")) + data.Data.Remove("posY"); - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "delete from terrain where " + - "RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - - ExecuteNonQuery(cmd); - - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; + string[] fields = new List(data.Data.Keys).ToArray(); - cmd.Parameters.AddWithValue("Heightfield", - SerializeTerrain(ter)); - - ExecuteNonQuery(cmd); - cmd.Dispose(); - } - } + MySqlCommand cmd = new MySqlCommand(); - public double[,] LoadTerrain(UUID regionID) - { - double[,] terrain = null; - - lock (m_Connection) + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) { - MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select RegionUUID, Revision, Heightfield " + - "from terrain where RegionUUID = ?RegionUUID "+ - "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - - try - { - while (reader.Read()) - { - terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; - terrain.Initialize(); + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; - MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); - int rev = 0; + first = false; - BinaryReader br = new BinaryReader(mstr); - for (int x = 0; x < (int)Constants.RegionSize; x++) - { - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - terrain[x, y] = br.ReadDouble(); - } - rev = Convert.ToInt32(reader["Revision"]); - } - m_log.InfoFormat("[REGION DB]: Loaded terrain " + - "revision r{0}", rev); - } - } - finally - { - reader.Close(); - } - cmd.Dispose(); + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); } - return terrain; - } - - public void RemoveLandObject(UUID globalID) - { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "delete from land where UUID = ?UUID"; + update += " where uuid = ?regionID"; - cmd.Parameters.AddWithValue("UUID", globalID.ToString()); + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - ExecuteNonQuery(cmd); - cmd.Dispose(); - } - } + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - public void StoreLandObject(ILandObject parcel) - { - lock (m_Connection) + if (ExecuteNonQuery(cmd) < 1) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "replace into land (UUID, RegionUUID, " + - "LocalLandID, Bitmap, Name, Description, " + - "OwnerUUID, IsGroupOwned, Area, AuctionID, " + - "Category, ClaimDate, ClaimPrice, GroupUUID, " + - "SalePrice, LandStatus, LandFlags, LandingType, " + - "MediaAutoScale, MediaTextureUUID, MediaURL, " + - "MusicURL, PassHours, PassPrice, SnapshotUUID, " + - "UserLocationX, UserLocationY, UserLocationZ, " + - "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, Dwell) values (" + - "?UUID, ?RegionUUID, " + - "?LocalLandID, ?Bitmap, ?Name, ?Description, " + - "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + - "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + - "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + - "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + - "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + - "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + - "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; - - FillLandCommand(cmd, parcel.landData, parcel.regionUUID); + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; - ExecuteNonQuery(cmd); + cmd.CommandText = insert; - cmd.CommandText = "delete from landaccesslist where " + - "LandUUID = ?UUID"; - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; - - foreach (ParcelManager.ParcelAccessEntry entry in - parcel.landData.ParcelAccessList) + if (ExecuteNonQuery(cmd) < 1) { - FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); - ExecuteNonQuery(cmd); - cmd.Parameters.Clear(); + cmd.Dispose(); + return false; } - cmd.Dispose(); } - } - public RegionSettings LoadRegionSettings(UUID regionUUID) - { - RegionSettings rs = null; - - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select * from regionsettings where " + - "regionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("regionUUID", regionUUID); - - IDataReader reader = ExecuteReader(cmd); - - try - { - if (reader.Read()) - { - rs = BuildRegionSettings(reader); - rs.OnSave += StoreRegionSettings; - } - else - { - rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; - - StoreRegionSettings(rs); - } - } - finally - { - reader.Close(); - } - cmd.Dispose(); - } - - return rs; - } - - public void StoreRegionSettings(RegionSettings rs) - { - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "replace into regionsettings (regionUUID, " + - "block_terraform, block_fly, allow_damage, " + - "restrict_pushing, allow_land_resell, " + - "allow_land_join_divide, block_show_in_search, " + - "agent_limit, object_bonus, maturity, " + - "disable_scripts, disable_collisions, " + - "disable_physics, terrain_texture_1, " + - "terrain_texture_2, terrain_texture_3, " + - "terrain_texture_4, elevation_1_nw, " + - "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, "+ - "elevation_2_se, elevation_1_sw, "+ - "elevation_2_sw, water_height, " + - "terrain_raise_limit, terrain_lower_limit, " + - "use_estate_sun, fixed_sun, sun_position, " + - "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " + - "?BlockFly, ?AllowDamage, ?RestrictPushing, " + - "?AllowLandResell, ?AllowLandJoinDivide, " + - "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + - "?Maturity, ?DisableScripts, ?DisableCollisions, " + - "?DisablePhysics, ?TerrainTexture1, " + - "?TerrainTexture2, ?TerrainTexture3, " + - "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + - "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + - "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + - "?WaterHeight, ?TerrainRaiseLimit, " + - "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)"; - - FillRegionSettingsCommand(cmd, rs); - - ExecuteNonQuery(cmd); - cmd.Dispose(); - - } - } - - public List LoadLandObjects(UUID regionUUID) - { - List landData = new List(); - - lock (m_Connection) - { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select * from land where " + - "RegionUUID = ?RegionUUID"; - - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - - try - { - while (reader.Read()) - { - LandData newLand = BuildLandData(reader); - landData.Add(newLand); - } - } - finally - { - reader.Close(); - } - - foreach (LandData land in landData) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "select * from landaccesslist " + - "where LandUUID = ?LandUUID"; - - cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); - - reader = ExecuteReader(cmd); - - try - { - while (reader.Read()) - { - land.ParcelAccessList.Add(BuildLandAccessData(reader)); - } - } - finally - { - reader.Close(); - } - } - cmd.Dispose(); - } - - return landData; - } - - public void Shutdown() - { - } - - private SceneObjectPart BuildPrim(IDataReader row) - { - SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new UUID((String) row["UUID"]); - // explicit conversion of integers is required, which sort - // of sucks. No idea if there is a shortcut here or not. - prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - if (row["Name"] != DBNull.Value) - prim.Name = (String)row["Name"]; - else - prim.Name = string.Empty; - // various text fields - prim.Text = (String) row["Text"]; - prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), - Convert.ToInt32(row["ColorR"]), - Convert.ToInt32(row["ColorG"]), - Convert.ToInt32(row["ColorB"])); - prim.Description = (String) row["Description"]; - prim.SitName = (String) row["SitName"]; - prim.TouchName = (String) row["TouchName"]; - // permissions - prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new UUID((String) row["CreatorID"]); - prim.OwnerID = new UUID((String) row["OwnerID"]); - prim.GroupID = new UUID((String) row["GroupID"]); - prim.LastOwnerID = new UUID((String) row["LastOwnerID"]); - prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); - prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); - prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); - prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); - prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); - // vectors - prim.OffsetPosition = new Vector3( - Convert.ToSingle(row["PositionX"]), - Convert.ToSingle(row["PositionY"]), - Convert.ToSingle(row["PositionZ"]) - ); - prim.GroupPosition = new Vector3( - Convert.ToSingle(row["GroupPositionX"]), - Convert.ToSingle(row["GroupPositionY"]), - Convert.ToSingle(row["GroupPositionZ"]) - ); - prim.Velocity = new Vector3( - Convert.ToSingle(row["VelocityX"]), - Convert.ToSingle(row["VelocityY"]), - Convert.ToSingle(row["VelocityZ"]) - ); - prim.AngularVelocity = new Vector3( - Convert.ToSingle(row["AngularVelocityX"]), - Convert.ToSingle(row["AngularVelocityY"]), - Convert.ToSingle(row["AngularVelocityZ"]) - ); - prim.Acceleration = new Vector3( - Convert.ToSingle(row["AccelerationX"]), - Convert.ToSingle(row["AccelerationY"]), - Convert.ToSingle(row["AccelerationZ"]) - ); - // quaternions - prim.RotationOffset = new Quaternion( - Convert.ToSingle(row["RotationX"]), - Convert.ToSingle(row["RotationY"]), - Convert.ToSingle(row["RotationZ"]), - Convert.ToSingle(row["RotationW"]) - ); - prim.SitTargetPositionLL = new Vector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"]) - ); - prim.SitTargetOrientationLL = new Quaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]) - ); - - prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]); - prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]); - prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]); - prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); - prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); - - prim.Sound = new UUID(row["LoopedSound"].ToString()); - prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); - prim.SoundFlags = 1; // If it's persisted at all, it's looped - - if (!(row["TextureAnimation"] is DBNull)) - prim.TextureAnimation = (Byte[])row["TextureAnimation"]; - if (!(row["ParticleSystem"] is DBNull)) - prim.ParticleSystem = (Byte[])row["ParticleSystem"]; - - prim.RotationalVelocity = new Vector3( - Convert.ToSingle(row["OmegaX"]), - Convert.ToSingle(row["OmegaY"]), - Convert.ToSingle(row["OmegaZ"]) - ); - - prim.SetCameraEyeOffset(new Vector3( - Convert.ToSingle(row["CameraEyeOffsetX"]), - Convert.ToSingle(row["CameraEyeOffsetY"]), - Convert.ToSingle(row["CameraEyeOffsetZ"]) - )); - - prim.SetCameraAtOffset(new Vector3( - Convert.ToSingle(row["CameraAtOffsetX"]), - Convert.ToSingle(row["CameraAtOffsetY"]), - Convert.ToSingle(row["CameraAtOffsetZ"]) - )); - - if (Convert.ToInt16(row["ForceMouselook"]) != 0) - prim.SetForceMouselook(true); - - prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]); - - if (Convert.ToInt16(row["AllowedDrop"]) != 0) - prim.AllowedDrop = true; - - if (Convert.ToInt16(row["DieAtEdge"]) != 0) - prim.DIE_AT_EDGE = true; - - prim.SalePrice = Convert.ToInt32(row["SalePrice"]); - prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"])); - - prim.Material = unchecked((byte)Convert.ToSByte(row["Material"])); - - if (!(row["ClickAction"] is DBNull)) - prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"])); - - prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); - prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); - - if (Convert.ToInt16(row["PassTouches"]) != 0) - prim.PassTouches = true; - prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); - - return prim; - } - - - /// - /// Build a prim inventory item from the persisted data. - /// - /// - /// - private static TaskInventoryItem BuildItem(IDataReader row) - { - TaskInventoryItem taskItem = new TaskInventoryItem(); - - taskItem.ItemID = new UUID((String)row["itemID"]); - taskItem.ParentPartID = new UUID((String)row["primID"]); - taskItem.AssetID = new UUID((String)row["assetID"]); - taskItem.ParentID = new UUID((String)row["parentFolderID"]); - - taskItem.InvType = Convert.ToInt32(row["invType"]); - taskItem.Type = Convert.ToInt32(row["assetType"]); - - taskItem.Name = (String)row["name"]; - taskItem.Description = (String)row["description"]; - taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorID = new UUID((String)row["creatorID"]); - taskItem.OwnerID = new UUID((String)row["ownerID"]); - taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]); - taskItem.GroupID = new UUID((String)row["groupID"]); - - taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); - taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); - taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); - taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); - taskItem.Flags = Convert.ToUInt32(row["flags"]); - - return taskItem; - } - - private static RegionSettings BuildRegionSettings(IDataReader row) - { - RegionSettings newSettings = new RegionSettings(); - - newSettings.RegionUUID = new UUID((string) row["regionUUID"]); - newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); - newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); - newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); - newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); - newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); - newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); - newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); - newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); - newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); - newSettings.Maturity = Convert.ToInt32(row["maturity"]); - newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); - newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); - newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); - newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]); - newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]); - newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]); - newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]); - newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); - newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); - newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); - newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); - newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); - newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); - newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); - newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); - newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); - newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); - newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); - newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); - newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); - newSettings.SunVector = new Vector3 ( - Convert.ToSingle(row["sunvectorx"]), - Convert.ToSingle(row["sunvectory"]), - Convert.ToSingle(row["sunvectorz"]) - ); - newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); - newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); - newSettings.Covenant = new UUID((String) row["covenant"]); - - newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); - - if (row["loaded_creation_id"] is DBNull) - newSettings.LoadedCreationID = ""; - else - newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; - - return newSettings; - } - - /// - /// - /// - /// - /// - private static LandData BuildLandData(IDataReader row) - { - LandData newData = new LandData(); - - newData.GlobalID = new UUID((String) row["UUID"]); - newData.LocalID = Convert.ToInt32(row["LocalLandID"]); - - // Bitmap is a byte[512] - newData.Bitmap = (Byte[]) row["Bitmap"]; - - newData.Name = (String) row["Name"]; - newData.Description = (String) row["Description"]; - newData.OwnerID = new UUID((String)row["OwnerUUID"]); - newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); - newData.Area = Convert.ToInt32(row["Area"]); - newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented - newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]); - //Enum libsecondlife.Parcel.ParcelCategory - newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); - newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.GroupID = new UUID((String) row["GroupUUID"]); - newData.SalePrice = Convert.ToInt32(row["SalePrice"]); - newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); - //Enum. libsecondlife.Parcel.ParcelStatus - newData.Flags = Convert.ToUInt32(row["LandFlags"]); - newData.LandingType = Convert.ToByte(row["LandingType"]); - newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.MediaID = new UUID((String) row["MediaTextureUUID"]); - newData.MediaURL = (String) row["MediaURL"]; - newData.MusicURL = (String) row["MusicURL"]; - newData.PassHours = Convert.ToSingle(row["PassHours"]); - newData.PassPrice = Convert.ToInt32(row["PassPrice"]); - UUID authedbuyer = UUID.Zero; - UUID snapshotID = UUID.Zero; - - UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); - UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); - newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); - newData.Dwell = Convert.ToInt32(row["Dwell"]); - - newData.AuthBuyerID = authedbuyer; - newData.SnapshotID = snapshotID; - try - { - newData.UserLocation = - new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), - Convert.ToSingle(row["UserLocationZ"])); - newData.UserLookAt = - new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), - Convert.ToSingle(row["UserLookAtZ"])); - } - catch (InvalidCastException) - { - newData.UserLocation = Vector3.Zero; - newData.UserLookAt = Vector3.Zero; - m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); - } - - newData.ParcelAccessList = new List(); - - return newData; - } - - /// - /// - /// - /// - /// - private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) - { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new UUID((string) row["AccessUUID"]); - entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); - entry.Time = new DateTime(); - return entry; - } - - /// - /// - /// - /// - /// - private static Array SerializeTerrain(double[,] val) - { - MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); - BinaryWriter bw = new BinaryWriter(str); - - // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < (int)Constants.RegionSize; x++) - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - double height = val[x, y]; - if (height == 0.0) - height = double.Epsilon; - - bw.Write(height); - } - - return str.ToArray(); - } - - /// - /// Fill the prim command with prim values - /// - /// - /// - /// - /// - private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) - { - cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); - cmd.Parameters.AddWithValue("Name", prim.Name); - cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString()); - // the UUID of the root part for this SceneObjectGroup - // various text fields - cmd.Parameters.AddWithValue("Text", prim.Text); - cmd.Parameters.AddWithValue("ColorR", prim.Color.R); - cmd.Parameters.AddWithValue("ColorG", prim.Color.G); - cmd.Parameters.AddWithValue("ColorB", prim.Color.B); - cmd.Parameters.AddWithValue("ColorA", prim.Color.A); - cmd.Parameters.AddWithValue("Description", prim.Description); - cmd.Parameters.AddWithValue("SitName", prim.SitName); - cmd.Parameters.AddWithValue("TouchName", prim.TouchName); - // permissions - cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags); - cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); - cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); - cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); - cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); - cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); - cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); - cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); - cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask); - cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask); - // vectors - cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X); - cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y); - cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z); - cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X); - cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y); - cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z); - cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X); - cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y); - cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z); - cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X); - cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y); - cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z); - cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X); - cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y); - cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z); - // quaternions - cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X); - cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y); - cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z); - cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W); - - // Sit target - Vector3 sitTargetPos = prim.SitTargetPositionLL; - cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X); - cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y); - cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z); - - Quaternion sitTargetOrient = prim.SitTargetOrientationLL; - cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W); - cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X); - cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y); - cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z); - - cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]); - cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]); - cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]); - cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]); - cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]); - - if ((prim.SoundFlags & 1) != 0) // Looped - { - cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString()); - cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain); - } - else - { - cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero); - cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f); - } - - cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); - cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); - - cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); - cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); - cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); - - cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); - cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); - cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z); - - cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X); - cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y); - cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z); - - if (prim.GetForceMouselook()) - cmd.Parameters.AddWithValue("ForceMouselook", 1); - else - cmd.Parameters.AddWithValue("ForceMouselook", 0); - - cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin); - - if (prim.AllowedDrop) - cmd.Parameters.AddWithValue("AllowedDrop", 1); - else - cmd.Parameters.AddWithValue("AllowedDrop", 0); - - if (prim.DIE_AT_EDGE) - cmd.Parameters.AddWithValue("DieAtEdge", 1); - else - cmd.Parameters.AddWithValue("DieAtEdge", 0); - - cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); - cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType))); - - byte clickAction = prim.ClickAction; - cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction))); - - cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material))); - - cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); - cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); - - if (prim.PassTouches) - cmd.Parameters.AddWithValue("PassTouches", 1); - else - cmd.Parameters.AddWithValue("PassTouches", 0); - - cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); - } - - /// - /// - /// - /// - /// - private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem) - { - cmd.Parameters.AddWithValue("itemID", taskItem.ItemID); - cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID); - cmd.Parameters.AddWithValue("assetID", taskItem.AssetID); - cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID); - - cmd.Parameters.AddWithValue("invType", taskItem.InvType); - cmd.Parameters.AddWithValue("assetType", taskItem.Type); - - cmd.Parameters.AddWithValue("name", taskItem.Name); - cmd.Parameters.AddWithValue("description", taskItem.Description); - cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate); - cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID); - cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID); - cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID); - cmd.Parameters.AddWithValue("groupID", taskItem.GroupID); - cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions); - cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions); - cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions); - cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions); - cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions); - cmd.Parameters.AddWithValue("flags", taskItem.Flags); - } - - /// - /// - /// - private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings) - { - cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString()); - cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform); - cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly); - cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage); - cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing); - cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell); - cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide); - cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch); - cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit); - cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus); - cmd.Parameters.AddWithValue("Maturity", settings.Maturity); - cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts); - cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions); - cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics); - cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString()); - cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString()); - cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString()); - cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString()); - cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW); - cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW); - cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE); - cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE); - cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE); - cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE); - cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW); - cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW); - cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight); - cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit); - cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit); - cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun); - cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox); - cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X); - cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y); - cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z); - cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); - cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); - cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); - cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); - cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); - - } - - /// - /// - /// - /// - /// - /// - private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID) - { - cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString()); - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - cmd.Parameters.AddWithValue("LocalLandID", land.LocalID); - - // Bitmap is a byte[512] - cmd.Parameters.AddWithValue("Bitmap", land.Bitmap); - - cmd.Parameters.AddWithValue("Name", land.Name); - cmd.Parameters.AddWithValue("Description", land.Description); - cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString()); - cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned); - cmd.Parameters.AddWithValue("Area", land.Area); - cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented - cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory - cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate); - cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice); - cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString()); - cmd.Parameters.AddWithValue("SalePrice", land.SalePrice); - cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus - cmd.Parameters.AddWithValue("LandFlags", land.Flags); - cmd.Parameters.AddWithValue("LandingType", land.LandingType); - cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale); - cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString()); - cmd.Parameters.AddWithValue("MediaURL", land.MediaURL); - cmd.Parameters.AddWithValue("MusicURL", land.MusicURL); - cmd.Parameters.AddWithValue("PassHours", land.PassHours); - cmd.Parameters.AddWithValue("PassPrice", land.PassPrice); - cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString()); - cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X); - cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y); - cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z); - cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X); - cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y); - cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); - cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); - cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); - cmd.Parameters.AddWithValue("Dwell", land.Dwell); - } + cmd.Dispose(); - /// - /// - /// - /// - /// - /// - private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) - { - cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); - cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); - cmd.Parameters.AddWithValue("Flags", entry.Flags); + return true; } - /// - /// - /// - /// - /// - private PrimitiveBaseShape BuildShape(IDataReader row) + public bool SetDataItem(UUID regionID, string item, string value) { - PrimitiveBaseShape s = new PrimitiveBaseShape(); - s.Scale = new Vector3( - Convert.ToSingle(row["ScaleX"]), - Convert.ToSingle(row["ScaleY"]), - Convert.ToSingle(row["ScaleZ"]) - ); - // paths - s.PCode = Convert.ToByte(row["PCode"]); - s.PathBegin = Convert.ToUInt16(row["PathBegin"]); - s.PathEnd = Convert.ToUInt16(row["PathEnd"]); - s.PathScaleX = Convert.ToByte(row["PathScaleX"]); - s.PathScaleY = Convert.ToByte(row["PathScaleY"]); - s.PathShearX = Convert.ToByte(row["PathShearX"]); - s.PathShearY = Convert.ToByte(row["PathShearY"]); - s.PathSkew = Convert.ToSByte(row["PathSkew"]); - s.PathCurve = Convert.ToByte(row["PathCurve"]); - s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); - s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); - s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); - s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); - s.PathTwist = Convert.ToSByte(row["PathTwist"]); - s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); - // profile - s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); - s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); - s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); - s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - byte[] textureEntry = (byte[]) row["Texture"]; - s.TextureEntry = textureEntry; + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); - s.ExtraParams = (byte[]) row["ExtraParams"]; - s.State = Convert.ToByte(row["State"]); + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - return s; - } + if (ExecuteNonQuery(cmd) > 0) + return true; - /// - /// - /// - /// - /// - private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim) - { - PrimitiveBaseShape s = prim.Shape; - cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); - // shape is an enum - cmd.Parameters.AddWithValue("Shape", 0); - // vectors - cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X); - cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y); - cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z); - // paths - cmd.Parameters.AddWithValue("PCode", s.PCode); - cmd.Parameters.AddWithValue("PathBegin", s.PathBegin); - cmd.Parameters.AddWithValue("PathEnd", s.PathEnd); - cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX); - cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY); - cmd.Parameters.AddWithValue("PathShearX", s.PathShearX); - cmd.Parameters.AddWithValue("PathShearY", s.PathShearY); - cmd.Parameters.AddWithValue("PathSkew", s.PathSkew); - cmd.Parameters.AddWithValue("PathCurve", s.PathCurve); - cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset); - cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions); - cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX); - cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY); - cmd.Parameters.AddWithValue("PathTwist", s.PathTwist); - cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin); - // profile - cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin); - cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd); - cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve); - cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow); - cmd.Parameters.AddWithValue("Texture", s.TextureEntry); - cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); - cmd.Parameters.AddWithValue("State", s.State); + return false; } - public void StorePrimInventory(UUID primID, ICollection items) + public bool Delete(UUID regionID) { - lock (m_Connection) - { - RemoveItems(primID); + MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + + "` where uuid = ?UUID"); - MySqlCommand cmd = m_Connection.CreateCommand(); - if (items.Count == 0) - return; + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - cmd.CommandText = "insert into primitems ("+ - "invType, assetType, name, "+ - "description, creationDate, nextPermissions, "+ - "currentPermissions, basePermissions, "+ - "everyonePermissions, groupPermissions, "+ - "flags, itemID, primID, assetID, "+ - "parentFolderID, creatorID, ownerID, "+ - "groupID, lastOwnerID) values (?invType, "+ - "?assetType, ?name, ?description, "+ - "?creationDate, ?nextPermissions, "+ - "?currentPermissions, ?basePermissions, "+ - "?everyonePermissions, ?groupPermissions, "+ - "?flags, ?itemID, ?primID, ?assetID, "+ - "?parentFolderID, ?creatorID, ?ownerID, "+ - "?groupID, ?lastOwnerID)"; + if (ExecuteNonQuery(cmd) > 0) + return true; - foreach (TaskInventoryItem item in items) - { - cmd.Parameters.Clear(); - - FillItemCommand(cmd, item); - - ExecuteNonQuery(cmd); - } - - cmd.Dispose(); - } + return false; } } } -- cgit v1.1 From a251864e64223e8f797e20d016952b422685e447 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 16 Sep 2009 17:56:24 +0100 Subject: Add the migration for scoping grid data --- OpenSim/Data/MySQL/Resources/003_GridStore.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/003_GridStore.sql b/OpenSim/Data/MySQL/Resources/003_GridStore.sql new file mode 100644 index 0000000..bc3fe7d --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_GridStore.sql @@ -0,0 +1,7 @@ +BEGIN; + +ALTER TABLE regions add column ScopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; + +create index ScopeID on regions(ScopeID); + +COMMIT; -- cgit v1.1 From 6a5d7650d02979c74abcbbb3595729a4a6b55411 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:23:55 -0700 Subject: All tests pass for MySQL/MySQLRegionData. Added OpenSim.GridServer.ini.example that I have been using for testing the ROBUST grid service with the GridClient. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ced26a4..e13e12c 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); List ret = RunCommand(cmd); - if (ret == null) + if (ret.Count == 0) return null; return ret[0]; @@ -95,7 +95,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); List ret = RunCommand(cmd); - if (ret == null) + if (ret.Count == 0) return null; return ret[0]; @@ -170,10 +170,7 @@ namespace OpenSim.Data.MySQL result.Close(); CloseReaderCommand(cmd); - if (retList.Count > 0) - return retList; - - return null; + return retList; } public bool Store(RegionData data) @@ -182,12 +179,6 @@ namespace OpenSim.Data.MySQL data.Data.Remove("uuid"); if (data.Data.ContainsKey("ScopeID")) data.Data.Remove("ScopeID"); - if (data.Data.ContainsKey("regionName")) - data.Data.Remove("regionName"); - if (data.Data.ContainsKey("posX")) - data.Data.Remove("posX"); - if (data.Data.ContainsKey("posY")) - data.Data.Remove("posY"); string[] fields = new List(data.Data.Keys).ToArray(); -- cgit v1.1 From 2995d87d75e3f65b9872aa02edbff0dda70bc03c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Sep 2009 19:29:40 +0100 Subject: minor: remove some mono compiler warnings --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e13e12c..e8cab4d 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL { private string m_Realm; private List m_ColumnNames = null; - private int m_LastExpire = 0; +// private int m_LastExpire = 0; public MySqlRegionData(string connectionString, string realm) : base(connectionString) diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 39d60ca..5352727 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL { private string m_Realm; private List m_ColumnNames = null; - private int m_LastExpire = 0; +// private int m_LastExpire = 0; public MySqlUserAccountData(string connectionString, string realm) : base(connectionString) -- cgit v1.1 From 8e091f590375d2b63c100e45a187b6cbfa76e161 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Sep 2009 21:17:23 +0100 Subject: Add the Migration for the regions table --- OpenSim/Data/MySQL/MySQLRegionData.cs | 22 ++++++++++++++-------- OpenSim/Data/MySQL/Resources/004_GridStore.sql | 6 ++++++ 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/004_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ced26a4..0d71c23 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -138,6 +138,8 @@ namespace OpenSim.Data.MySQL ret.RegionName = result["regionName"].ToString(); ret.posX = Convert.ToInt32(result["locX"]); ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); if (m_ColumnNames == null) { @@ -188,21 +190,21 @@ namespace OpenSim.Data.MySQL data.Data.Remove("posX"); if (data.Data.ContainsKey("posY")) data.Data.Remove("posY"); + if (data.Data.ContainsKey("sizeX")) + data.Data.Remove("sizeX"); + if (data.Data.ContainsKey("sizeY")) + data.Data.Remove("sizeY"); string[] fields = new List(data.Data.Keys).ToArray(); MySqlCommand cmd = new MySqlCommand(); - string update = "update `"+m_Realm+"` set "; - bool first = true; + string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; foreach (string field in fields) { - if (!first) - update += ", "; + update += ", "; update += "`" + field + "` = ?"+field; - first = false; - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); } @@ -214,12 +216,16 @@ namespace OpenSim.Data.MySQL cmd.CommandText = update; cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); if (ExecuteNonQuery(cmd) < 1) { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `" + String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?" + String.Join(", ?", fields) + ")"; cmd.CommandText = insert; diff --git a/OpenSim/Data/MySQL/Resources/004_GridStore.sql b/OpenSim/Data/MySQL/Resources/004_GridStore.sql new file mode 100644 index 0000000..2238a88 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_GridStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE regions add column sizeX integer not null default 0; +ALTER TABLE regions add column sizeY integer not null default 0; + +COMMIT; -- cgit v1.1 From 12640d082473d521f5131b640239013e56c8edd2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Sep 2009 21:58:34 +0100 Subject: Prevent manually setting Data["locX"] and Data["locY"], since that would overwrite the posX and posY members of the structure --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 64ac83f..8c99519 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -191,6 +191,10 @@ namespace OpenSim.Data.MySQL data.Data.Remove("sizeX"); if (data.Data.ContainsKey("sizeY")) data.Data.Remove("sizeY"); + if (data.Data.ContainsKey("locX")) + data.Data.Remove("locX"); + if (data.Data.ContainsKey("locY")) + data.Data.Remove("locY"); string[] fields = new List(data.Data.Keys).ToArray(); -- cgit v1.1 From 42746e99bdad71f81c9693d8638ffdf6bc3dd87a Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Sep 2009 23:02:40 +0100 Subject: Make the RegionData plugin store the RegionName --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 8c99519..06ef624 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -216,6 +216,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = update; cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); + cmd.Parameters.AddWithValue("?regionName", data.RegionName); cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); @@ -224,9 +225,9 @@ namespace OpenSim.Data.MySQL if (ExecuteNonQuery(cmd) < 1) { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `" + + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?" + String.Join(", ?", fields) + ")"; + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; cmd.CommandText = insert; -- cgit v1.1 From f00126dc2dfc9e23aa50227f02ee9adbe1efdfa6 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 29 Sep 2009 08:32:59 +0900 Subject: Add copyright header. Formatting cleanup. --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 2 +- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index afd59bd..e508b52 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -127,7 +127,7 @@ namespace OpenSim.Data.MySQL { string insert = "insert into `" + m_Realm + "` (`UUID`, `" + String.Join("`, `", fields) + - "`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")"; + "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; cmd.CommandText = insert; diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 4a16a70..ed62172 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -773,7 +773,7 @@ namespace OpenSim.Data.MySQL "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " + + "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 5352727..d48144d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -146,7 +146,7 @@ namespace OpenSim.Data.MySQL { string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + String.Join("`, `", fields) + - "`) values ( ?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; cmd.CommandText = insert; -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- OpenSim/Data/MySQL/MySQLInventoryData.cs | 12 ++++++------ OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- OpenSim/Data/MySQL/MySQLUserData.cs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 66c34fe..0502b2b 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -204,7 +204,7 @@ namespace OpenSim.Data.MySQL "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", _dbConnection.Connection); - string assetName = asset.Name; + string assetName = asset.Name; if (asset.Name.Length > 64) { assetName = asset.Name.Substring(0, 64); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 4521a0f..0eecf06 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -325,10 +325,10 @@ namespace OpenSim.Data.MySQL UUID GroupID = UUID.Zero; UUID.TryParse((string)reader["avatarID"], out Owner); UUID.TryParse((string)reader["groupID"], out GroupID); - item.Owner = Owner; + item.Owner = Owner; item.GroupID = GroupID; - // Rest of the parsing. If these UUID's fail, we're dead anyway + // Rest of the parsing. If these UUID's fail, we're dead anyway item.ID = new UUID((string) reader["inventoryID"]); item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; @@ -472,7 +472,7 @@ namespace OpenSim.Data.MySQL + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" + ", ?groupID, ?groupOwned, ?flags)"; - string itemName = item.Name; + string itemName = item.Name; if (item.Name.Length > 64) { itemName = item.Name.Substring(0, 64); @@ -484,7 +484,7 @@ namespace OpenSim.Data.MySQL { itemDesc = item.Description.Substring(0, 128); m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length + " to " + itemDesc.Length + " characters on add item"); - } + } try { @@ -590,12 +590,12 @@ namespace OpenSim.Data.MySQL "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; - string folderName = folder.Name; + string folderName = folder.Name; if (folderName.Length > 64) { folderName = folderName.Substring(0, 64); m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder"); - } + } database.CheckConnection(); diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index ed62172..c2dd788 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -464,7 +464,7 @@ namespace OpenSim.Data.MySQL prim.Name, prim.UUID, prim.GroupPosition, groupID); prim.UUID = groupID; - } + } grp = new SceneObjectGroup(prim); } @@ -533,7 +533,7 @@ namespace OpenSim.Data.MySQL /// /// Load in a prim's persisted inventory. /// - /// The prim + /// The prim private void LoadItems(SceneObjectPart prim) { lock (m_Connection) diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 537ef6c..04f872f 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -632,7 +632,7 @@ namespace OpenSim.Data.MySQL UUID zero = UUID.Zero; if (user.ID == zero) { - return; + return; } MySQLSuperManager dbm = GetLockedConnection("AddNewUserProfile"); @@ -666,7 +666,7 @@ namespace OpenSim.Data.MySQL { UUID zero = UUID.Zero; if (agent.ProfileID == zero || agent.SessionID == zero) - return; + return; MySQLSuperManager dbm = GetLockedConnection("AddNewUserAgent"); try -- cgit v1.1 From 2107b67f1b145f7718fdb1450be1a7b8dd1a0bf7 Mon Sep 17 00:00:00 2001 From: dr scofield (aka dirk husemann) Date: Fri, 2 Oct 2009 11:10:52 +0200 Subject: - cleaning up LandData/ILandObject capitalization issues - adding LandDataSerializer to OAR mechanics --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index c2dd788..f25bfd7 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -685,7 +685,7 @@ namespace OpenSim.Data.MySQL "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; - FillLandCommand(cmd, parcel.landData, parcel.regionUUID); + FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); ExecuteNonQuery(cmd); @@ -700,9 +700,9 @@ namespace OpenSim.Data.MySQL "?Flags)"; foreach (ParcelManager.ParcelAccessEntry entry in - parcel.landData.ParcelAccessList) + parcel.LandData.ParcelAccessList) { - FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID); + FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); ExecuteNonQuery(cmd); cmd.Parameters.Clear(); } -- cgit v1.1 From 29a4614529bbda02b9c690d2d1812be1d1e7bbae Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 4 Oct 2009 13:57:51 -0700 Subject: * MySQL data tests now pass by fixing a bad fix for a bad cast on the asset Local member in MySQLAssetData * First pass at applying the using(){} pattern to IDisposable objects. Always use the using pattern on IDisposable objects whenever possible, do not manually call .Close() or .Dispose() unless there is no other way to write the code. This pass mostly covers OpenSim.Data.MySQL, and should have no functional change (tests still pass) --- OpenSim/Data/MySQL/MySQLAssetData.cs | 102 +++-- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 50 ++- OpenSim/Data/MySQL/MySQLEstateData.cs | 310 ++++++++------- OpenSim/Data/MySQL/MySQLFramework.cs | 14 +- OpenSim/Data/MySQL/MySQLGridData.cs | 171 ++++----- OpenSim/Data/MySQL/MySQLInventoryData.cs | 335 ++++++++-------- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 531 ++++++++++++-------------- OpenSim/Data/MySQL/MySQLManager.cs | 60 ++- OpenSim/Data/MySQL/MySQLRegionData.cs | 240 ++++++------ OpenSim/Data/MySQL/MySQLUserAccountData.cs | 141 ++++--- OpenSim/Data/MySQL/MySQLUserData.cs | 370 +++++++++--------- 11 files changed, 1111 insertions(+), 1213 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 0502b2b..8f97440 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -142,46 +142,45 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - MySqlCommand cmd = - new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", - _dbConnection.Connection); - cmd.Parameters.AddWithValue("?id", assetID.ToString()); - - try + using (MySqlCommand cmd = new MySqlCommand( + "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + _dbConnection.Connection)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + cmd.Parameters.AddWithValue("?id", assetID.ToString()); + + try { - if (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - asset = new AssetBase(); - asset.Data = (byte[]) dbReader["data"]; - asset.Description = (string) dbReader["description"]; - asset.FullID = assetID; - try - { - asset.Local = (bool)dbReader["local"]; - } - catch (InvalidCastException) + if (dbReader.Read()) { - asset.Local = false; + asset = new AssetBase(); + asset.Data = (byte[])dbReader["data"]; + asset.Description = (string)dbReader["description"]; + asset.FullID = assetID; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Name = (string)dbReader["name"]; + asset.Type = (sbyte)dbReader["assetType"]; + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } - asset.Name = (string) dbReader["name"]; - asset.Type = (sbyte) dbReader["assetType"]; - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } - dbReader.Close(); - cmd.Dispose(); + + if (asset != null) + UpdateAccessTime(asset); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Reconnecting", assetID); + _dbConnection.Reconnect(); } - if (asset != null) - UpdateAccessTime(asset); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Reconnecting", assetID); - _dbConnection.Reconnect(); } } return asset; @@ -297,32 +296,27 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - MySqlCommand cmd = - new MySqlCommand( - "SELECT id FROM assets WHERE id=?id", - _dbConnection.Connection); - - cmd.Parameters.AddWithValue("?id", uuid.ToString()); - - try + using (MySqlCommand cmd = new MySqlCommand( + "SELECT id FROM assets WHERE id=?id", + _dbConnection.Connection)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + cmd.Parameters.AddWithValue("?id", uuid.ToString()); + + try { - if (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - assetExists = true; + if (dbReader.Read()) + assetExists = true; } - - dbReader.Close(); - cmd.Dispose(); } - } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", uuid); - _dbConnection.Reconnect(); + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", uuid); + _dbConnection.Reconnect(); + } } } diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e508b52..e96a123 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,44 +55,38 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - MySqlCommand cmd = new MySqlCommand( - "select * from `"+m_Realm+"` where UUID = ?principalID" - ); - - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - - IDataReader result = ExecuteReader(cmd); - - if (result.Read()) + using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID")) { - ret.PrincipalID = principalID; + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - if (m_ColumnNames == null) + using (IDataReader result = ExecuteReader(cmd)) { - m_ColumnNames = new List(); + if (result.Read()) + { + ret.PrincipalID = principalID; - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } - ret.Data[s] = result[s].ToString(); - } + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; - result.Close(); - CloseReaderCommand(cmd); + ret.Data[s] = result[s].ToString(); + } - return ret; + return ret; + } + } } - result.Close(); - CloseReaderCommand(cmd); - return null; } diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e8694fc..7166b29 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -95,21 +95,17 @@ namespace OpenSim.Data.MySQL protected void GetWaitTimeout() { - MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, - m_connection); - - using (MySqlDataReader dbReader = - cmd.ExecuteReader(CommandBehavior.SingleRow)) + using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection)) { - if (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * - TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * + TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } } - - dbReader.Close(); - cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -147,110 +143,103 @@ namespace OpenSim.Data.MySQL CheckConnection(); - MySqlCommand cmd = m_connection.CreateCommand(); + bool migration = true; - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - - IDataReader r = cmd.ExecuteReader(); - - if (r.Read()) + using (MySqlCommand cmd = m_connection.CreateCommand()) { - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); - } - else if (m_FieldMap[name].GetValue(es) is UUID) - { - UUID uuid = UUID.Zero; + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); - } - else + using (IDataReader r = cmd.ExecuteReader()) + { + if (r.Read()) { - m_FieldMap[name].SetValue(es, r[name]); + migration = false; + + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) + { + int v = Convert.ToInt32(r[name]); + if (v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else if (m_FieldMap[name].GetValue(es) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(r[name].ToString(), out uuid); + m_FieldMap[name].SetValue(es, uuid); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); + } + } } } - r.Close(); } - else + + if (migration) { // Migration case - // - r.Close(); - List names = new List(FieldList); names.Remove("EstateID"); sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - cmd.CommandText = sql; - cmd.Parameters.Clear(); - - foreach (string name in FieldList) + using (MySqlCommand cmd = m_connection.CreateCommand()) { - if (m_FieldMap[name].GetValue(es) is bool) + cmd.CommandText = sql; + cmd.Parameters.Clear(); + + foreach (string name in FieldList) { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); + else + cmd.Parameters.AddWithValue("?" + name, "0"); + } else - cmd.Parameters.AddWithValue("?" + name, "0"); + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + } } - else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); - } - } - - cmd.ExecuteNonQuery(); - cmd.CommandText = "select LAST_INSERT_ID() as id"; - cmd.Parameters.Clear(); - - r = cmd.ExecuteReader(); + cmd.ExecuteNonQuery(); - r.Read(); + cmd.CommandText = "select LAST_INSERT_ID() as id"; + cmd.Parameters.Clear(); - es.EstateID = Convert.ToUInt32(r["id"]); + using (IDataReader r = cmd.ExecuteReader()) + { + r.Read(); + es.EstateID = Convert.ToUInt32(r["id"]); + } - r.Close(); + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + // This will throw on dupe key + try { cmd.ExecuteNonQuery(); } + catch (Exception) { } - // This will throw on dupe key - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - } + // Munge and transfer the ban list + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - // Munge and transfer the ban list - // - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + try { cmd.ExecuteNonQuery(); } + catch (Exception) { } - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { + es.Save(); } - - es.Save(); } LoadBanList(es); @@ -267,26 +256,27 @@ namespace OpenSim.Data.MySQL CheckConnection(); - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = sql; - - foreach (string name in FieldList) + using (MySqlCommand cmd = m_connection.CreateCommand()) { - if (m_FieldMap[name].GetValue(es) is bool) + cmd.CommandText = sql; + + foreach (string name in FieldList) { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); + else + cmd.Parameters.AddWithValue("?" + name, "0"); + } else - cmd.Parameters.AddWithValue("?" + name, "0"); - } - else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + } } - } - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); + } SaveBanList(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); @@ -300,50 +290,52 @@ namespace OpenSim.Data.MySQL CheckConnection(); - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) + using (MySqlCommand cmd = m_connection.CreateCommand()) { - EstateBan eb = new EstateBan(); + cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); + + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + EstateBan eb = new EstateBan(); - UUID uuid = new UUID(); - UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + UUID uuid = new UUID(); + UUID.TryParse(r["bannedUUID"].ToString(), out uuid); - eb.BannedUserID = uuid; - eb.BannedHostAddress = "0.0.0.0"; - eb.BannedHostIPMask = "0.0.0.0"; - es.AddBan(eb); + eb.BannedUserID = uuid; + eb.BannedHostAddress = "0.0.0.0"; + eb.BannedHostIPMask = "0.0.0.0"; + es.AddBan(eb); + } + } } - r.Close(); } private void SaveBanList(EstateSettings es) { CheckConnection(); - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; - - foreach (EstateBan b in es.EstateBans) + using (MySqlCommand cmd = m_connection.CreateCommand()) { + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; + + foreach (EstateBan b in es.EstateBans) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } } } @@ -351,24 +343,25 @@ namespace OpenSim.Data.MySQL { CheckConnection(); - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; - - foreach (UUID uuid in data) + using (MySqlCommand cmd = m_connection.CreateCommand()) { + cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; + + foreach (UUID uuid in data) + { + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } } } @@ -378,23 +371,24 @@ namespace OpenSim.Data.MySQL CheckConnection(); - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) + using (MySqlCommand cmd = m_connection.CreateCommand()) { - // EstateBan eb = new EstateBan(); + cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID); - UUID uuid = new UUID(); - UUID.TryParse(r["uuid"].ToString(), out uuid); + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + // EstateBan eb = new EstateBan(); - uuids.Add(uuid); + UUID uuid = new UUID(); + UUID.TryParse(r["uuid"].ToString(), out uuid); + + uuids.Add(uuid); + } + } } - r.Close(); return uuids.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 6c73249..c756c9c 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,6 +40,8 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected MySqlConnection m_Connection; protected MySqlFramework(string connectionString) @@ -70,12 +72,11 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { -Console.WriteLine(e.ToString()); + m_log.Error(e.Message, e); if (errorSeen) throw; // This is "Server has gone away" and "Server lost" - // if (e.Number == 2006 || e.Number == 2013) { errorSeen = true; @@ -94,7 +95,7 @@ Console.WriteLine(e.ToString()); } catch (Exception e) { -Console.WriteLine(e.ToString()); + m_log.Error(e.Message, e); return 0; } } @@ -112,12 +113,5 @@ Console.WriteLine(e.ToString()); return cmd.ExecuteReader(); } - - protected void CloseReaderCommand(MySqlCommand cmd) - { - cmd.Connection.Close(); - cmd.Connection.Dispose(); - cmd.Dispose(); - } } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 1ec2609..38cb3b7 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -197,29 +197,27 @@ namespace OpenSim.Data.MySQL param["?xmax"] = xmax.ToString(); param["?ymax"] = ymax.ToString(); - IDbCommand result = - dbm.Manager.Query( + using (IDbCommand result = dbm.Manager.Query( "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", - param); - IDataReader reader = result.ExecuteReader(); + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row; - RegionProfileData row; + List rows = new List(); - List rows = new List(); + while ((row = dbm.Manager.readSimRow(reader)) != null) + rows.Add(row); - while ((row = dbm.Manager.readSimRow(reader)) != null) - { - rows.Add(row); + return rows.ToArray(); + } } - reader.Close(); - result.Dispose(); - - return rows.ToArray(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -243,29 +241,27 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName LIKE ?name", - param); - IDataReader reader = result.ExecuteReader(); + using (IDbCommand result = dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName LIKE ?name", + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row; - RegionProfileData row; + List rows = new List(); - List rows = new List(); + while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) + rows.Add(row); - while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) - { - rows.Add(row); + return rows; + } } - reader.Close(); - result.Dispose(); - - return rows; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -286,21 +282,21 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?handle"] = handle.ToString(); - - IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); - IDataReader reader = result.ExecuteReader(); + param["?handle"] = handle.ToString(); - RegionProfileData row = dbm.Manager.readSimRow(reader); - reader.Close(); - result.Dispose(); - - return row; + using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row = dbm.Manager.readSimRow(reader); + return row; + } } + } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -321,23 +317,24 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + param["?uuid"] = uuid.ToString(); - IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - - RegionProfileData row = dbm.Manager.readSimRow(reader); - reader.Close(); - result.Dispose(); - - return row; + using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row = dbm.Manager.readSimRow(reader); + return row; + } } + } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; - } finally + } + finally { dbm.Release(); } @@ -359,22 +356,21 @@ namespace OpenSim.Data.MySQL // Add % because this is a like query. param["?regionName"] = regionName + "%"; // Order by statement will return shorter matches first. Only returns one record or no record. - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", - param); - IDataReader reader = result.ExecuteReader(); - - RegionProfileData row = dbm.Manager.readSimRow(reader); - reader.Close(); - result.Dispose(); - - return row; + using (IDbCommand result = dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row = dbm.Manager.readSimRow(reader); + return row; + } + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -382,6 +378,7 @@ namespace OpenSim.Data.MySQL dbm.Release(); } } + m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } @@ -394,12 +391,12 @@ namespace OpenSim.Data.MySQL override public DataResponse StoreProfile(RegionProfileData profile) { MySQLSuperManager dbm = GetLockedConnection(); - try { + try + { if (dbm.Manager.insertRegion(profile)) - { return DataResponse.RESPONSE_OK; - } - return DataResponse.RESPONSE_ERROR; + else + return DataResponse.RESPONSE_ERROR; } finally { @@ -417,14 +414,14 @@ namespace OpenSim.Data.MySQL { MySQLSuperManager dbm = GetLockedConnection(); - - try { + try + { if (dbm.Manager.deleteRegion(uuid)) - { return DataResponse.RESPONSE_OK; - } - return DataResponse.RESPONSE_ERROR; - } finally + else + return DataResponse.RESPONSE_ERROR; + } + finally { dbm.Release(); } @@ -482,26 +479,26 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?x"] = x.ToString(); - param["?y"] = y.ToString(); - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", - param); - IDataReader reader = result.ExecuteReader(); - - ReservationData row = dbm.Manager.readReservationRow(reader); - reader.Close(); - result.Dispose(); - - return row; + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + using (IDbCommand result = dbm.Manager.Query( + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + ReservationData row = dbm.Manager.readReservationRow(reader); + return row; + } + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; - } finally + } + finally { dbm.Release(); } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 0eecf06..598971d 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL database.CheckConnection(); - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", folderID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); - - while (reader.Read()) + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", + database.Connection)) { - // A null item (because something went wrong) breaks everything in the folder - InventoryItemBase item = readInventoryItem(reader); - if (item != null) - items.Add(item); - } + result.Parameters.AddWithValue("?uuid", folderID.ToString()); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + // A null item (because something went wrong) breaks everything in the folder + InventoryItemBase item = readInventoryItem(reader); + if (item != null) + items.Add(item); + } - return items; + return items; + } + } } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -176,29 +176,28 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand result = - new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - MySqlDataReader reader = result.ExecuteReader(); - - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); - + using (MySqlCommand result = new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection)) + { + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - return items; + return items; + } + } } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -217,41 +216,38 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand result = - new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + using (MySqlCommand result = new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection)) + { + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - MySqlDataReader reader = result.ExecuteReader(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + InventoryFolderBase rootFolder = null; - InventoryFolderBase rootFolder = null; + // There should only ever be one root folder for a user. However, if there's more + // than one we'll simply use the first one rather than failing. It would be even + // nicer to print some message to this effect, but this feels like it's too low a + // to put such a message out, and it's too minor right now to spare the time to + // suitably refactor. + if (items.Count > 0) + rootFolder = items[0]; - // There should only ever be one root folder for a user. However, if there's more - // than one we'll simply use the first one rather than failing. It would be even - // nicer to print some message to this effect, but this feels like it's too low a - // to put such a message out, and it's too minor right now to spare the time to - // suitably refactor. - if (items.Count > 0) - { - rootFolder = items[0]; + return rootFolder; + } } - - reader.Close(); - result.Dispose(); - - return rootFolder; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -271,27 +267,26 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); - - List items = new List(); - - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", + database.Connection)) + { + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + using (MySqlDataReader reader = result.ExecuteReader()) + { + List items = new List(); - reader.Close(); - result.Dispose(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - return items; + return items; + } + } } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -370,25 +365,25 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); - result.Parameters.AddWithValue("?uuid", itemID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); - - InventoryItemBase item = null; - if (reader.Read()) - item = readInventoryItem(reader); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection)) + { + result.Parameters.AddWithValue("?uuid", itemID.ToString()); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + InventoryItemBase item = null; + if (reader.Read()) + item = readInventoryItem(reader); - return item; + return item; + } + } } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } return null; } @@ -413,7 +408,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } return null; @@ -433,24 +428,25 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); - result.Parameters.AddWithValue("?uuid", folderID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) + { + result.Parameters.AddWithValue("?uuid", folderID.ToString()); - InventoryFolderBase folder = null; - if (reader.Read()) - folder = readInventoryFolder(reader); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + InventoryFolderBase folder = null; + if (reader.Read()) + folder = readInventoryFolder(reader); - return folder; + return folder; + } + } } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -698,69 +694,73 @@ namespace OpenSim.Data.MySQL try { List folders = new List(); - Dictionary> hashtable - = new Dictionary>(); ; + Dictionary> hashtable = new Dictionary>(); ; List parentFolder = new List(); + bool buildResultsFromHashTable = false; + lock (database) { - MySqlCommand result; - MySqlDataReader reader; - bool buildResultsFromHashTable = false; - database.CheckConnection(); /* Fetch the parent folder from the database to determine the agent ID, and if * we're querying the root of the inventory folder tree */ - result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - reader = result.ExecuteReader(); - while (reader.Read()) // Should be at most 1 result - parentFolder.Add(readInventoryFolder(reader)); - reader.Close(); - result.Dispose(); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) + { + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) + { + // Should be at most 1 result + while (reader.Read()) + parentFolder.Add(readInventoryFolder(reader)); + } + } if (parentFolder.Count >= 1) // No result means parent folder does not exist { if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder { /* Get all of the agent's folders from the database, put them in a list and return it */ - result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - reader = result.ExecuteReader(); - while (reader.Read()) + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list - folders.Add(curFolder); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list + folders.Add(curFolder); + } + } } - reader.Close(); - result.Dispose(); } // if we are querying the root folder else // else we are querying a subtree of the inventory folder tree { /* Get all of the agent's folders from the database, put them all in a hash table * indexed by their parent ID */ - result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - reader = result.ExecuteReader(); - while (reader.Read()) + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling - hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list - else // else current folder has no known (yet) siblings + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) { - List siblingList = new List(); - siblingList.Add(curFolder); - // Current folder has no known (yet) siblings - hashtable.Add(curFolder.ParentID, siblingList); + while (reader.Read()) + { + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling + hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list + else // else current folder has no known (yet) siblings + { + List siblingList = new List(); + siblingList.Add(curFolder); + // Current folder has no known (yet) siblings + hashtable.Add(curFolder.ParentID, siblingList); + } + } // while more items to read from the database } - } // while more items to read from the database - reader.Close(); - result.Dispose(); + } // Set flag so we know we need to build the results from the hash table after // we unlock the database @@ -781,12 +781,13 @@ namespace OpenSim.Data.MySQL folders.AddRange(hashtable[folders[i].ID]); } } // lock (database) + return folders; } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -801,19 +802,18 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand cmd = - new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - - lock (database) + using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection)) { - cmd.ExecuteNonQuery(); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + + lock (database) + cmd.ExecuteNonQuery(); } } catch (MySqlException e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } } @@ -827,13 +827,12 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - MySqlCommand cmd = - new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - - lock (database) + using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection)) { - cmd.ExecuteNonQuery(); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + + lock (database) + cmd.ExecuteNonQuery(); } } catch (MySqlException e) @@ -865,40 +864,38 @@ namespace OpenSim.Data.MySQL public List fetchActiveGestures(UUID avatarID) { - MySqlDataReader result = null; - MySqlCommand sqlCmd = null; lock (database) { try { database.CheckConnection(); - sqlCmd = new MySqlCommand( - "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", - database.Connection); - sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); - sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); - result = sqlCmd.ExecuteReader(); - List list = new List(); - while (result.Read()) + using (MySqlCommand sqlCmd = new MySqlCommand( + "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", + database.Connection)) { - InventoryItemBase item = readInventoryItem(result); - if (item != null) - list.Add(item); + sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); + sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + + using (MySqlDataReader result = sqlCmd.ExecuteReader()) + { + List list = new List(); + while (result.Read()) + { + InventoryItemBase item = readInventoryItem(result); + if (item != null) + list.Add(item); + } + return list; + } } - return list; } catch (Exception e) { database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - if (result != null) result.Close(); - if (sqlCmd != null) sqlCmd.Dispose(); - } } } } diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index f25bfd7..fe0914b 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -268,6 +268,8 @@ namespace OpenSim.Data.MySQL public void RemoveObject(UUID obj, UUID regionUUID) { + List uuids = new List(); + // Formerly, this used to check the region UUID. // That makes no sense, as we remove the contents of a prim // unconditionally, but the prim dependent on the region ID. @@ -278,43 +280,31 @@ namespace OpenSim.Data.MySQL // lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select UUID from prims where "+ - "SceneGroupID= ?UUID"; - - cmd.Parameters.AddWithValue("UUID", obj.ToString()); - - List uuids = new List(); - - IDataReader reader = ExecuteReader(cmd); - - try + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; + cmd.Parameters.AddWithValue("UUID", obj.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - uuids.Add(new UUID(reader["UUID"].ToString())); + while (reader.Read()) + uuids.Add(new UUID(reader["UUID"].ToString())); } - } - finally - { - reader.Close(); - } - - // delete the main prims - cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - ExecuteNonQuery(cmd); - cmd.Dispose(); - // there is no way this should be < 1 unless there is - // a very corrupt database, but in that case be extra - // safe anyway. - if (uuids.Count > 0) - { - RemoveShapes(uuids); - RemoveItems(uuids); + // delete the main prims + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + ExecuteNonQuery(cmd); } } + + // there is no way this should be < 1 unless there is + // a very corrupt database, but in that case be extra + // safe anyway. + if (uuids.Count > 0) + { + RemoveShapes(uuids); + RemoveItems(uuids); + } } /// @@ -326,19 +316,16 @@ namespace OpenSim.Data.MySQL { lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "delete from primitems where " + - "PrimID = ?PrimID"; - - cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); - ExecuteNonQuery(cmd); - cmd.Dispose(); + ExecuteNonQuery(cmd); + } } } - /// /// Remove all persisted shapes for a list of prims /// The caller must acquire the necessrary synchronization locks @@ -349,28 +336,27 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { string sql = "delete from primshapes where "; - MySqlCommand cmd = m_Connection.CreateCommand(); - - for (int i = 0; i < uuids.Count; i++) + + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - if ((i + 1) == uuids.Count) - {// end of the list - sql += "(UUID = ?UUID" + i + ")"; - } - else + for (int i = 0; i < uuids.Count; i++) { - sql += "(UUID = ?UUID" + i + ") or "; + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(UUID = ?UUID" + i + ")"; + } + else + { + sql += "(UUID = ?UUID" + i + ") or "; + } } - } - cmd.CommandText = sql; + cmd.CommandText = sql; - for (int i = 0; i < uuids.Count; i++) - { - cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); - } + for (int i = 0; i < uuids.Count; i++) + cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); - ExecuteNonQuery(cmd); - cmd.Dispose(); + ExecuteNonQuery(cmd); + } } } @@ -384,28 +370,28 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { string sql = "delete from primitems where "; - MySqlCommand cmd = m_Connection.CreateCommand(); - - for (int i = 0; i < uuids.Count; i++) + + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - if ((i + 1) == uuids.Count) - {// end of the list - sql += "(PrimID = ?PrimID" + i + ")"; - } - else + for (int i = 0; i < uuids.Count; i++) { - sql += "(PrimID = ?PrimID" + i + ") or "; + if ((i + 1) == uuids.Count) + { + // end of the list + sql += "(PrimID = ?PrimID" + i + ")"; + } + else + { + sql += "(PrimID = ?PrimID" + i + ") or "; + } } - } - cmd.CommandText = sql; + cmd.CommandText = sql; - for (int i = 0; i < uuids.Count; i++) - { - cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); - } + for (int i = 0; i < uuids.Count; i++) + cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); - ExecuteNonQuery(cmd); - cmd.Dispose(); + ExecuteNonQuery(cmd); + } } } @@ -418,77 +404,71 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select *, " + + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "select *, " + "case when prims.UUID = SceneGroupID " + "then 0 else 1 end as sort from prims " + - "left join primshapes on prims.UUID = primshapes.UUID "+ + "left join primshapes on prims.UUID = primshapes.UUID " + "where RegionUUID = ?RegionUUID " + "order by SceneGroupID asc, sort asc, LinkNumber asc"; - - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - IDataReader reader = ExecuteReader(cmd); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - try - { - while (reader.Read()) + using (IDataReader reader = ExecuteReader(cmd)) { - SceneObjectPart prim = BuildPrim(reader); - if (reader["Shape"] is DBNull) - prim.Shape = PrimitiveBaseShape.Default; - else - prim.Shape = BuildShape(reader); + while (reader.Read()) + { + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); - prims[prim.UUID] = prim; + prims[prim.UUID] = prim; - UUID groupID = new UUID(reader["SceneGroupID"].ToString()); + UUID groupID = new UUID(reader["SceneGroupID"].ToString()); - if (groupID != lastGroupID) // New SOG - { - if (grp != null) - objects[grp.UUID] = grp; - - lastGroupID = groupID; - - // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are - // recorded as the root prim (for which the UUID must equal the persisted group UUID). In - // this case, force the UUID to be the same as the group UUID so that at least these can be - // deleted (we need to change the UUID so that any other prims in the linkset can also be - // deleted). - if (prim.UUID != groupID && groupID != UUID.Zero) + if (groupID != lastGroupID) // New SOG { - m_log.WarnFormat( - "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", - prim.Name, prim.UUID, prim.GroupPosition, groupID); - - prim.UUID = groupID; + if (grp != null) + objects[grp.UUID] = grp; + + lastGroupID = groupID; + + // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are + // recorded as the root prim (for which the UUID must equal the persisted group UUID). In + // this case, force the UUID to be the same as the group UUID so that at least these can be + // deleted (we need to change the UUID so that any other prims in the linkset can also be + // deleted). + if (prim.UUID != groupID && groupID != UUID.Zero) + { + m_log.WarnFormat( + "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", + prim.Name, prim.UUID, prim.GroupPosition, groupID); + + prim.UUID = groupID; + } + + grp = new SceneObjectGroup(prim); } + else + { + // Black magic to preserve link numbers + // + int link = prim.LinkNum; - grp = new SceneObjectGroup(prim); - } - else - { - // Black magic to preserve link numbers - // - int link = prim.LinkNum; - - grp.AddPart(prim); + grp.AddPart(prim); - if (link != 0) - prim.LinkNum = link; + if (link != 0) + prim.LinkNum = link; + } } } - } - finally - { - reader.Close(); - } - if (grp != null) - objects[grp.UUID] = grp; - cmd.Dispose(); + if (grp != null) + objects[grp.UUID] = grp; + } } // Instead of attempting to LoadItems on every prim, @@ -498,34 +478,29 @@ namespace OpenSim.Data.MySQL List primsWithInventory = new List(); lock (m_Connection) { - MySqlCommand itemCmd = m_Connection.CreateCommand(); - itemCmd.CommandText = "select distinct primID from primitems"; - IDataReader itemReader = ExecuteReader(itemCmd); - try + using (MySqlCommand itemCmd = m_Connection.CreateCommand()) { - while (itemReader.Read()) + itemCmd.CommandText = "select distinct primID from primitems"; + using (IDataReader itemReader = ExecuteReader(itemCmd)) { - if (!(itemReader["primID"] is DBNull)) + while (itemReader.Read()) { - UUID primID = new UUID(itemReader["primID"].ToString()); - if (prims.ContainsKey(primID)) + if (!(itemReader["primID"] is DBNull)) { - primsWithInventory.Add(prims[primID]); + UUID primID = new UUID(itemReader["primID"].ToString()); + if (prims.ContainsKey(primID)) + { + primsWithInventory.Add(prims[primID]); + } } } } } - finally - { - itemReader.Close(); - } - itemCmd.Dispose(); } foreach (SceneObjectPart prim in primsWithInventory) - { LoadItems(prim); - } + m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); return new List(objects.Values); } @@ -538,34 +513,25 @@ namespace OpenSim.Data.MySQL { lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select * from primitems where "+ - "PrimID = ?PrimID"; + List inventory = new List(); - cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - List inventory = - new List(); - - try + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - TaskInventoryItem item = BuildItem(reader); + while (reader.Read()) + { + TaskInventoryItem item = BuildItem(reader); - item.ParentID = prim.UUID; // Values in database are - // often wrong - inventory.Add(item); + item.ParentID = prim.UUID; // Values in database are often wrong + inventory.Add(item); + } } } - finally - { - reader.Close(); - } - cmd.Dispose(); prim.Inventory.RestoreInventoryItems(inventory); } } @@ -576,23 +542,21 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - cmd.CommandText = "delete from terrain where " + - "RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + ExecuteNonQuery(cmd); - ExecuteNonQuery(cmd); - - cmd.CommandText = "insert into terrain (RegionUUID, " + + cmd.CommandText = "insert into terrain (RegionUUID, " + "Revision, Heightfield) values (?RegionUUID, " + "1, ?Heightfield)"; - cmd.Parameters.AddWithValue("Heightfield", - SerializeTerrain(ter)); - - ExecuteNonQuery(cmd); - cmd.Dispose(); + cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); + + ExecuteNonQuery(cmd); + } } } @@ -602,42 +566,40 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "select RegionUUID, Revision, Heightfield " + - "from terrain where RegionUUID = ?RegionUUID "+ + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID " + "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - - IDataReader reader = ExecuteReader(cmd); + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - try - { - while (reader.Read()) + using (IDataReader reader = ExecuteReader(cmd)) { - terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; - terrain.Initialize(); + while (reader.Read()) + { + int rev = Convert.ToInt32(reader["Revision"]); - MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); - int rev = 0; + terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; + terrain.Initialize(); - BinaryReader br = new BinaryReader(mstr); - for (int x = 0; x < (int)Constants.RegionSize; x++) - { - for (int y = 0; y < (int)Constants.RegionSize; y++) + using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) { - terrain[x, y] = br.ReadDouble(); + using (BinaryReader br = new BinaryReader(mstr)) + { + for (int x = 0; x < (int)Constants.RegionSize; x++) + { + for (int y = 0; y < (int)Constants.RegionSize; y++) + { + terrain[x, y] = br.ReadDouble(); + } + } + } + + m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); } - rev = Convert.ToInt32(reader["Revision"]); } - m_log.InfoFormat("[REGION DB]: Loaded terrain " + - "revision r{0}", rev); } } - finally - { - reader.Close(); - } - cmd.Dispose(); } return terrain; @@ -647,14 +609,13 @@ namespace OpenSim.Data.MySQL { lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "delete from land where UUID = ?UUID"; - - cmd.Parameters.AddWithValue("UUID", globalID.ToString()); + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "delete from land where UUID = ?UUID"; + cmd.Parameters.AddWithValue("UUID", globalID.ToString()); - ExecuteNonQuery(cmd); - cmd.Dispose(); + ExecuteNonQuery(cmd); + } } } @@ -662,9 +623,9 @@ namespace OpenSim.Data.MySQL { lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "replace into land (UUID, RegionUUID, " + + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "replace into land (UUID, RegionUUID, " + "LocalLandID, Bitmap, Name, Description, " + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + "Category, ClaimDate, ClaimPrice, GroupUUID, " + @@ -685,28 +646,26 @@ namespace OpenSim.Data.MySQL "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; - FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); + FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); - ExecuteNonQuery(cmd); - - cmd.CommandText = "delete from landaccesslist where " + - "LandUUID = ?UUID"; - - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); - cmd.Parameters.Clear(); - cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; + cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; - foreach (ParcelManager.ParcelAccessEntry entry in - parcel.LandData.ParcelAccessList) - { - FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + { + FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + } } - cmd.Dispose(); } } @@ -716,35 +675,28 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select * from regionsettings where " + - "regionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("regionUUID", regionUUID); - - IDataReader reader = ExecuteReader(cmd); - - try + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - if (reader.Read()) - { - rs = BuildRegionSettings(reader); - rs.OnSave += StoreRegionSettings; - } - else + cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); + + using (IDataReader reader = ExecuteReader(cmd)) { - rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; + if (reader.Read()) + { + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; + } + else + { + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; - StoreRegionSettings(rs); + StoreRegionSettings(rs); + } } } - finally - { - reader.Close(); - } - cmd.Dispose(); } return rs; @@ -754,9 +706,9 @@ namespace OpenSim.Data.MySQL { lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "replace into regionsettings (regionUUID, " + + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "replace into regionsettings (regionUUID, " + "block_terraform, block_fly, allow_damage, " + "restrict_pushing, allow_land_resell, " + "allow_land_join_divide, block_show_in_search, " + @@ -766,8 +718,8 @@ namespace OpenSim.Data.MySQL "terrain_texture_2, terrain_texture_3, " + "terrain_texture_4, elevation_1_nw, " + "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, "+ - "elevation_2_se, elevation_1_sw, "+ + "elevation_2_ne, elevation_1_se, " + + "elevation_2_se, elevation_1_sw, " + "elevation_2_sw, water_height, " + "terrain_raise_limit, terrain_lower_limit, " + "use_estate_sun, fixed_sun, sun_position, " + @@ -789,11 +741,10 @@ namespace OpenSim.Data.MySQL "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID)"; - FillRegionSettingsCommand(cmd, rs); - - ExecuteNonQuery(cmd); - cmd.Dispose(); + FillRegionSettingsCommand(cmd, rs); + ExecuteNonQuery(cmd); + } } } @@ -803,52 +754,38 @@ namespace OpenSim.Data.MySQL lock (m_Connection) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = "select * from land where " + - "RegionUUID = ?RegionUUID"; - - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - - try + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - LandData newLand = BuildLandData(reader); - landData.Add(newLand); + while (reader.Read()) + { + LandData newLand = BuildLandData(reader); + landData.Add(newLand); + } } } - finally - { - reader.Close(); - } - foreach (LandData land in landData) + using (MySqlCommand cmd = m_Connection.CreateCommand()) { - cmd.Parameters.Clear(); - - cmd.CommandText = "select * from landaccesslist " + - "where LandUUID = ?LandUUID"; - - cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); - - reader = ExecuteReader(cmd); - - try + foreach (LandData land in landData) { - while (reader.Read()) + cmd.Parameters.Clear(); + cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; + cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - land.ParcelAccessList.Add(BuildLandAccessData(reader)); + while (reader.Read()) + { + land.ParcelAccessList.Add(BuildLandAccessData(reader)); + } } } - finally - { - reader.Close(); - } } - cmd.Dispose(); } return landData; diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a6cce57..a724a50 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -134,18 +134,16 @@ namespace OpenSim.Data.MySQL /// protected void GetWaitTimeout() { - MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); - - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) { - if (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } } - - dbReader.Close(); - cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -303,31 +301,31 @@ namespace OpenSim.Data.MySQL { CheckConnection(); - MySqlCommand tablesCmd = - new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", - dbcon); - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + using (MySqlCommand tablesCmd = new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon)) { - while (tables.Read()) + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { - try + while (tables.Read()) { - string tableName = (string) tables["TABLE_NAME"]; - string comment = (string) tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) + try { - tableList[tableName] = comment; + string tableName = (string)tables["TABLE_NAME"]; + string comment = (string)tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) + { + tableList[tableName] = comment; + } + } + catch (Exception e) + { + m_log.Error(e.Message, e); } - } - catch (Exception e) - { - m_log.Error(e.ToString()); } } - tables.Close(); } } } @@ -346,19 +344,19 @@ namespace OpenSim.Data.MySQL { CheckConnection(); // Not sure if this one is necessary - MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); + MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand) dbcommand; + return (IDbCommand)dbcommand; } catch (Exception e) { // Return null if it fails. - m_log.Error("Failed during Query generation: " + e.ToString()); + m_log.Error("Failed during Query generation: " + e.Message, e); return null; } } @@ -694,8 +692,6 @@ namespace OpenSim.Data.MySQL ret.Add(attachpoint, item); } - r.Close(); - return ret; } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 06ef624..04b24b6 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -56,12 +56,13 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?regionName", regionName); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?regionName", regionName); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return RunCommand(cmd); + return RunCommand(cmd); + } } public RegionData Get(int posX, int posY, UUID scopeID) @@ -70,17 +71,18 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?posX", posX.ToString()); - cmd.Parameters.AddWithValue("?posY", posY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?posX", posX.ToString()); + cmd.Parameters.AddWithValue("?posY", posY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; - return ret[0]; + return ret[0]; + } } public RegionData Get(UUID regionID, UUID scopeID) @@ -89,16 +91,17 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; - return ret[0]; + return ret[0]; + } } public List Get(int startX, int startY, int endX, int endY, UUID scopeID) @@ -107,71 +110,70 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?startX", startX.ToString()); - cmd.Parameters.AddWithValue("?startY", startY.ToString()); - cmd.Parameters.AddWithValue("?endX", endX.ToString()); - cmd.Parameters.AddWithValue("?endY", endY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?startX", startX.ToString()); + cmd.Parameters.AddWithValue("?startY", startY.ToString()); + cmd.Parameters.AddWithValue("?endX", endX.ToString()); + cmd.Parameters.AddWithValue("?endY", endY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return RunCommand(cmd); + return RunCommand(cmd); + } } public List RunCommand(MySqlCommand cmd) { List retList = new List(); - IDataReader result = ExecuteReader(cmd); - - while (result.Read()) + using (IDataReader result = ExecuteReader(cmd)) { - RegionData ret = new RegionData(); - ret.Data = new Dictionary(); - - UUID regionID; - UUID.TryParse(result["uuid"].ToString(), out regionID); - ret.RegionID = regionID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - ret.RegionName = result["regionName"].ToString(); - ret.posX = Convert.ToInt32(result["locX"]); - ret.posY = Convert.ToInt32(result["locY"]); - ret.sizeX = Convert.ToInt32(result["sizeX"]); - ret.sizeY = Convert.ToInt32(result["sizeY"]); - - if (m_ColumnNames == null) + while (result.Read()) { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); + RegionData ret = new RegionData(); + ret.Data = new Dictionary(); + + UUID regionID; + UUID.TryParse(result["uuid"].ToString(), out regionID); + ret.RegionID = regionID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + ret.RegionName = result["regionName"].ToString(); + ret.posX = Convert.ToInt32(result["locX"]); + ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "uuid") + continue; + if (s == "ScopeID") + continue; + if (s == "regionName") + continue; + if (s == "locX") + continue; + if (s == "locY") + continue; + + ret.Data[s] = result[s].ToString(); + } + + retList.Add(ret); } - - foreach (string s in m_ColumnNames) - { - if (s == "uuid") - continue; - if (s == "ScopeID") - continue; - if (s == "regionName") - continue; - if (s == "locX") - continue; - if (s == "locY") - continue; - - ret.Data[s] = result[s].ToString(); - } - - retList.Add(ret); } - result.Close(); - CloseReaderCommand(cmd); - return retList; } @@ -198,76 +200,72 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - MySqlCommand cmd = new MySqlCommand(); - - string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; - foreach (string field in fields) + using (MySqlCommand cmd = new MySqlCommand()) { - update += ", "; - update += "`" + field + "` = ?"+field; - - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); - } - - update += " where uuid = ?regionID"; + string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; + foreach (string field in fields) + { + update += ", "; + update += "`" + field + "` = ?" + field; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + cmd.Parameters.AddWithValue("?" + field, data.Data[field]); + } - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); - cmd.Parameters.AddWithValue("?regionName", data.RegionName); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); - cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); - cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); - cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); + update += " where uuid = ?regionID"; - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + - String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = insert; + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); + cmd.Parameters.AddWithValue("?regionName", data.RegionName); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); if (ExecuteNonQuery(cmd) < 1) { - cmd.Dispose(); - return false; + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + + String.Join("`, `", fields) + + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + { + return false; + } } } - cmd.Dispose(); - return true; } public bool SetDataItem(UUID regionID, string item, string value) { - MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + - "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); - - - cmd.Parameters.AddWithValue("?"+item, value); - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) + { + cmd.Parameters.AddWithValue("?" + item, value); + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } public bool Delete(UUID regionID) { - MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + - "` where uuid = ?UUID"); - - - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) + { + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index d48144d..c713a11 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -64,48 +64,44 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - IDataReader result = ExecuteReader(cmd); - - if (result.Read()) + using (MySqlCommand cmd = new MySqlCommand(command)) { - ret.PrincipalID = principalID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - if (m_ColumnNames == null) + using (IDataReader result = ExecuteReader(cmd)) { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); + if (result.Read()) + { + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + return ret; + } } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - if (s == "ScopeID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - result.Close(); - CloseReaderCommand(cmd); - - return ret; } - result.Close(); - CloseReaderCommand(cmd); - return null; } @@ -118,61 +114,60 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - MySqlCommand cmd = new MySqlCommand(); - - string update = "update `"+m_Realm+"` set "; - bool first = true; - foreach (string field in fields) + using (MySqlCommand cmd = new MySqlCommand()) { - if (!first) - update += ", "; - update += "`" + field + "` = ?"+field; - - first = false; - - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); - } + string update = "update `" + m_Realm + "` set "; + bool first = true; + foreach (string field in fields) + { + if (!first) + update += ", "; + update += "`" + field + "` = ?" + field; - update += " where UUID = ?principalID"; + first = false; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + cmd.Parameters.AddWithValue("?" + field, data.Data[field]); + } - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + update += " where UUID = ?principalID"; - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + - String.Join("`, `", fields) + - "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = insert; + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); if (ExecuteNonQuery(cmd) < 1) { - cmd.Dispose(); - return false; + string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; + } } } - cmd.Dispose(); - return true; } public bool SetDataItem(UUID principalID, string item, string value) { - MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + - "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - - - cmd.Parameters.AddWithValue("?"+item, value); - cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + + item + "` = ?" + item + " where UUID = ?UUID")) + { + cmd.Parameters.AddWithValue("?" + item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 04f872f..bd46dfc 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -181,21 +181,20 @@ namespace OpenSim.Data.MySQL param["?first"] = user; param["?second"] = last; - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); - IDataReader reader = result.ExecuteReader(); - - UserProfileData row = dbm.Manager.readUserRow(reader); - - reader.Dispose(); - result.Dispose(); - return row; + using (IDbCommand result = dbm.Manager.Query( + "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + UserProfileData row = dbm.Manager.readUserRow(reader); + return row; + } + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -220,28 +219,30 @@ namespace OpenSim.Data.MySQL try { - IDbCommand adder = - dbm.Manager.Query( - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?ownerID,?friendID,?friendPerms,?datetimestamp)", - param); - adder.ExecuteNonQuery(); - - adder = - dbm.Manager.Query( - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?friendID,?ownerID,?friendPerms,?datetimestamp)", - param); - adder.ExecuteNonQuery(); + using (IDbCommand adder = dbm.Manager.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", + param)) + { + adder.ExecuteNonQuery(); + } + + using (IDbCommand adder = dbm.Manager.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?friendID,?ownerID,?friendPerms,?datetimestamp)", + param)) + { + adder.ExecuteNonQuery(); + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } finally @@ -260,22 +261,24 @@ namespace OpenSim.Data.MySQL try { - IDbCommand updater = - dbm.Manager.Query( + using (IDbCommand updater = dbm.Manager.Query( "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", - param); - updater.ExecuteNonQuery(); + param)) + { + updater.ExecuteNonQuery(); + } - updater = - dbm.Manager.Query( + using (IDbCommand updater = dbm.Manager.Query( "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", - param); - updater.ExecuteNonQuery(); + param)) + { + updater.ExecuteNonQuery(); + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } finally @@ -295,18 +298,19 @@ namespace OpenSim.Data.MySQL try { - IDbCommand updater = - dbm.Manager.Query( + using (IDbCommand updater = dbm.Manager.Query( "update " + m_userFriendsTableName + " SET friendPerms = ?friendPerms " + "where ownerID = ?ownerID and friendID = ?friendID", - param); - updater.ExecuteNonQuery(); + param)) + { + updater.ExecuteNonQuery(); + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } finally @@ -327,34 +331,33 @@ namespace OpenSim.Data.MySQL try { //Left Join userfriends to itself - IDbCommand result = - dbm.Manager.Query( - "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + - m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + - " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) + using (IDbCommand result = dbm.Manager.Query( + "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", + param)) { - FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new UUID((string) reader["ownerID"]); - fli.Friend = new UUID((string) reader["friendID"]); - fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); - - // This is not a real column in the database table, it's a joined column from the opposite record - fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); - - Lfli.Add(fli); + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + FriendListItem fli = new FriendListItem(); + fli.FriendListOwner = new UUID((string)reader["ownerID"]); + fli.Friend = new UUID((string)reader["friendID"]); + fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); + + // This is not a real column in the database table, it's a joined column from the opposite record + fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); + + Lfli.Add(fli); + } + } } - - reader.Dispose(); - result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return Lfli; } finally @@ -376,29 +379,29 @@ namespace OpenSim.Data.MySQL { Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - IDbCommand result = - dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + - " where UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - while (reader.Read()) + using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + + " where UUID = ?uuid", param)) { - FriendRegionInfo fri = new FriendRegionInfo(); - fri.isOnline = (sbyte)reader["agentOnline"] != 0; - fri.regionHandle = (ulong)reader["currentHandle"]; - - infos[uuid] = fri; + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + FriendRegionInfo fri = new FriendRegionInfo(); + fri.isOnline = (sbyte)reader["agentOnline"] != 0; + fri.regionHandle = (ulong)reader["currentHandle"]; + + infos[uuid] = fri; + } + } } - - reader.Dispose(); - result.Dispose(); } } catch (Exception e) { m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } finally { @@ -427,28 +430,28 @@ namespace OpenSim.Data.MySQL try { - IDbCommand result = - dbm.Manager.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first AND lastname like ?second LIMIT 100", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) + using (IDbCommand result = dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first AND lastname like ?second LIMIT 100", + param)) { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string) reader["UUID"]); - user.firstName = (string) reader["username"]; - user.lastName = (string) reader["lastname"]; - returnlist.Add(user); + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["lastname"]; + returnlist.Add(user); + } + } } - reader.Dispose(); - result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return returnlist; } finally @@ -465,28 +468,28 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - IDbCommand result = - dbm.Manager.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first OR lastname like ?first LIMIT 100", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) + using (IDbCommand result = dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first OR lastname like ?first LIMIT 100", + param)) { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string) reader["UUID"]); - user.firstName = (string) reader["username"]; - user.lastName = (string) reader["lastname"]; - returnlist.Add(user); + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["lastname"]; + returnlist.Add(user); + } + } } - reader.Dispose(); - result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return returnlist; } finally @@ -510,20 +513,19 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - - UserProfileData row = dbm.Manager.readUserRow(reader); - - reader.Dispose(); - result.Dispose(); - - return row; + using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + UserProfileData row = dbm.Manager.readUserRow(reader); + return row; + } + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -569,15 +571,15 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.ExecuteParameterizedSql( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", - param); + dbm.Manager.ExecuteParameterizedSql( + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", + param); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } finally @@ -600,21 +602,19 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", - param); - IDataReader reader = result.ExecuteReader(); - - UserAgentData row = dbm.Manager.readAgentRow(reader); - - reader.Dispose(); - result.Dispose(); - - return row; + using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + UserAgentData row = dbm.Manager.readAgentRow(reader); + return row; + } + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -638,19 +638,20 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, - user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, - user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.CanDoMask, user.WantDoMask, - user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Manager.insertUserRow( + user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, + user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, + user.LastLogin, user.UserInventoryURI, user.UserAssetURI, + user.CanDoMask, user.WantDoMask, + user.AboutText, user.FirstLifeAboutText, user.Image, + user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } finally { @@ -676,7 +677,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } finally { @@ -693,14 +694,15 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); try { - dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, - user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, - user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Manager.updateUserRow( + user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, + user.UserInventoryURI, + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, + user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } finally { @@ -748,29 +750,29 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); - IDbCommand result = dbm.Manager.Query( - "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); - IDataReader reader = result.ExecuteReader(); - - AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); - - reader.Dispose(); - result.Dispose(); - - if (null == appearance) + using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) { - m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); - return null; + using (IDataReader reader = result.ExecuteReader()) + { + AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); + + if (appearance == null) + { + m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); + return null; + } + else + { + appearance.SetAttachments(GetUserAttachments(user)); + return appearance; + } + } } - - appearance.SetAttachments(GetUserAttachments(user)); - - return appearance; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -798,7 +800,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } finally { @@ -833,20 +835,20 @@ namespace OpenSim.Data.MySQL try { - IDbCommand result = dbm.Manager.Query( - "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - - Hashtable ret = dbm.Manager.readAttachments(reader); - - reader.Dispose(); - result.Dispose(); - return ret; + using (IDbCommand result = dbm.Manager.Query( + "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + Hashtable ret = dbm.Manager.readAttachments(reader); + return ret; + } + } } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } finally @@ -905,7 +907,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } finally -- cgit v1.1 From 672036937671a69426a12936c69efcb54d029e86 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 5 Oct 2009 16:39:40 -0700 Subject: Added CloseDBConnection() to replace the old CloseReaderCommand(). This will close the MySQLConnection attached to a MySQLCommand. I'm not sure if this accounts for every time a database connection needs to be closed, but it matches up 1:1 with the places where the database connection was previously being closed --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 8 ++++++-- OpenSim/Data/MySQL/MySQLFramework.cs | 14 +++++++------- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 ++ OpenSim/Data/MySQL/MySQLUserAccountData.cs | 8 ++++++-- 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e96a123..a41f9f8 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -82,12 +82,16 @@ namespace OpenSim.Data.MySQL ret.Data[s] = result[s].ToString(); } + CloseDBConnection(cmd); return ret; } + else + { + CloseDBConnection(cmd); + return null; + } } } - - return null; } public bool Store(AuthenticationData data) diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index c756c9c..f37e9bc 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -47,7 +47,6 @@ namespace OpenSim.Data.MySQL protected MySqlFramework(string connectionString) { m_Connection = new MySqlConnection(connectionString); - m_Connection.Open(); } @@ -82,8 +81,7 @@ namespace OpenSim.Data.MySQL errorSeen = true; m_Connection.Close(); - MySqlConnection newConnection = (MySqlConnection) - ((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); m_Connection.Dispose(); m_Connection = newConnection; m_Connection.Open(); @@ -104,14 +102,16 @@ namespace OpenSim.Data.MySQL protected IDataReader ExecuteReader(MySqlCommand cmd) { - MySqlConnection newConnection = (MySqlConnection) - ((ICloneable)m_Connection).Clone(); - + MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); newConnection.Open(); cmd.Connection = newConnection; - return cmd.ExecuteReader(); } + + protected void CloseDBConnection(MySqlCommand cmd) + { + cmd.Connection.Dispose(); + } } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 04b24b6..3fe27d5 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -172,6 +172,8 @@ namespace OpenSim.Data.MySQL retList.Add(ret); } + + CloseDBConnection(cmd); } return retList; diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index c713a11..38a6f55 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -97,12 +97,16 @@ namespace OpenSim.Data.MySQL ret.Data[s] = result[s].ToString(); } + CloseDBConnection(cmd); return ret; } + else + { + CloseDBConnection(cmd); + return null; + } } } - - return null; } public bool Store(UserAccountData data) -- cgit v1.1 From e7c877407f2a72a9519eb53debca5aeef20cded9 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 6 Oct 2009 02:38:00 -0700 Subject: * Continued work on the new LLUDP implementation. Appears to be functioning, although not everything is reimplemented yet * Replaced logic in ThreadTracker with a call to System.Diagnostics that does the same thing * Added Util.StringToBytes256() and Util.StringToBytes1024() to clamp output at byte[256] and byte[1024], respectively * Fixed formatting for a MySQLAssetData error logging line --- OpenSim/Data/MySQL/MySQLAssetData.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 8f97440..259e186 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -239,10 +239,8 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.ErrorFormat( - "[ASSETS DB]: " + - "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Attempting reconnect. Error: {2}", + asset.FullID, asset.Name, e.Message); _dbConnection.Reconnect(); } } -- cgit v1.1 From 8a7a947faaeeaeac2f74f695cefd6eb3e774dc15 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Oct 2009 14:30:25 +0100 Subject: Remove the using() constructs from the new style database modules; they caused the underlying connection of a reader or command to be closed before the reader or command itself. Added the proper logic to Close and dispose items in CloseDBConnection. Readers and Connections need Close(), Commands need Dispose(), in the order Reader, Command, Connection. Also reinstated 80-column-friendly formatting --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 62 +++++++++++----------- OpenSim/Data/MySQL/MySQLFramework.cs | 14 +++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 74 +++++++++++++-------------- 4 files changed, 77 insertions(+), 75 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index a41f9f8..0780936 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,42 +55,40 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID")) + MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) { - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + ret.PrincipalID = principalID; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); - using (IDataReader result = ExecuteReader(cmd)) + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) { - if (result.Read()) - { - ret.PrincipalID = principalID; - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - CloseDBConnection(cmd); - return ret; - } - else - { - CloseDBConnection(cmd); - return null; - } + if (s == "UUID") + continue; + + ret.Data[s] = result[s].ToString(); } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; } } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f37e9bc..ccd1ab0 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,7 +40,9 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger( + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected MySqlConnection m_Connection; @@ -81,7 +83,8 @@ namespace OpenSim.Data.MySQL errorSeen = true; m_Connection.Close(); - MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = + (MySqlConnection)((ICloneable)m_Connection).Clone(); m_Connection.Dispose(); m_Connection = newConnection; m_Connection.Open(); @@ -102,15 +105,18 @@ namespace OpenSim.Data.MySQL protected IDataReader ExecuteReader(MySqlCommand cmd) { - MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = + (MySqlConnection)((ICloneable)m_Connection).Clone(); newConnection.Open(); cmd.Connection = newConnection; return cmd.ExecuteReader(); } - protected void CloseDBConnection(MySqlCommand cmd) + protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) { + reader.Close(); + cmd.Connection.Close(); cmd.Connection.Dispose(); } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3fe27d5..3b561d1 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -173,7 +173,7 @@ namespace OpenSim.Data.MySQL retList.Add(ret); } - CloseDBConnection(cmd); + CloseDBConnection(result, cmd); } return retList; diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 38a6f55..0bbc3f5 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -64,48 +64,46 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) { - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; - using (IDataReader result = ExecuteReader(cmd)) + if (m_ColumnNames == null) { - if (result.Read()) - { - ret.PrincipalID = principalID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - if (s == "ScopeID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - CloseDBConnection(cmd); - return ret; - } - else - { - CloseDBConnection(cmd); - return null; - } + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; } } -- cgit v1.1 From a3a8691ebecf3a029e0e897786fde5051d3d6097 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 6 Oct 2009 14:18:37 -0700 Subject: MySQLLegacyRegionData: Extreme Spam Edition(tm) --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index fe0914b..d99bc30 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -402,8 +402,12 @@ namespace OpenSim.Data.MySQL Dictionary prims = new Dictionary(); SceneObjectGroup grp = null; + m_log.Debug("[REGION DB]: Entering LoadObjects()"); + lock (m_Connection) { + m_log.Debug("[REGION DB]: Entered LoadObjects() lock"); + using (MySqlCommand cmd = m_Connection.CreateCommand()) { cmd.CommandText = "select *, " + @@ -419,6 +423,8 @@ namespace OpenSim.Data.MySQL { while (reader.Read()) { + m_log.Debug("[REGION DB]: LoadObjects() Read a prim"); + SceneObjectPart prim = BuildPrim(reader); if (reader["Shape"] is DBNull) prim.Shape = PrimitiveBaseShape.Default; -- cgit v1.1 From c8558065484bfc3758804c6140ce88ad2c5aed37 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 6 Oct 2009 14:26:00 -0700 Subject: Reverting MySQLLegacyRegionData spam --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index d99bc30..fe0914b 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -402,12 +402,8 @@ namespace OpenSim.Data.MySQL Dictionary prims = new Dictionary(); SceneObjectGroup grp = null; - m_log.Debug("[REGION DB]: Entering LoadObjects()"); - lock (m_Connection) { - m_log.Debug("[REGION DB]: Entered LoadObjects() lock"); - using (MySqlCommand cmd = m_Connection.CreateCommand()) { cmd.CommandText = "select *, " + @@ -423,8 +419,6 @@ namespace OpenSim.Data.MySQL { while (reader.Read()) { - m_log.Debug("[REGION DB]: LoadObjects() Read a prim"); - SceneObjectPart prim = BuildPrim(reader); if (reader["Shape"] is DBNull) prim.Shape = PrimitiveBaseShape.Default; -- cgit v1.1 From 09cd2ac4437e3905ba48b84e04559a0e606aa679 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Oct 2009 20:46:19 +0100 Subject: Stop null values from being returned on database queries --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3b561d1..f514076 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -151,7 +151,10 @@ namespace OpenSim.Data.MySQL DataTable schemaTable = result.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); + { + if (row["ColumnName"] != null) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } } foreach (string s in m_ColumnNames) -- cgit v1.1 From 4790f8576c868ac92b5f2c9e96e1f8629af09d4d Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 14 Oct 2009 19:23:44 -0700 Subject: * Replaced (possibly broken?) math for calculating the unix timestamp in MySQLAssetData with Utils.DateTimeToUnixTime() * Disabled UpdateAccessTime() function since it was only writing zeros anyways. This gave me a significant performance improvement for startup times and avatar logins in standalone mode * Load attachments asynchronously so avatars with lots of attachments don't have to race the timeout clock to login --- OpenSim/Data/MySQL/MySQLAssetData.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 259e186..fc05d1d 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -44,7 +44,6 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private MySQLManager _dbConnection; - private long TicksToEpoch; #region IPlugin Members @@ -61,8 +60,6 @@ namespace OpenSim.Data.MySQL /// connect string override public void Initialise(string connect) { - TicksToEpoch = new DateTime(1970,1,1).Ticks; - // TODO: This will let you pass in the connect string in // the config, though someone will need to write that. if (connect == String.Empty) @@ -223,7 +220,7 @@ namespace OpenSim.Data.MySQL using (cmd) { // create unix epoch time - int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); cmd.Parameters.AddWithValue("?id", asset.ID); cmd.Parameters.AddWithValue("?name", assetName); cmd.Parameters.AddWithValue("?description", assetDescription); @@ -248,6 +245,9 @@ namespace OpenSim.Data.MySQL private void UpdateAccessTime(AssetBase asset) { + // Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph + return; + lock (_dbConnection) { _dbConnection.CheckConnection(); @@ -262,7 +262,7 @@ namespace OpenSim.Data.MySQL using (cmd) { // create unix epoch time - int now = (int)((DateTime.Now.Ticks - TicksToEpoch) / 10000000); + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); cmd.Parameters.AddWithValue("?id", asset.ID); cmd.Parameters.AddWithValue("?access_time", now); cmd.ExecuteNonQuery(); -- cgit v1.1 From a18489dc9badfccd775145f5a1a800a763d0c554 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 16 Oct 2009 12:20:01 -0700 Subject: * Change appearance packets from State to Task. This will hopefully fix the cloud issues * Changed the throttling logic to obey the requested client bandwidth limit but also share bandwidth between some of the categories to improve throughput on high prim or heavily trafficked regions --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index fe0914b..839ac7f 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -401,6 +401,7 @@ namespace OpenSim.Data.MySQL Dictionary objects = new Dictionary(); Dictionary prims = new Dictionary(); SceneObjectGroup grp = null; + int count = 0; lock (m_Connection) { @@ -463,6 +464,10 @@ namespace OpenSim.Data.MySQL if (link != 0) prim.LinkNum = link; } + + ++count; + if (count % 5000 == 0) + m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); } } -- cgit v1.1 From e776dfb1d71ea7f8de37399f84fceb005870e861 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 16 Oct 2009 13:22:45 -0700 Subject: * Changing the "clean dropped attachments" MySQL command to a using statement inside a try/catch. This statement times out for me very frequently * More verbose logging when zerocoding fails on an outbound packet --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 839ac7f..6bc8bec 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -68,12 +68,20 @@ namespace OpenSim.Data.MySQL // Clean dropped attachments // - MySqlCommand cmd = m_Connection.CreateCommand(); - cmd.CommandText = "delete from prims, primshapes using prims " + - "left join primshapes on prims.uuid = primshapes.uuid " + - "where PCode = 9 and State <> 0"; - ExecuteNonQuery(cmd); - cmd.Dispose(); + try + { + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = "delete from prims, primshapes using prims " + + "left join primshapes on prims.uuid = primshapes.uuid " + + "where PCode = 9 and State <> 0"; + ExecuteNonQuery(cmd); + } + } + catch (MySqlException ex) + { + m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); + } } private IDataReader ExecuteReader(MySqlCommand c) -- cgit v1.1 From b4526a5a6d170e04655990c8edb8e355156a2061 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 18 Oct 2009 02:00:42 -0700 Subject: * Big performance increase in loading prims from the region database with MySQL * Handle the AgentFOV packet * Bypass queuing and throttles for ping checks to make ping times more closely match network latency * Only track reliable bytes in LLUDPCLient.BytesSinceLastACK --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 271 ++++++++++++++-------------- 1 file changed, 138 insertions(+), 133 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 6bc8bec..801d6b9 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -403,26 +403,23 @@ namespace OpenSim.Data.MySQL } } - public List LoadObjects(UUID regionUUID) + public List LoadObjects(UUID regionID) { - UUID lastGroupID = UUID.Zero; + const int ROWS_PER_QUERY = 5000; + + Dictionary prims = new Dictionary(ROWS_PER_QUERY); Dictionary objects = new Dictionary(); - Dictionary prims = new Dictionary(); - SceneObjectGroup grp = null; int count = 0; + #region Prim Loading + lock (m_Connection) { using (MySqlCommand cmd = m_Connection.CreateCommand()) { - cmd.CommandText = "select *, " + - "case when prims.UUID = SceneGroupID " + - "then 0 else 1 end as sort from prims " + - "left join primshapes on prims.UUID = primshapes.UUID " + - "where RegionUUID = ?RegionUUID " + - "order by SceneGroupID asc, sort asc, LinkNumber asc"; - - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + cmd.CommandText = + "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); using (IDataReader reader = ExecuteReader(cmd)) { @@ -434,56 +431,61 @@ namespace OpenSim.Data.MySQL else prim.Shape = BuildShape(reader); - prims[prim.UUID] = prim; - - UUID groupID = new UUID(reader["SceneGroupID"].ToString()); + UUID parentID = new UUID(reader["SceneGroupID"].ToString()); + if (parentID != prim.UUID) + prim.ParentUUID = parentID; - if (groupID != lastGroupID) // New SOG - { - if (grp != null) - objects[grp.UUID] = grp; + prims[prim.UUID] = prim; - lastGroupID = groupID; + ++count; + if (count % ROWS_PER_QUERY == 0) + m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); + } + } + } + } - // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are - // recorded as the root prim (for which the UUID must equal the persisted group UUID). In - // this case, force the UUID to be the same as the group UUID so that at least these can be - // deleted (we need to change the UUID so that any other prims in the linkset can also be - // deleted). - if (prim.UUID != groupID && groupID != UUID.Zero) - { - m_log.WarnFormat( - "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", - prim.Name, prim.UUID, prim.GroupPosition, groupID); + #endregion Prim Loading - prim.UUID = groupID; - } + #region SceneObjectGroup Creation - grp = new SceneObjectGroup(prim); - } - else - { - // Black magic to preserve link numbers - // - int link = prim.LinkNum; + // Create all of the SOGs from the root prims first + foreach (SceneObjectPart prim in prims.Values) + { + if (prim.ParentUUID == UUID.Zero) + objects[prim.UUID] = new SceneObjectGroup(prim); + } - grp.AddPart(prim); + // Add all of the children objects to the SOGs + foreach (SceneObjectPart prim in prims.Values) + { + SceneObjectGroup sog; + if (prim.UUID != prim.ParentUUID) + { + if (objects.TryGetValue(prim.ParentUUID, out sog)) + { + int originalLinkNum = prim.LinkNum; - if (link != 0) - prim.LinkNum = link; - } + sog.AddPart(prim); - ++count; - if (count % 5000 == 0) - m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); - } + // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. + // We override that here + if (originalLinkNum != 0) + prim.LinkNum = originalLinkNum; + } + else + { + m_log.Warn("[REGION DB]: Database contains an orphan child prim " + prim.UUID + " pointing to missing parent " + prim.ParentUUID); } - - if (grp != null) - objects[grp.UUID] = grp; } } + #endregion SceneObjectGroup Creation + + m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); + + #region Prim Inventory Loading + // Instead of attempting to LoadItems on every prim, // most of which probably have no items... get a // list from DB of all prims which have items and @@ -493,7 +495,7 @@ namespace OpenSim.Data.MySQL { using (MySqlCommand itemCmd = m_Connection.CreateCommand()) { - itemCmd.CommandText = "select distinct primID from primitems"; + itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; using (IDataReader itemReader = ExecuteReader(itemCmd)) { while (itemReader.Read()) @@ -502,9 +504,7 @@ namespace OpenSim.Data.MySQL { UUID primID = new UUID(itemReader["primID"].ToString()); if (prims.ContainsKey(primID)) - { primsWithInventory.Add(prims[primID]); - } } } } @@ -512,9 +512,14 @@ namespace OpenSim.Data.MySQL } foreach (SceneObjectPart prim in primsWithInventory) + { LoadItems(prim); + } + + #endregion Prim Inventory Loading + + m_log.DebugFormat("[REGION DB]: Loaded inventory from {0} objects", primsWithInventory.Count); - m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); return new List(objects.Values); } @@ -811,137 +816,137 @@ namespace OpenSim.Data.MySQL private SceneObjectPart BuildPrim(IDataReader row) { SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new UUID((String) row["UUID"]); + prim.UUID = new UUID((string)row["UUID"]); // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. - prim.CreationDate = Convert.ToInt32(row["CreationDate"]); + prim.CreationDate = (int)row["CreationDate"]; if (row["Name"] != DBNull.Value) - prim.Name = (String)row["Name"]; + prim.Name = (string)row["Name"]; else - prim.Name = string.Empty; - // various text fields - prim.Text = (String) row["Text"]; - prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), - Convert.ToInt32(row["ColorR"]), - Convert.ToInt32(row["ColorG"]), - Convert.ToInt32(row["ColorB"])); - prim.Description = (String) row["Description"]; - prim.SitName = (String) row["SitName"]; - prim.TouchName = (String) row["TouchName"]; - // permissions - prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new UUID((String) row["CreatorID"]); - prim.OwnerID = new UUID((String) row["OwnerID"]); - prim.GroupID = new UUID((String) row["GroupID"]); - prim.LastOwnerID = new UUID((String) row["LastOwnerID"]); - prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); - prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); - prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); - prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); - prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); - // vectors + prim.Name = String.Empty; + // Various text fields + prim.Text = (string)row["Text"]; + prim.Color = Color.FromArgb((int)row["ColorA"], + (int)row["ColorR"], + (int)row["ColorG"], + (int)row["ColorB"]); + prim.Description = (string)row["Description"]; + prim.SitName = (string)row["SitName"]; + prim.TouchName = (string)row["TouchName"]; + // Permissions + prim.ObjectFlags = (uint)(int)row["ObjectFlags"]; + prim.CreatorID = new UUID((string)row["CreatorID"]); + prim.OwnerID = new UUID((string)row["OwnerID"]); + prim.GroupID = new UUID((string)row["GroupID"]); + prim.LastOwnerID = new UUID((string)row["LastOwnerID"]); + prim.OwnerMask = (uint)(int)row["OwnerMask"]; + prim.NextOwnerMask = (uint)(int)row["NextOwnerMask"]; + prim.GroupMask = (uint)(int)row["GroupMask"]; + prim.EveryoneMask = (uint)(int)row["EveryoneMask"]; + prim.BaseMask = (uint)(int)row["BaseMask"]; + // Vectors prim.OffsetPosition = new Vector3( - Convert.ToSingle(row["PositionX"]), - Convert.ToSingle(row["PositionY"]), - Convert.ToSingle(row["PositionZ"]) + (float)(double)row["PositionX"], + (float)(double)row["PositionY"], + (float)(double)row["PositionZ"] ); prim.GroupPosition = new Vector3( - Convert.ToSingle(row["GroupPositionX"]), - Convert.ToSingle(row["GroupPositionY"]), - Convert.ToSingle(row["GroupPositionZ"]) + (float)(double)row["GroupPositionX"], + (float)(double)row["GroupPositionY"], + (float)(double)row["GroupPositionZ"] ); prim.Velocity = new Vector3( - Convert.ToSingle(row["VelocityX"]), - Convert.ToSingle(row["VelocityY"]), - Convert.ToSingle(row["VelocityZ"]) + (float)(double)row["VelocityX"], + (float)(double)row["VelocityY"], + (float)(double)row["VelocityZ"] ); prim.AngularVelocity = new Vector3( - Convert.ToSingle(row["AngularVelocityX"]), - Convert.ToSingle(row["AngularVelocityY"]), - Convert.ToSingle(row["AngularVelocityZ"]) + (float)(double)row["AngularVelocityX"], + (float)(double)row["AngularVelocityY"], + (float)(double)row["AngularVelocityZ"] ); prim.Acceleration = new Vector3( - Convert.ToSingle(row["AccelerationX"]), - Convert.ToSingle(row["AccelerationY"]), - Convert.ToSingle(row["AccelerationZ"]) + (float)(double)row["AccelerationX"], + (float)(double)row["AccelerationY"], + (float)(double)row["AccelerationZ"] ); // quaternions prim.RotationOffset = new Quaternion( - Convert.ToSingle(row["RotationX"]), - Convert.ToSingle(row["RotationY"]), - Convert.ToSingle(row["RotationZ"]), - Convert.ToSingle(row["RotationW"]) + (float)(double)row["RotationX"], + (float)(double)row["RotationY"], + (float)(double)row["RotationZ"], + (float)(double)row["RotationW"] ); prim.SitTargetPositionLL = new Vector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"]) + (float)(double)row["SitTargetOffsetX"], + (float)(double)row["SitTargetOffsetY"], + (float)(double)row["SitTargetOffsetZ"] ); prim.SitTargetOrientationLL = new Quaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]) + (float)(double)row["SitTargetOrientX"], + (float)(double)row["SitTargetOrientY"], + (float)(double)row["SitTargetOrientZ"], + (float)(double)row["SitTargetOrientW"] ); - prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]); - prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]); - prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]); - prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); - prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); + prim.PayPrice[0] = (int)row["PayPrice"]; + prim.PayPrice[1] = (int)row["PayButton1"]; + prim.PayPrice[2] = (int)row["PayButton2"]; + prim.PayPrice[3] = (int)row["PayButton3"]; + prim.PayPrice[4] = (int)row["PayButton4"]; prim.Sound = new UUID(row["LoopedSound"].ToString()); - prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); + prim.SoundGain = (float)(double)row["LoopedSoundGain"]; prim.SoundFlags = 1; // If it's persisted at all, it's looped if (!(row["TextureAnimation"] is DBNull)) - prim.TextureAnimation = (Byte[])row["TextureAnimation"]; + prim.TextureAnimation = (byte[])row["TextureAnimation"]; if (!(row["ParticleSystem"] is DBNull)) - prim.ParticleSystem = (Byte[])row["ParticleSystem"]; + prim.ParticleSystem = (byte[])row["ParticleSystem"]; prim.RotationalVelocity = new Vector3( - Convert.ToSingle(row["OmegaX"]), - Convert.ToSingle(row["OmegaY"]), - Convert.ToSingle(row["OmegaZ"]) + (float)(double)row["OmegaX"], + (float)(double)row["OmegaY"], + (float)(double)row["OmegaZ"] ); prim.SetCameraEyeOffset(new Vector3( - Convert.ToSingle(row["CameraEyeOffsetX"]), - Convert.ToSingle(row["CameraEyeOffsetY"]), - Convert.ToSingle(row["CameraEyeOffsetZ"]) + (float)(double)row["CameraEyeOffsetX"], + (float)(double)row["CameraEyeOffsetY"], + (float)(double)row["CameraEyeOffsetZ"] )); prim.SetCameraAtOffset(new Vector3( - Convert.ToSingle(row["CameraAtOffsetX"]), - Convert.ToSingle(row["CameraAtOffsetY"]), - Convert.ToSingle(row["CameraAtOffsetZ"]) + (float)(double)row["CameraAtOffsetX"], + (float)(double)row["CameraAtOffsetY"], + (float)(double)row["CameraAtOffsetZ"] )); - if (Convert.ToInt16(row["ForceMouselook"]) != 0) + if ((sbyte)row["ForceMouselook"] != 0) prim.SetForceMouselook(true); - prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]); + prim.ScriptAccessPin = (int)row["ScriptAccessPin"]; - if (Convert.ToInt16(row["AllowedDrop"]) != 0) + if ((sbyte)row["AllowedDrop"] != 0) prim.AllowedDrop = true; - if (Convert.ToInt16(row["DieAtEdge"]) != 0) + if ((sbyte)row["DieAtEdge"] != 0) prim.DIE_AT_EDGE = true; - prim.SalePrice = Convert.ToInt32(row["SalePrice"]); - prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"])); + prim.SalePrice = (int)row["SalePrice"]; + prim.ObjectSaleType = unchecked((byte)(sbyte)row["SaleType"]); - prim.Material = unchecked((byte)Convert.ToSByte(row["Material"])); + prim.Material = unchecked((byte)(sbyte)row["Material"]); if (!(row["ClickAction"] is DBNull)) - prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"])); + prim.ClickAction = unchecked((byte)(sbyte)row["ClickAction"]); prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); - prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); + prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; - if (Convert.ToInt16(row["PassTouches"]) != 0) + if ((sbyte)row["PassTouches"] != 0) prim.PassTouches = true; - prim.LinkNum = Convert.ToInt32(row["LinkNumber"]); + prim.LinkNum = (int)row["LinkNumber"]; return prim; } -- cgit v1.1 From 730930955a7edc0bfa69ff1cac93acd024cf8d24 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 00:40:21 -0700 Subject: Changing Scene.ForEachClient to use the synchronous for loop instead of Parallel. This is quite possibly the source of some deadlocking, and at the very least the synchronous version gives better stack traces * Lock the LLUDPClient RTO math * Add a helper function for backing off the RTO, and follow the optional advice in RFC 2988 to clear existing SRTT and RTTVAR values during a backoff * Removing the unused PrimitiveBaseShape.SculptImage parameter * Improved performance of SceneObjectPart instantiation * ZeroMesher now drops SculptData bytes like Meshmerizer, to allow the texture data to be GCed * Improved typecasting speed in MySQLLegacyRegionData.BuildShape() * Improved the instantiation of PrimitiveBaseShape --- OpenSim/Data/MySQL/MySQLAssetData.cs | 3 -- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 53 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 30 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index fc05d1d..4d49733 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -167,9 +167,6 @@ namespace OpenSim.Data.MySQL asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } } - - if (asset != null) - UpdateAccessTime(asset); } catch (Exception e) { diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 801d6b9..c07963c 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -1430,37 +1430,36 @@ namespace OpenSim.Data.MySQL { PrimitiveBaseShape s = new PrimitiveBaseShape(); s.Scale = new Vector3( - Convert.ToSingle(row["ScaleX"]), - Convert.ToSingle(row["ScaleY"]), - Convert.ToSingle(row["ScaleZ"]) - ); + (float)(double)row["ScaleX"], + (float)(double)row["ScaleY"], + (float)(double)row["ScaleZ"] + ); // paths - s.PCode = Convert.ToByte(row["PCode"]); - s.PathBegin = Convert.ToUInt16(row["PathBegin"]); - s.PathEnd = Convert.ToUInt16(row["PathEnd"]); - s.PathScaleX = Convert.ToByte(row["PathScaleX"]); - s.PathScaleY = Convert.ToByte(row["PathScaleY"]); - s.PathShearX = Convert.ToByte(row["PathShearX"]); - s.PathShearY = Convert.ToByte(row["PathShearY"]); - s.PathSkew = Convert.ToSByte(row["PathSkew"]); - s.PathCurve = Convert.ToByte(row["PathCurve"]); - s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); - s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); - s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); - s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); - s.PathTwist = Convert.ToSByte(row["PathTwist"]); - s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); + s.PCode = (byte)(int)row["PCode"]; + s.PathBegin = (ushort)(int)row["PathBegin"]; + s.PathEnd = (ushort)(int)row["PathEnd"]; + s.PathScaleX = (byte)(int)row["PathScaleX"]; + s.PathScaleY = (byte)(int)row["PathScaleY"]; + s.PathShearX = (byte)(int)row["PathShearX"]; + s.PathShearY = (byte)(int)row["PathShearY"]; + s.PathSkew = (sbyte)(int)row["PathSkew"]; + s.PathCurve = (byte)(int)row["PathCurve"]; + s.PathRadiusOffset = (sbyte)(int)row["PathRadiusOffset"]; + s.PathRevolutions = (byte)(int)row["PathRevolutions"]; + s.PathTaperX = (sbyte)(int)row["PathTaperX"]; + s.PathTaperY = (sbyte)(int)row["PathTaperY"]; + s.PathTwist = (sbyte)(int)row["PathTwist"]; + s.PathTwistBegin = (sbyte)(int)row["PathTwistBegin"]; // profile - s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); - s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); - s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); - s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - byte[] textureEntry = (byte[]) row["Texture"]; - s.TextureEntry = textureEntry; + s.ProfileBegin = (ushort)(int)row["ProfileBegin"]; + s.ProfileEnd = (ushort)(int)row["ProfileEnd"]; + s.ProfileCurve = (byte)(int)row["ProfileCurve"]; + s.ProfileHollow = (ushort)(int)row["ProfileHollow"]; + s.TextureEntry = (byte[])row["Texture"]; - s.ExtraParams = (byte[]) row["ExtraParams"]; + s.ExtraParams = (byte[])row["ExtraParams"]; - s.State = Convert.ToByte(row["State"]); + s.State = (byte)(int)row["State"]; return s; } -- cgit v1.1 From b498693cff9b044e8ab3c7a88a18e9d67f16461b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 27 Oct 2009 01:46:14 -0700 Subject: * Tweak to region module loading to check for a matching constructor first instead of throwing and catching exceptions * Commenting out the MySQL startup sequence that cleans out dropped attachments under the advice that it is no longer relevant. If anything, it could be brought back as a database cleanup console command * Updated to the latest libomv 0.8.0-pre. UUID.TryParse() will no longer throw and catch exceptions for most failed UUID parses --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 32 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index c07963c..a807948 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -66,22 +66,26 @@ namespace OpenSim.Data.MySQL Migration m = new Migration(m_Connection, assem, "RegionStore"); m.Update(); + // NOTE: This is a very slow query that times out on regions with a lot of prims. + // I'm told that it is no longer relevant so it's commented out now, but if it + // is relevant it should be added as a console command instead of part of the + // startup phase // Clean dropped attachments // - try - { - using (MySqlCommand cmd = m_Connection.CreateCommand()) - { - cmd.CommandText = "delete from prims, primshapes using prims " + - "left join primshapes on prims.uuid = primshapes.uuid " + - "where PCode = 9 and State <> 0"; - ExecuteNonQuery(cmd); - } - } - catch (MySqlException ex) - { - m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); - } + //try + //{ + // using (MySqlCommand cmd = m_Connection.CreateCommand()) + // { + // cmd.CommandText = "delete from prims, primshapes using prims " + + // "left join primshapes on prims.uuid = primshapes.uuid " + + // "where PCode = 9 and State <> 0"; + // ExecuteNonQuery(cmd); + // } + //} + //catch (MySqlException ex) + //{ + // m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); + //} } private IDataReader ExecuteReader(MySqlCommand c) -- cgit v1.1 From 6309fcc5b4b42102b5bb901dbbdf44846f5643f2 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:19:55 -0800 Subject: Reverting the memory leak patch for MySQL. Problems have been reported with the grid server after running for several hours --- OpenSim/Data/MySQL/MySQLAssetData.cs | 102 +++---- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 18 +- OpenSim/Data/MySQL/MySQLEstateData.cs | 310 ++++++++++----------- OpenSim/Data/MySQL/MySQLFramework.cs | 13 +- OpenSim/Data/MySQL/MySQLGridData.cs | 171 ++++++------ OpenSim/Data/MySQL/MySQLInventoryData.cs | 335 +++++++++++------------ OpenSim/Data/MySQL/MySQLManager.cs | 60 +++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 228 ++++++++-------- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 87 +++--- OpenSim/Data/MySQL/MySQLUserData.cs | 370 +++++++++++++------------- 10 files changed, 860 insertions(+), 834 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4d49733..1fe6d29 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -139,42 +139,45 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", - _dbConnection.Connection)) - { - cmd.Parameters.AddWithValue("?id", assetID.ToString()); + MySqlCommand cmd = + new MySqlCommand( + "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + _dbConnection.Connection); + cmd.Parameters.AddWithValue("?id", assetID.ToString()); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - asset = new AssetBase(); - asset.Data = (byte[])dbReader["data"]; - asset.Description = (string)dbReader["description"]; - asset.FullID = assetID; - - string local = dbReader["local"].ToString(); - if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) - asset.Local = true; - else - asset.Local = false; - - asset.Name = (string)dbReader["name"]; - asset.Type = (sbyte)dbReader["assetType"]; - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); - } + asset = new AssetBase(); + asset.Data = (byte[]) dbReader["data"]; + asset.Description = (string) dbReader["description"]; + asset.FullID = assetID; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Name = (string) dbReader["name"]; + asset.Type = (sbyte) dbReader["assetType"]; + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } + dbReader.Close(); + cmd.Dispose(); } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Reconnecting", assetID); - _dbConnection.Reconnect(); - } + if (asset != null) + UpdateAccessTime(asset); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Reconnecting", assetID); + _dbConnection.Reconnect(); } } return asset; @@ -291,27 +294,32 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT id FROM assets WHERE id=?id", - _dbConnection.Connection)) - { - cmd.Parameters.AddWithValue("?id", uuid.ToString()); + MySqlCommand cmd = + new MySqlCommand( + "SELECT id FROM assets WHERE id=?id", + _dbConnection.Connection); + + cmd.Parameters.AddWithValue("?id", uuid.ToString()); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - assetExists = true; + assetExists = true; } + + dbReader.Close(); + cmd.Dispose(); } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", uuid); - _dbConnection.Reconnect(); - } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", uuid); + _dbConnection.Reconnect(); } } diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 0780936..e508b52 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,7 +55,9 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); + MySqlCommand cmd = new MySqlCommand( + "select * from `"+m_Realm+"` where UUID = ?principalID" + ); cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); @@ -82,14 +84,16 @@ namespace OpenSim.Data.MySQL ret.Data[s] = result[s].ToString(); } - CloseDBConnection(result, cmd); + result.Close(); + CloseReaderCommand(cmd); + return ret; } - else - { - CloseDBConnection(result, cmd); - return null; - } + + result.Close(); + CloseReaderCommand(cmd); + + return null; } public bool Store(AuthenticationData data) diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 7166b29..e8694fc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -95,17 +95,21 @@ namespace OpenSim.Data.MySQL protected void GetWaitTimeout() { - using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection)) + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, + m_connection); + + using (MySqlDataReader dbReader = + cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * - TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * + TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; } + + dbReader.Close(); + cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -143,103 +147,110 @@ namespace OpenSim.Data.MySQL CheckConnection(); - bool migration = true; + MySqlCommand cmd = m_connection.CreateCommand(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + IDataReader r = cmd.ExecuteReader(); - using (IDataReader r = cmd.ExecuteReader()) + if (r.Read()) + { + foreach (string name in FieldList) { - if (r.Read()) + if (m_FieldMap[name].GetValue(es) is bool) { - migration = false; - - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); - } - else if (m_FieldMap[name].GetValue(es) is UUID) - { - UUID uuid = UUID.Zero; - - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); - } - else - { - m_FieldMap[name].SetValue(es, r[name]); - } - } + int v = Convert.ToInt32(r[name]); + if (v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else if (m_FieldMap[name].GetValue(es) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(r[name].ToString(), out uuid); + m_FieldMap[name].SetValue(es, uuid); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); } } + r.Close(); } - - if (migration) + else { // Migration case + // + r.Close(); + List names = new List(FieldList); names.Remove("EstateID"); sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = sql; - cmd.Parameters.Clear(); + cmd.CommandText = sql; + cmd.Parameters.Clear(); - foreach (string name in FieldList) + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); - else - cmd.Parameters.AddWithValue("?" + name, "0"); - } + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); - } + cmd.Parameters.AddWithValue("?" + name, "0"); } + else + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + } + } - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); - cmd.CommandText = "select LAST_INSERT_ID() as id"; - cmd.Parameters.Clear(); + cmd.CommandText = "select LAST_INSERT_ID() as id"; + cmd.Parameters.Clear(); - using (IDataReader r = cmd.ExecuteReader()) - { - r.Read(); - es.EstateID = Convert.ToUInt32(r["id"]); - } + r = cmd.ExecuteReader(); + + r.Read(); - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + es.EstateID = Convert.ToUInt32(r["id"]); - // This will throw on dupe key - try { cmd.ExecuteNonQuery(); } - catch (Exception) { } + r.Close(); + + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - // Munge and transfer the ban list - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + // This will throw on dupe key + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } - try { cmd.ExecuteNonQuery(); } - catch (Exception) { } + // Munge and transfer the ban list + // + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - es.Save(); + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { } + + es.Save(); } LoadBanList(es); @@ -256,28 +267,27 @@ namespace OpenSim.Data.MySQL CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = sql; + MySqlCommand cmd = m_connection.CreateCommand(); - foreach (string name in FieldList) + cmd.CommandText = sql; + + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); - else - cmd.Parameters.AddWithValue("?" + name, "0"); - } + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); - } + cmd.Parameters.AddWithValue("?" + name, "0"); + } + else + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } - - cmd.ExecuteNonQuery(); } + cmd.ExecuteNonQuery(); + SaveBanList(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); @@ -290,52 +300,50 @@ namespace OpenSim.Data.MySQL CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID); + MySqlCommand cmd = m_connection.CreateCommand(); - using (IDataReader r = cmd.ExecuteReader()) - { - while (r.Read()) - { - EstateBan eb = new EstateBan(); + cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - UUID uuid = new UUID(); - UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + IDataReader r = cmd.ExecuteReader(); - eb.BannedUserID = uuid; - eb.BannedHostAddress = "0.0.0.0"; - eb.BannedHostIPMask = "0.0.0.0"; - es.AddBan(eb); - } - } + while (r.Read()) + { + EstateBan eb = new EstateBan(); + + UUID uuid = new UUID(); + UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + + eb.BannedUserID = uuid; + eb.BannedHostAddress = "0.0.0.0"; + eb.BannedHostIPMask = "0.0.0.0"; + es.AddBan(eb); } + r.Close(); } private void SaveBanList(EstateSettings es) { CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + MySqlCommand cmd = m_connection.CreateCommand(); - cmd.ExecuteNonQuery(); + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.Clear(); + cmd.ExecuteNonQuery(); - cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; + cmd.Parameters.Clear(); - foreach (EstateBan b in es.EstateBans) - { - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } + foreach (EstateBan b in es.EstateBans) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); } } @@ -343,25 +351,24 @@ namespace OpenSim.Data.MySQL { CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + MySqlCommand cmd = m_connection.CreateCommand(); - cmd.ExecuteNonQuery(); + cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.Parameters.Clear(); + cmd.ExecuteNonQuery(); - cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; + cmd.Parameters.Clear(); - foreach (UUID uuid in data) - { - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); + cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } + foreach (UUID uuid in data) + { + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); } } @@ -371,24 +378,23 @@ namespace OpenSim.Data.MySQL CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID); + MySqlCommand cmd = m_connection.CreateCommand(); - using (IDataReader r = cmd.ExecuteReader()) - { - while (r.Read()) - { - // EstateBan eb = new EstateBan(); + cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID); - UUID uuid = new UUID(); - UUID.TryParse(r["uuid"].ToString(), out uuid); + IDataReader r = cmd.ExecuteReader(); - uuids.Add(uuid); - } - } + while (r.Read()) + { + // EstateBan eb = new EstateBan(); + + UUID uuid = new UUID(); + UUID.TryParse(r["uuid"].ToString(), out uuid); + + uuids.Add(uuid); } + r.Close(); return uuids.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index ccd1ab0..fd428ae 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,10 +40,6 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - private static readonly log4net.ILog m_log = - log4net.LogManager.GetLogger( - System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - protected MySqlConnection m_Connection; protected MySqlFramework(string connectionString) @@ -73,11 +69,12 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.Error(e.Message, e); +Console.WriteLine(e.ToString()); if (errorSeen) throw; // This is "Server has gone away" and "Server lost" + // if (e.Number == 2006 || e.Number == 2013) { errorSeen = true; @@ -96,7 +93,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error(e.Message, e); +Console.WriteLine(e.ToString()); return 0; } } @@ -113,11 +110,11 @@ namespace OpenSim.Data.MySQL return cmd.ExecuteReader(); } - protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) + protected void CloseReaderCommand(MySqlCommand cmd) { - reader.Close(); cmd.Connection.Close(); cmd.Connection.Dispose(); + cmd.Dispose(); } } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 38cb3b7..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL param["?xmax"] = xmax.ToString(); param["?ymax"] = ymax.ToString(); - using (IDbCommand result = dbm.Manager.Query( + IDbCommand result = + dbm.Manager.Query( "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; + param); + IDataReader reader = result.ExecuteReader(); - List rows = new List(); + RegionProfileData row; - while ((row = dbm.Manager.readSimRow(reader)) != null) - rows.Add(row); + List rows = new List(); - return rows.ToArray(); - } + while ((row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); } + reader.Close(); + result.Dispose(); + + return rows.ToArray(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName LIKE ?name", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName LIKE ?name", + param); + IDataReader reader = result.ExecuteReader(); - List rows = new List(); + RegionProfileData row; - while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) - rows.Add(row); + List rows = new List(); - return rows; - } + while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); } + reader.Close(); + result.Dispose(); + + return rows; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?handle"] = handle.ToString(); + param["?handle"] = handle.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } - } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } - } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; - } - finally + } finally { dbm.Release(); } @@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL // Add % because this is a like query. param["?regionName"] = regionName + "%"; // Order by statement will return shorter matches first. Only returns one record or no record. - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } - } + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL dbm.Release(); } } - m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } @@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL override public DataResponse StoreProfile(RegionProfileData profile) { MySQLSuperManager dbm = GetLockedConnection(); - try - { + try { if (dbm.Manager.insertRegion(profile)) + { return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; + } + return DataResponse.RESPONSE_ERROR; } finally { @@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL { MySQLSuperManager dbm = GetLockedConnection(); - try - { + + try { if (dbm.Manager.deleteRegion(uuid)) + { return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; - } - finally + } + return DataResponse.RESPONSE_ERROR; + } finally { dbm.Release(); } @@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?x"] = x.ToString(); - param["?y"] = y.ToString(); - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - ReservationData row = dbm.Manager.readReservationRow(reader); - return row; - } - } + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param); + IDataReader reader = result.ExecuteReader(); + + ReservationData row = dbm.Manager.readReservationRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; - } - finally + } finally { dbm.Release(); } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 598971d..0eecf06 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", - database.Connection)) + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - result.Parameters.AddWithValue("?uuid", folderID.ToString()); + // A null item (because something went wrong) breaks everything in the folder + InventoryItemBase item = readInventoryItem(reader); + if (item != null) + items.Add(item); + } - using (MySqlDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - // A null item (because something went wrong) breaks everything in the folder - InventoryItemBase item = readInventoryItem(reader); - if (item != null) - items.Add(item); - } + reader.Close(); + result.Dispose(); - return items; - } - } + return items; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -176,28 +176,29 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection)) - { - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - using (MySqlDataReader reader = result.ExecuteReader()) - { - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - return items; - } - } + + reader.Close(); + result.Dispose(); + + return items; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -216,38 +217,41 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection)) - { - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - using (MySqlDataReader reader = result.ExecuteReader()) - { - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + MySqlDataReader reader = result.ExecuteReader(); - InventoryFolderBase rootFolder = null; + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - // There should only ever be one root folder for a user. However, if there's more - // than one we'll simply use the first one rather than failing. It would be even - // nicer to print some message to this effect, but this feels like it's too low a - // to put such a message out, and it's too minor right now to spare the time to - // suitably refactor. - if (items.Count > 0) - rootFolder = items[0]; + InventoryFolderBase rootFolder = null; - return rootFolder; - } + // There should only ever be one root folder for a user. However, if there's more + // than one we'll simply use the first one rather than failing. It would be even + // nicer to print some message to this effect, but this feels like it's too low a + // to put such a message out, and it's too minor right now to spare the time to + // suitably refactor. + if (items.Count > 0) + { + rootFolder = items[0]; } + + reader.Close(); + result.Dispose(); + + return rootFolder; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -267,26 +271,27 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", - database.Connection)) - { - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - using (MySqlDataReader reader = result.ExecuteReader()) - { - List items = new List(); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + List items = new List(); - return items; - } - } + while (reader.Read()) + items.Add(readInventoryFolder(reader)); + + reader.Close(); + result.Dispose(); + + return items; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -365,25 +370,25 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection)) - { - result.Parameters.AddWithValue("?uuid", itemID.ToString()); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); + result.Parameters.AddWithValue("?uuid", itemID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - using (MySqlDataReader reader = result.ExecuteReader()) - { - InventoryItemBase item = null; - if (reader.Read()) - item = readInventoryItem(reader); + InventoryItemBase item = null; + if (reader.Read()) + item = readInventoryItem(reader); - return item; - } - } + reader.Close(); + result.Dispose(); + + return item; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } return null; } @@ -408,7 +413,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } return null; @@ -428,25 +433,24 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) - { - result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - using (MySqlDataReader reader = result.ExecuteReader()) - { - InventoryFolderBase folder = null; - if (reader.Read()) - folder = readInventoryFolder(reader); + InventoryFolderBase folder = null; + if (reader.Read()) + folder = readInventoryFolder(reader); + reader.Close(); + result.Dispose(); - return folder; - } - } + return folder; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -694,73 +698,69 @@ namespace OpenSim.Data.MySQL try { List folders = new List(); - Dictionary> hashtable = new Dictionary>(); ; + Dictionary> hashtable + = new Dictionary>(); ; List parentFolder = new List(); - bool buildResultsFromHashTable = false; - lock (database) { + MySqlCommand result; + MySqlDataReader reader; + bool buildResultsFromHashTable = false; + database.CheckConnection(); /* Fetch the parent folder from the database to determine the agent ID, and if * we're querying the root of the inventory folder tree */ - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) - { - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - - using (MySqlDataReader reader = result.ExecuteReader()) - { - // Should be at most 1 result - while (reader.Read()) - parentFolder.Add(readInventoryFolder(reader)); - } - } + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) // Should be at most 1 result + parentFolder.Add(readInventoryFolder(reader)); + reader.Close(); + result.Dispose(); if (parentFolder.Count >= 1) // No result means parent folder does not exist { if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder { /* Get all of the agent's folders from the database, put them in a list and return it */ - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) { - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - - using (MySqlDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list - folders.Add(curFolder); - } - } + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list + folders.Add(curFolder); } + reader.Close(); + result.Dispose(); } // if we are querying the root folder else // else we are querying a subtree of the inventory folder tree { /* Get all of the agent's folders from the database, put them all in a hash table * indexed by their parent ID */ - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) { - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - - using (MySqlDataReader reader = result.ExecuteReader()) + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling + hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list + else // else current folder has no known (yet) siblings { - while (reader.Read()) - { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling - hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list - else // else current folder has no known (yet) siblings - { - List siblingList = new List(); - siblingList.Add(curFolder); - // Current folder has no known (yet) siblings - hashtable.Add(curFolder.ParentID, siblingList); - } - } // while more items to read from the database + List siblingList = new List(); + siblingList.Add(curFolder); + // Current folder has no known (yet) siblings + hashtable.Add(curFolder.ParentID, siblingList); } - } + } // while more items to read from the database + reader.Close(); + result.Dispose(); // Set flag so we know we need to build the results from the hash table after // we unlock the database @@ -781,13 +781,12 @@ namespace OpenSim.Data.MySQL folders.AddRange(hashtable[folders[i].ID]); } } // lock (database) - return folders; } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -802,18 +801,19 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection)) - { - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - lock (database) - cmd.ExecuteNonQuery(); + lock (database) + { + cmd.ExecuteNonQuery(); } } catch (MySqlException e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } } @@ -827,12 +827,13 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection)) - { - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - lock (database) - cmd.ExecuteNonQuery(); + lock (database) + { + cmd.ExecuteNonQuery(); } } catch (MySqlException e) @@ -864,38 +865,40 @@ namespace OpenSim.Data.MySQL public List fetchActiveGestures(UUID avatarID) { + MySqlDataReader result = null; + MySqlCommand sqlCmd = null; lock (database) { try { database.CheckConnection(); - - using (MySqlCommand sqlCmd = new MySqlCommand( + sqlCmd = new MySqlCommand( "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", - database.Connection)) - { - sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); - sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + database.Connection); + sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); + sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + result = sqlCmd.ExecuteReader(); - using (MySqlDataReader result = sqlCmd.ExecuteReader()) - { - List list = new List(); - while (result.Read()) - { - InventoryItemBase item = readInventoryItem(result); - if (item != null) - list.Add(item); - } - return list; - } + List list = new List(); + while (result.Read()) + { + InventoryItemBase item = readInventoryItem(result); + if (item != null) + list.Add(item); } + return list; } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } + finally + { + if (result != null) result.Close(); + if (sqlCmd != null) sqlCmd.Dispose(); + } } } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a724a50..a6cce57 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -134,16 +134,18 @@ namespace OpenSim.Data.MySQL /// protected void GetWaitTimeout() { - using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); + + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; } + + dbReader.Close(); + cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -301,31 +303,31 @@ namespace OpenSim.Data.MySQL { CheckConnection(); - using (MySqlCommand tablesCmd = new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", - dbcon)) - { - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + MySqlCommand tablesCmd = + new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon); + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + { + while (tables.Read()) { - while (tables.Read()) + try { - try - { - string tableName = (string)tables["TABLE_NAME"]; - string comment = (string)tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) - { - tableList[tableName] = comment; - } - } - catch (Exception e) + string tableName = (string) tables["TABLE_NAME"]; + string comment = (string) tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) { - m_log.Error(e.Message, e); + tableList[tableName] = comment; } } + catch (Exception e) + { + m_log.Error(e.ToString()); + } } + tables.Close(); } } } @@ -344,19 +346,19 @@ namespace OpenSim.Data.MySQL { CheckConnection(); // Not sure if this one is necessary - MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand)dbcommand; + return (IDbCommand) dbcommand; } catch (Exception e) { // Return null if it fails. - m_log.Error("Failed during Query generation: " + e.Message, e); + m_log.Error("Failed during Query generation: " + e.ToString()); return null; } } @@ -692,6 +694,8 @@ namespace OpenSim.Data.MySQL ret.Add(attachpoint, item); } + r.Close(); + return ret; } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index f514076..b0075e8 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -56,13 +56,12 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?regionName", regionName); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - return RunCommand(cmd); - } + cmd.Parameters.AddWithValue("?regionName", regionName); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); } public RegionData Get(int posX, int posY, UUID scopeID) @@ -71,18 +70,17 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?posX", posX.ToString()); - cmd.Parameters.AddWithValue("?posY", posY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + cmd.Parameters.AddWithValue("?posX", posX.ToString()); + cmd.Parameters.AddWithValue("?posY", posY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return ret[0]; - } + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; + + return ret[0]; } public RegionData Get(UUID regionID, UUID scopeID) @@ -91,17 +89,16 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return ret[0]; - } + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; + + return ret[0]; } public List Get(int startX, int startY, int endX, int endY, UUID scopeID) @@ -110,44 +107,43 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?startX", startX.ToString()); - cmd.Parameters.AddWithValue("?startY", startY.ToString()); - cmd.Parameters.AddWithValue("?endX", endX.ToString()); - cmd.Parameters.AddWithValue("?endY", endY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - return RunCommand(cmd); - } + cmd.Parameters.AddWithValue("?startX", startX.ToString()); + cmd.Parameters.AddWithValue("?startY", startY.ToString()); + cmd.Parameters.AddWithValue("?endX", endX.ToString()); + cmd.Parameters.AddWithValue("?endY", endY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); } public List RunCommand(MySqlCommand cmd) { List retList = new List(); - using (IDataReader result = ExecuteReader(cmd)) + IDataReader result = ExecuteReader(cmd); + + while (result.Read()) { - while (result.Read()) + RegionData ret = new RegionData(); + ret.Data = new Dictionary(); + + UUID regionID; + UUID.TryParse(result["uuid"].ToString(), out regionID); + ret.RegionID = regionID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + ret.RegionName = result["regionName"].ToString(); + ret.posX = Convert.ToInt32(result["locX"]); + ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); + + if (m_ColumnNames == null) { - RegionData ret = new RegionData(); - ret.Data = new Dictionary(); - - UUID regionID; - UUID.TryParse(result["uuid"].ToString(), out regionID); - ret.RegionID = regionID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - ret.RegionName = result["regionName"].ToString(); - ret.posX = Convert.ToInt32(result["locX"]); - ret.posY = Convert.ToInt32(result["locY"]); - ret.sizeX = Convert.ToInt32(result["sizeX"]); - ret.sizeY = Convert.ToInt32(result["sizeY"]); - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); + m_ColumnNames = new List(); DataTable schemaTable = result.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) @@ -157,28 +153,28 @@ namespace OpenSim.Data.MySQL } } - foreach (string s in m_ColumnNames) - { - if (s == "uuid") - continue; - if (s == "ScopeID") - continue; - if (s == "regionName") - continue; - if (s == "locX") - continue; - if (s == "locY") - continue; - - ret.Data[s] = result[s].ToString(); - } - - retList.Add(ret); + foreach (string s in m_ColumnNames) + { + if (s == "uuid") + continue; + if (s == "ScopeID") + continue; + if (s == "regionName") + continue; + if (s == "locX") + continue; + if (s == "locY") + continue; + + ret.Data[s] = result[s].ToString(); } - CloseDBConnection(result, cmd); + retList.Add(ret); } + result.Close(); + CloseReaderCommand(cmd); + return retList; } @@ -205,72 +201,76 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - using (MySqlCommand cmd = new MySqlCommand()) + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; + foreach (string field in fields) { - string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; - foreach (string field in fields) - { - update += ", "; - update += "`" + field + "` = ?" + field; + update += ", "; + update += "`" + field + "` = ?"+field; - cmd.Parameters.AddWithValue("?" + field, data.Data[field]); - } + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } - update += " where uuid = ?regionID"; + update += " where uuid = ?regionID"; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); - cmd.Parameters.AddWithValue("?regionName", data.RegionName); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); - cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); - cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); - cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); + cmd.Parameters.AddWithValue("?regionName", data.RegionName); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + - String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + + String.Join("`, `", fields) + + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; - cmd.CommandText = insert; + cmd.CommandText = insert; - if (ExecuteNonQuery(cmd) < 1) - { - return false; - } + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; } } + cmd.Dispose(); + return true; } public bool SetDataItem(UUID regionID, string item, string value) { - using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) - { - cmd.Parameters.AddWithValue("?" + item, value); - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); - if (ExecuteNonQuery(cmd) > 0) - return true; - } + + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } public bool Delete(UUID regionID) { - using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) - { - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + + "` where uuid = ?UUID"); - if (ExecuteNonQuery(cmd) > 0) - return true; - } + + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 0bbc3f5..d48144d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -97,14 +97,16 @@ namespace OpenSim.Data.MySQL ret.Data[s] = result[s].ToString(); } - CloseDBConnection(result, cmd); + result.Close(); + CloseReaderCommand(cmd); + return ret; } - else - { - CloseDBConnection(result, cmd); - return null; - } + + result.Close(); + CloseReaderCommand(cmd); + + return null; } public bool Store(UserAccountData data) @@ -116,60 +118,61 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - using (MySqlCommand cmd = new MySqlCommand()) + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) { - string update = "update `" + m_Realm + "` set "; - bool first = true; - foreach (string field in fields) - { - if (!first) - update += ", "; - update += "`" + field + "` = ?" + field; + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; - first = false; + first = false; - cmd.Parameters.AddWithValue("?" + field, data.Data[field]); - } + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } - update += " where UUID = ?principalID"; + update += " where UUID = ?principalID"; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + - String.Join("`, `", fields) + - "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; - cmd.CommandText = insert; + cmd.CommandText = insert; - if (ExecuteNonQuery(cmd) < 1) - { - cmd.Dispose(); - return false; - } + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; } } + cmd.Dispose(); + return true; } public bool SetDataItem(UUID principalID, string item, string value) { - using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + - item + "` = ?" + item + " where UUID = ?UUID")) - { - cmd.Parameters.AddWithValue("?" + item, value); - cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - if (ExecuteNonQuery(cmd) > 0) - return true; - } + + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index bd46dfc..04f872f 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -181,20 +181,21 @@ namespace OpenSim.Data.MySQL param["?first"] = user; param["?second"] = last; - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserProfileData row = dbm.Manager.readUserRow(reader); - return row; - } - } + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + UserProfileData row = dbm.Manager.readUserRow(reader); + + reader.Dispose(); + result.Dispose(); + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -219,30 +220,28 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand adder = dbm.Manager.Query( - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?ownerID,?friendID,?friendPerms,?datetimestamp)", - param)) - { - adder.ExecuteNonQuery(); - } - - using (IDbCommand adder = dbm.Manager.Query( - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?friendID,?ownerID,?friendPerms,?datetimestamp)", - param)) - { - adder.ExecuteNonQuery(); - } + IDbCommand adder = + dbm.Manager.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", + param); + adder.ExecuteNonQuery(); + + adder = + dbm.Manager.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?friendID,?ownerID,?friendPerms,?datetimestamp)", + param); + adder.ExecuteNonQuery(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -261,24 +260,22 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand updater = dbm.Manager.Query( + IDbCommand updater = + dbm.Manager.Query( "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", - param)) - { - updater.ExecuteNonQuery(); - } + param); + updater.ExecuteNonQuery(); - using (IDbCommand updater = dbm.Manager.Query( + updater = + dbm.Manager.Query( "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", - param)) - { - updater.ExecuteNonQuery(); - } + param); + updater.ExecuteNonQuery(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -298,19 +295,18 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand updater = dbm.Manager.Query( + IDbCommand updater = + dbm.Manager.Query( "update " + m_userFriendsTableName + " SET friendPerms = ?friendPerms " + "where ownerID = ?ownerID and friendID = ?friendID", - param)) - { - updater.ExecuteNonQuery(); - } + param); + updater.ExecuteNonQuery(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -331,33 +327,34 @@ namespace OpenSim.Data.MySQL try { //Left Join userfriends to itself - using (IDbCommand result = dbm.Manager.Query( - "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + - m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + - " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", - param)) + IDbCommand result = + dbm.Manager.Query( + "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new UUID((string)reader["ownerID"]); - fli.Friend = new UUID((string)reader["friendID"]); - fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); - - // This is not a real column in the database table, it's a joined column from the opposite record - fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); - - Lfli.Add(fli); - } - } + FriendListItem fli = new FriendListItem(); + fli.FriendListOwner = new UUID((string) reader["ownerID"]); + fli.Friend = new UUID((string) reader["friendID"]); + fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); + + // This is not a real column in the database table, it's a joined column from the opposite record + fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); + + Lfli.Add(fli); } + + reader.Dispose(); + result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return Lfli; } finally @@ -379,29 +376,29 @@ namespace OpenSim.Data.MySQL { Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); + IDbCommand result = + dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + + " where UUID = ?uuid", param); - using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + - " where UUID = ?uuid", param)) + IDataReader reader = result.ExecuteReader(); + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - FriendRegionInfo fri = new FriendRegionInfo(); - fri.isOnline = (sbyte)reader["agentOnline"] != 0; - fri.regionHandle = (ulong)reader["currentHandle"]; - - infos[uuid] = fri; - } - } + FriendRegionInfo fri = new FriendRegionInfo(); + fri.isOnline = (sbyte)reader["agentOnline"] != 0; + fri.regionHandle = (ulong)reader["currentHandle"]; + + infos[uuid] = fri; } + + reader.Dispose(); + result.Dispose(); } } catch (Exception e) { m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -430,28 +427,28 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand result = dbm.Manager.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first AND lastname like ?second LIMIT 100", - param)) + IDbCommand result = + dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first AND lastname like ?second LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; - returnlist.Add(user); - } - } + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); } + reader.Dispose(); + result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return returnlist; } finally @@ -468,28 +465,28 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - using (IDbCommand result = dbm.Manager.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first OR lastname like ?first LIMIT 100", - param)) + IDbCommand result = + dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first OR lastname like ?first LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; - returnlist.Add(user); - } - } + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); } + reader.Dispose(); + result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return returnlist; } finally @@ -513,19 +510,20 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserProfileData row = dbm.Manager.readUserRow(reader); - return row; - } - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + UserProfileData row = dbm.Manager.readUserRow(reader); + + reader.Dispose(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -571,15 +569,15 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.ExecuteParameterizedSql( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", - param); + dbm.Manager.ExecuteParameterizedSql( + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", + param); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -602,19 +600,21 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserAgentData row = dbm.Manager.readAgentRow(reader); - return row; - } - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", + param); + IDataReader reader = result.ExecuteReader(); + + UserAgentData row = dbm.Manager.readAgentRow(reader); + + reader.Dispose(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -638,20 +638,19 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.insertUserRow( - user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, - user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, - user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.CanDoMask, user.WantDoMask, - user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, + user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, + user.LastLogin, user.UserInventoryURI, user.UserAssetURI, + user.CanDoMask, user.WantDoMask, + user.AboutText, user.FirstLifeAboutText, user.Image, + user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -677,7 +676,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -694,15 +693,14 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); try { - dbm.Manager.updateUserRow( - user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, - user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, - user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, + user.UserInventoryURI, + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, + user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } finally { @@ -750,29 +748,29 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) + IDbCommand result = dbm.Manager.Query( + "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); + IDataReader reader = result.ExecuteReader(); + + AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); + + reader.Dispose(); + result.Dispose(); + + if (null == appearance) { - using (IDataReader reader = result.ExecuteReader()) - { - AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); - - if (appearance == null) - { - m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); - return null; - } - else - { - appearance.SetAttachments(GetUserAttachments(user)); - return appearance; - } - } + m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); + return null; } + + appearance.SetAttachments(GetUserAttachments(user)); + + return appearance; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -800,7 +798,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -835,20 +833,20 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand result = dbm.Manager.Query( - "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - Hashtable ret = dbm.Manager.readAttachments(reader); - return ret; - } - } + IDbCommand result = dbm.Manager.Query( + "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + Hashtable ret = dbm.Manager.readAttachments(reader); + + reader.Dispose(); + result.Dispose(); + return ret; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -907,7 +905,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally -- cgit v1.1 From 67ac9881faf2034facfe92613538938695c2cda9 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:28:35 -0800 Subject: Removing duplicate SceneObjectPart.RotationalVelocity property --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a807948..c49153f 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -908,7 +908,7 @@ namespace OpenSim.Data.MySQL if (!(row["ParticleSystem"] is DBNull)) prim.ParticleSystem = (byte[])row["ParticleSystem"]; - prim.RotationalVelocity = new Vector3( + prim.AngularVelocity = new Vector3( (float)(double)row["OmegaX"], (float)(double)row["OmegaY"], (float)(double)row["OmegaZ"] @@ -1240,9 +1240,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); - cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); - cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); - cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); + cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z); cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); -- cgit v1.1 From de71d23e145de5df080f5a9abfebb367b81b2527 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:54:39 -0800 Subject: Removing Console.WriteLine()s that were brought in with the revert --- OpenSim/Data/MySQL/MySQLFramework.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index fd428ae..fca0ca5 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -69,7 +69,6 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { -Console.WriteLine(e.ToString()); if (errorSeen) throw; @@ -93,7 +92,6 @@ Console.WriteLine(e.ToString()); } catch (Exception e) { -Console.WriteLine(e.ToString()); return 0; } } -- cgit v1.1 From afef1ac191d32e9c1514c294b17e404b1d4ae217 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 13:10:58 -0800 Subject: Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen --- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 1fe6d29..6a4ccd7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -151,10 +151,9 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; - asset.FullID = assetID; string local = dbReader["local"].ToString(); if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) @@ -162,8 +161,6 @@ namespace OpenSim.Data.MySQL else asset.Local = false; - asset.Name = (string) dbReader["name"]; - asset.Type = (sbyte) dbReader["assetType"]; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } dbReader.Close(); -- cgit v1.1 From 99977902119d0bb981f507a5a6a96c1148766e77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Nov 2009 20:19:19 +0000 Subject: Committing the incomplete table handler to get it into the tree. No user functionality yet --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 200 +++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLGenericTableHandler.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs new file mode 100644 index 0000000..4eb4a24 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -0,0 +1,200 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using log4net; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; + +namespace OpenSim.Data.MySQL +{ + public class MySQLGenericTableHandler : MySqlFramework where T: struct + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + + protected Dictionary m_Fields = + new Dictionary(); + + protected List m_ColumnNames = null; + protected string m_Realm; + protected FieldInfo m_DataField = null; + + public MySQLGenericTableHandler(string connectionString, + string realm, string storeName) : base(connectionString) + { + m_Realm = realm; + if (storeName != String.Empty) + { + Assembly assem = GetType().Assembly; + + Migration m = new Migration(m_Connection, assem, storeName); + m.Update(); + } + + Type t = typeof(T); + FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | + BindingFlags.Instance | + BindingFlags.DeclaredOnly); + + if (fields.Length == 0) + return; + + foreach (FieldInfo f in fields) + { + if (f.Name != "Data") + m_Fields[f.Name] = f; + else + m_DataField = f; + } + } + + private void CheckColumnNames(IDataReader reader) + { + if (m_ColumnNames != null) + return; + + m_ColumnNames = new List(); + + DataTable schemaTable = reader.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + { + if (row["ColumnName"] != null && + (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + } + + public T[] Get(string field, string key) + { + return Get(new string[] { field }, new string[] { key }); + } + + public T[] Get(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return new T[0]; + + List terms = new List(); + + MySqlCommand cmd = new MySqlCommand(); + + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add(fields[i] + " = ?" + fields[i]); + } + + string where = String.Join(" and ", terms.ToArray()); + + string query = String.Format("select * from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + return DoQuery(cmd); + } + + protected T[] DoQuery(MySqlCommand cmd) + { + IDataReader reader = ExecuteReader(cmd); + if (reader == null) + return new T[0]; + + CheckColumnNames(reader); + + List result = new List(); + + while(reader.Read()) + { + T row = new T(); + + foreach (string name in m_Fields.Keys) + { + if (m_Fields[name].GetValue(row) is bool) + { + int v = Convert.ToInt32(reader[name]); + m_Fields[name].SetValue(row, v != 0 ? true : false); + } + else if(m_Fields[name].GetValue(row) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(reader[name].ToString(), out uuid); + m_Fields[name].SetValue(row, uuid); + } + else + { + m_Fields[name].SetValue(row, reader[name]); + } + } + + if (m_DataField != null) + { + Dictionary data = + new Dictionary(); + + foreach (string col in m_ColumnNames) + data[col] = reader[col].ToString(); + + m_DataField.SetValue(row, data); + } + + result.Add(row); + } + + CloseReaderCommand(cmd); + + return result.ToArray(); + } + + public T[] Get(string where) + { + MySqlCommand cmd = new MySqlCommand(); + + string query = String.Format("select * from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + return DoQuery(cmd); + } + + public void Store(T row) + { + MySqlCommand cmd = new MySqlCommand(); + + string query = ""; + } + } +} -- cgit v1.1 From 06ecdf1967848e3f0c6b6f98aba61c7ad099f65d Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Nov 2009 08:21:28 +0000 Subject: Tweak presence handling and whip up a database connector and handler for testign the new generic table handling --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 4eb4a24..1521dc7 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -190,11 +190,13 @@ namespace OpenSim.Data.MySQL return DoQuery(cmd); } - public void Store(T row) + public bool Store(T row) { MySqlCommand cmd = new MySqlCommand(); string query = ""; + + return false; } } } -- cgit v1.1 From 23438e66e7ee3cd71652cdf6fd6a801544179ec0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Nov 2009 08:53:07 +0000 Subject: Implement generic delete method --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 1521dc7..4e27e26 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL for (int i = 0 ; i < fields.Length ; i++) { cmd.Parameters.AddWithValue(fields[i], keys[i]); - terms.Add(fields[i] + " = ?" + fields[i]); + terms.Add("`" + fields[i] + "` = ?" + fields[i]); } string where = String.Join(" and ", terms.ToArray()); @@ -198,5 +198,18 @@ namespace OpenSim.Data.MySQL return false; } + + public bool Delete(string field, string val) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); + cmd.Parameters.AddWithValue(field, val); + + if (ExecuteNonQuery(cmd) > 0) + return true; + + return false; + } } } -- cgit v1.1 From 9f5c2acd128828d220bf7e47bd4fe13d7a2a910b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 23 Nov 2009 11:26:06 +0900 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 4e27e26..2f5937d 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -135,7 +135,7 @@ namespace OpenSim.Data.MySQL List result = new List(); - while(reader.Read()) + while (reader.Read()) { T row = new T(); @@ -146,7 +146,7 @@ namespace OpenSim.Data.MySQL int v = Convert.ToInt32(reader[name]); m_Fields[name].SetValue(row, v != 0 ? true : false); } - else if(m_Fields[name].GetValue(row) is UUID) + else if (m_Fields[name].GetValue(row) is UUID) { UUID uuid = UUID.Zero; -- cgit v1.1 From 4973c057eb4566b97fcf1d56c3b8814516275d38 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 23 Nov 2009 16:08:06 +1100 Subject: * Adds a modicum of additional checking to the Inventory Service (MySQL only) * Enable "opengridmode=true" in your Inventory Connector (where the mysql connection strings are) to enable if you are running a 'wide-open-grid'. * More comprehensive rollback support being implemented, should be available later today. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 0eecf06..063dd91 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -48,6 +48,10 @@ namespace OpenSim.Data.MySQL /// private MySQLManager database; + private bool rollbackStore = false; + private bool opengridmode = false; + private string rollbackDir = ""; + public void Initialise() { m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!"); @@ -82,6 +86,10 @@ namespace OpenSim.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); + rollbackDir = GridDataMySqlFile.ParseFileReadValue("rollbackdir"); + rollbackStore = GridDataMySqlFile.ParseFileReadValue("rollback") == "true"; + opengridmode = GridDataMySqlFile.ParseFileReadValue("opengridmode") == "true"; + database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); @@ -851,16 +859,25 @@ namespace OpenSim.Data.MySQL { List subFolders = getFolderHierarchy(folderID); - //Delete all sub-folders - foreach (InventoryFolderBase f in subFolders) + // Dont delete in OGM - makes for easier restores if someone sends a malcious command. (just restore the folder entry) + if (opengridmode == false) { - deleteOneFolder(f.ID); - deleteItemsInFolder(f.ID); + //Delete all sub-folders + foreach (InventoryFolderBase f in subFolders) + { + deleteOneFolder(f.ID); + deleteItemsInFolder(f.ID); + } } //Delete the actual row deleteOneFolder(folderID); - deleteItemsInFolder(folderID); + + // Just delete the folder context in OGM + if (opengridmode == false) + { + deleteItemsInFolder(folderID); + } } public List fetchActiveGestures(UUID avatarID) -- cgit v1.1 From b516fe67a00b81923945ecaab49e996408aa8172 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 23 Nov 2009 17:20:03 +1100 Subject: * Implements SQL Rollback support to Inventory Service for quicker backup restoration. * Can optionally replace the OpenGridMode committed earlier. * Will create a series of incrementing restore SQL files, one per user, in folders listed per-day. * For MySql Section of InventoryService INI: rollback = "true" rollbackdir = "/absolute/path/to/rollback/storage/dir" --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 154 +++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 063dd91..0ea0cb7 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -26,6 +26,7 @@ */ using System; +using System.IO; using System.Collections.Generic; using System.Reflection; using log4net; @@ -463,6 +464,125 @@ namespace OpenSim.Data.MySQL } } + #region Inventory Rollback-via-.sql Support + /// + /// Not a good SQL escape function, but it'll do the job (if mutilate the data.) + /// Someone may want to write something better here. + /// + /// + /// + private static string cheapSQLescape(string str) + { + str = str.Replace("\\", ""); + str = str.Replace("'", ""); + str = str.Replace("\"", ""); + return "'" + str + "'"; + } + + private static string InventoryItemToSql(InventoryItemBase item) + { + string sql = + "REPLACE /*! INVITEM AT ***$SUBS$*** */ INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName" + + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType" + + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType" + + ", creationDate, groupID, groupOwned, flags) VALUES "; + sql += + "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription" + + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID" + + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" + + ", ?groupID, ?groupOwned, ?flags);\r\n"; + + string itemName = item.Name; + string itemDesc = item.Description; + + sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString()); + + sql = sql.Replace("?inventoryID", cheapSQLescape(item.ID.ToString())); + sql = sql.Replace("?assetID", cheapSQLescape(item.AssetID.ToString())); + sql = sql.Replace("?assetType", cheapSQLescape(item.AssetType.ToString())); + sql = sql.Replace("?parentFolderID", cheapSQLescape(item.Folder.ToString())); + sql = sql.Replace("?avatarID", cheapSQLescape(item.Owner.ToString())); + sql = sql.Replace("?inventoryName", cheapSQLescape(itemName)); + sql = sql.Replace("?inventoryDescription", cheapSQLescape(itemDesc)); + sql = sql.Replace("?inventoryNextPermissions", cheapSQLescape(item.NextPermissions.ToString())); + sql = sql.Replace("?inventoryCurrentPermissions", cheapSQLescape(item.CurrentPermissions.ToString())); + sql = sql.Replace("?invType", cheapSQLescape(item.InvType.ToString())); + sql = sql.Replace("?creatorID", cheapSQLescape(item.CreatorId)); + sql = sql.Replace("?inventoryBasePermissions", cheapSQLescape(item.BasePermissions.ToString())); + sql = sql.Replace("?inventoryEveryOnePermissions", cheapSQLescape(item.EveryOnePermissions.ToString())); + sql = sql.Replace("?inventoryGroupPermissions", cheapSQLescape(item.GroupPermissions.ToString())); + sql = sql.Replace("?salePrice", cheapSQLescape(item.SalePrice.ToString())); + sql = sql.Replace("?saleType", cheapSQLescape(unchecked((sbyte)item.SaleType).ToString())); + sql = sql.Replace("?creationDate", cheapSQLescape(item.CreationDate.ToString())); + sql = sql.Replace("?groupID", cheapSQLescape(item.GroupID.ToString())); + sql = sql.Replace("?groupOwned", cheapSQLescape(item.GroupOwned.ToString())); + sql = sql.Replace("?flags", cheapSQLescape(item.Flags.ToString())); + + return sql; + } + + private static string InventoryFolderToSql(InventoryFolderBase folder) + { + string sql = + "REPLACE /*! INVFOLDER AT ***$SUBS$*** */ INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; + sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version);\r\n"; + + string folderName = folder.Name; + + sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString()); + + sql = sql.Replace("?folderID", cheapSQLescape(folder.ID.ToString())); + sql = sql.Replace("?agentID", cheapSQLescape(folder.Owner.ToString())); + sql = sql.Replace("?parentFolderID", cheapSQLescape(folder.ParentID.ToString())); + sql = sql.Replace("?folderName", cheapSQLescape(folderName)); + sql = sql.Replace("?type", cheapSQLescape(folder.Type.ToString())); + sql = sql.Replace("?version", cheapSQLescape(folder.Version.ToString())); + + return sql; + } + + private static string getRollbackFolderDate() + { + return DateTime.UtcNow.Year.ToString() + "-" + DateTime.UtcNow.Month.ToString() + "-" + + DateTime.UtcNow.Day.ToString(); + } + + private void StoreRollbackItem(UUID ItemID) + { + if(rollbackStore == true) + { + string todaysPath = RollbackGetTodaysPath(); + + InventoryItemBase imb = getInventoryItem(ItemID); + string sql = InventoryItemToSql(imb); + File.AppendAllText(Path.Combine(todaysPath, imb.Owner.ToString()), sql); + } + } + + private void StoreRollbackFolder(UUID FolderID) + { + if (rollbackStore == true) + { + string todaysPath = RollbackGetTodaysPath(); + + InventoryFolderBase ifb = getInventoryFolder(FolderID); + string sql = InventoryFolderToSql(ifb); + File.AppendAllText(Path.Combine(todaysPath, ifb.Owner.ToString()), sql); + } + } + + private string RollbackGetTodaysPath() + { + if (!Directory.Exists(rollbackDir)) + Directory.CreateDirectory(rollbackDir); + + string todaysPath = Path.Combine(rollbackDir, getRollbackFolderDate()); + if (!Directory.Exists(todaysPath)) + Directory.CreateDirectory(todaysPath); + return todaysPath; + } + #endregion + /// /// Adds a specified item to the database /// @@ -549,6 +669,8 @@ namespace OpenSim.Data.MySQL /// Inventory item to update public void updateInventoryItem(InventoryItemBase item) { + StoreRollbackItem(item.ID); + addInventoryItem(item); } @@ -558,6 +680,8 @@ namespace OpenSim.Data.MySQL /// The inventory item UUID to delete public void deleteInventoryItem(UUID itemID) { + StoreRollbackItem(itemID); + try { database.CheckConnection(); @@ -634,6 +758,7 @@ namespace OpenSim.Data.MySQL /// Folder to update public void updateInventoryFolder(InventoryFolderBase folder) { + StoreRollbackFolder(folder.ID); addInventoryFolder(folder); } @@ -644,6 +769,8 @@ namespace OpenSim.Data.MySQL /// UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID public void moveInventoryFolder(InventoryFolderBase folder) { + StoreRollbackFolder(folder.ID); + string sql = "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; @@ -805,6 +932,8 @@ namespace OpenSim.Data.MySQL /// the folder UUID protected void deleteOneFolder(UUID folderID) { + StoreRollbackFolder(folderID); + try { database.CheckConnection(); @@ -831,6 +960,14 @@ namespace OpenSim.Data.MySQL /// the folder UUID protected void deleteItemsInFolder(UUID folderID) { + if (rollbackStore) + { + foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID)) + { + StoreRollbackItem(itemBase.ID); + } + } + try { database.CheckConnection(); @@ -865,17 +1002,34 @@ namespace OpenSim.Data.MySQL //Delete all sub-folders foreach (InventoryFolderBase f in subFolders) { + StoreRollbackFolder(f.ID); deleteOneFolder(f.ID); + + if(rollbackStore) + { + foreach (InventoryItemBase itemBase in getInventoryInFolder(f.ID)) + { + StoreRollbackItem(itemBase.ID); + } + } deleteItemsInFolder(f.ID); } } + StoreRollbackFolder(folderID); //Delete the actual row deleteOneFolder(folderID); // Just delete the folder context in OGM if (opengridmode == false) { + if (rollbackStore) + { + foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID)) + { + StoreRollbackItem(itemBase.ID); + } + } deleteItemsInFolder(folderID); } } -- cgit v1.1 From c58d30616be81df0714ce232de9dcdd955b61011 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Dec 2009 18:53:08 +0000 Subject: Log old position and region information when an orphaned child prim is found --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index c49153f..aecfaa3 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -479,7 +479,9 @@ namespace OpenSim.Data.MySQL } else { - m_log.Warn("[REGION DB]: Database contains an orphan child prim " + prim.UUID + " pointing to missing parent " + prim.ParentUUID); + m_log.WarnFormat( + "[REGION DB]: Database contains an orphan child prim {0} {1} at {2} in region {3} pointing to missing parent {4}. This prim will not be loaded.", + prim.Name, prim.UUID, prim.AbsolutePosition, regionID, prim.ParentUUID); } } } -- cgit v1.1 From d68b6642439d70178f367ef2cac5aa7b573fea44 Mon Sep 17 00:00:00 2001 From: grid Date: Thu, 10 Dec 2009 22:09:16 -0500 Subject: Kill a NRE caused by an error message trying to print unavailable data --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index aecfaa3..c33dc52 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -480,8 +480,8 @@ namespace OpenSim.Data.MySQL else { m_log.WarnFormat( - "[REGION DB]: Database contains an orphan child prim {0} {1} at {2} in region {3} pointing to missing parent {4}. This prim will not be loaded.", - prim.Name, prim.UUID, prim.AbsolutePosition, regionID, prim.ParentUUID); + "[REGION DB]: Database contains an orphan child prim {0} {1} in region {3} pointing to missing parent {4}. This prim will not be loaded.", + prim.Name, prim.UUID, regionID, prim.ParentUUID); } } } -- cgit v1.1 From 204c59c5acc79b30f90a0de9e69350bcd0de06c3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 11 Dec 2009 02:40:33 +0000 Subject: Refix the fix --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index c33dc52..9a4a4bb 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -480,7 +480,7 @@ namespace OpenSim.Data.MySQL else { m_log.WarnFormat( - "[REGION DB]: Database contains an orphan child prim {0} {1} in region {3} pointing to missing parent {4}. This prim will not be loaded.", + "[REGION DB]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.", prim.Name, prim.UUID, regionID, prim.ParentUUID); } } -- cgit v1.1 From 963cf25813ad2bd6dceaa39757391fbf94d6f09e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 13 Dec 2009 03:04:16 +1100 Subject: * Implements OSSL function: osGetSimulatorMemory - returns the current amount of memory allocated to the simulator process (Moderate Threat Level). * Cleans redundant information out of the Simulator Version. Versions now look like: "OpenSimulator 0.6.9(dev) Unix/Mono" * [Minor] additional log info for MySQLInventoryData --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 0ea0cb7..d560c5f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -91,6 +91,9 @@ namespace OpenSim.Data.MySQL rollbackStore = GridDataMySqlFile.ParseFileReadValue("rollback") == "true"; opengridmode = GridDataMySqlFile.ParseFileReadValue("opengridmode") == "true"; + if(rollbackStore) + m_log.Warn("[MysqlInventory] Enabling rollback mode in: " + rollbackDir); + database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); -- cgit v1.1 From 9972b12812d343c48843057ddb2f4ea9c7f96bb4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 26 Dec 2009 00:19:54 +0000 Subject: Add a generic REPLACE INTO handler for put into the generic table handler --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 2f5937d..9b8a001 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -195,6 +195,31 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); string query = ""; + List names = new List(); + List values = new List(); + + foreach (FieldInfo fi in m_Fields.Values) + { + names.Add(fi.Name); + values.Add(fi.GetValue(row).ToString()); + } + + if (m_DataField != null) + { + Dictionary data = + (Dictionary)m_DataField.GetValue(row); + + foreach (KeyValuePair kvp in data) + { + names.Add(kvp.Key); + values.Add(kvp.Value); + } + } + + query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values ('" + String.Join("','", values.ToArray()) + "')"; + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } -- cgit v1.1 From 92be01d5e60c00568a4b8efc4bfa17f8b3df8a63 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 26 Dec 2009 03:24:46 +0100 Subject: Make the GenericTableHandler work as intended --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 9b8a001..4dfc324 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Data.MySQL { - public class MySQLGenericTableHandler : MySqlFramework where T: struct + public class MySQLGenericTableHandler : MySqlFramework where T: class, new() { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -63,7 +63,7 @@ namespace OpenSim.Data.MySQL } Type t = typeof(T); - FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | + FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); @@ -165,7 +165,11 @@ namespace OpenSim.Data.MySQL new Dictionary(); foreach (string col in m_ColumnNames) + { data[col] = reader[col].ToString(); + if (data[col] == null) + data[col] = String.Empty; + } m_DataField.SetValue(row, data); } @@ -218,6 +222,8 @@ namespace OpenSim.Data.MySQL query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values ('" + String.Join("','", values.ToArray()) + "')"; + cmd.CommandText = query; + if (ExecuteNonQuery(cmd) > 0) return true; -- cgit v1.1 From 0369256720811e5247cbbe24b2f875cce259e01c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 26 Dec 2009 23:38:11 +0000 Subject: Close a SQL injection loophole in the new database driver --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 4dfc324..58b95d7 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -216,11 +216,12 @@ namespace OpenSim.Data.MySQL foreach (KeyValuePair kvp in data) { names.Add(kvp.Key); - values.Add(kvp.Value); + values.Add("?" + kvp.Key); + cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value); } } - query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values ('" + String.Join("','", values.ToArray()) + "')"; + query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; cmd.CommandText = query; -- cgit v1.1 From b7951d5177c0b575815f4d8a9ef35a0e7af58973 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 27 Dec 2009 01:32:23 +0100 Subject: Correct some issues with the last commit --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 58b95d7..b2bd5f6 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -205,7 +205,8 @@ namespace OpenSim.Data.MySQL foreach (FieldInfo fi in m_Fields.Values) { names.Add(fi.Name); - values.Add(fi.GetValue(row).ToString()); + values.Add("?" + fi.Name); + cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); } if (m_DataField != null) -- cgit v1.1 From 831f75964440ebd9997f71201fab3005b5c8c6a1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 03:05:45 +0000 Subject: Add the MySQL presence data module --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 93 +++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLPresenceData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs new file mode 100644 index 0000000..95619a5 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -0,0 +1,93 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for the Grid Server + /// + public class MySQLPresenceData : MySQLGenericTableHandler, + IPresenceData + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySQLPresenceData(string connectionString, string realm) : + base(connectionString, realm, "Presence") + { + } + + public PresenceData Get(UUID sessionID) + { + PresenceData[] ret = Get("SessionID", + sessionID.ToString()); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public void LogoutRegionAgents(UUID regionID) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("update {0} set Online='false' where `RegionID`=?RegionID", m_Realm); + + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + ExecuteNonQuery(cmd); + } + + public bool ReportAgent(UUID sessionID, UUID regionID, string position, + string lookAt) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt', Online='true' where `SessionID`=?SessionID", m_Realm); + + cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Position", position); + cmd.Parameters.AddWithValue("?LookAt", lookAt); + + if (ExecuteNonQuery(cmd) == 0) + return false; + + return true; + } + } +} -- cgit v1.1 From 9a8f6c79c9eafca4289d6a2c961ae54d7e7b8d4f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 17:57:45 +0000 Subject: Forgot the migration file --- OpenSim/Data/MySQL/Resources/001_Presence.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_Presence.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql new file mode 100644 index 0000000..b8abaf7 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Presence.sql @@ -0,0 +1,15 @@ +BEGIN; + +CREATE TABLE `Presence` ( + `UserID` VARCHAR(255) NOT NULL, + `RegionID` CHAR(36) NOT NULL, + `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `Online` CHAR(5) NOT NULL DEFAULT 'false', + `Login` CHAR(16) NOT NULL DEFAULT '0', + `Logout` CHAR(16) NOT NULL DEFAULT '0', + `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' +) ENGINE=InnoDB; + +COMMIT; -- cgit v1.1 From 397a29649203513a4ef24c04e06aace43e02b367 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 18:52:24 +0000 Subject: Add the migration for friends and guard the presence Report function --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 4 ++++ OpenSim/Data/MySQL/Resources/001_Friends.sql | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_Friends.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 95619a5..8ccad90 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -75,6 +75,10 @@ namespace OpenSim.Data.MySQL public bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt) { + PresenceData[] pd = Get("SessionID", sessionID.ToString()); + if (pd.Length == 0) + return false; + MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt', Online='true' where `SessionID`=?SessionID", m_Realm); diff --git a/OpenSim/Data/MySQL/Resources/001_Friends.sql b/OpenSim/Data/MySQL/Resources/001_Friends.sql new file mode 100644 index 0000000..e158a2c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Friends.sql @@ -0,0 +1,9 @@ +BEGIN; + +CREATE TABLE `Friends` ( + `PrincipalID` CHAR(36) NOT NULL, + `FriendID` VARCHAR(255) NOT NULL, + `Flags` CHAR(16) NOT NULL DEFAULT '0' +) ENGINE=InnoDB; + +COMMIT; -- cgit v1.1 From 2ed207509b0df83d1aaf49919df5978f6f70f934 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 19:12:33 +0000 Subject: Add the second step of the friends migration to pull data from the old table into the new --- OpenSim/Data/MySQL/Resources/002_Friends.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/002_Friends.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_Friends.sql b/OpenSim/Data/MySQL/Resources/002_Friends.sql new file mode 100644 index 0000000..5ff6438 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_Friends.sql @@ -0,0 +1,5 @@ +BEGIN; + +INSERT INTO Friends (PrincipalID, FriendID, Flags) SELECT ownerID, friendID, friendPerms FROM userfriends; + +COMMIT; -- cgit v1.1 From e0fc854f05b137c353196356e5b26d11b6ee6867 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 23:42:08 +0000 Subject: Adding new fields and home location methid to presence. Adding cleanup (deleting all but one presence record) on logout so that they don't pile up. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 2 + OpenSim/Data/MySQL/MySQLPresenceData.cs | 52 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index b2bd5f6..873d6d4 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -177,6 +177,8 @@ namespace OpenSim.Data.MySQL result.Add(row); } + reader.Close(); + CloseReaderCommand(cmd); return result.ToArray(); diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 8ccad90..72b8a0c 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -93,5 +93,57 @@ namespace OpenSim.Data.MySQL return true; } + + public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + PresenceData[] pd = Get("UserID", userID); + if (pd.Length == 0) + return false; + + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); + + cmd.Parameters.AddWithValue("?UserID", userID); + cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?HomePosition", position); + cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); + + if (ExecuteNonQuery(cmd) == 0) + return false; + + return true; + } + + public void Prune(string userID) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); + + cmd.Parameters.AddWithValue("?UserID", userID); + + IDataReader reader = ExecuteReader(cmd); + + List deleteSessions = new List(); + int online = 0; + + while(reader.Read()) + { + if (bool.Parse(reader["Online"].ToString())) + online++; + else + deleteSessions.Add(new UUID(reader["SessionID"].ToString())); + } + + if (online == 0 && deleteSessions.Count > 0) + deleteSessions.RemoveAt(0); + + reader.Close(); + CloseReaderCommand(cmd); + + foreach (UUID s in deleteSessions) + Delete("SessionID", s.ToString()); + } } } -- cgit v1.1 From c4f5ac970cc2c43c6a833416d9df918d3c869152 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 23:45:15 +0000 Subject: Add a migration to add the 3 new fields --- OpenSim/Data/MySQL/Resources/002_Presence.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/002_Presence.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_Presence.sql b/OpenSim/Data/MySQL/Resources/002_Presence.sql new file mode 100644 index 0000000..e65f105 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_Presence.sql @@ -0,0 +1,7 @@ +BEGIN; + +ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; +ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; +ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; + +COMMIT; -- cgit v1.1 From 3249d5be9a7ef649b70cce1444a46cfb64796b16 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 23:47:58 +0000 Subject: Add the indices to really make this table work --- OpenSim/Data/MySQL/Resources/003_Presence.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_Presence.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/003_Presence.sql b/OpenSim/Data/MySQL/Resources/003_Presence.sql new file mode 100644 index 0000000..0efefa8 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_Presence.sql @@ -0,0 +1,6 @@ +BEGIN; + +CREATE UNIQUE INDEX SessionID ON Presence(SessionID); +CREATE INDEX UserID ON Presence(UserID); + +COMMIT; -- cgit v1.1 From e9df86a6d6e79c7c370a454a6c2b5cdd3c3f3641 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 09:22:52 -0800 Subject: * Added useraccount table --- OpenSim/Data/MySQL/Resources/001_UserAccount.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_UserAccount.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql new file mode 100644 index 0000000..f946430 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql @@ -0,0 +1,13 @@ +BEGIN; + +CREATE TABLE `useraccount` ( + `UserID` CHAR(36) NOT NULL, + `ScopeID` CHAR(36) NOT NULL, + `FirstName` VARCHAR(64) NOT NULL, + `LastName` VARCHAR(64) NOT NULL, + `Email` VARCHAR(64), + `ServiceURLs` TEXT, + `Created` DATETIME +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; -- cgit v1.1 From 18ca978b81fb504b53bddadf292319b85807a299 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 Dec 2009 18:31:27 +0000 Subject: Give the new user tables the once-over. Strip the current set of methods from IUserAccountService, we need to define what goes in there. Change the handler to the generic handler. Adjust migrations, add index --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 139 +---------------------- OpenSim/Data/MySQL/Resources/001_UserAccount.sql | 4 +- OpenSim/Data/MySQL/Resources/002_UserAccount.sql | 5 + OpenSim/Data/MySQL/Resources/003_UserAccount.sql | 9 ++ 4 files changed, 18 insertions(+), 139 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/002_UserAccount.sql create mode 100644 OpenSim/Data/MySQL/Resources/003_UserAccount.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index d48144d..9624d79 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -35,146 +35,11 @@ using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL { - public class MySqlUserAccountData : MySqlFramework, IUserAccountData + public class MySqlUserAccountData : MySQLGenericTableHandler, IUserAccountData { - private string m_Realm; - private List m_ColumnNames = null; -// private int m_LastExpire = 0; - public MySqlUserAccountData(string connectionString, string realm) - : base(connectionString) - { - m_Realm = realm; - - Migration m = new Migration(m_Connection, GetType().Assembly, "UserStore"); - m.Update(); - } - - public List Query(UUID principalID, UUID scopeID, string query) - { - return null; - } - - public UserAccountData Get(UUID principalID, UUID scopeID) - { - UserAccountData ret = new UserAccountData(); - ret.Data = new Dictionary(); - - string command = "select * from `"+m_Realm+"` where UUID = ?principalID"; - if (scopeID != UUID.Zero) - command += " and ScopeID = ?scopeID"; - - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - IDataReader result = ExecuteReader(cmd); - - if (result.Read()) - { - ret.PrincipalID = principalID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - if (s == "ScopeID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - result.Close(); - CloseReaderCommand(cmd); - - return ret; - } - - result.Close(); - CloseReaderCommand(cmd); - - return null; - } - - public bool Store(UserAccountData data) - { - if (data.Data.ContainsKey("UUID")) - data.Data.Remove("UUID"); - if (data.Data.ContainsKey("ScopeID")) - data.Data.Remove("ScopeID"); - - string[] fields = new List(data.Data.Keys).ToArray(); - - MySqlCommand cmd = new MySqlCommand(); - - string update = "update `"+m_Realm+"` set "; - bool first = true; - foreach (string field in fields) - { - if (!first) - update += ", "; - update += "`" + field + "` = ?"+field; - - first = false; - - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); - } - - update += " where UUID = ?principalID"; - - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; - - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + - String.Join("`, `", fields) + - "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; - - cmd.CommandText = insert; - - if (ExecuteNonQuery(cmd) < 1) - { - cmd.Dispose(); - return false; - } - } - - cmd.Dispose(); - - return true; - } - - public bool SetDataItem(UUID principalID, string item, string value) + : base(connectionString, realm, "UserAccount") { - MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + - "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - - - cmd.Parameters.AddWithValue("?"+item, value); - cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); - - if (ExecuteNonQuery(cmd) > 0) - return true; - - return false; } } } diff --git a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql index f946430..7d63816 100644 --- a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql +++ b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql @@ -1,7 +1,7 @@ BEGIN; -CREATE TABLE `useraccount` ( - `UserID` CHAR(36) NOT NULL, +CREATE TABLE `UserAccounts` ( + `PrincipalID` CHAR(36) NOT NULL, `ScopeID` CHAR(36) NOT NULL, `FirstName` VARCHAR(64) NOT NULL, `LastName` VARCHAR(64) NOT NULL, diff --git a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql new file mode 100644 index 0000000..08a0f87 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql @@ -0,0 +1,5 @@ +BEGIN; + +INSERT INTO UserAccounts (UserID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_UserAccount.sql b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql new file mode 100644 index 0000000..e42d93b --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql @@ -0,0 +1,9 @@ +BEGIN; + +CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); +CREATE INDEX Email ON UserAccounts(Email); +CREATE INDEX FirstName ON UserAccounts(FirstName); +CREATE INDEX LastName ON UserAccounts(LastName); +CREATE INDEX Name ON UserAccounts(FirstName,LastName); + +COMMIT; -- cgit v1.1 From 8631cea2154f0ded2e3fa27349045650ce6f5998 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 Dec 2009 20:14:26 +0000 Subject: Change the interface a bit before someone depends on it's current form --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 9624d79..e3b5f1d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -40,6 +40,10 @@ namespace OpenSim.Data.MySQL public MySqlUserAccountData(string connectionString, string realm) : base(connectionString, realm, "UserAccount") { + public bool Store(UserAccountData data, UUID principalID, string token) + { + Store(data); + } } } } -- cgit v1.1 From 6eb5754f5a4b9707f43572ce1e5743054d784818 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 13:27:21 -0800 Subject: Polished the IUserService interface. --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index e3b5f1d..c6eb44d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -40,10 +40,10 @@ namespace OpenSim.Data.MySQL public MySqlUserAccountData(string connectionString, string realm) : base(connectionString, realm, "UserAccount") { - public bool Store(UserAccountData data, UUID principalID, string token) - { - Store(data); - } + } + public bool Store(UserAccountData data, UUID principalID, string token) + { + return Store(data); } } } -- cgit v1.1 From 28516e2648068dd59c7e3c44c3212168ef0c66dd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 16:51:59 -0800 Subject: Fixed a couple of bugs that were bombing the data migration. --- OpenSim/Data/MySQL/Resources/001_UserAccount.sql | 2 +- OpenSim/Data/MySQL/Resources/002_UserAccount.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql index 7d63816..07da571 100644 --- a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql +++ b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql @@ -7,7 +7,7 @@ CREATE TABLE `UserAccounts` ( `LastName` VARCHAR(64) NOT NULL, `Email` VARCHAR(64), `ServiceURLs` TEXT, - `Created` DATETIME + `Created` INT(11) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql index 08a0f87..ad2ddda 100644 --- a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql +++ b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql @@ -1,5 +1,5 @@ BEGIN; -INSERT INTO UserAccounts (UserID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; +INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; COMMIT; -- cgit v1.1 From b6097ae9a8a4566330d882213179feba6d05da62 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 30 Dec 2009 22:23:17 +0000 Subject: Some modifications to user service. Query by name is implemented now --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index c6eb44d..e2ce6d1 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -41,6 +41,7 @@ namespace OpenSim.Data.MySQL : base(connectionString, realm, "UserAccount") { } + public bool Store(UserAccountData data, UUID principalID, string token) { return Store(data); -- cgit v1.1 From 99ad7aac7f854eaae075e93880c39796183ba7e4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:34:03 +0000 Subject: Implement saving user account data --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index e2ce6d1..ae7d5ca 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -42,7 +42,7 @@ namespace OpenSim.Data.MySQL { } - public bool Store(UserAccountData data, UUID principalID, string token) + public bool Store(UserAccountData data) { return Store(data); } -- cgit v1.1 From 01f6aee020eddb46893cbfbcf3b1e114a85ac261 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 02:26:00 +0000 Subject: Implement avatar picker queries --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 38 ++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index ae7d5ca..aa69d68 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -42,9 +42,43 @@ namespace OpenSim.Data.MySQL { } - public bool Store(UserAccountData data) + public UserAccountData[] GetUsers(UUID scopeID, string query) { - return Store(data); + string[] words = query.Split(new char[] {' '}); + + for (int i = 0 ; i < words.Length ; i++) + { + if (words[i].Length < 3) + { + if (i != words.Length - 1) + Array.Copy(words, i + 1, words, i, words.Length - i - 1); + Array.Resize(ref words, words.Length - 1); + } + } + + if (words.Length == 0) + return new UserAccountData[0]; + + if (words.Length > 2) + return new UserAccountData[0]; + + MySqlCommand cmd = new MySqlCommand(); + + if (words.Length == 1) + { + 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); + cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + else + { + 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); + cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + + return DoQuery(cmd); } } } -- cgit v1.1 From c540c93b543358988b2c66c2c35d1616c41ee8d2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 08:45:41 -0800 Subject: Auth data migration. --- OpenSim/Data/MySQL/Resources/002_AuthStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/002_AuthStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/002_AuthStore.sql b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql new file mode 100644 index 0000000..dc7dfe0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; + +COMMIT; -- cgit v1.1 From 0d9591bf3562955a39c57dd289d0cc0bb0ba85a3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 1 Jan 2010 22:51:00 +0000 Subject: Prevent the creation of duplicate inventory folders in the case of a login database issue. Now the login will instaead fail later. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index d560c5f..f7b286f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -264,7 +264,7 @@ namespace OpenSim.Data.MySQL { database.Reconnect(); m_log.Error(e.ToString()); - return null; + throw; } } -- cgit v1.1 From 4240f2dec6f7348a99aea0d1b040fca6ea9d493b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 16:54:24 -0800 Subject: New LL login service is working! -- tested in standalone only. Things still missing from response, namely Library and Friends. Appearance service is also missing. --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 72b8a0c..e5dd0e5 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -81,12 +81,12 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt', Online='true' where `SessionID`=?SessionID", m_Realm); + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?Position", position); - cmd.Parameters.AddWithValue("?LookAt", lookAt); + cmd.Parameters.AddWithValue("?Position", position.ToString()); + cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString()); if (ExecuteNonQuery(cmd) == 0) return false; -- cgit v1.1 From 70d5b1c34cf2eb6621f383169fdee03966850762 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 4 Jan 2010 06:10:45 +0900 Subject: Formatting cleanup. Add copyright headers. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index f7b286f..f566fde 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -91,7 +91,7 @@ namespace OpenSim.Data.MySQL rollbackStore = GridDataMySqlFile.ParseFileReadValue("rollback") == "true"; opengridmode = GridDataMySqlFile.ParseFileReadValue("opengridmode") == "true"; - if(rollbackStore) + if (rollbackStore) m_log.Warn("[MysqlInventory] Enabling rollback mode in: " + rollbackDir); database = @@ -552,7 +552,7 @@ namespace OpenSim.Data.MySQL private void StoreRollbackItem(UUID ItemID) { - if(rollbackStore == true) + if (rollbackStore == true) { string todaysPath = RollbackGetTodaysPath(); @@ -1008,7 +1008,7 @@ namespace OpenSim.Data.MySQL StoreRollbackFolder(f.ID); deleteOneFolder(f.ID); - if(rollbackStore) + if (rollbackStore) { foreach (InventoryItemBase itemBase in getInventoryInFolder(f.ID)) { -- cgit v1.1 From 6e8d94685d4e5784398ff656fdab169310dc219a Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 02:52:43 +0000 Subject: AvatarStore. Untested, but complete --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 10 +++++----- OpenSim/Data/MySQL/Resources/001_Avatar.sql | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/001_Avatar.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 873d6d4..1a97fee 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -95,12 +95,12 @@ namespace OpenSim.Data.MySQL } } - public T[] Get(string field, string key) + public virtual T[] Get(string field, string key) { return Get(new string[] { field }, new string[] { key }); } - public T[] Get(string[] fields, string[] keys) + public virtual T[] Get(string[] fields, string[] keys) { if (fields.Length != keys.Length) return new T[0]; @@ -184,7 +184,7 @@ namespace OpenSim.Data.MySQL return result.ToArray(); } - public T[] Get(string where) + public virtual T[] Get(string where) { MySqlCommand cmd = new MySqlCommand(); @@ -196,7 +196,7 @@ namespace OpenSim.Data.MySQL return DoQuery(cmd); } - public bool Store(T row) + public virtual bool Store(T row) { MySqlCommand cmd = new MySqlCommand(); @@ -234,7 +234,7 @@ namespace OpenSim.Data.MySQL return false; } - public bool Delete(string field, string val) + public virtual bool Delete(string field, string val) { MySqlCommand cmd = new MySqlCommand(); diff --git a/OpenSim/Data/MySQL/Resources/001_Avatar.sql b/OpenSim/Data/MySQL/Resources/001_Avatar.sql new file mode 100644 index 0000000..27a3072 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Avatar.sql @@ -0,0 +1,5 @@ +BEGIN; + +CREATE TABLE Avatars (PrincipalID CHAR(36) NOT NULL, Name VARCHAR(32) NOT NULL, Value VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY(PrincipalID, Name), KEY(PrincipalID)); + +COMMIT; -- cgit v1.1 From d4d55b4f4b1c495d38283fdc5f843f7ca617691d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 02:53:22 +0000 Subject: Add the data service --- OpenSim/Data/MySQL/MySQLAvatarData.cs | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLAvatarData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs new file mode 100644 index 0000000..5611302 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for the Grid Server + /// + public class MySQLAvatarData : MySQLGenericTableHandler, + IAvatarData + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySQLAvatarData(string connectionString, string realm) : + base(connectionString, realm, "Avatar") + { + } + + public bool Delete(UUID principalID, string name) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + + if (ExecuteNonQuery(cmd) > 0) + return true; + + return false; + } + } +} -- cgit v1.1 From e76333555d2016412b17f43039962d32ad8c0609 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 18:47:47 +0000 Subject: First stage port of the XInventoryService --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 5 ++ OpenSim/Data/MySQL/MySQLXInventoryData.cs | 113 +++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLXInventoryData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index b2bd5f6..fdb98eb 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -153,6 +153,11 @@ namespace OpenSim.Data.MySQL UUID.TryParse(reader[name].ToString(), out uuid); m_Fields[name].SetValue(row, uuid); } + else if (m_Fields[name].GetValue(row) is int) + { + int v = Convert.ToInt32(reader[name]); + m_Fields[name].SetValue(row, v); + } else { m_Fields[name].SetValue(row, reader[name]); diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs new file mode 100644 index 0000000..dd3e6ea --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -0,0 +1,113 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Data; +using System.Reflection; +using System.Collections.Generic; +using log4net; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for the Asset Server + /// + public class MySQLXInventoryData : IXInventoryData + { + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private MySQLGenericTableHandler m_Folders; + private MySqlItemHandler m_Items; + + public MySQLXInventoryData(string conn, string realm) + { + m_Folders = new MySQLGenericTableHandler( + conn, "inventoryfolders", "InventoryStore"); + m_Items = new MySqlItemHandler( + conn, "inventoryitems", String.Empty); + } + + public XInventoryFolder[] GetFolders(string[] fields, string[] vals) + { + return m_Folders.Get(fields, vals); + } + + public XInventoryItem[] GetItems(string[] fields, string[] vals) + { + return m_Items.Get(fields, vals); + } + + public bool StoreFolder(XInventoryFolder folder) + { + return m_Folders.Store(folder); + } + + public bool StoreItem(XInventoryItem item) + { + return m_Items.Store(item); + } + + public bool DeleteFolders(string field, string val) + { + return m_Folders.Delete(field, val); + } + + public bool DeleteItems(string field, string val) + { + return m_Items.Delete(field, val); + } + + public bool MoveItem(string principalID, string id, string newParent) + { + return m_Items.MoveItem(principalID, id, newParent); + } + } + + public class MySqlItemHandler : MySQLGenericTableHandler + { + public MySqlItemHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public bool MoveItem(string principalID, string id, string newParent) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where agentID = ?AgentID and folderID = ?FolderID"); + cmd.Parameters.AddWithValue("?ParentFolderID", newParent); + cmd.Parameters.AddWithValue("?FolderID", id); + cmd.Parameters.AddWithValue("?AgentID", principalID); + + return ExecuteNonQuery(cmd) == 0 ? false : true; + } + } +} -- cgit v1.1 From 1ae9bfc0746b97f57031f282d4f6721b08c27f0c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 20:52:44 +0000 Subject: Finish conversion if XInventoryService --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 55 +++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index dd3e6ea..0eebc9c 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -85,9 +85,19 @@ namespace OpenSim.Data.MySQL return m_Items.Delete(field, val); } - public bool MoveItem(string principalID, string id, string newParent) + public bool MoveItem(string id, string newParent) { - return m_Items.MoveItem(principalID, id, newParent); + return m_Items.MoveItem(id, newParent); + } + + public XInventoryItem[] GetActiveGestures(UUID principalID) + { + return m_Items.GetActiveGestures(principalID); + } + + public int GetAssetPermissions(UUID principalID, UUID assetID) + { + return m_Items.GetAssetPermissions(principalID, assetID); } } @@ -98,16 +108,49 @@ namespace OpenSim.Data.MySQL { } - public bool MoveItem(string principalID, string id, string newParent) + public bool MoveItem(string id, string newParent) { MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where agentID = ?AgentID and folderID = ?FolderID"); + cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.Parameters.AddWithValue("?ParentFolderID", newParent); - cmd.Parameters.AddWithValue("?FolderID", id); - cmd.Parameters.AddWithValue("?AgentID", principalID); + cmd.Parameters.AddWithValue("?InventoryID", id); return ExecuteNonQuery(cmd) == 0 ? false : true; } + + public XInventoryItem[] GetActiveGestures(UUID principalID) + { + MySqlCommand cmd = new MySqlCommand(); + cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); + + cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); + cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + + return DoQuery(cmd); + } + + public int GetAssetPermissions(UUID principalID, UUID assetID) + { + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?AssetID", assetID.ToString()); + + IDataReader reader = ExecuteReader(cmd); + + int perms = 0; + + if (reader.Read()) + { + perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); + } + + reader.Close(); + CloseReaderCommand(cmd); + + return perms; + } } } -- cgit v1.1 From d14589d1abf4ca39a5fc5ba7be10e57edff4333c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Jan 2010 18:10:59 +0000 Subject: Add migrations to add fields to user and auth tables --- OpenSim/Data/MySQL/Resources/003_AuthStore.sql | 5 +++++ OpenSim/Data/MySQL/Resources/004_UserAccount.sql | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_AuthStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/004_UserAccount.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/003_AuthStore.sql b/OpenSim/Data/MySQL/Resources/003_AuthStore.sql new file mode 100644 index 0000000..af9ffe6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_AuthStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE `auth` ADD COLUMN `accountType` VARCHAR(32) NOT NULL DEFAULT 'UserAccount'; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/004_UserAccount.sql b/OpenSim/Data/MySQL/Resources/004_UserAccount.sql new file mode 100644 index 0000000..8abcd53 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_UserAccount.sql @@ -0,0 +1,8 @@ +BEGIN; + +ALTER TABLE UserAccounts ADD COLUMN UserLevel integer NOT NULL DEFAULT 0; +ALTER TABLE UserAccounts ADD COLUMN UserFlags integer NOT NULL DEFAULT 0; +ALTER TABLE UserAccounts ADD COLUMN UserTitle varchar(64) NOT NULL DEFAULT ''; + +COMMIT; + -- cgit v1.1 From 28d6705358c2e383fb46c57f064de4dcff144e33 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 9 Jan 2010 20:46:32 +0000 Subject: Preliminary work on the new default region setting mechanism --- OpenSim/Data/MySQL/MySQLRegionData.cs | 26 ++++++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/005_GridStore.sql | 6 ++++++ 2 files changed, 32 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/005_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index b0075e8..d045f61 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -274,5 +274,31 @@ namespace OpenSim.Data.MySQL return false; } + public List GetDefaultRegions(UUID scopeID) + { + string command = "select * from `"+m_Realm+"` where (flags & 1) <> 0"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; + + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); + } + + public List GetFallbackRegions(UUID scopeID, int x, int y) + { + string command = "select * from `"+m_Realm+"` where (flags & 2) <> 0"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; + + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + // TODO: distance-sort results + return RunCommand(cmd); + } } } diff --git a/OpenSim/Data/MySQL/Resources/005_GridStore.sql b/OpenSim/Data/MySQL/Resources/005_GridStore.sql new file mode 100644 index 0000000..835ba89 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_GridStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `flags` integer NOT NULL DEFAULT 0; +CREATE INDEX flags ON regions(flags); + +COMMIT; -- cgit v1.1 From e189b3056fff7223f6474bc26af559ef32891fa6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 02:13:55 +0000 Subject: Add last_seen field to regions table --- OpenSim/Data/MySQL/Resources/006_GridStore.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/006_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/006_GridStore.sql b/OpenSim/Data/MySQL/Resources/006_GridStore.sql new file mode 100644 index 0000000..91322d6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/006_GridStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `last_seen` integer NOT NULL DEFAULT 0; + +COMMIT; -- cgit v1.1 From 0d5f182c0235139a7bb343bf9856e064cf19e2da Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:13:57 +0000 Subject: Add a handful of new region flags and a small migration --- OpenSim/Data/MySQL/Resources/007_GridStore.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/007_GridStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/007_GridStore.sql b/OpenSim/Data/MySQL/Resources/007_GridStore.sql new file mode 100644 index 0000000..3f88d3d --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_GridStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; + +COMMIT; + -- cgit v1.1 From 5ce12c92d976fa32c076689bb3f937d8a8d60dc0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 16 Jan 2010 08:32:32 -0800 Subject: Fixed a missing field in the last regions table migration. --- OpenSim/Data/MySQL/Resources/007_GridStore.sql | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/007_GridStore.sql b/OpenSim/Data/MySQL/Resources/007_GridStore.sql index 3f88d3d..dbec584 100644 --- a/OpenSim/Data/MySQL/Resources/007_GridStore.sql +++ b/OpenSim/Data/MySQL/Resources/007_GridStore.sql @@ -1,6 +1,7 @@ BEGIN; ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +ALTER TABLE `regions` ADD COLUMN `Token` varchar(255) NOT NULL; COMMIT; -- cgit v1.1 From bb736cee6bc6cefa30c6ba5ca60f75b17d4c42e1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Feb 2010 16:05:59 -0800 Subject: Beginning of friends. --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLFriendsData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs new file mode 100644 index 0000000..923810b --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySqlFriendsData : MySQLGenericTableHandler, IFriendsData + { + public MySqlFriendsData(string connectionString, string realm) + : base(connectionString, realm, "Friends") + { + } + + public bool Delete(UUID principalID, UUID friendID) + { + // We need to delete the row where PrincipalID=principalID AND FriendID=firnedID + return false; + } + + public FriendsData[] GetFriends(UUID userID) + { + return Get("PrincipalID =\'" + userID.ToString() + "'"); + } + } +} -- cgit v1.1 From b92cb6126d8ca59121468fce44dc7b4c3b805181 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 5 Feb 2010 12:31:29 +0000 Subject: Implement the friends data adaptor --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 19 +++++++++++++------ OpenSim/Data/MySQL/Resources/001_FriendsStore.sql | 5 +++++ OpenSim/Data/MySQL/Resources/002_FriendsStore.sql | 5 +++++ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/001_FriendsStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/002_FriendsStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 923810b..9f7e850 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -38,19 +38,26 @@ namespace OpenSim.Data.MySQL public class MySqlFriendsData : MySQLGenericTableHandler, IFriendsData { public MySqlFriendsData(string connectionString, string realm) - : base(connectionString, realm, "Friends") + : base(connectionString, realm, "FriendsStore") { } - public bool Delete(UUID principalID, UUID friendID) + public bool Delete(UUID principalID, string friend) { - // We need to delete the row where PrincipalID=principalID AND FriendID=firnedID - return false; + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?Friend", friend); + + ExecuteNonQuery(cmd); + + return true; } - public FriendsData[] GetFriends(UUID userID) + public FriendsData[] GetFriends(UUID principalID) { - return Get("PrincipalID =\'" + userID.ToString() + "'"); + return Get("PrincipalID", principalID.ToString()); } } } diff --git a/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql new file mode 100644 index 0000000..da2c59c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +CREATE TABLE `Friends` (`PrincipalID` CHAR(36) NOT NULL, `Friend` VARCHAR(255) NOT NULL, `Flags` VARCHAR(16) NOT NULL DEFAULT 0, `Offered` VARCHAR(32) NOT NULL DEFAULT 0, PRIMARY KEY(`PrincipalID`, `Friend`), KEY(`PrincipalID`)); + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql new file mode 100644 index 0000000..a363867 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; + +COMMIT; -- cgit v1.1 From e982397cde06f95af7388d20ebe4c6c5ee238b17 Mon Sep 17 00:00:00 2001 From: OpenSim Master Date: Mon, 18 Jan 2010 15:50:33 -0800 Subject: * Fixed the Cable Beach inventory server to save the CreatorID as well as properly handling null item names and descriptions * Fixed the MySQL reader to safely handle null values in string columns that can be null --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index f566fde..4b71e39 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -345,8 +345,8 @@ namespace OpenSim.Data.MySQL item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; item.Folder = new UUID((string) reader["parentFolderID"]); - item.Name = (string) reader["inventoryName"]; - item.Description = (string) reader["inventoryDescription"]; + item.Name = (string)(reader["inventoryName"] ?? String.Empty); + item.Description = (string)(reader["inventoryDescription"] ?? String.Empty); item.NextPermissions = (uint) reader["inventoryNextPermissions"]; item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; item.InvType = (int) reader["invType"]; -- cgit v1.1 From 310e14cf03e5b4f78e1643b2eb3b1f104def6888 Mon Sep 17 00:00:00 2001 From: OpenSim Master Date: Mon, 18 Jan 2010 13:47:41 -0800 Subject: Fixing an incorrect logging message in insertUserRow --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a6cce57..243394e 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -778,7 +778,7 @@ namespace OpenSim.Data.MySQL string aboutText, string firstText, UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) { - m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); + m_log.Debug("[MySQLManager]: Creating profile for \"" + username + " " + lastname + "\" (" + uuid + ")"); string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, "; sql += -- cgit v1.1 From 3e697ad57e8f26e50e13b88fff059855ed17e660 Mon Sep 17 00:00:00 2001 From: OpenSim Master Date: Mon, 18 Jan 2010 15:50:33 -0800 Subject: * Fixed the Cable Beach inventory server to save the CreatorID as well as properly handling null item names and descriptions * Fixed the MySQL reader to safely handle null values in string columns that can be null --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index f566fde..4b71e39 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -345,8 +345,8 @@ namespace OpenSim.Data.MySQL item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; item.Folder = new UUID((string) reader["parentFolderID"]); - item.Name = (string) reader["inventoryName"]; - item.Description = (string) reader["inventoryDescription"]; + item.Name = (string)(reader["inventoryName"] ?? String.Empty); + item.Description = (string)(reader["inventoryDescription"] ?? String.Empty); item.NextPermissions = (uint) reader["inventoryNextPermissions"]; item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; item.InvType = (int) reader["invType"]; -- cgit v1.1 From 5f1f5c29e93d5ef92ccf93386c0738a205df4150 Mon Sep 17 00:00:00 2001 From: OpenSim Master Date: Mon, 18 Jan 2010 13:47:41 -0800 Subject: Fixing an incorrect logging message in insertUserRow --- OpenSim/Data/MySQL/MySQLManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a6cce57..243394e 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -778,7 +778,7 @@ namespace OpenSim.Data.MySQL string aboutText, string firstText, UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) { - m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); + m_log.Debug("[MySQLManager]: Creating profile for \"" + username + " " + lastname + "\" (" + uuid + ")"); string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, "; sql += -- cgit v1.1 From e1b5c612472b9d1acf47383c0bf75b555daff2e6 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Thu, 4 Feb 2010 13:19:30 -0800 Subject: Updated MySQL connection management to use the MySQL connection pooling. This should accommodate various timeout problems that exist with the current connection pool code in a more general and standard way. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 355 +++++----- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 71 +- OpenSim/Data/MySQL/MySQLEstateData.cs | 440 ++++++------ OpenSim/Data/MySQL/MySQLFramework.cs | 62 +- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 215 +++--- OpenSim/Data/MySQL/MySQLGridData.cs | 338 ++++----- OpenSim/Data/MySQL/MySQLInventoryData.cs | 847 +++++++++-------------- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 924 +++++++++++++------------ OpenSim/Data/MySQL/MySQLLogData.cs | 16 +- OpenSim/Data/MySQL/MySQLManager.cs | 428 ++++++------ OpenSim/Data/MySQL/MySQLRegionData.cs | 257 +++---- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 156 +++-- OpenSim/Data/MySQL/MySQLUserData.cs | 676 +++++++----------- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 65 +- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 9 +- 15 files changed, 2230 insertions(+), 2629 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 6a4ccd7..666c22f 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -43,10 +43,13 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private MySQLManager _dbConnection; + private string m_connectionString; + private object m_dbLock = new object(); #region IPlugin Members + public override string Version { get { return "1.0.0.0"; } } + /// /// Initialises Asset interface /// @@ -58,63 +61,29 @@ namespace OpenSim.Data.MySQL /// /// /// connect string - override public void Initialise(string connect) + public override void Initialise(string connect) { - // TODO: This will let you pass in the connect string in - // the config, though someone will need to write that. - if (connect == String.Empty) - { - // This is old seperate config file - m_log.Warn("no connect string, using old mysql_connection.ini instead"); - Initialise(); - } - else - { - _dbConnection = new MySQLManager(connect); - } + m_connectionString = connect; // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, assem, "AssetStore"); + m.Update(); + } } - /// - /// Initialises Asset interface - /// - /// - /// Loads and initialises the MySQL storage plugin - /// uses the obsolete mysql_connection.ini - /// - /// - /// - /// DEPRECATED and shouldn't be used public override void Initialise() { - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string hostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string database = GridDataMySqlFile.ParseFileReadValue("database"); - string username = GridDataMySqlFile.ParseFileReadValue("username"); - string password = GridDataMySqlFile.ParseFileReadValue("password"); - string pooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string port = GridDataMySqlFile.ParseFileReadValue("port"); - - _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port); - + throw new NotImplementedException(); } public override void Dispose() { } /// - /// Database provider version - /// - override public string Version - { - get { return _dbConnection.getVersion(); } - } - - /// /// The name of this DB provider /// override public string Name @@ -135,46 +104,43 @@ namespace OpenSim.Data.MySQL override public AssetBase GetAsset(UUID assetID) { AssetBase asset = null; - lock (_dbConnection) + lock (m_dbLock) { - _dbConnection.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand( + using (MySqlCommand cmd = new MySqlCommand( "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", - _dbConnection.Connection); - cmd.Parameters.AddWithValue("?id", assetID.ToString()); - - try - { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + dbcon)) { - if (dbReader.Read()) - { - asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); - asset.Data = (byte[]) dbReader["data"]; - asset.Description = (string) dbReader["description"]; + cmd.Parameters.AddWithValue("?id", assetID.ToString()); - string local = dbReader["local"].ToString(); - if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) - asset.Local = true; - else - asset.Local = false; - - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); + asset.Data = (byte[])dbReader["data"]; + asset.Description = (string)dbReader["description"]; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + } + } + } + catch (Exception e) + { + m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message); } - dbReader.Close(); - cmd.Dispose(); } - if (asset != null) - UpdateAccessTime(asset); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Reconnecting", assetID); - _dbConnection.Reconnect(); } } return asset; @@ -187,55 +153,57 @@ namespace OpenSim.Data.MySQL /// On failure : Throw an exception and attempt to reconnect to database override public void StoreAsset(AssetBase asset) { - lock (_dbConnection) + lock (m_dbLock) { - _dbConnection.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand( - "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", - _dbConnection.Connection); + MySqlCommand cmd = + new MySqlCommand( + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", + dbcon); - string assetName = asset.Name; - if (asset.Name.Length > 64) - { - assetName = asset.Name.Substring(0, 64); - m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); - } - - string assetDescription = asset.Description; - if (asset.Description.Length > 64) - { - assetDescription = asset.Description.Substring(0, 64); - m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); - } - - // need to ensure we dispose - try - { - using (cmd) + string assetName = asset.Name; + if (asset.Name.Length > 64) { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?name", assetName); - cmd.Parameters.AddWithValue("?description", assetDescription); - cmd.Parameters.AddWithValue("?assetType", asset.Type); - cmd.Parameters.AddWithValue("?local", asset.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Temporary); - cmd.Parameters.AddWithValue("?create_time", now); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.Parameters.AddWithValue("?data", asset.Data); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + assetName = asset.Name.Substring(0, 64); + m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + } + + string assetDescription = asset.Description; + if (asset.Description.Length > 64) + { + assetDescription = asset.Description.Substring(0, 64); + m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + } + + // need to ensure we dispose + try + { + using (cmd) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?name", assetName); + cmd.Parameters.AddWithValue("?description", assetDescription); + cmd.Parameters.AddWithValue("?assetType", asset.Type); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?create_time", now); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); } - } - catch (Exception e) - { - m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Attempting reconnect. Error: {2}", - asset.FullID, asset.Name, e.Message); - _dbConnection.Reconnect(); } } } @@ -245,35 +213,36 @@ namespace OpenSim.Data.MySQL // Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph return; - lock (_dbConnection) + lock (m_dbLock) { - _dbConnection.CheckConnection(); - - MySqlCommand cmd = - new MySqlCommand("update assets set access_time=?access_time where id=?id", - _dbConnection.Connection); - - // need to ensure we dispose - try + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (cmd) + dbcon.Open(); + MySqlCommand cmd = + new MySqlCommand("update assets set access_time=?access_time where id=?id", + dbcon); + + // need to ensure we dispose + try + { + using (cmd) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + } + catch (Exception e) { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + m_log.ErrorFormat( + "[ASSETS DB]: " + + "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); } } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: " + - "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); - _dbConnection.Reconnect(); - } } } @@ -287,37 +256,30 @@ namespace OpenSim.Data.MySQL { bool assetExists = false; - lock (_dbConnection) + lock (m_dbLock) { - _dbConnection.CheckConnection(); - - MySqlCommand cmd = - new MySqlCommand( - "SELECT id FROM assets WHERE id=?id", - _dbConnection.Connection); - - cmd.Parameters.AddWithValue("?id", uuid.ToString()); - - try + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) { - if (dbReader.Read()) + cmd.Parameters.AddWithValue("?id", uuid.ToString()); + + try { - assetExists = true; + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + assetExists = true; + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); } - - dbReader.Close(); - cmd.Dispose(); } } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", uuid); - _dbConnection.Reconnect(); - } } return assetExists; @@ -335,38 +297,39 @@ namespace OpenSim.Data.MySQL { List retList = new List(count); - lock (_dbConnection) + lock (m_dbLock) { - _dbConnection.CheckConnection(); - - MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection); - cmd.Parameters.AddWithValue("?start", start); - cmd.Parameters.AddWithValue("?count", count); - - try + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", dbcon); + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); + + try { - while (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - AssetMetadata metadata = new AssetMetadata(); - metadata.Name = (string) dbReader["name"]; - metadata.Description = (string) dbReader["description"]; - metadata.Type = (sbyte) dbReader["assetType"]; - metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. - metadata.FullID = new UUID((string) dbReader["id"]); - - // Current SHA1s are not stored/computed. - metadata.SHA1 = new byte[] {}; - - retList.Add(metadata); + while (dbReader.Read()) + { + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string)dbReader["name"]; + metadata.Description = (string)dbReader["description"]; + metadata.Type = (sbyte)dbReader["assetType"]; + metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.FullID = new UUID((string)dbReader["id"]); + + // Current SHA1s are not stored/computed. + metadata.SHA1 = new byte[] { }; + + retList.Add(metadata); + } } } - } - catch (Exception e) - { - m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection"); - _dbConnection.Reconnect(); + catch (Exception e) + { + m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + } } } @@ -374,7 +337,5 @@ namespace OpenSim.Data.MySQL } #endregion - - } } diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e508b52..5056aee 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -38,16 +38,22 @@ namespace OpenSim.Data.MySQL public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData { private string m_Realm; - private List m_ColumnNames = null; - private int m_LastExpire = 0; + private List m_ColumnNames; + private int m_LastExpire; + // private string m_connectionString; public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) { m_Realm = realm; + m_connectionString = connectionString; - Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); + m.Update(); + } } public AuthenticationData Get(UUID principalID) @@ -55,45 +61,42 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - MySqlCommand cmd = new MySqlCommand( - "select * from `"+m_Realm+"` where UUID = ?principalID" - ); - - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - - IDataReader result = ExecuteReader(cmd); - - if (result.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - ret.PrincipalID = principalID; + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); + IDataReader result = cmd.ExecuteReader(); - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) + if (result.Read()) { - if (s == "UUID") - continue; + ret.PrincipalID = principalID; - ret.Data[s] = result[s].ToString(); - } + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); - result.Close(); - CloseReaderCommand(cmd); + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } - return ret; - } + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; - result.Close(); - CloseReaderCommand(cmd); + ret.Data[s] = result[s].ToString(); + } - return null; + return ret; + } + else + { + return null; + } + } } public bool Store(AuthenticationData data) diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e8694fc..2eae2d8 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -44,7 +44,6 @@ namespace OpenSim.Data.MySQL private const string m_waitTimeoutSelect = "select @@wait_timeout"; - private MySqlConnection m_connection; private string m_connectionString; private long m_waitTimeout; private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; @@ -67,24 +66,26 @@ namespace OpenSim.Data.MySQL m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); } - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); - GetWaitTimeout(); - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_connection, assem, "EstateStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + Assembly assem = GetType().Assembly; + Migration m = new Migration(dbcon, assem, "EstateStore"); + m.Update(); - Type t = typeof(EstateSettings); - m_Fields = t.GetFields(BindingFlags.NonPublic | - BindingFlags.Instance | - BindingFlags.DeclaredOnly); + Type t = typeof(EstateSettings); + m_Fields = t.GetFields(BindingFlags.NonPublic | + BindingFlags.Instance | + BindingFlags.DeclaredOnly); - foreach (FieldInfo f in m_Fields) - { - if (f.Name.Substring(0, 2) == "m_") - m_FieldMap[f.Name.Substring(2)] = f; + foreach (FieldInfo f in m_Fields) + { + if (f.Name.Substring(0, 2) == "m_") + m_FieldMap[f.Name.Substring(2)] = f; + } } } @@ -95,47 +96,29 @@ namespace OpenSim.Data.MySQL protected void GetWaitTimeout() { - MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, - m_connection); - - using (MySqlDataReader dbReader = - cmd.ExecuteReader(CommandBehavior.SingleRow)) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - if (dbReader.Read()) + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * - TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * + TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + } } - dbReader.Close(); - cmd.Dispose(); - } - - m_lastConnectionUse = DateTime.Now.Ticks; - - m_log.DebugFormat( - "[REGION DB]: Connection wait timeout {0} seconds", - m_waitTimeout / TimeSpan.TicksPerSecond); - } - - protected void CheckConnection() - { - long timeNow = DateTime.Now.Ticks; - if (timeNow - m_lastConnectionUse > m_waitTimeout || - m_connection.State != ConnectionState.Open) - { - m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); + m_lastConnectionUse = DateTime.Now.Ticks; - lock (m_connection) - { - m_connection.Close(); - m_connection = new MySqlConnection(m_connectionString); - m_connection.Open(); - } + m_log.DebugFormat( + "[REGION DB]: Connection wait timeout {0} seconds", + m_waitTimeout / TimeSpan.TicksPerSecond); } - - m_lastConnectionUse = timeNow; } public EstateSettings LoadEstateSettings(UUID regionID) @@ -143,114 +126,111 @@ namespace OpenSim.Data.MySQL EstateSettings es = new EstateSettings(); es.OnSave += StoreEstateSettings; - string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; + string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; - CheckConnection(); + bool migration = true; - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - - IDataReader r = cmd.ExecuteReader(); - - if (r.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - foreach (string name in FieldList) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - if (m_FieldMap[name].GetValue(es) is bool) - { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); - } - else if (m_FieldMap[name].GetValue(es) is UUID) - { - UUID uuid = UUID.Zero; + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); - } - else + using (IDataReader r = cmd.ExecuteReader()) { - m_FieldMap[name].SetValue(es, r[name]); + if (r.Read()) + { + migration = false; + + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) + { + int v = Convert.ToInt32(r[name]); + if (v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else if (m_FieldMap[name].GetValue(es) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(r[name].ToString(), out uuid); + m_FieldMap[name].SetValue(es, uuid); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); + } + } + } } } - r.Close(); - } - else - { - // Migration case - // - r.Close(); - - List names = new List(FieldList); - names.Remove("EstateID"); + if (migration) + { + // Migration case + List names = new List(FieldList); - sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; + names.Remove("EstateID"); - cmd.CommandText = sql; - cmd.Parameters.Clear(); + sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); - else - cmd.Parameters.AddWithValue("?" + name, "0"); - } - else + using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + cmd.CommandText = sql; + cmd.Parameters.Clear(); + + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); + else + cmd.Parameters.AddWithValue("?" + name, "0"); + } + else + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "select LAST_INSERT_ID() as id"; + cmd.Parameters.Clear(); + + using (IDataReader r = cmd.ExecuteReader()) + { + r.Read(); + es.EstateID = Convert.ToUInt32(r["id"]); + } + + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + + // This will throw on dupe key + try { cmd.ExecuteNonQuery(); } + catch (Exception) { } + + // Munge and transfer the ban list + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + + try { cmd.ExecuteNonQuery(); } + catch (Exception) { } + + es.Save(); } } - - cmd.ExecuteNonQuery(); - - cmd.CommandText = "select LAST_INSERT_ID() as id"; - cmd.Parameters.Clear(); - - r = cmd.ExecuteReader(); - - r.Read(); - - es.EstateID = Convert.ToUInt32(r["id"]); - - r.Close(); - - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - - // This will throw on dupe key - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - } - - // Munge and transfer the ban list - // - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - } - - es.Save(); } LoadBanList(es); @@ -265,29 +245,33 @@ namespace OpenSim.Data.MySQL { string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")"; - CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = m_connection.CreateCommand(); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = sql; - cmd.CommandText = sql; + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); + else + cmd.Parameters.AddWithValue("?" + name, "0"); + } + else + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + } + } - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); - else - cmd.Parameters.AddWithValue("?" + name, "0"); - } - else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + cmd.ExecuteNonQuery(); } } - cmd.ExecuteNonQuery(); - SaveBanList(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); @@ -298,77 +282,89 @@ namespace OpenSim.Data.MySQL { es.ClearBans(); - CheckConnection(); - - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - EstateBan eb = new EstateBan(); + dbcon.Open(); - UUID uuid = new UUID(); - UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - eb.BannedUserID = uuid; - eb.BannedHostAddress = "0.0.0.0"; - eb.BannedHostIPMask = "0.0.0.0"; - es.AddBan(eb); + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + EstateBan eb = new EstateBan(); + + UUID uuid = new UUID(); + UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + + eb.BannedUserID = uuid; + eb.BannedHostAddress = "0.0.0.0"; + eb.BannedHostIPMask = "0.0.0.0"; + es.AddBan(eb); + } + } + } } - r.Close(); } private void SaveBanList(EstateSettings es) { - CheckConnection(); - - MySqlCommand cmd = m_connection.CreateCommand(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); + cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; - foreach (EstateBan b in es.EstateBans) - { - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + foreach (EstateBan b in es.EstateBans) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } } } void SaveUUIDList(uint EstateID, string table, UUID[] data) { - CheckConnection(); - - MySqlCommand cmd = m_connection.CreateCommand(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); + cmd.Parameters.Clear(); - cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; + cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; - foreach (UUID uuid in data) - { - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); + foreach (UUID uuid in data) + { + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } } } @@ -376,25 +372,29 @@ namespace OpenSim.Data.MySQL { List uuids = new List(); - CheckConnection(); - - MySqlCommand cmd = m_connection.CreateCommand(); - - cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - IDataReader r = cmd.ExecuteReader(); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID); - while (r.Read()) - { - // EstateBan eb = new EstateBan(); + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + // EstateBan eb = new EstateBan(); - UUID uuid = new UUID(); - UUID.TryParse(r["uuid"].ToString(), out uuid); + UUID uuid = new UUID(); + UUID.TryParse(r["uuid"].ToString(), out uuid); - uuids.Add(uuid); + uuids.Add(uuid); + } + } + } } - r.Close(); return uuids.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index fca0ca5..3fdcf1e 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,12 +40,16 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - protected MySqlConnection m_Connection; + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger( + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + protected string m_connectionString; + protected object m_dbLock = new object(); protected MySqlFramework(string connectionString) { - m_Connection = new MySqlConnection(connectionString); - m_Connection.Open(); + m_connectionString = connectionString; } ////////////////////////////////////////////////////////////// @@ -55,64 +59,24 @@ namespace OpenSim.Data.MySQL // protected int ExecuteNonQuery(MySqlCommand cmd) { - lock (m_Connection) + lock (m_dbLock) { - cmd.Connection = m_Connection; - - bool errorSeen = false; - - while (true) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { + dbcon.Open(); + cmd.Connection = dbcon; + try { return cmd.ExecuteNonQuery(); } - catch (MySqlException e) - { - if (errorSeen) - throw; - - // This is "Server has gone away" and "Server lost" - // - if (e.Number == 2006 || e.Number == 2013) - { - errorSeen = true; - - m_Connection.Close(); - MySqlConnection newConnection = - (MySqlConnection)((ICloneable)m_Connection).Clone(); - m_Connection.Dispose(); - m_Connection = newConnection; - m_Connection.Open(); - - cmd.Connection = m_Connection; - } - else - throw; - } catch (Exception e) { + m_log.Error(e.Message, e); return 0; } } } } - - protected IDataReader ExecuteReader(MySqlCommand cmd) - { - MySqlConnection newConnection = - (MySqlConnection)((ICloneable)m_Connection).Clone(); - newConnection.Open(); - - cmd.Connection = newConnection; - return cmd.ExecuteReader(); - } - - protected void CloseReaderCommand(MySqlCommand cmd) - { - cmd.Connection.Close(); - cmd.Connection.Dispose(); - cmd.Dispose(); - } } } diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index fdb98eb..698bf52 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -54,12 +54,16 @@ namespace OpenSim.Data.MySQL string realm, string storeName) : base(connectionString) { m_Realm = realm; + m_connectionString = connectionString; + if (storeName != String.Empty) { - Assembly assem = GetType().Assembly; - - Migration m = new Migration(m_Connection, assem, storeName); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, GetType().Assembly, storeName); + m.Update(); + } } Type t = typeof(T); @@ -107,147 +111,160 @@ namespace OpenSim.Data.MySQL List terms = new List(); - MySqlCommand cmd = new MySqlCommand(); - - for (int i = 0 ; i < fields.Length ; i++) + using (MySqlCommand cmd = new MySqlCommand()) { - cmd.Parameters.AddWithValue(fields[i], keys[i]); - terms.Add("`" + fields[i] + "` = ?" + fields[i]); - } - - string where = String.Join(" and ", terms.ToArray()); + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add("`" + fields[i] + "` = ?" + fields[i]); + } - string query = String.Format("select * from {0} where {1}", - m_Realm, where); + string where = String.Join(" and ", terms.ToArray()); - cmd.CommandText = query; + string query = String.Format("select * from {0} where {1}", + m_Realm, where); - return DoQuery(cmd); + cmd.CommandText = query; + + return DoQuery(cmd); + } } protected T[] DoQuery(MySqlCommand cmd) { - IDataReader reader = ExecuteReader(cmd); - if (reader == null) - return new T[0]; - - CheckColumnNames(reader); - List result = new List(); - while (reader.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - T row = new T(); + dbcon.Open(); + cmd.Connection = dbcon; - foreach (string name in m_Fields.Keys) + using (IDataReader reader = cmd.ExecuteReader()) { - if (m_Fields[name].GetValue(row) is bool) - { - int v = Convert.ToInt32(reader[name]); - m_Fields[name].SetValue(row, v != 0 ? true : false); - } - else if (m_Fields[name].GetValue(row) is UUID) - { - UUID uuid = UUID.Zero; + if (reader == null) + return new T[0]; - UUID.TryParse(reader[name].ToString(), out uuid); - m_Fields[name].SetValue(row, uuid); - } - else if (m_Fields[name].GetValue(row) is int) - { - int v = Convert.ToInt32(reader[name]); - m_Fields[name].SetValue(row, v); - } - else - { - m_Fields[name].SetValue(row, reader[name]); - } - } - - if (m_DataField != null) - { - Dictionary data = - new Dictionary(); + CheckColumnNames(reader); - foreach (string col in m_ColumnNames) + while (reader.Read()) { - data[col] = reader[col].ToString(); - if (data[col] == null) - data[col] = String.Empty; + T row = new T(); + + foreach (string name in m_Fields.Keys) + { + if (m_Fields[name].GetValue(row) is bool) + { + int v = Convert.ToInt32(reader[name]); + m_Fields[name].SetValue(row, v != 0 ? true : false); + } + else if (m_Fields[name].GetValue(row) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(reader[name].ToString(), out uuid); + m_Fields[name].SetValue(row, uuid); + } + else if (m_Fields[name].GetValue(row) is int) + { + int v = Convert.ToInt32(reader[name]); + m_Fields[name].SetValue(row, v); + } + else + { + m_Fields[name].SetValue(row, reader[name]); + } + } + + if (m_DataField != null) + { + Dictionary data = + new Dictionary(); + + foreach (string col in m_ColumnNames) + { + data[col] = reader[col].ToString(); + if (data[col] == null) + data[col] = String.Empty; + } + + m_DataField.SetValue(row, data); + } + + result.Add(row); } - - m_DataField.SetValue(row, data); } - - result.Add(row); } - CloseReaderCommand(cmd); - return result.ToArray(); } public T[] Get(string where) { - MySqlCommand cmd = new MySqlCommand(); - - string query = String.Format("select * from {0} where {1}", - m_Realm, where); - - cmd.CommandText = query; - - return DoQuery(cmd); + using (MySqlCommand cmd = new MySqlCommand()) + { + + string query = String.Format("select * from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + return DoQuery(cmd); + } } public bool Store(T row) { - MySqlCommand cmd = new MySqlCommand(); + using (MySqlCommand cmd = new MySqlCommand()) + { - string query = ""; - List names = new List(); - List values = new List(); + string query = ""; + List names = new List(); + List values = new List(); - foreach (FieldInfo fi in m_Fields.Values) - { - names.Add(fi.Name); - values.Add("?" + fi.Name); - cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); - } + foreach (FieldInfo fi in m_Fields.Values) + { + names.Add(fi.Name); + values.Add("?" + fi.Name); + cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); + } - if (m_DataField != null) - { - Dictionary data = + if (m_DataField != null) + { + Dictionary data = (Dictionary)m_DataField.GetValue(row); - foreach (KeyValuePair kvp in data) - { - names.Add(kvp.Key); - values.Add("?" + kvp.Key); - cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value); + foreach (KeyValuePair kvp in data) + { + names.Add(kvp.Key); + values.Add("?" + kvp.Key); + cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value); + } } - } - query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; + query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; - cmd.CommandText = query; + cmd.CommandText = query; - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; - return false; + return false; + } } public bool Delete(string field, string val) { - MySqlCommand cmd = new MySqlCommand(); + using (MySqlCommand cmd = new MySqlCommand()) + { - cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); - cmd.Parameters.AddWithValue(field, val); + cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); + cmd.Parameters.AddWithValue(field, val); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; - return false; + return false; + } } } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 1ec2609..f4e7b85 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -31,6 +31,7 @@ using System.Data; using System.Reflection; using System.Threading; using log4net; +using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; @@ -43,49 +44,9 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - /// - /// MySQL Database Manager - /// - private MySQLManager database; - - - /// - /// Better DB manager. Swap-in replacement too. - /// - public Dictionary m_dbconnections = new Dictionary(); - - public int m_maxConnections = 10; - public int m_lastConnect; - - public MySQLSuperManager GetLockedConnection() - { - int lockedCons = 0; - while (true) - { - m_lastConnect++; - - // Overflow protection - if (m_lastConnect == int.MaxValue) - m_lastConnect = 0; - - MySQLSuperManager x = m_dbconnections[m_lastConnect % m_maxConnections]; - if (!x.Locked) - { - x.GetLock(); - return x; - } - - lockedCons++; - if (lockedCons > m_maxConnections) - { - lockedCons = 0; - Thread.Sleep(1000); // Wait some time before searching them again. - m_log.Debug( - "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); - } - } - } - + private MySQLManager m_database; + private object m_dbLock = new object(); + private string m_connectionString; override public void Initialise() { @@ -106,49 +67,17 @@ namespace OpenSim.Data.MySQL /// connect string. override public void Initialise(string connect) { - if (connect != String.Empty) - { - database = new MySQLManager(connect); + m_connectionString = connect; + m_database = new MySQLManager(connect); - m_log.Info("Creating " + m_maxConnections + " DB connections..."); - for (int i = 0; i < m_maxConnections; i++) - { - m_log.Info("Connecting to DB... [" + i + "]"); - MySQLSuperManager msm = new MySQLSuperManager(); - msm.Manager = new MySQLManager(connect); - m_dbconnections.Add(i, msm); - } + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; - } - else + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); - string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); - string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - - database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, - settingPooling, settingPort); - - m_log.Info("Creating " + m_maxConnections + " DB connections..."); - for (int i = 0; i < m_maxConnections; i++) - { - m_log.Info("Connecting to DB... [" + i + "]"); - MySQLSuperManager msm = new MySQLSuperManager(); - msm.Manager = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, - settingPooling, settingPort); - m_dbconnections.Add(i, msm); - } + Migration m = new Migration(dbcon, assem, "GridStore"); + m.Update(); } - - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "GridStore"); - m.Update(); } /// @@ -156,7 +85,6 @@ namespace OpenSim.Data.MySQL /// override public void Dispose() { - database.Close(); } /// @@ -187,8 +115,6 @@ namespace OpenSim.Data.MySQL /// Array of sim profiles override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) { - MySQLSuperManager dbm = GetLockedConnection(); - try { Dictionary param = new Dictionary(); @@ -197,35 +123,33 @@ namespace OpenSim.Data.MySQL param["?xmax"] = xmax.ToString(); param["?ymax"] = ymax.ToString(); - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", - param); - IDataReader reader = result.ExecuteReader(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand result = m_database.Query(dbcon, + "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row; - RegionProfileData row; + List rows = new List(); - List rows = new List(); + while ((row = m_database.readSimRow(reader)) != null) + rows.Add(row); - while ((row = dbm.Manager.readSimRow(reader)) != null) - { - rows.Add(row); + return rows.ToArray(); + } + } } - reader.Close(); - result.Dispose(); - - return rows.ToArray(); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } /// @@ -236,42 +160,38 @@ namespace OpenSim.Data.MySQL /// A list of sim profiles override public List GetRegionsByName(string namePrefix, uint maxNum) { - MySQLSuperManager dbm = GetLockedConnection(); - try { Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; - IDbCommand result = - dbm.Manager.Query( + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionName LIKE ?name", - param); - IDataReader reader = result.ExecuteReader(); + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row; - RegionProfileData row; + List rows = new List(); - List rows = new List(); + while (rows.Count < maxNum && (row = m_database.readSimRow(reader)) != null) + rows.Add(row); - while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) - { - rows.Add(row); + return rows; + } + } } - reader.Close(); - result.Dispose(); - - return rows; } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } /// @@ -281,32 +201,30 @@ namespace OpenSim.Data.MySQL /// Sim profile override public RegionProfileData GetProfileByHandle(ulong handle) { - MySQLSuperManager dbm = GetLockedConnection(); - try { Dictionary param = new Dictionary(); - param["?handle"] = handle.ToString(); - - IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); - IDataReader reader = result.ExecuteReader(); + param["?handle"] = handle.ToString(); - RegionProfileData row = dbm.Manager.readSimRow(reader); - reader.Close(); - result.Dispose(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - return row; + using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionHandle = ?handle", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row = m_database.readSimRow(reader); + return row; + } + } } + } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } /// @@ -316,30 +234,29 @@ namespace OpenSim.Data.MySQL /// The sim profile override public RegionProfileData GetProfileByUUID(UUID uuid) { - MySQLSuperManager dbm = GetLockedConnection(); - try { Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + param["?uuid"] = uuid.ToString(); - IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - - RegionProfileData row = dbm.Manager.readSimRow(reader); - reader.Close(); - result.Dispose(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - return row; + using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE uuid = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row = m_database.readSimRow(reader); + return row; + } + } } + } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; - } finally - { - dbm.Release(); } } @@ -351,37 +268,36 @@ namespace OpenSim.Data.MySQL { if (regionName.Length > 2) { - MySQLSuperManager dbm = GetLockedConnection(); - try { Dictionary param = new Dictionary(); // Add % because this is a like query. param["?regionName"] = regionName + "%"; - // Order by statement will return shorter matches first. Only returns one record or no record. - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", - param); - IDataReader reader = result.ExecuteReader(); - RegionProfileData row = dbm.Manager.readSimRow(reader); - reader.Close(); - result.Dispose(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - return row; + // Order by statement will return shorter matches first. Only returns one record or no record. + using (IDbCommand result = m_database.Query(dbcon, + "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + RegionProfileData row = m_database.readSimRow(reader); + return row; + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } + m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } @@ -393,17 +309,16 @@ namespace OpenSim.Data.MySQL /// Successful? override public DataResponse StoreProfile(RegionProfileData profile) { - MySQLSuperManager dbm = GetLockedConnection(); - try { - if (dbm.Manager.insertRegion(profile)) - { + try + { + if (m_database.insertRegion(profile)) return DataResponse.RESPONSE_OK; - } - return DataResponse.RESPONSE_ERROR; + else + return DataResponse.RESPONSE_ERROR; } - finally + catch { - dbm.Release(); + return DataResponse.RESPONSE_ERROR; } } @@ -415,18 +330,16 @@ namespace OpenSim.Data.MySQL //public DataResponse DeleteProfile(RegionProfileData profile) override public DataResponse DeleteProfile(string uuid) { - MySQLSuperManager dbm = GetLockedConnection(); - - - try { - if (dbm.Manager.deleteRegion(uuid)) - { + try + { + if (m_database.deleteRegion(uuid)) return DataResponse.RESPONSE_OK; - } - return DataResponse.RESPONSE_ERROR; - } finally + else + return DataResponse.RESPONSE_ERROR; + } + catch { - dbm.Release(); + return DataResponse.RESPONSE_ERROR; } } @@ -477,33 +390,32 @@ namespace OpenSim.Data.MySQL /// override public ReservationData GetReservationAtPoint(uint x, uint y) { - MySQLSuperManager dbm = GetLockedConnection(); - try { Dictionary param = new Dictionary(); - param["?x"] = x.ToString(); - param["?y"] = y.ToString(); - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", - param); - IDataReader reader = result.ExecuteReader(); - - ReservationData row = dbm.Manager.readReservationRow(reader); - reader.Close(); - result.Dispose(); - - return row; + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand result = m_database.Query(dbcon, + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + ReservationData row = m_database.readReservationRow(reader); + return row; + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; - } finally - { - dbm.Release(); } } } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 4b71e39..192deb2 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -26,7 +26,6 @@ */ using System; -using System.IO; using System.Collections.Generic; using System.Reflection; using log4net; @@ -44,14 +43,10 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - /// - /// The database manager - /// - private MySQLManager database; + private string m_connectionString; + private object m_dbLock = new object(); - private bool rollbackStore = false; - private bool opengridmode = false; - private string rollbackDir = ""; + public string Version { get { return "1.0.0.0"; } } public void Initialise() { @@ -72,37 +67,17 @@ namespace OpenSim.Data.MySQL /// connect string public void Initialise(string connect) { - if (connect != String.Empty) - { - database = new MySQLManager(connect); - } - else - { - m_log.Warn("Reverting to deprecated mysql_connection.ini file for connection info"); - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); - string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); - string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - - rollbackDir = GridDataMySqlFile.ParseFileReadValue("rollbackdir"); - rollbackStore = GridDataMySqlFile.ParseFileReadValue("rollback") == "true"; - opengridmode = GridDataMySqlFile.ParseFileReadValue("opengridmode") == "true"; - - if (rollbackStore) - m_log.Warn("[MysqlInventory] Enabling rollback mode in: " + rollbackDir); - - database = - new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, - settingPort); - } + m_connectionString = connect; // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "InventoryStore"); - m.Update(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, assem, "InventoryStore"); + m.Update(); + } } /// @@ -124,15 +99,6 @@ namespace OpenSim.Data.MySQL } /// - /// Returns the version of this DB provider - /// - /// A string containing the DB provider version - public string Version - { - get { return database.getVersion(); } - } - - /// /// Returns a list of items in a specified folder /// /// The folder to search @@ -141,36 +107,37 @@ namespace OpenSim.Data.MySQL { try { - lock (database) + lock (m_dbLock) { List items = new List(); - database.CheckConnection(); - - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", folderID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); - - while (reader.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - // A null item (because something went wrong) breaks everything in the folder - InventoryItemBase item = readInventoryItem(reader); - if (item != null) - items.Add(item); - } + dbcon.Open(); - reader.Close(); - result.Dispose(); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + // A null item (because something went wrong) breaks everything in the folder + InventoryItemBase item = readInventoryItem(reader); + if (item != null) + items.Add(item); + } - return items; + return items; + } + } + } } } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -184,33 +151,33 @@ namespace OpenSim.Data.MySQL { try { - lock (database) + lock (m_dbLock) { - database.CheckConnection(); - - MySqlCommand result = - new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - MySqlDataReader reader = result.ExecuteReader(); - - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + using (MySqlCommand result = new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - return items; + return items; + } + } + } } } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -225,46 +192,44 @@ namespace OpenSim.Data.MySQL { try { - lock (database) + lock (m_dbLock) { - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand result = - new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + using (MySqlCommand result = new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - MySqlDataReader reader = result.ExecuteReader(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + InventoryFolderBase rootFolder = null; - InventoryFolderBase rootFolder = null; + // There should only ever be one root folder for a user. However, if there's more + // than one we'll simply use the first one rather than failing. It would be even + // nicer to print some message to this effect, but this feels like it's too low a + // to put such a message out, and it's too minor right now to spare the time to + // suitably refactor. + if (items.Count > 0) + rootFolder = items[0]; - // There should only ever be one root folder for a user. However, if there's more - // than one we'll simply use the first one rather than failing. It would be even - // nicer to print some message to this effect, but this feels like it's too low a - // to put such a message out, and it's too minor right now to spare the time to - // suitably refactor. - if (items.Count > 0) - { - rootFolder = items[0]; + return rootFolder; + } + } } - - reader.Close(); - result.Dispose(); - - return rootFolder; } } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); - throw; + m_log.Error(e.Message, e); + return null; } } @@ -279,31 +244,31 @@ namespace OpenSim.Data.MySQL { try { - lock (database) + lock (m_dbLock) { - database.CheckConnection(); - - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - List items = new List(); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + using (MySqlDataReader reader = result.ExecuteReader()) + { + List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - reader.Close(); - result.Dispose(); - - return items; + return items; + } + } + } } } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -378,29 +343,31 @@ namespace OpenSim.Data.MySQL { try { - lock (database) + lock (m_dbLock) { - database.CheckConnection(); - - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); - result.Parameters.AddWithValue("?uuid", itemID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - InventoryItemBase item = null; - if (reader.Read()) - item = readInventoryItem(reader); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", itemID.ToString()); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + InventoryItemBase item = null; + if (reader.Read()) + item = readInventoryItem(reader); - return item; + return item; + } + } + } } } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } return null; } @@ -425,7 +392,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } return null; @@ -441,151 +408,35 @@ namespace OpenSim.Data.MySQL { try { - lock (database) + lock (m_dbLock) { - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand result = - new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); - result.Parameters.AddWithValue("?uuid", folderID.ToString()); - MySqlDataReader reader = result.ExecuteReader(); + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", folderID.ToString()); - InventoryFolderBase folder = null; - if (reader.Read()) - folder = readInventoryFolder(reader); - reader.Close(); - result.Dispose(); + using (MySqlDataReader reader = result.ExecuteReader()) + { + InventoryFolderBase folder = null; + if (reader.Read()) + folder = readInventoryFolder(reader); - return folder; + return folder; + } + } + } } } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } - #region Inventory Rollback-via-.sql Support - /// - /// Not a good SQL escape function, but it'll do the job (if mutilate the data.) - /// Someone may want to write something better here. - /// - /// - /// - private static string cheapSQLescape(string str) - { - str = str.Replace("\\", ""); - str = str.Replace("'", ""); - str = str.Replace("\"", ""); - return "'" + str + "'"; - } - - private static string InventoryItemToSql(InventoryItemBase item) - { - string sql = - "REPLACE /*! INVITEM AT ***$SUBS$*** */ INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName" - + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType" - + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType" - + ", creationDate, groupID, groupOwned, flags) VALUES "; - sql += - "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription" - + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID" - + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate" - + ", ?groupID, ?groupOwned, ?flags);\r\n"; - - string itemName = item.Name; - string itemDesc = item.Description; - - sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString()); - - sql = sql.Replace("?inventoryID", cheapSQLescape(item.ID.ToString())); - sql = sql.Replace("?assetID", cheapSQLescape(item.AssetID.ToString())); - sql = sql.Replace("?assetType", cheapSQLescape(item.AssetType.ToString())); - sql = sql.Replace("?parentFolderID", cheapSQLescape(item.Folder.ToString())); - sql = sql.Replace("?avatarID", cheapSQLescape(item.Owner.ToString())); - sql = sql.Replace("?inventoryName", cheapSQLescape(itemName)); - sql = sql.Replace("?inventoryDescription", cheapSQLescape(itemDesc)); - sql = sql.Replace("?inventoryNextPermissions", cheapSQLescape(item.NextPermissions.ToString())); - sql = sql.Replace("?inventoryCurrentPermissions", cheapSQLescape(item.CurrentPermissions.ToString())); - sql = sql.Replace("?invType", cheapSQLescape(item.InvType.ToString())); - sql = sql.Replace("?creatorID", cheapSQLescape(item.CreatorId)); - sql = sql.Replace("?inventoryBasePermissions", cheapSQLescape(item.BasePermissions.ToString())); - sql = sql.Replace("?inventoryEveryOnePermissions", cheapSQLescape(item.EveryOnePermissions.ToString())); - sql = sql.Replace("?inventoryGroupPermissions", cheapSQLescape(item.GroupPermissions.ToString())); - sql = sql.Replace("?salePrice", cheapSQLescape(item.SalePrice.ToString())); - sql = sql.Replace("?saleType", cheapSQLescape(unchecked((sbyte)item.SaleType).ToString())); - sql = sql.Replace("?creationDate", cheapSQLescape(item.CreationDate.ToString())); - sql = sql.Replace("?groupID", cheapSQLescape(item.GroupID.ToString())); - sql = sql.Replace("?groupOwned", cheapSQLescape(item.GroupOwned.ToString())); - sql = sql.Replace("?flags", cheapSQLescape(item.Flags.ToString())); - - return sql; - } - - private static string InventoryFolderToSql(InventoryFolderBase folder) - { - string sql = - "REPLACE /*! INVFOLDER AT ***$SUBS$*** */ INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; - sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version);\r\n"; - - string folderName = folder.Name; - - sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString()); - - sql = sql.Replace("?folderID", cheapSQLescape(folder.ID.ToString())); - sql = sql.Replace("?agentID", cheapSQLescape(folder.Owner.ToString())); - sql = sql.Replace("?parentFolderID", cheapSQLescape(folder.ParentID.ToString())); - sql = sql.Replace("?folderName", cheapSQLescape(folderName)); - sql = sql.Replace("?type", cheapSQLescape(folder.Type.ToString())); - sql = sql.Replace("?version", cheapSQLescape(folder.Version.ToString())); - - return sql; - } - - private static string getRollbackFolderDate() - { - return DateTime.UtcNow.Year.ToString() + "-" + DateTime.UtcNow.Month.ToString() + "-" + - DateTime.UtcNow.Day.ToString(); - } - - private void StoreRollbackItem(UUID ItemID) - { - if (rollbackStore == true) - { - string todaysPath = RollbackGetTodaysPath(); - - InventoryItemBase imb = getInventoryItem(ItemID); - string sql = InventoryItemToSql(imb); - File.AppendAllText(Path.Combine(todaysPath, imb.Owner.ToString()), sql); - } - } - - private void StoreRollbackFolder(UUID FolderID) - { - if (rollbackStore == true) - { - string todaysPath = RollbackGetTodaysPath(); - - InventoryFolderBase ifb = getInventoryFolder(FolderID); - string sql = InventoryFolderToSql(ifb); - File.AppendAllText(Path.Combine(todaysPath, ifb.Owner.ToString()), sql); - } - } - - private string RollbackGetTodaysPath() - { - if (!Directory.Exists(rollbackDir)) - Directory.CreateDirectory(rollbackDir); - - string todaysPath = Path.Combine(rollbackDir, getRollbackFolderDate()); - if (!Directory.Exists(todaysPath)) - Directory.CreateDirectory(todaysPath); - return todaysPath; - } - #endregion - /// /// Adds a specified item to the database /// @@ -619,46 +470,48 @@ namespace OpenSim.Data.MySQL try { - database.CheckConnection(); - - MySqlCommand result = new MySqlCommand(sql, database.Connection); - result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); - result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); - result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); - result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); - result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); - result.Parameters.AddWithValue("?inventoryName", itemName); - result.Parameters.AddWithValue("?inventoryDescription", itemDesc); - result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); - result.Parameters.AddWithValue("?inventoryCurrentPermissions", - item.CurrentPermissions.ToString()); - result.Parameters.AddWithValue("?invType", item.InvType); - result.Parameters.AddWithValue("?creatorID", item.CreatorId); - result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); - result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); - result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); - result.Parameters.AddWithValue("?salePrice", item.SalePrice); - result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); - result.Parameters.AddWithValue("?creationDate", item.CreationDate); - result.Parameters.AddWithValue("?groupID", item.GroupID); - result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); - result.Parameters.AddWithValue("?flags", item.Flags); - - lock (database) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - result.ExecuteNonQuery(); - } + dbcon.Open(); + + MySqlCommand result = new MySqlCommand(sql, dbcon); + result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); + result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); + result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); + result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); + result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); + result.Parameters.AddWithValue("?inventoryName", itemName); + result.Parameters.AddWithValue("?inventoryDescription", itemDesc); + result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); + result.Parameters.AddWithValue("?inventoryCurrentPermissions", + item.CurrentPermissions.ToString()); + result.Parameters.AddWithValue("?invType", item.InvType); + result.Parameters.AddWithValue("?creatorID", item.CreatorId); + result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); + result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); + result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); + result.Parameters.AddWithValue("?salePrice", item.SalePrice); + result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); + result.Parameters.AddWithValue("?creationDate", item.CreationDate); + result.Parameters.AddWithValue("?groupID", item.GroupID); + result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); + result.Parameters.AddWithValue("?flags", item.Flags); + + lock (m_dbLock) + { + result.ExecuteNonQuery(); + } - result.Dispose(); + result.Dispose(); - result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", database.Connection); - result.Parameters.AddWithValue("?folderID", item.Folder.ToString -()); - lock (database) - { - result.ExecuteNonQuery(); + result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon); + result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); + lock (m_dbLock) + { + result.ExecuteNonQuery(); + } + result.Dispose(); } - result.Dispose(); } catch (MySqlException e) { @@ -672,8 +525,6 @@ namespace OpenSim.Data.MySQL /// Inventory item to update public void updateInventoryItem(InventoryItemBase item) { - StoreRollbackItem(item.ID); - addInventoryItem(item); } @@ -683,25 +534,24 @@ namespace OpenSim.Data.MySQL /// The inventory item UUID to delete public void deleteInventoryItem(UUID itemID) { - StoreRollbackItem(itemID); - try { - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); - cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); + MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); + cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); - lock (database) - { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + { + cmd.ExecuteNonQuery(); + } } } catch (MySqlException e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } } @@ -732,26 +582,29 @@ namespace OpenSim.Data.MySQL m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder"); } - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = new MySqlCommand(sql, database.Connection); - cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); - cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); - cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); - cmd.Parameters.AddWithValue("?folderName", folderName); - cmd.Parameters.AddWithValue("?type", folder.Type); - cmd.Parameters.AddWithValue("?version", folder.Version); + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); + cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); + cmd.Parameters.AddWithValue("?folderName", folderName); + cmd.Parameters.AddWithValue("?type", folder.Type); + cmd.Parameters.AddWithValue("?version", folder.Version); - try - { - lock (database) + try { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + { + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); } - } - catch (Exception e) - { - m_log.Error(e.ToString()); } } @@ -761,7 +614,6 @@ namespace OpenSim.Data.MySQL /// Folder to update public void updateInventoryFolder(InventoryFolderBase folder) { - StoreRollbackFolder(folder.ID); addInventoryFolder(folder); } @@ -772,27 +624,28 @@ namespace OpenSim.Data.MySQL /// UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID public void moveInventoryFolder(InventoryFolderBase folder) { - StoreRollbackFolder(folder.ID); - string sql = "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = new MySqlCommand(sql, database.Connection); - cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); - cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); - try - { - lock (database) + try { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + { + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); } - } - catch (Exception e) - { - m_log.Error(e.ToString()); } } @@ -836,95 +689,102 @@ namespace OpenSim.Data.MySQL try { List folders = new List(); - Dictionary> hashtable - = new Dictionary>(); ; + Dictionary> hashtable = new Dictionary>(); ; List parentFolder = new List(); - lock (database) - { - MySqlCommand result; - MySqlDataReader reader; - bool buildResultsFromHashTable = false; - - database.CheckConnection(); - - /* Fetch the parent folder from the database to determine the agent ID, and if - * we're querying the root of the inventory folder tree */ - result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - reader = result.ExecuteReader(); - while (reader.Read()) // Should be at most 1 result - parentFolder.Add(readInventoryFolder(reader)); - reader.Close(); - result.Dispose(); + bool buildResultsFromHashTable = false; - if (parentFolder.Count >= 1) // No result means parent folder does not exist + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder + dbcon.Open(); + + /* Fetch the parent folder from the database to determine the agent ID, and if + * we're querying the root of the inventory folder tree */ + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", dbcon)) { - /* Get all of the agent's folders from the database, put them in a list and return it */ - result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - reader = result.ExecuteReader(); - while (reader.Read()) + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list - folders.Add(curFolder); + // Should be at most 1 result + while (reader.Read()) + parentFolder.Add(readInventoryFolder(reader)); } - reader.Close(); - result.Dispose(); - } // if we are querying the root folder - else // else we are querying a subtree of the inventory folder tree + } + + if (parentFolder.Count >= 1) // No result means parent folder does not exist { - /* Get all of the agent's folders from the database, put them all in a hash table - * indexed by their parent ID */ - result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", - database.Connection); - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - reader = result.ExecuteReader(); - while (reader.Read()) + if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling - hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list - else // else current folder has no known (yet) siblings + /* Get all of the agent's folders from the database, put them in a list and return it */ + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", dbcon)) { - List siblingList = new List(); - siblingList.Add(curFolder); - // Current folder has no known (yet) siblings - hashtable.Add(curFolder.ParentID, siblingList); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list + folders.Add(curFolder); + } + } + } + } // if we are querying the root folder + else // else we are querying a subtree of the inventory folder tree + { + /* Get all of the agent's folders from the database, put them all in a hash table + * indexed by their parent ID */ + using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", dbcon)) + { + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + + using (MySqlDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling + hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list + else // else current folder has no known (yet) siblings + { + List siblingList = new List(); + siblingList.Add(curFolder); + // Current folder has no known (yet) siblings + hashtable.Add(curFolder.ParentID, siblingList); + } + } // while more items to read from the database + } } - } // while more items to read from the database - reader.Close(); - result.Dispose(); - // Set flag so we know we need to build the results from the hash table after - // we unlock the database - buildResultsFromHashTable = true; + // Set flag so we know we need to build the results from the hash table after + // we unlock the database + buildResultsFromHashTable = true; - } // else we are querying a subtree of the inventory folder tree - } // if folder parentID exists + } // else we are querying a subtree of the inventory folder tree + } // if folder parentID exists - if (buildResultsFromHashTable) - { - /* We have all of the user's folders stored in a hash table indexed by their parent ID - * and we need to return the requested subtree. We will build the requested subtree - * by performing a breadth-first-search on the hash table */ - if (hashtable.ContainsKey(parentID)) - folders.AddRange(hashtable[parentID]); - for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static - if (hashtable.ContainsKey(folders[i].ID)) - folders.AddRange(hashtable[folders[i].ID]); + if (buildResultsFromHashTable) + { + /* We have all of the user's folders stored in a hash table indexed by their parent ID + * and we need to return the requested subtree. We will build the requested subtree + * by performing a breadth-first-search on the hash table */ + if (hashtable.ContainsKey(parentID)) + folders.AddRange(hashtable[parentID]); + for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static + if (hashtable.ContainsKey(folders[i].ID)) + folders.AddRange(hashtable[folders[i].ID]); + } } } // lock (database) + return folders; } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } } @@ -935,25 +795,24 @@ namespace OpenSim.Data.MySQL /// the folder UUID protected void deleteOneFolder(UUID folderID) { - StoreRollbackFolder(folderID); - try { - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", dbcon)) + { + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - lock (database) - { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + cmd.ExecuteNonQuery(); + } } } catch (MySqlException e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); } } @@ -963,30 +822,23 @@ namespace OpenSim.Data.MySQL /// the folder UUID protected void deleteItemsInFolder(UUID folderID) { - if (rollbackStore) - { - foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID)) - { - StoreRollbackItem(itemBase.ID); - } - } - try { - database.CheckConnection(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", dbcon)) + { + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - lock (database) - { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + cmd.ExecuteNonQuery(); + } } } catch (MySqlException e) { - database.Reconnect(); m_log.Error(e.ToString()); } } @@ -999,80 +851,53 @@ namespace OpenSim.Data.MySQL { List subFolders = getFolderHierarchy(folderID); - // Dont delete in OGM - makes for easier restores if someone sends a malcious command. (just restore the folder entry) - if (opengridmode == false) + //Delete all sub-folders + foreach (InventoryFolderBase f in subFolders) { - //Delete all sub-folders - foreach (InventoryFolderBase f in subFolders) - { - StoreRollbackFolder(f.ID); - deleteOneFolder(f.ID); - - if (rollbackStore) - { - foreach (InventoryItemBase itemBase in getInventoryInFolder(f.ID)) - { - StoreRollbackItem(itemBase.ID); - } - } - deleteItemsInFolder(f.ID); - } + deleteOneFolder(f.ID); + deleteItemsInFolder(f.ID); } - StoreRollbackFolder(folderID); //Delete the actual row deleteOneFolder(folderID); - - // Just delete the folder context in OGM - if (opengridmode == false) - { - if (rollbackStore) - { - foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID)) - { - StoreRollbackItem(itemBase.ID); - } - } - deleteItemsInFolder(folderID); - } + deleteItemsInFolder(folderID); } public List fetchActiveGestures(UUID avatarID) { - MySqlDataReader result = null; - MySqlCommand sqlCmd = null; - lock (database) + lock (m_dbLock) { try { - database.CheckConnection(); - sqlCmd = new MySqlCommand( - "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", - database.Connection); - sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); - sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); - result = sqlCmd.ExecuteReader(); - - List list = new List(); - while (result.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - InventoryItemBase item = readInventoryItem(result); - if (item != null) - list.Add(item); + dbcon.Open(); + + using (MySqlCommand sqlCmd = new MySqlCommand( + "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", dbcon)) + { + sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); + sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + + using (MySqlDataReader result = sqlCmd.ExecuteReader()) + { + List list = new List(); + while (result.Read()) + { + InventoryItemBase item = readInventoryItem(result); + if (item != null) + list.Add(item); + } + return list; + } + } } - return list; } catch (Exception e) { - database.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - if (result != null) result.Close(); - if (sqlCmd != null) sqlCmd.Dispose(); - } } } } diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 9a4a4bb..a06eec3 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -48,75 +48,54 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private string m_ConnectionString; - - private MySqlConnection m_Connection = null; + private string m_connectionString; + private object m_dbLock = new object(); public void Initialise(string connectionString) { - m_ConnectionString = connectionString; + m_connectionString = connectionString; - m_Connection = new MySqlConnection(m_ConnectionString); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - m_Connection.Open(); + // Apply new Migrations + // + Assembly assem = GetType().Assembly; + Migration m = new Migration(dbcon, assem, "RegionStore"); + m.Update(); - // Apply new Migrations - // - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_Connection, assem, "RegionStore"); - m.Update(); - - // NOTE: This is a very slow query that times out on regions with a lot of prims. - // I'm told that it is no longer relevant so it's commented out now, but if it - // is relevant it should be added as a console command instead of part of the - // startup phase - // Clean dropped attachments - // - //try - //{ - // using (MySqlCommand cmd = m_Connection.CreateCommand()) - // { - // cmd.CommandText = "delete from prims, primshapes using prims " + - // "left join primshapes on prims.uuid = primshapes.uuid " + - // "where PCode = 9 and State <> 0"; - // ExecuteNonQuery(cmd); - // } - //} - //catch (MySqlException ex) - //{ - // m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); - //} + // Clean dropped attachments + // + try + { + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from prims, primshapes using prims " + + "left join primshapes on prims.uuid = primshapes.uuid " + + "where PCode = 9 and State <> 0"; + ExecuteNonQuery(cmd); + } + } + catch (MySqlException ex) + { + m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); + } + } } private IDataReader ExecuteReader(MySqlCommand c) { IDataReader r = null; - bool errorSeen = false; - while (true) + try { - try - { - r = c.ExecuteReader(); - } - catch (Exception) - { - Thread.Sleep(500); - - m_Connection.Close(); - m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - m_Connection.Open(); - c.Connection = m_Connection; - - if (!errorSeen) - { - errorSeen = true; - continue; - } - throw; - } - - break; + r = c.ExecuteReader(); + } + catch (Exception e) + { + m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); + throw; } return r; @@ -124,32 +103,14 @@ namespace OpenSim.Data.MySQL private void ExecuteNonQuery(MySqlCommand c) { - bool errorSeen = false; - - while (true) + try { - try - { - c.ExecuteNonQuery(); - } - catch (Exception) - { - Thread.Sleep(500); - - m_Connection.Close(); - m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); - m_Connection.Open(); - c.Connection = m_Connection; - - if (!errorSeen) - { - errorSeen = true; - continue; - } - throw; - } - - break; + c.ExecuteNonQuery(); + } + catch (Exception e) + { + m_log.Error("[REGION DB]: MySQL error in ExecuteNonQuery: " + e.Message); + throw; } } @@ -166,115 +127,119 @@ namespace OpenSim.Data.MySQL if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) return; - lock (m_Connection) + lock (m_dbLock) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - foreach (SceneObjectPart prim in obj.Children.Values) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims ("+ - "UUID, CreationDate, "+ - "Name, Text, Description, "+ - "SitName, TouchName, ObjectFlags, "+ - "OwnerMask, NextOwnerMask, GroupMask, "+ - "EveryoneMask, BaseMask, PositionX, "+ - "PositionY, PositionZ, GroupPositionX, "+ - "GroupPositionY, GroupPositionZ, VelocityX, "+ - "VelocityY, VelocityZ, AngularVelocityX, "+ - "AngularVelocityY, AngularVelocityZ, "+ - "AccelerationX, AccelerationY, "+ - "AccelerationZ, RotationX, "+ - "RotationY, RotationZ, "+ - "RotationW, SitTargetOffsetX, "+ - "SitTargetOffsetY, SitTargetOffsetZ, "+ - "SitTargetOrientW, SitTargetOrientX, "+ - "SitTargetOrientY, SitTargetOrientZ, "+ - "RegionUUID, CreatorID, "+ - "OwnerID, GroupID, "+ - "LastOwnerID, SceneGroupID, "+ - "PayPrice, PayButton1, "+ - "PayButton2, PayButton3, "+ - "PayButton4, LoopedSound, "+ - "LoopedSoundGain, TextureAnimation, "+ - "OmegaX, OmegaY, OmegaZ, "+ - "CameraEyeOffsetX, CameraEyeOffsetY, "+ - "CameraEyeOffsetZ, CameraAtOffsetX, "+ - "CameraAtOffsetY, CameraAtOffsetZ, "+ - "ForceMouselook, ScriptAccessPin, "+ - "AllowedDrop, DieAtEdge, "+ - "SalePrice, SaleType, "+ - "ColorR, ColorG, ColorB, ColorA, "+ - "ParticleSystem, ClickAction, Material, "+ - "CollisionSound, CollisionSoundVolume, "+ - "PassTouches, "+ - "LinkNumber) values (" + "?UUID, "+ - "?CreationDate, ?Name, ?Text, "+ - "?Description, ?SitName, ?TouchName, "+ - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ - "?GroupMask, ?EveryoneMask, ?BaseMask, "+ - "?PositionX, ?PositionY, ?PositionZ, "+ - "?GroupPositionX, ?GroupPositionY, "+ - "?GroupPositionZ, ?VelocityX, "+ - "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ - "?AngularVelocityY, ?AngularVelocityZ, "+ - "?AccelerationX, ?AccelerationY, "+ - "?AccelerationZ, ?RotationX, "+ - "?RotationY, ?RotationZ, "+ - "?RotationW, ?SitTargetOffsetX, "+ - "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ - "?SitTargetOrientW, ?SitTargetOrientX, "+ - "?SitTargetOrientY, ?SitTargetOrientZ, "+ - "?RegionUUID, ?CreatorID, ?OwnerID, "+ - "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ - "?PayPrice, ?PayButton1, ?PayButton2, "+ - "?PayButton3, ?PayButton4, ?LoopedSound, "+ - "?LoopedSoundGain, ?TextureAnimation, "+ - "?OmegaX, ?OmegaY, ?OmegaZ, "+ - "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ - "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ - "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ - "?ForceMouselook, ?ScriptAccessPin, "+ - "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ - "?SaleType, ?ColorR, ?ColorG, "+ - "?ColorB, ?ColorA, ?ParticleSystem, "+ - "?ClickAction, ?Material, ?CollisionSound, "+ - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes ("+ - "UUID, Shape, ScaleX, ScaleY, "+ - "ScaleZ, PCode, PathBegin, PathEnd, "+ - "PathScaleX, PathScaleY, PathShearX, "+ - "PathShearY, PathSkew, PathCurve, "+ - "PathRadiusOffset, PathRevolutions, "+ - "PathTaperX, PathTaperY, PathTwist, "+ - "PathTwistBegin, ProfileBegin, ProfileEnd, "+ - "ProfileCurve, ProfileHollow, Texture, "+ - "ExtraParams, State) values (?UUID, "+ - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ - "?PCode, ?PathBegin, ?PathEnd, "+ - "?PathScaleX, ?PathScaleY, "+ - "?PathShearX, ?PathShearY, "+ - "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ - "?PathRevolutions, ?PathTaperX, "+ - "?PathTaperY, ?PathTwist, "+ - "?PathTwistBegin, ?ProfileBegin, "+ - "?ProfileEnd, ?ProfileCurve, "+ - "?ProfileHollow, ?Texture, ?ExtraParams, "+ - "?State)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); + dbcon.Open(); + MySqlCommand cmd = dbcon.CreateCommand(); + + foreach (SceneObjectPart prim in obj.Children.Values) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims (" + + "UUID, CreationDate, " + + "Name, Text, Description, " + + "SitName, TouchName, ObjectFlags, " + + "OwnerMask, NextOwnerMask, GroupMask, " + + "EveryoneMask, BaseMask, PositionX, " + + "PositionY, PositionZ, GroupPositionX, " + + "GroupPositionY, GroupPositionZ, VelocityX, " + + "VelocityY, VelocityZ, AngularVelocityX, " + + "AngularVelocityY, AngularVelocityZ, " + + "AccelerationX, AccelerationY, " + + "AccelerationZ, RotationX, " + + "RotationY, RotationZ, " + + "RotationW, SitTargetOffsetX, " + + "SitTargetOffsetY, SitTargetOffsetZ, " + + "SitTargetOrientW, SitTargetOrientX, " + + "SitTargetOrientY, SitTargetOrientZ, " + + "RegionUUID, CreatorID, " + + "OwnerID, GroupID, " + + "LastOwnerID, SceneGroupID, " + + "PayPrice, PayButton1, " + + "PayButton2, PayButton3, " + + "PayButton4, LoopedSound, " + + "LoopedSoundGain, TextureAnimation, " + + "OmegaX, OmegaY, OmegaZ, " + + "CameraEyeOffsetX, CameraEyeOffsetY, " + + "CameraEyeOffsetZ, CameraAtOffsetX, " + + "CameraAtOffsetY, CameraAtOffsetZ, " + + "ForceMouselook, ScriptAccessPin, " + + "AllowedDrop, DieAtEdge, " + + "SalePrice, SaleType, " + + "ColorR, ColorG, ColorB, ColorA, " + + "ParticleSystem, ClickAction, Material, " + + "CollisionSound, CollisionSoundVolume, " + + "PassTouches, " + + "LinkNumber) values (" + "?UUID, " + + "?CreationDate, ?Name, ?Text, " + + "?Description, ?SitName, ?TouchName, " + + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + + "?GroupMask, ?EveryoneMask, ?BaseMask, " + + "?PositionX, ?PositionY, ?PositionZ, " + + "?GroupPositionX, ?GroupPositionY, " + + "?GroupPositionZ, ?VelocityX, " + + "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + + "?AngularVelocityY, ?AngularVelocityZ, " + + "?AccelerationX, ?AccelerationY, " + + "?AccelerationZ, ?RotationX, " + + "?RotationY, ?RotationZ, " + + "?RotationW, ?SitTargetOffsetX, " + + "?SitTargetOffsetY, ?SitTargetOffsetZ, " + + "?SitTargetOrientW, ?SitTargetOrientX, " + + "?SitTargetOrientY, ?SitTargetOrientZ, " + + "?RegionUUID, ?CreatorID, ?OwnerID, " + + "?GroupID, ?LastOwnerID, ?SceneGroupID, " + + "?PayPrice, ?PayButton1, ?PayButton2, " + + "?PayButton3, ?PayButton4, ?LoopedSound, " + + "?LoopedSoundGain, ?TextureAnimation, " + + "?OmegaX, ?OmegaY, ?OmegaZ, " + + "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + + "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + + "?CameraAtOffsetY, ?CameraAtOffsetZ, " + + "?ForceMouselook, ?ScriptAccessPin, " + + "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + + "?SaleType, ?ColorR, ?ColorG, " + + "?ColorB, ?ColorA, ?ParticleSystem, " + + "?ClickAction, ?Material, ?CollisionSound, " + + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes (" + + "UUID, Shape, ScaleX, ScaleY, " + + "ScaleZ, PCode, PathBegin, PathEnd, " + + "PathScaleX, PathScaleY, PathShearX, " + + "PathShearY, PathSkew, PathCurve, " + + "PathRadiusOffset, PathRevolutions, " + + "PathTaperX, PathTaperY, PathTwist, " + + "PathTwistBegin, ProfileBegin, ProfileEnd, " + + "ProfileCurve, ProfileHollow, Texture, " + + "ExtraParams, State) values (?UUID, " + + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + + "?PCode, ?PathBegin, ?PathEnd, " + + "?PathScaleX, ?PathScaleY, " + + "?PathShearX, ?PathShearY, " + + "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + + "?PathRevolutions, ?PathTaperX, " + + "?PathTaperY, ?PathTwist, " + + "?PathTwistBegin, ?ProfileBegin, " + + "?ProfileEnd, ?ProfileCurve, " + + "?ProfileHollow, ?Texture, ?ExtraParams, " + + "?State)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); + } + cmd.Dispose(); } - cmd.Dispose(); } } @@ -290,22 +255,27 @@ namespace OpenSim.Data.MySQL // cause the loss of a prim, but is cleaner. // It's also faster because it uses the primary key. // - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; - cmd.Parameters.AddWithValue("UUID", obj.ToString()); + dbcon.Open(); - using (IDataReader reader = ExecuteReader(cmd)) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - while (reader.Read()) - uuids.Add(new UUID(reader["UUID"].ToString())); - } + cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; + cmd.Parameters.AddWithValue("UUID", obj.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + uuids.Add(new UUID(reader["UUID"].ToString())); + } - // delete the main prims - cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - ExecuteNonQuery(cmd); + // delete the main prims + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + ExecuteNonQuery(cmd); + } } } @@ -326,14 +296,19 @@ namespace OpenSim.Data.MySQL /// the Item UUID private void RemoveItems(UUID uuid) { - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; - cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); + } } } } @@ -345,29 +320,33 @@ namespace OpenSim.Data.MySQL /// the list of UUIDs private void RemoveShapes(List uuids) { - lock (m_Connection) + lock (m_dbLock) { string sql = "delete from primshapes where "; - - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - for (int i = 0; i < uuids.Count; i++) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - if ((i + 1) == uuids.Count) - {// end of the list - sql += "(UUID = ?UUID" + i + ")"; - } - else + for (int i = 0; i < uuids.Count; i++) { - sql += "(UUID = ?UUID" + i + ") or "; + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(UUID = ?UUID" + i + ")"; + } + else + { + sql += "(UUID = ?UUID" + i + ") or "; + } } - } - cmd.CommandText = sql; + cmd.CommandText = sql; - for (int i = 0; i < uuids.Count; i++) - cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); + for (int i = 0; i < uuids.Count; i++) + cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); + } } } } @@ -379,30 +358,34 @@ namespace OpenSim.Data.MySQL /// the list of UUIDs private void RemoveItems(List uuids) { - lock (m_Connection) + lock (m_dbLock) { string sql = "delete from primitems where "; - - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - for (int i = 0; i < uuids.Count; i++) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - if ((i + 1) == uuids.Count) + for (int i = 0; i < uuids.Count; i++) { - // end of the list - sql += "(PrimID = ?PrimID" + i + ")"; - } - else - { - sql += "(PrimID = ?PrimID" + i + ") or "; + if ((i + 1) == uuids.Count) + { + // end of the list + sql += "(PrimID = ?PrimID" + i + ")"; + } + else + { + sql += "(PrimID = ?PrimID" + i + ") or "; + } } - } - cmd.CommandText = sql; + cmd.CommandText = sql; - for (int i = 0; i < uuids.Count; i++) - cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); + for (int i = 0; i < uuids.Count; i++) + cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); + } } } } @@ -417,33 +400,38 @@ namespace OpenSim.Data.MySQL #region Prim Loading - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = - "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + dbcon.Open(); - using (IDataReader reader = ExecuteReader(cmd)) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = + "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - SceneObjectPart prim = BuildPrim(reader); - if (reader["Shape"] is DBNull) - prim.Shape = PrimitiveBaseShape.Default; - else - prim.Shape = BuildShape(reader); + while (reader.Read()) + { + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); - UUID parentID = new UUID(reader["SceneGroupID"].ToString()); - if (parentID != prim.UUID) - prim.ParentUUID = parentID; + UUID parentID = new UUID(reader["SceneGroupID"].ToString()); + if (parentID != prim.UUID) + prim.ParentUUID = parentID; - prims[prim.UUID] = prim; + prims[prim.UUID] = prim; - ++count; - if (count % ROWS_PER_QUERY == 0) - m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); + ++count; + if (count % ROWS_PER_QUERY == 0) + m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); + } } } } @@ -497,20 +485,25 @@ namespace OpenSim.Data.MySQL // list from DB of all prims which have items and // LoadItems only on those List primsWithInventory = new List(); - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand itemCmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; - using (IDataReader itemReader = ExecuteReader(itemCmd)) + dbcon.Open(); + + using (MySqlCommand itemCmd = dbcon.CreateCommand()) { - while (itemReader.Read()) + itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; + using (IDataReader itemReader = ExecuteReader(itemCmd)) { - if (!(itemReader["primID"] is DBNull)) + while (itemReader.Read()) { - UUID primID = new UUID(itemReader["primID"].ToString()); - if (prims.ContainsKey(primID)) - primsWithInventory.Add(prims[primID]); + if (!(itemReader["primID"] is DBNull)) + { + UUID primID = new UUID(itemReader["primID"].ToString()); + if (prims.ContainsKey(primID)) + primsWithInventory.Add(prims[primID]); + } } } } @@ -535,23 +528,28 @@ namespace OpenSim.Data.MySQL /// The prim private void LoadItems(SceneObjectPart prim) { - lock (m_Connection) + lock (m_dbLock) { List inventory = new List(); - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; - cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + dbcon.Open(); - using (IDataReader reader = ExecuteReader(cmd)) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - TaskInventoryItem item = BuildItem(reader); + while (reader.Read()) + { + TaskInventoryItem item = BuildItem(reader); - item.ParentID = prim.UUID; // Values in database are often wrong - inventory.Add(item); + item.ParentID = prim.UUID; // Values in database are often wrong + inventory.Add(item); + } } } } @@ -564,22 +562,27 @@ namespace OpenSim.Data.MySQL { m_log.Info("[REGION DB]: Storing terrain"); - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + dbcon.Open(); - ExecuteNonQuery(cmd); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; + ExecuteNonQuery(cmd); - cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); + cmd.CommandText = "insert into terrain (RegionUUID, " + + "Revision, Heightfield) values (?RegionUUID, " + + "1, ?Heightfield)"; - ExecuteNonQuery(cmd); + cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); + + ExecuteNonQuery(cmd); + } } } } @@ -588,38 +591,43 @@ namespace OpenSim.Data.MySQL { double[,] terrain = null; - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "select RegionUUID, Revision, Heightfield " + - "from terrain where RegionUUID = ?RegionUUID " + - "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + dbcon.Open(); - using (IDataReader reader = ExecuteReader(cmd)) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID " + + "order by Revision desc limit 1"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - int rev = Convert.ToInt32(reader["Revision"]); + while (reader.Read()) + { + int rev = Convert.ToInt32(reader["Revision"]); - terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; - terrain.Initialize(); + terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; + terrain.Initialize(); - using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) - { - using (BinaryReader br = new BinaryReader(mstr)) + using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) { - for (int x = 0; x < (int)Constants.RegionSize; x++) + using (BinaryReader br = new BinaryReader(mstr)) { - for (int y = 0; y < (int)Constants.RegionSize; y++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - terrain[x, y] = br.ReadDouble(); + for (int y = 0; y < (int)Constants.RegionSize; y++) + { + terrain[x, y] = br.ReadDouble(); + } } } - } - m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); + m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); + } } } } @@ -631,63 +639,73 @@ namespace OpenSim.Data.MySQL public void RemoveLandObject(UUID globalID) { - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "delete from land where UUID = ?UUID"; - cmd.Parameters.AddWithValue("UUID", globalID.ToString()); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from land where UUID = ?UUID"; + cmd.Parameters.AddWithValue("UUID", globalID.ToString()); - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); + } } } } public void StoreLandObject(ILandObject parcel) { - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "replace into land (UUID, RegionUUID, " + - "LocalLandID, Bitmap, Name, Description, " + - "OwnerUUID, IsGroupOwned, Area, AuctionID, " + - "Category, ClaimDate, ClaimPrice, GroupUUID, " + - "SalePrice, LandStatus, LandFlags, LandingType, " + - "MediaAutoScale, MediaTextureUUID, MediaURL, " + - "MusicURL, PassHours, PassPrice, SnapshotUUID, " + - "UserLocationX, UserLocationY, UserLocationZ, " + - "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, Dwell) values (" + - "?UUID, ?RegionUUID, " + - "?LocalLandID, ?Bitmap, ?Name, ?Description, " + - "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + - "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + - "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + - "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + - "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + - "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + - "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; - - FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); - - ExecuteNonQuery(cmd); - - cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; - - foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); + cmd.CommandText = "replace into land (UUID, RegionUUID, " + + "LocalLandID, Bitmap, Name, Description, " + + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + + "Category, ClaimDate, ClaimPrice, GroupUUID, " + + "SalePrice, LandStatus, LandFlags, LandingType, " + + "MediaAutoScale, MediaTextureUUID, MediaURL, " + + "MusicURL, PassHours, PassPrice, SnapshotUUID, " + + "UserLocationX, UserLocationY, UserLocationZ, " + + "UserLookAtX, UserLookAtY, UserLookAtZ, " + + "AuthbuyerID, OtherCleanTime, Dwell) values (" + + "?UUID, ?RegionUUID, " + + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + + "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + + "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + + "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + + "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + + "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; + + FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); + ExecuteNonQuery(cmd); + + cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; + + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + { + FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + } } } } @@ -697,27 +715,32 @@ namespace OpenSim.Data.MySQL { RegionSettings rs = null; - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("regionUUID", regionUUID); + dbcon.Open(); - using (IDataReader reader = ExecuteReader(cmd)) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - if (reader.Read()) - { - rs = BuildRegionSettings(reader); - rs.OnSave += StoreRegionSettings; - } - else + cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); + + using (IDataReader reader = ExecuteReader(cmd)) { - rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; + if (reader.Read()) + { + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; + } + else + { + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; - StoreRegionSettings(rs); + StoreRegionSettings(rs); + } } } } @@ -728,46 +751,51 @@ namespace OpenSim.Data.MySQL public void StoreRegionSettings(RegionSettings rs) { - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "replace into regionsettings (regionUUID, " + - "block_terraform, block_fly, allow_damage, " + - "restrict_pushing, allow_land_resell, " + - "allow_land_join_divide, block_show_in_search, " + - "agent_limit, object_bonus, maturity, " + - "disable_scripts, disable_collisions, " + - "disable_physics, terrain_texture_1, " + - "terrain_texture_2, terrain_texture_3, " + - "terrain_texture_4, elevation_1_nw, " + - "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, " + - "elevation_2_se, elevation_1_sw, " + - "elevation_2_sw, water_height, " + - "terrain_raise_limit, terrain_lower_limit, " + - "use_estate_sun, fixed_sun, sun_position, " + - "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + - "?BlockFly, ?AllowDamage, ?RestrictPushing, " + - "?AllowLandResell, ?AllowLandJoinDivide, " + - "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + - "?Maturity, ?DisableScripts, ?DisableCollisions, " + - "?DisablePhysics, ?TerrainTexture1, " + - "?TerrainTexture2, ?TerrainTexture3, " + - "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + - "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + - "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + - "?WaterHeight, ?TerrainRaiseLimit, " + - "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)"; - - FillRegionSettingsCommand(cmd, rs); - - ExecuteNonQuery(cmd); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, " + + "elevation_2_se, elevation_1_sw, " + + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz, loaded_creation_datetime, " + + "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + + "?LoadedCreationDateTime, ?LoadedCreationID)"; + + FillRegionSettingsCommand(cmd, rs); + + ExecuteNonQuery(cmd); + } } } } @@ -776,36 +804,41 @@ namespace OpenSim.Data.MySQL { List landData = new List(); - lock (m_Connection) + lock (m_dbLock) { - using (MySqlCommand cmd = m_Connection.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + dbcon.Open(); - using (IDataReader reader = ExecuteReader(cmd)) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - while (reader.Read()) + cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - LandData newLand = BuildLandData(reader); - landData.Add(newLand); + while (reader.Read()) + { + LandData newLand = BuildLandData(reader); + landData.Add(newLand); + } } } - } - using (MySqlCommand cmd = m_Connection.CreateCommand()) - { - foreach (LandData land in landData) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.Parameters.Clear(); - cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; - cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) + foreach (LandData land in landData) { - while (reader.Read()) + cmd.Parameters.Clear(); + cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; + cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) { - land.ParcelAccessList.Add(BuildLandAccessData(reader)); + while (reader.Read()) + { + land.ParcelAccessList.Add(BuildLandAccessData(reader)); + } } } } @@ -1513,41 +1546,46 @@ namespace OpenSim.Data.MySQL public void StorePrimInventory(UUID primID, ICollection items) { - lock (m_Connection) + lock (m_dbLock) { RemoveItems(primID); - MySqlCommand cmd = m_Connection.CreateCommand(); - - if (items.Count == 0) - return; - - cmd.CommandText = "insert into primitems ("+ - "invType, assetType, name, "+ - "description, creationDate, nextPermissions, "+ - "currentPermissions, basePermissions, "+ - "everyonePermissions, groupPermissions, "+ - "flags, itemID, primID, assetID, "+ - "parentFolderID, creatorID, ownerID, "+ - "groupID, lastOwnerID) values (?invType, "+ - "?assetType, ?name, ?description, "+ - "?creationDate, ?nextPermissions, "+ - "?currentPermissions, ?basePermissions, "+ - "?everyonePermissions, ?groupPermissions, "+ - "?flags, ?itemID, ?primID, ?assetID, "+ - "?parentFolderID, ?creatorID, ?ownerID, "+ - "?groupID, ?lastOwnerID)"; - - foreach (TaskInventoryItem item in items) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.Parameters.Clear(); + dbcon.Open(); + + MySqlCommand cmd = dbcon.CreateCommand(); + + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems (" + + "invType, assetType, name, " + + "description, creationDate, nextPermissions, " + + "currentPermissions, basePermissions, " + + "everyonePermissions, groupPermissions, " + + "flags, itemID, primID, assetID, " + + "parentFolderID, creatorID, ownerID, " + + "groupID, lastOwnerID) values (?invType, " + + "?assetType, ?name, ?description, " + + "?creationDate, ?nextPermissions, " + + "?currentPermissions, ?basePermissions, " + + "?everyonePermissions, ?groupPermissions, " + + "?flags, ?itemID, ?primID, ?assetID, " + + "?parentFolderID, ?creatorID, ?ownerID, " + + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) + { + cmd.Parameters.Clear(); + + FillItemCommand(cmd, item); - FillItemCommand(cmd, item); + ExecuteNonQuery(cmd); + } - ExecuteNonQuery(cmd); + cmd.Dispose(); } - - cmd.Dispose(); } } } diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs index 8f67eeb..304883c 100644 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ b/OpenSim/Data/MySQL/MySQLLogData.cs @@ -79,14 +79,19 @@ namespace OpenSim.Data.MySQL // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "LogStore"); - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m); + using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(connect)) + { + dbcon.Open(); + + Migration m = new Migration(dbcon, assem, "LogStore"); - m.Update(); + // TODO: After rev 6000, remove this. People should have + // been rolled onto the new migration code by then. + TestTables(m); + m.Update(); + } } /// @@ -128,7 +133,6 @@ namespace OpenSim.Data.MySQL } catch { - database.Reconnect(); } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 243394e..ace2027 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -46,15 +46,12 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// - /// The database connection object - /// - private MySqlConnection dbcon; - - /// /// Connection string for ADO.net /// private string connectionString; + private object m_dbLock = new object(); + private const string m_waitTimeoutSelect = "select @@wait_timeout"; /// @@ -109,11 +106,11 @@ namespace OpenSim.Data.MySQL try { connectionString = connect; - dbcon = new MySqlConnection(connectionString); + //dbcon = new MySqlConnection(connectionString); try { - dbcon.Open(); + //dbcon.Open(); } catch(Exception e) { @@ -134,18 +131,21 @@ namespace OpenSim.Data.MySQL /// protected void GetWaitTimeout() { - MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); - - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) { - if (dbReader.Read()) + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + } } - - dbReader.Close(); - cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -154,66 +154,9 @@ namespace OpenSim.Data.MySQL "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); } - /// - /// Should be called before any db operation. This checks to see if the connection has not timed out - /// - public void CheckConnection() + public string ConnectionString { - //m_log.Debug("[REGION DB]: Checking connection"); - - long timeNow = DateTime.Now.Ticks; - if (timeNow - m_lastConnectionUse > m_waitTimeout || dbcon.State != ConnectionState.Open) - { - m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); - Reconnect(); - } - - // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather - // than require the code to call another method - the timeout leeway should be large enough to cover the - // inaccuracy. - m_lastConnectionUse = timeNow; - } - - /// - /// Get the connection being used - /// - /// MySqlConnection Object - public MySqlConnection Connection - { - get { return dbcon; } - } - - /// - /// Shuts down the database connection - /// - public void Close() - { - dbcon.Close(); - dbcon = null; - } - - /// - /// Reconnects to the database - /// - public void Reconnect() - { - m_log.Info("[REGION DB] Reconnecting database"); - - lock (dbcon) - { - try - { - // Close the DB connection - dbcon.Close(); - // Try reopen it - dbcon = new MySqlConnection(connectionString); - dbcon.Open(); - } - catch (Exception e) - { - m_log.Error("Unable to reconnect to database " + e.ToString()); - } - } + get { return connectionString; } } /// @@ -264,9 +207,13 @@ namespace OpenSim.Data.MySQL /// name of embedded resource public void ExecuteResourceSql(string name) { - CheckConnection(); - MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); - cmd.ExecuteNonQuery(); + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); + + MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); + cmd.ExecuteNonQuery(); + } } /// @@ -275,22 +222,29 @@ namespace OpenSim.Data.MySQL /// sql string to execute public void ExecuteSql(string sql) { - CheckConnection(); - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); + + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); + } } public void ExecuteParameterizedSql(string sql, Dictionary parameters) { - CheckConnection(); - - MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); - cmd.CommandText = sql; - foreach (KeyValuePair param in parameters) + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) { - cmd.Parameters.AddWithValue(param.Key, param.Value); + dbcon.Open(); + + MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); + cmd.CommandText = sql; + foreach (KeyValuePair param in parameters) + { + cmd.Parameters.AddWithValue(param.Key, param.Value); + } + cmd.ExecuteNonQuery(); } - cmd.ExecuteNonQuery(); } /// @@ -299,35 +253,37 @@ namespace OpenSim.Data.MySQL /// public void GetTableVersion(Dictionary tableList) { - lock (dbcon) + lock (m_dbLock) { - CheckConnection(); - - MySqlCommand tablesCmd = - new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", - dbcon); - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) { - while (tables.Read()) + dbcon.Open(); + + using (MySqlCommand tablesCmd = new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon)) { - try + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { - string tableName = (string) tables["TABLE_NAME"]; - string comment = (string) tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) + while (tables.Read()) { - tableList[tableName] = comment; + try + { + string tableName = (string)tables["TABLE_NAME"]; + string comment = (string)tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) + { + tableList[tableName] = comment; + } + } + catch (Exception e) + { + m_log.Error(e.Message, e); + } } } - catch (Exception e) - { - m_log.Error(e.ToString()); - } } - tables.Close(); } } } @@ -337,28 +293,27 @@ namespace OpenSim.Data.MySQL /// /// Runs a query with protection against SQL Injection by using parameterised input. /// + /// Database connection /// The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y /// The parameters - index so that @y is indexed as 'y' /// A MySQL DB Command - public IDbCommand Query(string sql, Dictionary parameters) + public IDbCommand Query(MySqlConnection dbcon, string sql, Dictionary parameters) { try { - CheckConnection(); // Not sure if this one is necessary - - MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); + MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand) dbcommand; + return (IDbCommand)dbcommand; } catch (Exception e) { // Return null if it fails. - m_log.Error("Failed during Query generation: " + e.ToString()); + m_log.Error("Failed during Query generation: " + e.Message, e); return null; } } @@ -694,8 +649,6 @@ namespace OpenSim.Data.MySQL ret.Add(attachpoint, item); } - r.Close(); - return ret; } @@ -727,12 +680,17 @@ namespace OpenSim.Data.MySQL try { - IDbCommand result = Query(sql, parameters); + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); + + IDbCommand result = Query(dbcon, sql, parameters); - if (result.ExecuteNonQuery() == 1) - returnval = true; + if (result.ExecuteNonQuery() == 1) + returnval = true; - result.Dispose(); + result.Dispose(); + } } catch (Exception e) { @@ -828,12 +786,17 @@ namespace OpenSim.Data.MySQL try { - IDbCommand result = Query(sql, parameters); + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); - if (result.ExecuteNonQuery() == 1) - returnval = true; + IDbCommand result = Query(dbcon, sql, parameters); - result.Dispose(); + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } } catch (Exception e) { @@ -927,12 +890,17 @@ namespace OpenSim.Data.MySQL bool returnval = false; try { - IDbCommand result = Query(sql, parameters); + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); - if (result.ExecuteNonQuery() == 1) - returnval = true; + IDbCommand result = Query(dbcon, sql, parameters); - result.Dispose(); + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } } catch (Exception e) { @@ -1030,18 +998,23 @@ namespace OpenSim.Data.MySQL try { - IDbCommand result = Query(sql, parameters); - - // int x; - // if ((x = result.ExecuteNonQuery()) > 0) - // { - // returnval = true; - // } - if (result.ExecuteNonQuery() > 0) + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) { - returnval = true; + dbcon.Open(); + + IDbCommand result = Query(dbcon, sql, parameters); + + // int x; + // if ((x = result.ExecuteNonQuery()) > 0) + // { + // returnval = true; + // } + if (result.ExecuteNonQuery() > 0) + { + returnval = true; + } + result.Dispose(); } - result.Dispose(); } catch (Exception e) { @@ -1070,18 +1043,23 @@ namespace OpenSim.Data.MySQL { parameters["?uuid"] = uuid; - IDbCommand result = Query(sql, parameters); - - // int x; - // if ((x = result.ExecuteNonQuery()) > 0) - // { - // returnval = true; - // } - if (result.ExecuteNonQuery() > 0) + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) { - returnval = true; + dbcon.Open(); + + IDbCommand result = Query(dbcon, sql, parameters); + + // int x; + // if ((x = result.ExecuteNonQuery()) > 0) + // { + // returnval = true; + // } + if (result.ExecuteNonQuery() > 0) + { + returnval = true; + } + result.Dispose(); } - result.Dispose(); } catch (Exception e) { @@ -1122,18 +1100,23 @@ namespace OpenSim.Data.MySQL try { - IDbCommand result = Query(sql, parameters); - - // int x; - // if ((x = result.ExecuteNonQuery()) > 0) - // { - // returnval = true; - // } - if (result.ExecuteNonQuery() > 0) + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) { - returnval = true; + dbcon.Open(); + + IDbCommand result = Query(dbcon, sql, parameters); + + // int x; + // if ((x = result.ExecuteNonQuery()) > 0) + // { + // returnval = true; + // } + if (result.ExecuteNonQuery() > 0) + { + returnval = true; + } + result.Dispose(); } - result.Dispose(); } catch (Exception e) { @@ -1167,45 +1150,51 @@ namespace OpenSim.Data.MySQL bool returnval = false; // we want to send in byte data, which means we can't just pass down strings - try { - MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); - cmd.Parameters.AddWithValue("?serial", appearance.Serial); - cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); - cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); - cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); - cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); - cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); - cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); - cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); - cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); - cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); - cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); - cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); - cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); - cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); - cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); - cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); - cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); - cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); - cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); - cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); - cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); - cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); - cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); - cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); - cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); - cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); - cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); - cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); - cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); - cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); - - if (cmd.ExecuteNonQuery() > 0) - returnval = true; - - cmd.Dispose(); + try + { + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); + cmd.Parameters.AddWithValue("?serial", appearance.Serial); + cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); + cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); + cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); + cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); + cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); + cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); + cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); + cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); + cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); + cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); + cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); + cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); + cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); + cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); + cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); + cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); + cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); + cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); + cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); + cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); + cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); + cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); + cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); + cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); + cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); + cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); + cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); + cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); + cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); + + if (cmd.ExecuteNonQuery() > 0) + returnval = true; + } + } } catch (Exception e) { @@ -1221,33 +1210,38 @@ namespace OpenSim.Data.MySQL { string sql = "delete from avatarattachments where UUID = ?uuid"; - MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); + using (MySqlConnection dbcon = new MySqlConnection(connectionString)) + { + dbcon.Open(); + + MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); - if (data == null) - return; + if (data == null) + return; - sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; + sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; - cmd = (MySqlCommand) dbcon.CreateCommand(); - cmd.CommandText = sql; + cmd = (MySqlCommand)dbcon.CreateCommand(); + cmd.CommandText = sql; - foreach (DictionaryEntry e in data) - { - int attachpoint = Convert.ToInt32(e.Key); + foreach (DictionaryEntry e in data) + { + int attachpoint = Convert.ToInt32(e.Key); - Hashtable item = (Hashtable)e.Value; + Hashtable item = (Hashtable)e.Value; - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - cmd.Parameters.AddWithValue("?attachpoint", attachpoint); - cmd.Parameters.AddWithValue("?item", item["item"]); - cmd.Parameters.AddWithValue("?asset", item["asset"]); + cmd.Parameters.Clear(); + cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); + cmd.Parameters.AddWithValue("?attachpoint", attachpoint); + cmd.Parameters.AddWithValue("?item", item["item"]); + cmd.Parameters.AddWithValue("?asset", item["asset"]); - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); + } } } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index b0075e8..a1a08b1 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -38,16 +38,21 @@ namespace OpenSim.Data.MySQL public class MySqlRegionData : MySqlFramework, IRegionData { private string m_Realm; - private List m_ColumnNames = null; -// private int m_LastExpire = 0; + private List m_ColumnNames; + //private string m_connectionString; public MySqlRegionData(string connectionString, string realm) : base(connectionString) { m_Realm = realm; + m_connectionString = connectionString; - Migration m = new Migration(m_Connection, GetType().Assembly, "GridStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, GetType().Assembly, "GridStore"); + m.Update(); + } } public List Get(string regionName, UUID scopeID) @@ -56,12 +61,13 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?regionName", regionName); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?regionName", regionName); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return RunCommand(cmd); + return RunCommand(cmd); + } } public RegionData Get(int posX, int posY, UUID scopeID) @@ -70,17 +76,18 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?posX", posX.ToString()); - cmd.Parameters.AddWithValue("?posY", posY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?posX", posX.ToString()); + cmd.Parameters.AddWithValue("?posY", posY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; - return ret[0]; + return ret[0]; + } } public RegionData Get(UUID regionID, UUID scopeID) @@ -89,16 +96,17 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; - return ret[0]; + return ret[0]; + } } public List Get(int startX, int startY, int endX, int endY, UUID scopeID) @@ -107,74 +115,79 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?startX", startX.ToString()); - cmd.Parameters.AddWithValue("?startY", startY.ToString()); - cmd.Parameters.AddWithValue("?endX", endX.ToString()); - cmd.Parameters.AddWithValue("?endY", endY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?startX", startX.ToString()); + cmd.Parameters.AddWithValue("?startY", startY.ToString()); + cmd.Parameters.AddWithValue("?endX", endX.ToString()); + cmd.Parameters.AddWithValue("?endY", endY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return RunCommand(cmd); + return RunCommand(cmd); + } } public List RunCommand(MySqlCommand cmd) { List retList = new List(); - IDataReader result = ExecuteReader(cmd); - - while (result.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - RegionData ret = new RegionData(); - ret.Data = new Dictionary(); - - UUID regionID; - UUID.TryParse(result["uuid"].ToString(), out regionID); - ret.RegionID = regionID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - ret.RegionName = result["regionName"].ToString(); - ret.posX = Convert.ToInt32(result["locX"]); - ret.posY = Convert.ToInt32(result["locY"]); - ret.sizeX = Convert.ToInt32(result["sizeX"]); - ret.sizeY = Convert.ToInt32(result["sizeY"]); - - if (m_ColumnNames == null) + dbcon.Open(); + cmd.Connection = dbcon; + + using (IDataReader result = cmd.ExecuteReader()) { - m_ColumnNames = new List(); + while (result.Read()) + { + RegionData ret = new RegionData(); + ret.Data = new Dictionary(); + + UUID regionID; + UUID.TryParse(result["uuid"].ToString(), out regionID); + ret.RegionID = regionID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + ret.RegionName = result["regionName"].ToString(); + ret.posX = Convert.ToInt32(result["locX"]); + ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + { + if (row["ColumnName"] != null) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + } - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) + foreach (string s in m_ColumnNames) { - if (row["ColumnName"] != null) - m_ColumnNames.Add(row["ColumnName"].ToString()); + if (s == "uuid") + continue; + if (s == "ScopeID") + continue; + if (s == "regionName") + continue; + if (s == "locX") + continue; + if (s == "locY") + continue; + + ret.Data[s] = result[s].ToString(); } - } - foreach (string s in m_ColumnNames) - { - if (s == "uuid") - continue; - if (s == "ScopeID") - continue; - if (s == "regionName") - continue; - if (s == "locX") - continue; - if (s == "locY") - continue; - - ret.Data[s] = result[s].ToString(); + retList.Add(ret); + } } - - retList.Add(ret); } - result.Close(); - CloseReaderCommand(cmd); - return retList; } @@ -201,76 +214,72 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - MySqlCommand cmd = new MySqlCommand(); - - string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; - foreach (string field in fields) + using (MySqlCommand cmd = new MySqlCommand()) { - update += ", "; - update += "`" + field + "` = ?"+field; - - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); - } - - update += " where uuid = ?regionID"; + string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; + foreach (string field in fields) + { + update += ", "; + update += "`" + field + "` = ?" + field; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + cmd.Parameters.AddWithValue("?" + field, data.Data[field]); + } - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); - cmd.Parameters.AddWithValue("?regionName", data.RegionName); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); - cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); - cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); - cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); + update += " where uuid = ?regionID"; - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + - String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = insert; + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); + cmd.Parameters.AddWithValue("?regionName", data.RegionName); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); if (ExecuteNonQuery(cmd) < 1) { - cmd.Dispose(); - return false; + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + + String.Join("`, `", fields) + + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + { + return false; + } } } - cmd.Dispose(); - return true; } public bool SetDataItem(UUID regionID, string item, string value) { - MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + - "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); - - - cmd.Parameters.AddWithValue("?"+item, value); - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) + { + cmd.Parameters.AddWithValue("?" + item, value); + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } public bool Delete(UUID regionID) { - MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + - "` where uuid = ?UUID"); - - - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) + { + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index d48144d..3cb0010 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -38,16 +38,21 @@ namespace OpenSim.Data.MySQL public class MySqlUserAccountData : MySqlFramework, IUserAccountData { private string m_Realm; - private List m_ColumnNames = null; -// private int m_LastExpire = 0; + private List m_ColumnNames; + // private string m_connectionString; public MySqlUserAccountData(string connectionString, string realm) : base(connectionString) { m_Realm = realm; + m_connectionString = connectionString; - Migration m = new Migration(m_Connection, GetType().Assembly, "UserStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, GetType().Assembly, "UserStore"); + m.Update(); + } } public List Query(UUID principalID, UUID scopeID, string query) @@ -64,49 +69,49 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand(command, dbcon); - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - IDataReader result = ExecuteReader(cmd); + IDataReader result = cmd.ExecuteReader(); - if (result.Read()) - { - ret.PrincipalID = principalID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - - if (m_ColumnNames == null) + if (result.Read()) { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + return ret; } - - foreach (string s in m_ColumnNames) + else { - if (s == "UUID") - continue; - if (s == "ScopeID") - continue; - - ret.Data[s] = result[s].ToString(); + return null; } - - result.Close(); - CloseReaderCommand(cmd); - - return ret; } - - result.Close(); - CloseReaderCommand(cmd); - - return null; } public bool Store(UserAccountData data) @@ -118,61 +123,60 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - MySqlCommand cmd = new MySqlCommand(); - - string update = "update `"+m_Realm+"` set "; - bool first = true; - foreach (string field in fields) + using (MySqlCommand cmd = new MySqlCommand()) { - if (!first) - update += ", "; - update += "`" + field + "` = ?"+field; - - first = false; - - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); - } + string update = "update `" + m_Realm + "` set "; + bool first = true; + foreach (string field in fields) + { + if (!first) + update += ", "; + update += "`" + field + "` = ?" + field; - update += " where UUID = ?principalID"; + first = false; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + cmd.Parameters.AddWithValue("?" + field, data.Data[field]); + } - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + update += " where UUID = ?principalID"; - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + - String.Join("`, `", fields) + - "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = insert; + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); if (ExecuteNonQuery(cmd) < 1) { - cmd.Dispose(); - return false; + string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; + } } } - cmd.Dispose(); - return true; } public bool SetDataItem(UUID principalID, string item, string value) { - MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + - "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - - - cmd.Parameters.AddWithValue("?"+item, value); - cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + + item + "` = ?" + item + " where UUID = ?UUID")) + { + cmd.Parameters.AddWithValue("?" + item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); - if (ExecuteNonQuery(cmd) > 0) - return true; + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 04f872f..2cf88b8 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -33,6 +33,7 @@ using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using log4net; +using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; @@ -45,15 +46,9 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - /// - /// Database manager for MySQL - /// - public MySQLManager database; - - /// - /// Better DB manager. Swap-in replacement too. - /// - public Dictionary m_dbconnections = new Dictionary(); + private MySQLManager m_database; + private string m_connectionString; + private object m_dbLock = new object(); public int m_maxConnections = 10; public int m_lastConnect; @@ -63,7 +58,6 @@ namespace OpenSim.Data.MySQL private string m_userFriendsTableName = "userfriends"; private string m_appearanceTableName = "avatarappearance"; private string m_attachmentsTableName = "avatarattachments"; - private string m_connectString; public override void Initialise() { @@ -71,41 +65,6 @@ namespace OpenSim.Data.MySQL throw new PluginNotInitialisedException(Name); } - public MySQLSuperManager GetLockedConnection(string why) - { - int lockedCons = 0; - while (true) - { - m_lastConnect++; - - // Overflow protection - if (m_lastConnect == int.MaxValue) - m_lastConnect = 0; - - MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections]; - if (!x.Locked) - { - x.GetLock(); - x.Running = why; - return x; - } - - lockedCons++; - if (lockedCons > m_maxConnections) - { - lockedCons = 0; - Thread.Sleep(1000); // Wait some time before searching them again. - m_log.Debug( - "WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound."); - m_log.Debug("Current connections-in-use dump:"); - foreach (KeyValuePair kvp in m_dbconnections) - { - m_log.Debug(kvp.Value.Running); - } - } - } - } - /// /// Initialise User Interface /// Loads and initialises the MySQL storage plugin @@ -115,55 +74,18 @@ namespace OpenSim.Data.MySQL /// connect string. public override void Initialise(string connect) { - if (connect == String.Empty) - { - // TODO: actually do something with our connect string - // instead of loading the second config - - m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead"); - IniFile iniFile = new IniFile("mysql_connection.ini"); - string settingHostname = iniFile.ParseFileReadValue("hostname"); - string settingDatabase = iniFile.ParseFileReadValue("database"); - string settingUsername = iniFile.ParseFileReadValue("username"); - string settingPassword = iniFile.ParseFileReadValue("password"); - string settingPooling = iniFile.ParseFileReadValue("pooling"); - string settingPort = iniFile.ParseFileReadValue("port"); - - m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + - ";User ID=" + - settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";"; - - m_log.Info("Creating " + m_maxConnections + " DB connections..."); - for (int i = 0; i < m_maxConnections; i++) - { - m_log.Info("Connecting to DB... [" + i + "]"); - MySQLSuperManager msm = new MySQLSuperManager(); - msm.Manager = new MySQLManager(m_connectString); - m_dbconnections.Add(i, msm); - } - - database = new MySQLManager(m_connectString); - } - else - { - m_connectString = connect; - database = new MySQLManager(m_connectString); - - m_log.Info("Creating " + m_maxConnections + " DB connections..."); - for (int i = 0; i < m_maxConnections; i++) - { - m_log.Info("Connecting to DB... [" + i + "]"); - MySQLSuperManager msm = new MySQLSuperManager(); - msm.Manager = new MySQLManager(m_connectString); - m_dbconnections.Add(i, msm); - } - } + m_connectionString = connect; + m_database = new MySQLManager(connect); // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "UserStore"); - m.Update(); + using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, assem, "UserStore"); + m.Update(); + } } public override void Dispose() @@ -173,35 +95,32 @@ namespace OpenSim.Data.MySQL // see IUserDataPlugin public override UserProfileData GetUserByName(string user, string last) { - MySQLSuperManager dbm = GetLockedConnection("GetUserByName"); - try { Dictionary param = new Dictionary(); param["?first"] = user; param["?second"] = last; - IDbCommand result = - dbm.Manager.Query( - "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); - IDataReader reader = result.ExecuteReader(); - - UserProfileData row = dbm.Manager.readUserRow(reader); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - reader.Dispose(); - result.Dispose(); - return row; + using (IDbCommand result = m_database.Query(dbcon, + "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + UserProfileData row = m_database.readUserRow(reader); + return row; + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } #region User Friends List Data @@ -216,38 +135,38 @@ namespace OpenSim.Data.MySQL param["?friendPerms"] = perms.ToString(); param["?datetimestamp"] = dtvalue.ToString(); - MySQLSuperManager dbm = GetLockedConnection("AddNewUserFriend"); - try { - IDbCommand adder = - dbm.Manager.Query( + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand adder = m_database.Query(dbcon, "INSERT INTO `" + m_userFriendsTableName + "` " + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + "VALUES " + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", - param); - adder.ExecuteNonQuery(); + param)) + { + adder.ExecuteNonQuery(); + } - adder = - dbm.Manager.Query( + using (IDbCommand adder = m_database.Query(dbcon, "INSERT INTO `" + m_userFriendsTableName + "` " + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + "VALUES " + "(?friendID,?ownerID,?friendPerms,?datetimestamp)", - param); - adder.ExecuteNonQuery(); + param)) + { + adder.ExecuteNonQuery(); + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } - finally - { - dbm.Release(); - } } public override void RemoveUserFriend(UUID friendlistowner, UUID friend) @@ -256,32 +175,32 @@ namespace OpenSim.Data.MySQL param["?ownerID"] = friendlistowner.ToString(); param["?friendID"] = friend.ToString(); - MySQLSuperManager dbm = GetLockedConnection("RemoveUserFriend"); - try { - IDbCommand updater = - dbm.Manager.Query( - "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", - param); - updater.ExecuteNonQuery(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - updater = - dbm.Manager.Query( - "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", - param); - updater.ExecuteNonQuery(); + using (IDbCommand updater = m_database.Query(dbcon, + "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", + param)) + { + updater.ExecuteNonQuery(); + } + + using (IDbCommand updater = m_database.Query(dbcon, + "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", + param)) + { + updater.ExecuteNonQuery(); + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } - finally - { - dbm.Release(); - } } public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) @@ -291,28 +210,27 @@ namespace OpenSim.Data.MySQL param["?friendID"] = friend.ToString(); param["?friendPerms"] = perms.ToString(); - MySQLSuperManager dbm = GetLockedConnection("UpdateUserFriendPerms"); - try { - IDbCommand updater = - dbm.Manager.Query( - "update " + m_userFriendsTableName + - " SET friendPerms = ?friendPerms " + - "where ownerID = ?ownerID and friendID = ?friendID", - param); - updater.ExecuteNonQuery(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand updater = m_database.Query(dbcon, + "update " + m_userFriendsTableName + + " SET friendPerms = ?friendPerms " + + "where ownerID = ?ownerID and friendID = ?friendID", + param)) + { + updater.ExecuteNonQuery(); + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } - finally - { - dbm.Release(); - } } public override List GetUserFriendList(UUID friendlistowner) @@ -322,87 +240,83 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.ToString(); - MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); - try { - //Left Join userfriends to itself - IDbCommand result = - dbm.Manager.Query( + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + //Left Join userfriends to itself + using (IDbCommand result = m_database.Query(dbcon, "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) - { - FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new UUID((string) reader["ownerID"]); - fli.Friend = new UUID((string) reader["friendID"]); - fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); - - // This is not a real column in the database table, it's a joined column from the opposite record - fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); - - Lfli.Add(fli); + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + FriendListItem fli = new FriendListItem(); + fli.FriendListOwner = new UUID((string)reader["ownerID"]); + fli.Friend = new UUID((string)reader["friendID"]); + fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); + + // This is not a real column in the database table, it's a joined column from the opposite record + fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); + + Lfli.Add(fli); + } + } + } } - - reader.Dispose(); - result.Dispose(); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return Lfli; } - finally - { - dbm.Release(); - } return Lfli; } override public Dictionary GetFriendRegionInfos (List uuids) { - MySQLSuperManager dbm = GetLockedConnection("GetFriendRegionInfos"); Dictionary infos = new Dictionary(); try { - foreach (UUID uuid in uuids) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); - IDbCommand result = - dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + - " where UUID = ?uuid", param); + dbcon.Open(); - IDataReader reader = result.ExecuteReader(); - while (reader.Read()) + foreach (UUID uuid in uuids) { - FriendRegionInfo fri = new FriendRegionInfo(); - fri.isOnline = (sbyte)reader["agentOnline"] != 0; - fri.regionHandle = (ulong)reader["currentHandle"]; - - infos[uuid] = fri; + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToString(); + + using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName + + " where UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + FriendRegionInfo fri = new FriendRegionInfo(); + fri.isOnline = (sbyte)reader["agentOnline"] != 0; + fri.regionHandle = (ulong)reader["currentHandle"]; + + infos[uuid] = fri; + } + } + } } - - reader.Dispose(); - result.Dispose(); } } catch (Exception e) { m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); - } - finally - { - dbm.Release(); + m_log.Error(e.Message, e); } return infos; @@ -423,76 +337,73 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; - MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); try { - IDbCommand result = - dbm.Manager.Query( + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand result = m_database.Query(dbcon, "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first AND lastname like ?second LIMIT 100", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string) reader["UUID"]); - user.firstName = (string) reader["username"]; - user.lastName = (string) reader["lastname"]; - returnlist.Add(user); + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["lastname"]; + returnlist.Add(user); + } + } + } } - reader.Dispose(); - result.Dispose(); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return returnlist; } - finally - { - dbm.Release(); - } } else { - MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); - try { Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - IDbCommand result = - dbm.Manager.Query( + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (IDbCommand result = m_database.Query(dbcon, "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first OR lastname like ?first LIMIT 100", - param); - IDataReader reader = result.ExecuteReader(); - - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string) reader["UUID"]); - user.firstName = (string) reader["username"]; - user.lastName = (string) reader["lastname"]; - returnlist.Add(user); + param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + while (reader.Read()) + { + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["lastname"]; + returnlist.Add(user); + } + } + } } - reader.Dispose(); - result.Dispose(); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return returnlist; } - finally - { - dbm.Release(); - } } return returnlist; } @@ -504,32 +415,30 @@ namespace OpenSim.Data.MySQL /// User profile data public override UserProfileData GetUserByUUID(UUID uuid) { - MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID"); try { Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - - UserProfileData row = dbm.Manager.readUserRow(reader); - - reader.Dispose(); - result.Dispose(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - return row; + using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + UserProfileData row = m_database.readUserRow(reader); + return row; + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } /// @@ -565,25 +474,18 @@ namespace OpenSim.Data.MySQL param["?UUID"] = AgentID.ToString(); param["?webLoginKey"] = WebLoginKey.ToString(); - MySQLSuperManager dbm = GetLockedConnection("StoreWebLoginKey"); - try { - dbm.Manager.ExecuteParameterizedSql( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", - param); + m_database.ExecuteParameterizedSql( + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", + param); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } - finally - { - dbm.Release(); - } } /// @@ -593,34 +495,30 @@ namespace OpenSim.Data.MySQL /// The users session public override UserAgentData GetAgentByUUID(UUID uuid) { - MySQLSuperManager dbm = GetLockedConnection("GetAgentByUUID"); - try { Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", - param); - IDataReader reader = result.ExecuteReader(); - - UserAgentData row = dbm.Manager.readAgentRow(reader); - - reader.Dispose(); - result.Dispose(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - return row; + using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + UserAgentData row = m_database.readAgentRow(reader); + return row; + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } /// @@ -634,27 +532,22 @@ namespace OpenSim.Data.MySQL { return; } - MySQLSuperManager dbm = GetLockedConnection("AddNewUserProfile"); try { - dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, - user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, - user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.CanDoMask, user.WantDoMask, - user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + m_database.insertUserRow( + user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, + user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, + user.LastLogin, user.UserInventoryURI, user.UserAssetURI, + user.CanDoMask, user.WantDoMask, + user.AboutText, user.FirstLifeAboutText, user.Image, + user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); - } - finally - { - dbm.Release(); + m_log.Error(e.Message, e); } } @@ -668,19 +561,13 @@ namespace OpenSim.Data.MySQL if (agent.ProfileID == zero || agent.SessionID == zero) return; - MySQLSuperManager dbm = GetLockedConnection("AddNewUserAgent"); try { - dbm.Manager.insertAgentRow(agent); + m_database.insertAgentRow(agent); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); - } - finally - { - dbm.Release(); + m_log.Error(e.Message, e); } } @@ -690,24 +577,24 @@ namespace OpenSim.Data.MySQL /// The profile data to use to update the DB public override bool UpdateUserProfile(UserProfileData user) { - MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); try { - dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, - user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, - user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + m_database.updateUserRow( + user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, + user.UserInventoryURI, + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, + user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + + return true; } - finally + catch { - dbm.Release(); + return false; } - - return true; } /// @@ -742,41 +629,40 @@ namespace OpenSim.Data.MySQL /// public override AvatarAppearance GetUserAppearance(UUID user) { - MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance"); try { Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); - IDbCommand result = dbm.Manager.Query( - "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); - IDataReader reader = result.ExecuteReader(); - - AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); - - reader.Dispose(); - result.Dispose(); - - if (null == appearance) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); - return null; - } - - appearance.SetAttachments(GetUserAttachments(user)); + dbcon.Open(); - return appearance; + using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + AvatarAppearance appearance = m_database.readAppearanceRow(reader); + + if (appearance == null) + { + m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); + return null; + } + else + { + appearance.SetAttachments(GetUserAttachments(user)); + return appearance; + } + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } /// @@ -787,22 +673,16 @@ namespace OpenSim.Data.MySQL // override public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { - MySQLSuperManager dbm = GetLockedConnection("UpdateUserAppearance"); try { appearance.Owner = user; - dbm.Manager.insertAppearanceRow(appearance); + m_database.insertAppearanceRow(appearance); UpdateUserAttachments(user, appearance.GetAttachments()); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); - } - finally - { - dbm.Release(); + m_log.Error(e.Message, e); } } @@ -829,43 +709,33 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = agentID.ToString(); - MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); - try { - IDbCommand result = dbm.Manager.Query( - "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); - IDataReader reader = result.ExecuteReader(); - - Hashtable ret = dbm.Manager.readAttachments(reader); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - reader.Dispose(); - result.Dispose(); - return ret; + using (IDbCommand result = m_database.Query(dbcon, + "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) + { + using (IDataReader reader = result.ExecuteReader()) + { + Hashtable ret = m_database.readAttachments(reader); + return ret; + } + } + } } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return null; } - finally - { - dbm.Release(); - } } public void UpdateUserAttachments(UUID agentID, Hashtable data) { - MySQLSuperManager dbm = GetLockedConnection("UpdateUserAttachments"); - try - { - dbm.Manager.writeAttachments(agentID, data); - } - finally - { - dbm.Release(); - } + m_database.writeAttachments(agentID, data); } public override void ResetAttachments(UUID userID) @@ -873,19 +743,10 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = userID.ToString(); - MySQLSuperManager dbm = GetLockedConnection("ResetAttachments"); - - try - { - dbm.Manager.ExecuteParameterizedSql( - "UPDATE " + m_attachmentsTableName + - " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", - param); - } - finally - { - dbm.Release(); - } + m_database.ExecuteParameterizedSql( + "UPDATE " + m_attachmentsTableName + + " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", + param); } public override void LogoutUsers(UUID regionID) @@ -893,25 +754,18 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?regionID"] = regionID.ToString(); - MySQLSuperManager dbm = GetLockedConnection("LogoutUsers"); - try { - dbm.Manager.ExecuteParameterizedSql( - "update " + m_agentsTableName + " SET agentOnline = 0 " + - "where currentRegion = ?regionID", - param); + m_database.ExecuteParameterizedSql( + "update " + m_agentsTableName + " SET agentOnline = 0 " + + "where currentRegion = ?regionID", + param); } catch (Exception e) { - dbm.Manager.Reconnect(); - m_log.Error(e.ToString()); + m_log.Error(e.Message, e); return; } - finally - { - dbm.Release(); - } } } } diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 0eebc9c..b5866cb 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -110,47 +110,58 @@ namespace OpenSim.Data.MySQL public bool MoveItem(string id, string newParent) { - MySqlCommand cmd = new MySqlCommand(); + using (MySqlCommand cmd = new MySqlCommand()) + { - cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); - cmd.Parameters.AddWithValue("?ParentFolderID", newParent); - cmd.Parameters.AddWithValue("?InventoryID", id); + cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); + cmd.Parameters.AddWithValue("?ParentFolderID", newParent); + cmd.Parameters.AddWithValue("?InventoryID", id); - return ExecuteNonQuery(cmd) == 0 ? false : true; + return ExecuteNonQuery(cmd) == 0 ? false : true; + } } public XInventoryItem[] GetActiveGestures(UUID principalID) { - MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); - cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); - cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); + cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); - return DoQuery(cmd); + return DoQuery(cmd); + } } public int GetAssetPermissions(UUID principalID, UUID assetID) { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm); - cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?AssetID", assetID.ToString()); - - IDataReader reader = ExecuteReader(cmd); - - int perms = 0; - - if (reader.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.Connection = dbcon; + + cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?AssetID", assetID.ToString()); + + using (IDataReader reader = cmd.ExecuteReader()) + { + + int perms = 0; + + if (reader.Read()) + { + perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); + } + + return perms; + } + } } - - reader.Close(); - CloseReaderCommand(cmd); - - return perms; } } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs index d1d5c2a..8272316 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs @@ -31,6 +31,7 @@ using OpenSim.Data.Tests; using log4net; using System.Reflection; using OpenSim.Tests.Common; +using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL.Tests { @@ -65,9 +66,13 @@ namespace OpenSim.Data.MySQL.Tests // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; - Migration m = new Migration(database.Connection, assem, "GridStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(connect)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, assem, "AssetStore"); + m.Update(); + } } [TestFixtureTearDown] -- cgit v1.1 From c6adbccc27141109f27c9cb9e65fea2b08b07850 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 7 Feb 2010 12:06:00 +0000 Subject: Finish the "Get friends" method --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 9f7e850..e416eea 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -57,7 +57,12 @@ namespace OpenSim.Data.MySQL public FriendsData[] GetFriends(UUID principalID) { - return Get("PrincipalID", principalID.ToString()); + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("select a.*,b.Flags as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + + return DoQuery(cmd); } } } -- cgit v1.1 From 210649f0d4c55b840fc5886fe41e7d4505fa5097 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 8 Feb 2010 17:38:05 +0000 Subject: Make an exception report more clear. Fix a database access in Presence to conform to the changes in the generic table handler. --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 4950f7f..fcbe3d6 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -122,26 +122,33 @@ namespace OpenSim.Data.MySQL cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); cmd.Parameters.AddWithValue("?UserID", userID); +; + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); - using (IDataReader reader = cmd.ExecuteReader()) - { + cmd.Connection = dbcon; - List deleteSessions = new List(); - int online = 0; - - while(reader.Read()) + using (IDataReader reader = cmd.ExecuteReader()) { - if (bool.Parse(reader["Online"].ToString())) - online++; - else - deleteSessions.Add(new UUID(reader["SessionID"].ToString())); - } - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); + List deleteSessions = new List(); + int online = 0; + + while(reader.Read()) + { + if (bool.Parse(reader["Online"].ToString())) + online++; + else + deleteSessions.Add(new UUID(reader["SessionID"].ToString())); + } - foreach (UUID s in deleteSessions) - Delete("SessionID", s.ToString()); + if (online == 0 && deleteSessions.Count > 0) + deleteSessions.RemoveAt(0); + + foreach (UUID s in deleteSessions) + Delete("SessionID", s.ToString()); + } } } } -- cgit v1.1 From 1dfcf683307c24f4810961f52e0e643a59ef8d8c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 9 Feb 2010 07:05:38 +0000 Subject: Add the friends service skel and correct some namespace issues --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index e416eea..7a43bb6 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -59,7 +59,7 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("select a.*,b.Flags as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); + cmd.CommandText = String.Format("select a.*,b.Flags as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID and b.Flags is not null", m_Realm); cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); return DoQuery(cmd); -- cgit v1.1 From 802a969267da9ed2780ea66c736c3d531e336dfa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Feb 2010 21:32:03 +0000 Subject: Fix http://opensimulator.org/mantis/view.php?id=4224 This resolves the problem where eyes and hair would turn white on standalone configurations When a client receives body part information, for some insane reason or other it always ends up uploading this back to the server and then immediately re-requesting it. This should have been okay since we stored that asset in cache. However, the standalone asset service connector was not checking this cache properly, so every time the client made the request for the asset it has just loaded it would get a big fat null back in the face, causing it to make clothes and hair white. This bug did not affect grids since they use a different service connector. --- OpenSim/Data/MySQL/MySQLUserData.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 2cf88b8..0a9d2e3 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -622,11 +622,6 @@ namespace OpenSim.Data.MySQL return false; } - /// - /// Appearance - /// TODO: stubs for now to get us to a compiling state gently - /// override - /// public override AvatarAppearance GetUserAppearance(UUID user) { try -- cgit v1.1 From bb171717ceaef37b022a135209c2e0bf031d21f9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 15:38:52 -0800 Subject: Deleted obsolete files in the Data layer. Compiles. --- OpenSim/Data/MySQL/MySQLGridData.cs | 422 -------- OpenSim/Data/MySQL/MySQLLogData.cs | 166 ---- OpenSim/Data/MySQL/MySQLManager.cs | 1248 ------------------------ OpenSim/Data/MySQL/MySQLSuperManager.cs | 52 - OpenSim/Data/MySQL/MySQLUserData.cs | 766 --------------- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 22 +- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 54 +- OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 94 -- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 30 +- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 53 +- OpenSim/Data/MySQL/Tests/MySQLUserTest.cs | 85 -- 11 files changed, 103 insertions(+), 2889 deletions(-) delete mode 100644 OpenSim/Data/MySQL/MySQLGridData.cs delete mode 100644 OpenSim/Data/MySQL/MySQLLogData.cs delete mode 100644 OpenSim/Data/MySQL/MySQLManager.cs delete mode 100644 OpenSim/Data/MySQL/MySQLSuperManager.cs delete mode 100644 OpenSim/Data/MySQL/MySQLUserData.cs delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLGridTest.cs delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLUserTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs deleted file mode 100644 index f4e7b85..0000000 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; -using System.Threading; -using log4net; -using MySql.Data.MySqlClient; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Data.MySQL -{ - /// - /// A MySQL Interface for the Grid Server - /// - public class MySQLGridData : GridDataBase - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private MySQLManager m_database; - private object m_dbLock = new object(); - private string m_connectionString; - - override public void Initialise() - { - m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); - throw new PluginNotInitialisedException (Name); - } - - /// - /// Initialises Grid interface - /// - /// - /// Loads and initialises the MySQL storage plugin - /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. - /// Check for migration - /// - /// - /// - /// connect string. - override public void Initialise(string connect) - { - m_connectionString = connect; - m_database = new MySQLManager(connect); - - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - Migration m = new Migration(dbcon, assem, "GridStore"); - m.Update(); - } - } - - /// - /// Shuts down the grid interface - /// - override public void Dispose() - { - } - - /// - /// Returns the plugin name - /// - /// Plugin name - override public string Name - { - get { return "MySql OpenGridData"; } - } - - /// - /// Returns the plugin version - /// - /// Plugin version - override public string Version - { - get { return "0.1"; } - } - - /// - /// Returns all the specified region profiles within coordates -- coordinates are inclusive - /// - /// Minimum X coordinate - /// Minimum Y coordinate - /// Maximum X coordinate - /// Maximum Y coordinate - /// Array of sim profiles - override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) - { - try - { - Dictionary param = new Dictionary(); - param["?xmin"] = xmin.ToString(); - param["?ymin"] = ymin.ToString(); - param["?xmax"] = xmax.ToString(); - param["?ymax"] = ymax.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; - - List rows = new List(); - - while ((row = m_database.readSimRow(reader)) != null) - rows.Add(row); - - return rows.ToArray(); - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Returns up to maxNum profiles of regions that have a name starting with namePrefix - /// - /// The name to match against - /// Maximum number of profiles to return - /// A list of sim profiles - override public List GetRegionsByName(string namePrefix, uint maxNum) - { - try - { - Dictionary param = new Dictionary(); - param["?name"] = namePrefix + "%"; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT * FROM regions WHERE regionName LIKE ?name", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; - - List rows = new List(); - - while (rows.Count < maxNum && (row = m_database.readSimRow(reader)) != null) - rows.Add(row); - - return rows; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Returns a sim profile from it's location - /// - /// Region location handle - /// Sim profile - override public RegionProfileData GetProfileByHandle(ulong handle) - { - try - { - Dictionary param = new Dictionary(); - param["?handle"] = handle.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionHandle = ?handle", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = m_database.readSimRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Returns a sim profile from it's UUID - /// - /// The region UUID - /// The sim profile - override public RegionProfileData GetProfileByUUID(UUID uuid) - { - try - { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE uuid = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = m_database.readSimRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Returns a sim profile from it's Region name string - /// - /// The sim profile - override public RegionProfileData GetProfileByString(string regionName) - { - if (regionName.Length > 2) - { - try - { - Dictionary param = new Dictionary(); - // Add % because this is a like query. - param["?regionName"] = regionName + "%"; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - // Order by statement will return shorter matches first. Only returns one record or no record. - using (IDbCommand result = m_database.Query(dbcon, - "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = m_database.readSimRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); - return null; - } - - /// - /// Adds a new profile to the database - /// - /// The profile to add - /// Successful? - override public DataResponse StoreProfile(RegionProfileData profile) - { - try - { - if (m_database.insertRegion(profile)) - return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; - } - catch - { - return DataResponse.RESPONSE_ERROR; - } - } - - /// - /// Deletes a sim profile from the database - /// - /// the sim UUID - /// Successful? - //public DataResponse DeleteProfile(RegionProfileData profile) - override public DataResponse DeleteProfile(string uuid) - { - try - { - if (m_database.deleteRegion(uuid)) - return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; - } - catch - { - return DataResponse.RESPONSE_ERROR; - } - } - - /// - /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. - /// - /// The UUID of the challenger - /// The attempted regionHandle of the challenger - /// The secret - /// Whether the secret and regionhandle match the database entry for UUID - override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) - { - bool throwHissyFit = false; // Should be true by 1.0 - - if (throwHissyFit) - throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); - - RegionProfileData data = GetProfileByUUID(uuid); - - return (handle == data.regionHandle && authkey == data.regionSecret); - } - - /// - /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region - /// - /// This requires a security audit. - /// - /// - /// - /// - /// - public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) - { - // SHA512Managed HashProvider = new SHA512Managed(); - // Encoding TextProvider = new UTF8Encoding(); - - // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); - // byte[] hash = HashProvider.ComputeHash(stream); - - return false; - } - - /// - /// Adds a location reservation - /// - /// x coordinate - /// y coordinate - /// - override public ReservationData GetReservationAtPoint(uint x, uint y) - { - try - { - Dictionary param = new Dictionary(); - param["?x"] = x.ToString(); - param["?y"] = y.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - ReservationData row = m_database.readReservationRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - } -} diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs deleted file mode 100644 index 304883c..0000000 --- a/OpenSim/Data/MySQL/MySQLLogData.cs +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -using System; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using OpenSim.Framework; - -namespace OpenSim.Data.MySQL -{ - /// - /// An interface to the log database for MySQL - /// - internal class MySQLLogData : ILogDataPlugin - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// The database manager - /// - public MySQLManager database; - - public void Initialise() - { - m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); - throw new PluginNotInitialisedException (Name); - } - - /// - /// Artificial constructor called when the plugin is loaded - /// Uses the obsolete mysql_connection.ini if connect string is empty. - /// - /// connect string - public void Initialise(string connect) - { - if (connect != String.Empty) - { - database = new MySQLManager(connect); - } - else - { - m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead"); - - IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); - string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); - string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); - string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); - string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); - string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - - database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, - settingPooling, settingPort); - } - - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - - using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(connect)) - { - dbcon.Open(); - - Migration m = new Migration(dbcon, assem, "LogStore"); - - // TODO: After rev 6000, remove this. People should have - // been rolled onto the new migration code by then. - TestTables(m); - - m.Update(); - } - } - - /// - /// - private void TestTables(Migration m) - { - // under migrations, bail - if (m.Version > 0) - return; - - Dictionary tableList = new Dictionary(); - tableList["logs"] = null; - database.GetTableVersion(tableList); - - // migrations will handle it - if (tableList["logs"] == null) - return; - - // we have the table, so pretend like we did the first migration in the past - if (m.Version == 0) - m.Version = 1; - } - - /// - /// Saves a log item to the database - /// - /// The daemon triggering the event - /// The target of the action (region / agent UUID, etc) - /// The method call where the problem occured - /// The arguments passed to the method - /// How critical is this? - /// The message to log - public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, - string logMessage) - { - try - { - database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage); - } - catch - { - } - } - - /// - /// Returns the name of this DB provider - /// - /// A string containing the DB provider name - public string Name - { - get { return "MySQL Logdata Interface";} - } - - /// - /// Closes the database provider - /// - /// do nothing - public void Dispose() - { - // Do nothing. - } - - /// - /// Returns the version of this DB provider - /// - /// A string containing the provider version - public string Version - { - get { return "0.1"; } - } - } -} diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs deleted file mode 100644 index ace2027..0000000 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ /dev/null @@ -1,1248 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Reflection; -using log4net; -using MySql.Data.MySqlClient; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Data.MySQL -{ - /// - /// A MySQL Database manager - /// - public class MySQLManager - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Connection string for ADO.net - /// - private string connectionString; - - private object m_dbLock = new object(); - - private const string m_waitTimeoutSelect = "select @@wait_timeout"; - - /// - /// Wait timeout for our connection in ticks. - /// - private long m_waitTimeout; - - /// - /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long - /// running database operations. - /// - private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; - - /// - /// Holds the last tick time that the connection was used. - /// - private long m_lastConnectionUse; - - /// - /// Initialises and creates a new MySQL connection and maintains it. - /// - /// The MySQL server being connected to - /// The name of the MySQL database being used - /// The username logging into the database - /// The password for the user logging in - /// Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'. - /// The MySQL server port - public MySQLManager(string hostname, string database, string username, string password, string cpooling, - string port) - { - string s = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + - username + ";Password=" + password + ";Pooling=" + cpooling + ";"; - - Initialise(s); - } - - /// - /// Initialises and creates a new MySQL connection and maintains it. - /// - /// connectionString - public MySQLManager(String connect) - { - Initialise(connect); - } - - /// - /// Initialises and creates a new MySQL connection and maintains it. - /// - /// connectionString - public void Initialise(String connect) - { - try - { - connectionString = connect; - //dbcon = new MySqlConnection(connectionString); - - try - { - //dbcon.Open(); - } - catch(Exception e) - { - throw new Exception("Connection error while using connection string ["+connectionString+"]", e); - } - - m_log.Info("[MYSQL]: Connection established"); - GetWaitTimeout(); - } - catch (Exception e) - { - throw new Exception("Error initialising MySql Database: " + e.ToString()); - } - } - - /// - /// Get the wait_timeout value for our connection - /// - protected void GetWaitTimeout() - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) - { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } - } - } - } - - m_lastConnectionUse = DateTime.Now.Ticks; - - m_log.DebugFormat( - "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); - } - - public string ConnectionString - { - get { return connectionString; } - } - - /// - /// Returns the version of this DB provider - /// - /// A string containing the DB provider - public string getVersion() - { - Module module = GetType().Module; - // string dllName = module.Assembly.ManifestModule.Name; - Version dllVersion = module.Assembly.GetName().Version; - - return - string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); - } - - /// - /// Extract a named string resource from the embedded resources - /// - /// name of embedded resource - /// string contained within the embedded resource - private string getResourceString(string name) - { - Assembly assem = GetType().Assembly; - string[] names = assem.GetManifestResourceNames(); - - foreach (string s in names) - { - if (s.EndsWith(name)) - { - using (Stream resource = assem.GetManifestResourceStream(s)) - { - using (StreamReader resourceReader = new StreamReader(resource)) - { - string resourceString = resourceReader.ReadToEnd(); - return resourceString; - } - } - } - } - throw new Exception(string.Format("Resource '{0}' was not found", name)); - } - - /// - /// Execute a SQL statement stored in a resource, as a string - /// - /// name of embedded resource - public void ExecuteResourceSql(string name) - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon); - cmd.ExecuteNonQuery(); - } - } - - /// - /// Execute a MySqlCommand - /// - /// sql string to execute - public void ExecuteSql(string sql) - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); - } - } - - public void ExecuteParameterizedSql(string sql, Dictionary parameters) - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); - cmd.CommandText = sql; - foreach (KeyValuePair param in parameters) - { - cmd.Parameters.AddWithValue(param.Key, param.Value); - } - cmd.ExecuteNonQuery(); - } - } - - /// - /// Given a list of tables, return the version of the tables, as seen in the database - /// - /// - public void GetTableVersion(Dictionary tableList) - { - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - using (MySqlCommand tablesCmd = new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon)) - { - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) - { - while (tables.Read()) - { - try - { - string tableName = (string)tables["TABLE_NAME"]; - string comment = (string)tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) - { - tableList[tableName] = comment; - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - } - } - } - } - } - } - } - - // TODO: at some time this code should be cleaned up - - /// - /// Runs a query with protection against SQL Injection by using parameterised input. - /// - /// Database connection - /// The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y - /// The parameters - index so that @y is indexed as 'y' - /// A MySQL DB Command - public IDbCommand Query(MySqlConnection dbcon, string sql, Dictionary parameters) - { - try - { - MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); - dbcommand.CommandText = sql; - foreach (KeyValuePair param in parameters) - { - dbcommand.Parameters.AddWithValue(param.Key, param.Value); - } - - return (IDbCommand)dbcommand; - } - catch (Exception e) - { - // Return null if it fails. - m_log.Error("Failed during Query generation: " + e.Message, e); - return null; - } - } - - /// - /// Reads a region row from a database reader - /// - /// An active database reader - /// A region profile - public RegionProfileData readSimRow(IDataReader reader) - { - RegionProfileData retval = new RegionProfileData(); - - if (reader.Read()) - { - // Region Main gotta-have-or-we-return-null parts - UInt64 tmp64; - if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) - { - return null; - } - else - { - retval.regionHandle = tmp64; - } - UUID tmp_uuid; - if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid)) - { - return null; - } - else - { - retval.UUID = tmp_uuid; - } - - // non-critical parts - retval.regionName = (string)reader["regionName"]; - retval.originUUID = new UUID((string) reader["originUUID"]); - - // Secrets - retval.regionRecvKey = (string) reader["regionRecvKey"]; - retval.regionSecret = (string) reader["regionSecret"]; - retval.regionSendKey = (string) reader["regionSendKey"]; - - // Region Server - retval.regionDataURI = (string) reader["regionDataURI"]; - retval.regionOnline = false; // Needs to be pinged before this can be set. - retval.serverIP = (string) reader["serverIP"]; - retval.serverPort = (uint) reader["serverPort"]; - retval.serverURI = (string) reader["serverURI"]; - retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); - retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); - - // Location - retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); - retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); - retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); - - // Neighbours - 0 = No Override - retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); - retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); - retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); - retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); - - // Assets - retval.regionAssetURI = (string) reader["regionAssetURI"]; - retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; - retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; - - // Userserver - retval.regionUserURI = (string) reader["regionUserURI"]; - retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; - retval.regionUserSendKey = (string) reader["regionUserSendKey"]; - - // World Map Addition - UUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID); - UUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid); - retval.maturity = Convert.ToUInt32(reader["access"]); - } - else - { - return null; - } - return retval; - } - - /// - /// Reads a reservation row from a database reader - /// - /// An active database reader - /// A reservation data object - public ReservationData readReservationRow(IDataReader reader) - { - ReservationData retval = new ReservationData(); - if (reader.Read()) - { - retval.gridRecvKey = (string) reader["gridRecvKey"]; - retval.gridSendKey = (string) reader["gridSendKey"]; - retval.reservationCompany = (string) reader["resCompany"]; - retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); - retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); - retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); - retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); - retval.reservationName = (string) reader["resName"]; - retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; - UUID tmp; - UUID.TryParse((string) reader["userUUID"], out tmp); - retval.userUUID = tmp; - } - else - { - return null; - } - return retval; - } - - /// - /// Reads an agent row from a database reader - /// - /// An active database reader - /// A user session agent - public UserAgentData readAgentRow(IDataReader reader) - { - UserAgentData retval = new UserAgentData(); - - if (reader.Read()) - { - // Agent IDs - UUID tmp; - if (!UUID.TryParse((string)reader["UUID"], out tmp)) - return null; - retval.ProfileID = tmp; - - UUID.TryParse((string) reader["sessionID"], out tmp); - retval.SessionID = tmp; - - UUID.TryParse((string)reader["secureSessionID"], out tmp); - retval.SecureSessionID = tmp; - - // Agent Who? - retval.AgentIP = (string) reader["agentIP"]; - retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString()); - retval.AgentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString())); - - // Login/Logout times (UNIX Epoch) - retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString()); - retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); - - // Current position - retval.Region = new UUID((string)reader["currentRegion"]); - retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString()); - Vector3 tmp_v; - Vector3.TryParse((string) reader["currentPos"], out tmp_v); - retval.Position = tmp_v; - Vector3.TryParse((string)reader["currentLookAt"], out tmp_v); - retval.LookAt = tmp_v; - } - else - { - return null; - } - return retval; - } - - /// - /// Reads a user profile from an active data reader - /// - /// An active database reader - /// A user profile - public UserProfileData readUserRow(IDataReader reader) - { - UserProfileData retval = new UserProfileData(); - - if (reader.Read()) - { - UUID id; - if (!UUID.TryParse((string)reader["UUID"], out id)) - return null; - - retval.ID = id; - retval.FirstName = (string) reader["username"]; - retval.SurName = (string) reader["lastname"]; - retval.Email = (reader.IsDBNull(reader.GetOrdinal("email"))) ? "" : (string) reader["email"]; - - retval.PasswordHash = (string) reader["passwordHash"]; - retval.PasswordSalt = (string) reader["passwordSalt"]; - - retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); - retval.HomeLocation = new Vector3( - Convert.ToSingle(reader["homeLocationX"].ToString()), - Convert.ToSingle(reader["homeLocationY"].ToString()), - Convert.ToSingle(reader["homeLocationZ"].ToString())); - retval.HomeLookAt = new Vector3( - Convert.ToSingle(reader["homeLookAtX"].ToString()), - Convert.ToSingle(reader["homeLookAtY"].ToString()), - Convert.ToSingle(reader["homeLookAtZ"].ToString())); - - UUID regionID = UUID.Zero; - UUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use UUID.Zero - retval.HomeRegionID = regionID; - - retval.Created = Convert.ToInt32(reader["created"].ToString()); - retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); - - retval.UserInventoryURI = (string) reader["userInventoryURI"]; - retval.UserAssetURI = (string) reader["userAssetURI"]; - - retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); - retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); - - if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) - retval.AboutText = ""; - else - retval.AboutText = (string) reader["profileAboutText"]; - - if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) - retval.FirstLifeAboutText = ""; - else - retval.FirstLifeAboutText = (string)reader["profileFirstText"]; - - if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) - retval.Image = UUID.Zero; - else { - UUID tmp; - UUID.TryParse((string)reader["profileImage"], out tmp); - retval.Image = tmp; - } - - if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) - retval.FirstLifeImage = UUID.Zero; - else { - UUID tmp; - UUID.TryParse((string)reader["profileFirstImage"], out tmp); - retval.FirstLifeImage = tmp; - } - - if (reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) - { - retval.WebLoginKey = UUID.Zero; - } - else - { - UUID tmp; - UUID.TryParse((string)reader["webLoginKey"], out tmp); - retval.WebLoginKey = tmp; - } - - retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString()); - retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString()); - if (reader.IsDBNull(reader.GetOrdinal("customType"))) - retval.CustomType = ""; - else - retval.CustomType = reader["customType"].ToString(); - - if (reader.IsDBNull(reader.GetOrdinal("partner"))) - { - retval.Partner = UUID.Zero; - } - else - { - UUID tmp; - UUID.TryParse((string)reader["partner"], out tmp); - retval.Partner = tmp; - } - } - else - { - return null; - } - return retval; - } - - /// - /// Reads an avatar appearence from an active data reader - /// - /// An active database reader - /// An avatar appearence - public AvatarAppearance readAppearanceRow(IDataReader reader) - { - AvatarAppearance appearance = null; - if (reader.Read()) - { - appearance = new AvatarAppearance(); - appearance.Owner = new UUID((string)reader["owner"]); - appearance.Serial = Convert.ToInt32(reader["serial"]); - appearance.VisualParams = (byte[])reader["visual_params"]; - appearance.Texture = new Primitive.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); - appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); - appearance.BodyItem = new UUID((string)reader["body_item"]); - appearance.BodyAsset = new UUID((string)reader["body_asset"]); - appearance.SkinItem = new UUID((string)reader["skin_item"]); - appearance.SkinAsset = new UUID((string)reader["skin_asset"]); - appearance.HairItem = new UUID((string)reader["hair_item"]); - appearance.HairAsset = new UUID((string)reader["hair_asset"]); - appearance.EyesItem = new UUID((string)reader["eyes_item"]); - appearance.EyesAsset = new UUID((string)reader["eyes_asset"]); - appearance.ShirtItem = new UUID((string)reader["shirt_item"]); - appearance.ShirtAsset = new UUID((string)reader["shirt_asset"]); - appearance.PantsItem = new UUID((string)reader["pants_item"]); - appearance.PantsAsset = new UUID((string)reader["pants_asset"]); - appearance.ShoesItem = new UUID((string)reader["shoes_item"]); - appearance.ShoesAsset = new UUID((string)reader["shoes_asset"]); - appearance.SocksItem = new UUID((string)reader["socks_item"]); - appearance.SocksAsset = new UUID((string)reader["socks_asset"]); - appearance.JacketItem = new UUID((string)reader["jacket_item"]); - appearance.JacketAsset = new UUID((string)reader["jacket_asset"]); - appearance.GlovesItem = new UUID((string)reader["gloves_item"]); - appearance.GlovesAsset = new UUID((string)reader["gloves_asset"]); - appearance.UnderShirtItem = new UUID((string)reader["undershirt_item"]); - appearance.UnderShirtAsset = new UUID((string)reader["undershirt_asset"]); - appearance.UnderPantsItem = new UUID((string)reader["underpants_item"]); - appearance.UnderPantsAsset = new UUID((string)reader["underpants_asset"]); - appearance.SkirtItem = new UUID((string)reader["skirt_item"]); - appearance.SkirtAsset = new UUID((string)reader["skirt_asset"]); - } - return appearance; - } - - // Read attachment list from data reader - public Hashtable readAttachments(IDataReader r) - { - Hashtable ret = new Hashtable(); - - while (r.Read()) - { - int attachpoint = Convert.ToInt32(r["attachpoint"]); - if (ret.ContainsKey(attachpoint)) - continue; - Hashtable item = new Hashtable(); - item.Add("item", r["item"].ToString()); - item.Add("asset", r["asset"].ToString()); - - ret.Add(attachpoint, item); - } - - return ret; - } - - /// - /// Inserts a new row into the log database - /// - /// The daemon which triggered this event - /// Who were we operating on when this occured (region UUID, user UUID, etc) - /// The method call where the problem occured - /// The arguments passed to the method - /// How critical is this? - /// Extra message info - /// Saved successfully? - public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, - string logMessage) - { - string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; - sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; - - Dictionary parameters = new Dictionary(); - parameters["?server"] = serverDaemon; - parameters["?target"] = target; - parameters["?method"] = methodCall; - parameters["?arguments"] = arguments; - parameters["?priority"] = priority.ToString(); - parameters["?message"] = logMessage; - - bool returnval = false; - - try - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - IDbCommand result = Query(dbcon, sql, parameters); - - if (result.ExecuteNonQuery() == 1) - returnval = true; - - result.Dispose(); - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - return returnval; - } - - /// - /// Creates a new user and inserts it into the database - /// - /// User ID - /// First part of the login - /// Second part of the login - /// A salted hash of the users password - /// The salt used for the password hash - /// A regionHandle of the users home region - /// The UUID of the user's home region - /// Home region position vector - /// Home region position vector - /// Home region position vector - /// Home region 'look at' vector - /// Home region 'look at' vector - /// Home region 'look at' vector - /// Account created (unix timestamp) - /// Last login (unix timestamp) - /// Users inventory URI - /// Users asset URI - /// I can do mask - /// I want to do mask - /// Profile text - /// Firstlife text - /// UUID for profile image - /// UUID for firstlife image - /// Ignored - /// Success? - public bool insertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, - string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, - float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, - string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, - string aboutText, string firstText, - UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) - { - m_log.Debug("[MySQLManager]: Creating profile for \"" + username + " " + lastname + "\" (" + uuid + ")"); - string sql = - "INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, "; - sql += - "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; - sql += - "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; - sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES "; - - sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, ?homeRegionID, "; - sql += - "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; - sql += - "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; - sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; - - Dictionary parameters = new Dictionary(); - parameters["?UUID"] = uuid.ToString(); - parameters["?username"] = username; - parameters["?lastname"] = lastname; - parameters["?email"] = email; - parameters["?passwordHash"] = passwordHash; - parameters["?passwordSalt"] = passwordSalt; - parameters["?homeRegion"] = homeRegion; - parameters["?homeRegionID"] = homeRegionID.ToString(); - parameters["?homeLocationX"] = homeLocX; - parameters["?homeLocationY"] = homeLocY; - parameters["?homeLocationZ"] = homeLocZ; - parameters["?homeLookAtX"] = homeLookAtX; - parameters["?homeLookAtY"] = homeLookAtY; - parameters["?homeLookAtZ"] = homeLookAtZ; - parameters["?created"] = created; - parameters["?lastLogin"] = lastlogin; - parameters["?userInventoryURI"] = inventoryURI; - parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = canDoMask; - parameters["?profileWantDoMask"] = wantDoMask; - parameters["?profileAboutText"] = aboutText; - parameters["?profileFirstText"] = firstText; - parameters["?profileImage"] = profileImage.ToString(); - parameters["?profileFirstImage"] = firstImage.ToString(); - parameters["?webLoginKey"] = webLoginKey.ToString(); - parameters["?userFlags"] = userFlags; - parameters["?godLevel"] = godLevel; - parameters["?customType"] = customType == null ? "" : customType; - parameters["?partner"] = partner.ToString(); - bool returnval = false; - - try - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - IDbCommand result = Query(dbcon, sql, parameters); - - if (result.ExecuteNonQuery() == 1) - returnval = true; - - result.Dispose(); - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - //m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString()); - return returnval; - } - - /// - /// Update user data into the database where User ID = uuid - /// - /// User ID - /// First part of the login - /// Second part of the login - /// A salted hash of the users password - /// The salt used for the password hash - /// A regionHandle of the users home region - /// Home region position vector - /// Home region position vector - /// Home region position vector - /// Home region 'look at' vector - /// Home region 'look at' vector - /// Home region 'look at' vector - /// Account created (unix timestamp) - /// Last login (unix timestamp) - /// Users inventory URI - /// Users asset URI - /// I can do mask - /// I want to do mask - /// Profile text - /// Firstlife text - /// UUID for profile image - /// UUID for firstlife image - /// UUID for weblogin Key - /// Success? - public bool updateUserRow(UUID uuid, string username, string lastname, string email, string passwordHash, - string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, - float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, - string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, - string aboutText, string firstText, - UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner) - { - string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname, `email` = ?email "; - sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; - sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , "; - sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; - sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; - sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; - sql += "`userInventoryURI` = ?userInventoryURI , `userAssetURI` = ?userAssetURI , "; - sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , "; - sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; - sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; - sql += "`userFlags` = ?userFlags , `godLevel` = ?godLevel , "; - sql += "`customType` = ?customType , `partner` = ?partner , "; - sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; - - Dictionary parameters = new Dictionary(); - parameters["?UUID"] = uuid.ToString(); - parameters["?username"] = username; - parameters["?lastname"] = lastname; - parameters["?email"] = email; - parameters["?passwordHash"] = passwordHash; - parameters["?passwordSalt"] = passwordSalt; - parameters["?homeRegion"] = homeRegion; - parameters["?homeRegionID"] = homeRegionID.ToString(); - parameters["?homeLocationX"] = homeLocX; - parameters["?homeLocationY"] = homeLocY; - parameters["?homeLocationZ"] = homeLocZ; - parameters["?homeLookAtX"] = homeLookAtX; - parameters["?homeLookAtY"] = homeLookAtY; - parameters["?homeLookAtZ"] = homeLookAtZ; - parameters["?created"] = created; - parameters["?lastLogin"] = lastlogin; - parameters["?userInventoryURI"] = inventoryURI; - parameters["?userAssetURI"] = assetURI; - parameters["?profileCanDoMask"] = canDoMask; - parameters["?profileWantDoMask"] = wantDoMask; - parameters["?profileAboutText"] = aboutText; - parameters["?profileFirstText"] = firstText; - parameters["?profileImage"] = profileImage.ToString(); - parameters["?profileFirstImage"] = firstImage.ToString(); - parameters["?webLoginKey"] = webLoginKey.ToString(); - parameters["?userFlags"] = userFlags; - parameters["?godLevel"] = godLevel; - parameters["?customType"] = customType == null ? "" : customType; - parameters["?partner"] = partner.ToString(); - - bool returnval = false; - try - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - IDbCommand result = Query(dbcon, sql, parameters); - - if (result.ExecuteNonQuery() == 1) - returnval = true; - - result.Dispose(); - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - //m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString()); - return returnval; - } - - /// - /// Inserts a new region into the database - /// - /// The region to insert - /// Success? - public bool insertRegion(RegionProfileData regiondata) - { - bool GRID_ONLY_UPDATE_NECESSARY_DATA = false; - - string sql = String.Empty; - if (GRID_ONLY_UPDATE_NECESSARY_DATA) - { - sql += "INSERT INTO "; - } - else - { - sql += "REPLACE INTO "; - } - - sql += "regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; - sql += - "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; - - // part of an initial brutish effort to provide accurate information (as per the xml region spec) - // wrt the ownership of a given region - // the (very bad) assumption is that this value is being read and handled inconsistently or - // not at all. Current strategy is to put the code in place to support the validity of this information - // and to roll forward debugging any issues from that point - // - // this particular section of the mod attempts to implement the commit of a supplied value - // server for the UUID of the region's owner (master avatar). It consists of the addition of the column and value to the relevant sql, - // as well as the related parameterization - sql += - "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID, access) VALUES "; - - sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; - sql += - "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; - sql += - "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort, ?owner_uuid, ?originUUID, ?access)"; - - if (GRID_ONLY_UPDATE_NECESSARY_DATA) - { - sql += "ON DUPLICATE KEY UPDATE serverIP = ?serverIP, serverPort = ?serverPort, serverURI = ?serverURI, owner_uuid - ?owner_uuid;"; - } - else - { - sql += ";"; - } - - Dictionary parameters = new Dictionary(); - - parameters["?regionHandle"] = regiondata.regionHandle.ToString(); - parameters["?regionName"] = regiondata.regionName.ToString(); - parameters["?uuid"] = regiondata.UUID.ToString(); - parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString(); - parameters["?regionSecret"] = regiondata.regionSecret.ToString(); - parameters["?regionSendKey"] = regiondata.regionSendKey.ToString(); - parameters["?regionDataURI"] = regiondata.regionDataURI.ToString(); - parameters["?serverIP"] = regiondata.serverIP.ToString(); - parameters["?serverPort"] = regiondata.serverPort.ToString(); - parameters["?serverURI"] = regiondata.serverURI.ToString(); - parameters["?locX"] = regiondata.regionLocX.ToString(); - parameters["?locY"] = regiondata.regionLocY.ToString(); - parameters["?locZ"] = regiondata.regionLocZ.ToString(); - parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString(); - parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString(); - parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString(); - parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString(); - parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString(); - parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString(); - parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString(); - parameters["?regionUserURI"] = regiondata.regionUserURI.ToString(); - parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString(); - parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString(); - parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToString(); - parameters["?serverHttpPort"] = regiondata.httpPort.ToString(); - parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString(); - parameters["?owner_uuid"] = regiondata.owner_uuid.ToString(); - parameters["?originUUID"] = regiondata.originUUID.ToString(); - parameters["?access"] = regiondata.maturity.ToString(); - - bool returnval = false; - - try - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - IDbCommand result = Query(dbcon, sql, parameters); - - // int x; - // if ((x = result.ExecuteNonQuery()) > 0) - // { - // returnval = true; - // } - if (result.ExecuteNonQuery() > 0) - { - returnval = true; - } - result.Dispose(); - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - return returnval; - } - - /// - /// Delete a region from the database - /// - /// The region to delete - /// Success? - //public bool deleteRegion(RegionProfileData regiondata) - public bool deleteRegion(string uuid) - { - bool returnval = false; - - string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; - - Dictionary parameters = new Dictionary(); - - try - { - parameters["?uuid"] = uuid; - - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - IDbCommand result = Query(dbcon, sql, parameters); - - // int x; - // if ((x = result.ExecuteNonQuery()) > 0) - // { - // returnval = true; - // } - if (result.ExecuteNonQuery() > 0) - { - returnval = true; - } - result.Dispose(); - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - return returnval; - } - - /// - /// Creates a new agent and inserts it into the database - /// - /// The agent data to be inserted - /// Success? - public bool insertAgentRow(UserAgentData agentdata) - { - string sql = String.Empty; - sql += "REPLACE INTO "; - sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES "; - sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);"; - Dictionary parameters = new Dictionary(); - - parameters["?UUID"] = agentdata.ProfileID.ToString(); - parameters["?sessionID"] = agentdata.SessionID.ToString(); - parameters["?secureSessionID"] = agentdata.SecureSessionID.ToString(); - parameters["?agentIP"] = agentdata.AgentIP.ToString(); - parameters["?agentPort"] = agentdata.AgentPort.ToString(); - parameters["?agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0"; - parameters["?loginTime"] = agentdata.LoginTime.ToString(); - parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); - parameters["?currentRegion"] = agentdata.Region.ToString(); - parameters["?currentHandle"] = agentdata.Handle.ToString(); - parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString().Replace(",", ".") + "," + (agentdata.Position.Y).ToString().Replace(",", ".") + "," + (agentdata.Position.Z).ToString().Replace(",", ".") + ">"; - parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Y).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Z).ToString().Replace(",", ".") + ">"; - - bool returnval = false; - - try - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - IDbCommand result = Query(dbcon, sql, parameters); - - // int x; - // if ((x = result.ExecuteNonQuery()) > 0) - // { - // returnval = true; - // } - if (result.ExecuteNonQuery() > 0) - { - returnval = true; - } - result.Dispose(); - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - return returnval; - } - - /// - /// Create (or replace if existing) an avatar appearence - /// - /// - /// Succes? - public bool insertAppearanceRow(AvatarAppearance appearance) - { - string sql = String.Empty; - sql += "REPLACE INTO "; - sql += "avatarappearance (owner, serial, visual_params, texture, avatar_height, "; - sql += "body_item, body_asset, skin_item, skin_asset, hair_item, hair_asset, eyes_item, eyes_asset, "; - sql += "shirt_item, shirt_asset, pants_item, pants_asset, shoes_item, shoes_asset, socks_item, socks_asset, "; - sql += "jacket_item, jacket_asset, gloves_item, gloves_asset, undershirt_item, undershirt_asset, underpants_item, underpants_asset, "; - sql += "skirt_item, skirt_asset) values ("; - sql += "?owner, ?serial, ?visual_params, ?texture, ?avatar_height, "; - sql += "?body_item, ?body_asset, ?skin_item, ?skin_asset, ?hair_item, ?hair_asset, ?eyes_item, ?eyes_asset, "; - sql += "?shirt_item, ?shirt_asset, ?pants_item, ?pants_asset, ?shoes_item, ?shoes_asset, ?socks_item, ?socks_asset, "; - sql += "?jacket_item, ?jacket_asset, ?gloves_item, ?gloves_asset, ?undershirt_item, ?undershirt_asset, ?underpants_item, ?underpants_asset, "; - sql += "?skirt_item, ?skirt_asset)"; - - bool returnval = false; - - // we want to send in byte data, which means we can't just pass down strings - try - { - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand()) - { - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); - cmd.Parameters.AddWithValue("?serial", appearance.Serial); - cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); - cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes()); - cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); - cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); - cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); - cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); - cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString()); - cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString()); - cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString()); - cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString()); - cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString()); - cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString()); - cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString()); - cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString()); - cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString()); - cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString()); - cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString()); - cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString()); - cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString()); - cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString()); - cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString()); - cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString()); - cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString()); - cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString()); - cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString()); - cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString()); - cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); - cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); - cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); - - if (cmd.ExecuteNonQuery() > 0) - returnval = true; - } - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - return false; - } - - return returnval; - - } - - public void writeAttachments(UUID agentID, Hashtable data) - { - string sql = "delete from avatarattachments where UUID = ?uuid"; - - using (MySqlConnection dbcon = new MySqlConnection(connectionString)) - { - dbcon.Open(); - - MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand(); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - - cmd.ExecuteNonQuery(); - - if (data == null) - return; - - sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)"; - - cmd = (MySqlCommand)dbcon.CreateCommand(); - cmd.CommandText = sql; - - foreach (DictionaryEntry e in data) - { - int attachpoint = Convert.ToInt32(e.Key); - - Hashtable item = (Hashtable)e.Value; - - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); - cmd.Parameters.AddWithValue("?attachpoint", attachpoint); - cmd.Parameters.AddWithValue("?item", item["item"]); - cmd.Parameters.AddWithValue("?asset", item["asset"]); - - cmd.ExecuteNonQuery(); - } - } - } - } -} diff --git a/OpenSim/Data/MySQL/MySQLSuperManager.cs b/OpenSim/Data/MySQL/MySQLSuperManager.cs deleted file mode 100644 index c579432..0000000 --- a/OpenSim/Data/MySQL/MySQLSuperManager.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Threading; - -namespace OpenSim.Data.MySQL -{ - public class MySQLSuperManager - { - public bool Locked; - private readonly Mutex m_lock = new Mutex(false); - public MySQLManager Manager; - public string Running; - - public void GetLock() - { - Locked = true; - m_lock.WaitOne(); - } - - public void Release() - { - m_lock.ReleaseMutex(); - Locked = false; - } - - } -} diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs deleted file mode 100644 index 0a9d2e3..0000000 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ /dev/null @@ -1,766 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using log4net; -using MySql.Data.MySqlClient; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Data.MySQL -{ - /// - /// A database interface class to a user profile storage system - /// - public class MySQLUserData : UserDataBase - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private MySQLManager m_database; - private string m_connectionString; - private object m_dbLock = new object(); - - public int m_maxConnections = 10; - public int m_lastConnect; - - private string m_agentsTableName = "agents"; - private string m_usersTableName = "users"; - private string m_userFriendsTableName = "userfriends"; - private string m_appearanceTableName = "avatarappearance"; - private string m_attachmentsTableName = "avatarattachments"; - - public override void Initialise() - { - m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!"); - throw new PluginNotInitialisedException(Name); - } - - /// - /// Initialise User Interface - /// Loads and initialises the MySQL storage plugin - /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. - /// Checks for migration - /// - /// connect string. - public override void Initialise(string connect) - { - m_connectionString = connect; - m_database = new MySQLManager(connect); - - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - - using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString)) - { - dbcon.Open(); - Migration m = new Migration(dbcon, assem, "UserStore"); - m.Update(); - } - } - - public override void Dispose() - { - } - - // see IUserDataPlugin - public override UserProfileData GetUserByName(string user, string last) - { - try - { - Dictionary param = new Dictionary(); - param["?first"] = user; - param["?second"] = last; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserProfileData row = m_database.readUserRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - #region User Friends List Data - - public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) - { - int dtvalue = Util.UnixTimeSinceEpoch(); - - Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.ToString(); - param["?friendID"] = friend.ToString(); - param["?friendPerms"] = perms.ToString(); - param["?datetimestamp"] = dtvalue.ToString(); - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand adder = m_database.Query(dbcon, - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?ownerID,?friendID,?friendPerms,?datetimestamp)", - param)) - { - adder.ExecuteNonQuery(); - } - - using (IDbCommand adder = m_database.Query(dbcon, - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?friendID,?ownerID,?friendPerms,?datetimestamp)", - param)) - { - adder.ExecuteNonQuery(); - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return; - } - } - - public override void RemoveUserFriend(UUID friendlistowner, UUID friend) - { - Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.ToString(); - param["?friendID"] = friend.ToString(); - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand updater = m_database.Query(dbcon, - "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", - param)) - { - updater.ExecuteNonQuery(); - } - - using (IDbCommand updater = m_database.Query(dbcon, - "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", - param)) - { - updater.ExecuteNonQuery(); - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return; - } - } - - public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) - { - Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.ToString(); - param["?friendID"] = friend.ToString(); - param["?friendPerms"] = perms.ToString(); - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand updater = m_database.Query(dbcon, - "update " + m_userFriendsTableName + - " SET friendPerms = ?friendPerms " + - "where ownerID = ?ownerID and friendID = ?friendID", - param)) - { - updater.ExecuteNonQuery(); - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return; - } - } - - public override List GetUserFriendList(UUID friendlistowner) - { - List Lfli = new List(); - - Dictionary param = new Dictionary(); - param["?ownerID"] = friendlistowner.ToString(); - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - //Left Join userfriends to itself - using (IDbCommand result = m_database.Query(dbcon, - "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + - m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + - " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new UUID((string)reader["ownerID"]); - fli.Friend = new UUID((string)reader["friendID"]); - fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); - - // This is not a real column in the database table, it's a joined column from the opposite record - fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); - - Lfli.Add(fli); - } - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return Lfli; - } - - return Lfli; - } - - override public Dictionary GetFriendRegionInfos (List uuids) - { - Dictionary infos = new Dictionary(); - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - foreach (UUID uuid in uuids) - { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); - - using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName + - " where UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - FriendRegionInfo fri = new FriendRegionInfo(); - fri.isOnline = (sbyte)reader["agentOnline"] != 0; - fri.regionHandle = (ulong)reader["currentHandle"]; - - infos[uuid] = fri; - } - } - } - } - } - } - catch (Exception e) - { - m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); - m_log.Error(e.Message, e); - } - - return infos; - } - - #endregion - - public override List GeneratePickerResults(UUID queryID, string query) - { - List returnlist = new List(); - - Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); - - string[] querysplit; - querysplit = query.Split(' '); - if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty) - { - Dictionary param = new Dictionary(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first AND lastname like ?second LIMIT 100", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; - returnlist.Add(user); - } - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return returnlist; - } - } - else - { - try - { - Dictionary param = new Dictionary(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first OR lastname like ?first LIMIT 100", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; - returnlist.Add(user); - } - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return returnlist; - } - } - return returnlist; - } - - /// - /// See IUserDataPlugin - /// - /// User UUID - /// User profile data - public override UserProfileData GetUserByUUID(UUID uuid) - { - try - { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserProfileData row = m_database.readUserRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Returns a user session searching by name - /// - /// The account name : "Username Lastname" - /// The users session - public override UserAgentData GetAgentByName(string name) - { - return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]); - } - - /// - /// Returns a user session by account name - /// - /// First part of the users account name - /// Second part of the users account name - /// The users session - public override UserAgentData GetAgentByName(string user, string last) - { - UserProfileData profile = GetUserByName(user, last); - return GetAgentByUUID(profile.ID); - } - - /// - /// - /// - /// - /// is it still used ? - public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey) - { - Dictionary param = new Dictionary(); - param["?UUID"] = AgentID.ToString(); - param["?webLoginKey"] = WebLoginKey.ToString(); - - try - { - m_database.ExecuteParameterizedSql( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", - param); - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return; - } - } - - /// - /// Returns an agent session by account UUID - /// - /// The accounts UUID - /// The users session - public override UserAgentData GetAgentByUUID(UUID uuid) - { - try - { - Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserAgentData row = m_database.readAgentRow(reader); - return row; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Creates a new users profile - /// - /// The user profile to create - public override void AddNewUserProfile(UserProfileData user) - { - UUID zero = UUID.Zero; - if (user.ID == zero) - { - return; - } - - try - { - m_database.insertUserRow( - user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, - user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, - user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.CanDoMask, user.WantDoMask, - user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); - } - catch (Exception e) - { - m_log.Error(e.Message, e); - } - } - - /// - /// Creates a new agent - /// - /// The agent to create - public override void AddNewUserAgent(UserAgentData agent) - { - UUID zero = UUID.Zero; - if (agent.ProfileID == zero || agent.SessionID == zero) - return; - - try - { - m_database.insertAgentRow(agent); - } - catch (Exception e) - { - m_log.Error(e.Message, e); - } - } - - /// - /// Updates a user profile stored in the DB - /// - /// The profile data to use to update the DB - public override bool UpdateUserProfile(UserProfileData user) - { - try - { - m_database.updateUserRow( - user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, - user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, - user.UserFlags, user.GodLevel, user.CustomType, user.Partner); - - return true; - } - catch - { - return false; - } - } - - /// - /// Performs a money transfer request between two accounts - /// - /// The senders account ID - /// The receivers account ID - /// The amount to transfer - /// Success? - public override bool MoneyTransferRequest(UUID from, UUID to, uint amount) - { - return false; - } - - /// - /// Performs an inventory transfer request between two accounts - /// - /// TODO: Move to inventory server - /// The senders account ID - /// The receivers account ID - /// The item to transfer - /// Success? - public override bool InventoryTransferRequest(UUID from, UUID to, UUID item) - { - return false; - } - - public override AvatarAppearance GetUserAppearance(UUID user) - { - try - { - Dictionary param = new Dictionary(); - param["?owner"] = user.ToString(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - AvatarAppearance appearance = m_database.readAppearanceRow(reader); - - if (appearance == null) - { - m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); - return null; - } - else - { - appearance.SetAttachments(GetUserAttachments(user)); - return appearance; - } - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - /// - /// Updates an avatar appearence - /// - /// The user UUID - /// The avatar appearance - // override - public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance) - { - try - { - appearance.Owner = user; - m_database.insertAppearanceRow(appearance); - - UpdateUserAttachments(user, appearance.GetAttachments()); - } - catch (Exception e) - { - m_log.Error(e.Message, e); - } - } - - /// - /// Database provider name - /// - /// Provider name - public override string Name - { - get { return "MySQL Userdata Interface"; } - } - - /// - /// Database provider version - /// - /// provider version - public override string Version - { - get { return "0.1"; } - } - - public Hashtable GetUserAttachments(UUID agentID) - { - Dictionary param = new Dictionary(); - param["?uuid"] = agentID.ToString(); - - try - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (IDbCommand result = m_database.Query(dbcon, - "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - Hashtable ret = m_database.readAttachments(reader); - return ret; - } - } - } - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return null; - } - } - - public void UpdateUserAttachments(UUID agentID, Hashtable data) - { - m_database.writeAttachments(agentID, data); - } - - public override void ResetAttachments(UUID userID) - { - Dictionary param = new Dictionary(); - param["?uuid"] = userID.ToString(); - - m_database.ExecuteParameterizedSql( - "UPDATE " + m_attachmentsTableName + - " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid", - param); - } - - public override void LogoutUsers(UUID regionID) - { - Dictionary param = new Dictionary(); - param["?regionID"] = regionID.ToString(); - - try - { - m_database.ExecuteParameterizedSql( - "update " + m_agentsTableName + " SET agentOnline = 0 " + - "where currentRegion = ?regionID", - param); - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return; - } - } - } -} diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs index e1d3f81..a46fdf8 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs @@ -31,6 +31,7 @@ using OpenSim.Data.Tests; using log4net; using System.Reflection; using OpenSim.Tests.Common; +using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL.Tests { @@ -39,7 +40,7 @@ namespace OpenSim.Data.MySQL.Tests { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; - public MySQLManager database; + private string m_connectionString; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; [TestFixtureSetUp] @@ -52,7 +53,6 @@ namespace OpenSim.Data.MySQL.Tests // tests. try { - database = new MySQLManager(connect); db = new MySQLAssetData(); db.Initialise(connect); } @@ -70,10 +70,22 @@ namespace OpenSim.Data.MySQL.Tests { db.Dispose(); } - if (database != null) + ExecuteSql("drop table migrations"); + ExecuteSql("drop table assets"); + } + + /// + /// Execute a MySqlCommand + /// + /// sql string to execute + private void ExecuteSql(string sql) + { + using (MySqlConnection dbcon = new MySqlConnection(connect)) { - database.ExecuteSql("drop table migrations"); - database.ExecuteSql("drop table assets"); + dbcon.Open(); + + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); } } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs index 48486b1..01afcae 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs @@ -31,6 +31,8 @@ using OpenSim.Data.Tests; using log4net; using System.Reflection; using OpenSim.Tests.Common; +using MySql.Data.MySqlClient; + namespace OpenSim.Data.MySQL.Tests { @@ -39,7 +41,6 @@ namespace OpenSim.Data.MySQL.Tests { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; - public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; [TestFixtureSetUp] @@ -52,9 +53,8 @@ namespace OpenSim.Data.MySQL.Tests // tests. try { - database = new MySQLManager(connect); // clear db incase to ensure we are in a clean state - ClearDB(database); + ClearDB(); regionDb = new MySQLDataStore(); regionDb.Initialise(connect); @@ -75,29 +75,41 @@ namespace OpenSim.Data.MySQL.Tests { regionDb.Dispose(); } - ClearDB(database); + ClearDB(); } - private void ClearDB(MySQLManager manager) + private void ClearDB() { // if a new table is added, it has to be dropped here - if (manager != null) + ExecuteSql("drop table if exists migrations"); + ExecuteSql("drop table if exists prims"); + ExecuteSql("drop table if exists primshapes"); + ExecuteSql("drop table if exists primitems"); + ExecuteSql("drop table if exists terrain"); + ExecuteSql("drop table if exists land"); + ExecuteSql("drop table if exists landaccesslist"); + ExecuteSql("drop table if exists regionban"); + ExecuteSql("drop table if exists regionsettings"); + ExecuteSql("drop table if exists estate_managers"); + ExecuteSql("drop table if exists estate_groups"); + ExecuteSql("drop table if exists estate_users"); + ExecuteSql("drop table if exists estateban"); + ExecuteSql("drop table if exists estate_settings"); + ExecuteSql("drop table if exists estate_map"); + } + + /// + /// Execute a MySqlCommand + /// + /// sql string to execute + private void ExecuteSql(string sql) + { + using (MySqlConnection dbcon = new MySqlConnection(connect)) { - manager.ExecuteSql("drop table if exists migrations"); - manager.ExecuteSql("drop table if exists prims"); - manager.ExecuteSql("drop table if exists primshapes"); - manager.ExecuteSql("drop table if exists primitems"); - manager.ExecuteSql("drop table if exists terrain"); - manager.ExecuteSql("drop table if exists land"); - manager.ExecuteSql("drop table if exists landaccesslist"); - manager.ExecuteSql("drop table if exists regionban"); - manager.ExecuteSql("drop table if exists regionsettings"); - manager.ExecuteSql("drop table if exists estate_managers"); - manager.ExecuteSql("drop table if exists estate_groups"); - manager.ExecuteSql("drop table if exists estate_users"); - manager.ExecuteSql("drop table if exists estateban"); - manager.ExecuteSql("drop table if exists estate_settings"); - manager.ExecuteSql("drop table if exists estate_map"); + dbcon.Open(); + + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); } } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs deleted file mode 100644 index 8272316..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; -using OpenSim.Data.Tests; -using log4net; -using System.Reflection; -using OpenSim.Tests.Common; -using MySql.Data.MySqlClient; - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture, DatabaseTest] - public class MySQLGridTest : BasicGridTest - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public string file; - public MySQLManager database; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - database = new MySQLManager(connect); - db = new MySQLGridData(); - db.Initialise(connect); - } - catch (Exception e) - { - m_log.Error("Exception {0}", e); - Assert.Ignore(); - } - - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - - using (MySqlConnection dbcon = new MySqlConnection(connect)) - { - dbcon.Open(); - Migration m = new Migration(dbcon, assem, "AssetStore"); - m.Update(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - m_log.Warn("Cleaning up."); - if (db != null) - { - db.Dispose(); - } - // if a new table is added, it has to be dropped here - if (database != null) - { - database.ExecuteSql("drop table migrations"); - database.ExecuteSql("drop table regions"); - } - } - } -} diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs index a3a32dc..4575493 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs @@ -31,6 +31,8 @@ using OpenSim.Data.Tests; using log4net; using System.Reflection; using OpenSim.Tests.Common; +using MySql.Data.MySqlClient; + namespace OpenSim.Data.MySQL.Tests { @@ -39,7 +41,6 @@ namespace OpenSim.Data.MySQL.Tests { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; - public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; [TestFixtureSetUp] @@ -52,7 +53,6 @@ namespace OpenSim.Data.MySQL.Tests // tests. try { - database = new MySQLManager(connect); DropTables(); db = new MySQLInventoryData(); db.Initialise(connect); @@ -71,17 +71,29 @@ namespace OpenSim.Data.MySQL.Tests { db.Dispose(); } - if (database != null) - { - DropTables(); - } + DropTables(); } private void DropTables() { - database.ExecuteSql("drop table IF EXISTS inventoryitems"); - database.ExecuteSql("drop table IF EXISTS inventoryfolders"); - database.ExecuteSql("drop table IF EXISTS migrations"); + ExecuteSql("drop table IF EXISTS inventoryitems"); + ExecuteSql("drop table IF EXISTS inventoryfolders"); + ExecuteSql("drop table IF EXISTS migrations"); + } + + /// + /// Execute a MySqlCommand + /// + /// sql string to execute + private void ExecuteSql(string sql) + { + using (MySqlConnection dbcon = new MySqlConnection(connect)) + { + dbcon.Open(); + + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); + } } } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs index 0dc8b7d..e7e57e4 100644 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs @@ -31,6 +31,7 @@ using OpenSim.Data.Tests; using log4net; using System.Reflection; using OpenSim.Tests.Common; +using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL.Tests { @@ -39,7 +40,6 @@ namespace OpenSim.Data.MySQL.Tests { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public string file; - public MySQLManager database; public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; [TestFixtureSetUp] @@ -52,9 +52,8 @@ namespace OpenSim.Data.MySQL.Tests // tests. try { - database = new MySQLManager(connect); // this is important in case a previous run ended badly - ClearDB(database); + ClearDB(); db = new MySQLDataStore(); db.Initialise(connect); @@ -73,28 +72,40 @@ namespace OpenSim.Data.MySQL.Tests { db.Dispose(); } - ClearDB(database); + ClearDB(); } - private void ClearDB(MySQLManager manager) + private void ClearDB() { - if (manager != null) + ExecuteSql("drop table if exists migrations"); + ExecuteSql("drop table if exists prims"); + ExecuteSql("drop table if exists primshapes"); + ExecuteSql("drop table if exists primitems"); + ExecuteSql("drop table if exists terrain"); + ExecuteSql("drop table if exists land"); + ExecuteSql("drop table if exists landaccesslist"); + ExecuteSql("drop table if exists regionban"); + ExecuteSql("drop table if exists regionsettings"); + ExecuteSql("drop table if exists estate_managers"); + ExecuteSql("drop table if exists estate_groups"); + ExecuteSql("drop table if exists estate_users"); + ExecuteSql("drop table if exists estateban"); + ExecuteSql("drop table if exists estate_settings"); + ExecuteSql("drop table if exists estate_map"); + } + + /// + /// Execute a MySqlCommand + /// + /// sql string to execute + private void ExecuteSql(string sql) + { + using (MySqlConnection dbcon = new MySqlConnection(connect)) { - manager.ExecuteSql("drop table if exists migrations"); - manager.ExecuteSql("drop table if exists prims"); - manager.ExecuteSql("drop table if exists primshapes"); - manager.ExecuteSql("drop table if exists primitems"); - manager.ExecuteSql("drop table if exists terrain"); - manager.ExecuteSql("drop table if exists land"); - manager.ExecuteSql("drop table if exists landaccesslist"); - manager.ExecuteSql("drop table if exists regionban"); - manager.ExecuteSql("drop table if exists regionsettings"); - manager.ExecuteSql("drop table if exists estate_managers"); - manager.ExecuteSql("drop table if exists estate_groups"); - manager.ExecuteSql("drop table if exists estate_users"); - manager.ExecuteSql("drop table if exists estateban"); - manager.ExecuteSql("drop table if exists estate_settings"); - manager.ExecuteSql("drop table if exists estate_map"); + dbcon.Open(); + + MySqlCommand cmd = new MySqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); } } } diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs deleted file mode 100644 index cf8139a..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; -using OpenSim.Data.Tests; -using log4net; -using System.Reflection; -using OpenSim.Tests.Common; - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture, DatabaseTest] - public class MySQLUserTest : BasicUserTest - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string file; - public MySQLManager database; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - database = new MySQLManager(connect); - db = new MySQLUserData(); - db.Initialise(connect); - } - catch (Exception e) - { - m_log.Error("Exception {0}", e); - Assert.Ignore(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - if (db != null) - { - db.Dispose(); - } - // if a new table is added, it has to be dropped here - if (database != null) - { - database.ExecuteSql("drop table migrations"); - database.ExecuteSql("drop table users"); - database.ExecuteSql("drop table userfriends"); - database.ExecuteSql("drop table agents"); - database.ExecuteSql("drop table avatarappearance"); - database.ExecuteSql("drop table avatarattachments"); - } - } - } -} -- cgit v1.1 From 7665aad002ef066fc31fa9497225d2668641c769 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 22 Feb 2010 13:27:17 -0800 Subject: * Adds CreatorID to asset metadata. This is just the plumbing to support CreatorID, it doesn't modify database backends or OAR files to support storing/loading it --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 666c22f..a1b5d94 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], UUID.Zero); asset.Data = (byte[])dbReader["data"]; asset.Description = (string)dbReader["description"]; -- cgit v1.1 From df76e95aa2dc9f3f3a0c546761b7624adc183ed0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 22 Feb 2010 14:18:59 -0800 Subject: Changed asset CreatorID to a string --- OpenSim/Data/MySQL/MySQLAssetData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a1b5d94..d55369a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], UUID.Zero); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], UUID.Zero.ToString()); asset.Data = (byte[])dbReader["data"]; asset.Description = (string)dbReader["description"]; -- cgit v1.1 From bfcc57c0712170e3431617bcb09999bfbb96b8dd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 1 Mar 2010 00:02:14 +0000 Subject: Change friends to handle offers as it was originally designed. This may need to be changed in SQLite & MSSQL as well --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 7a43bb6..663fad6 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -59,7 +59,7 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("select a.*,b.Flags as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID and b.Flags is not null", m_Realm); + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); return DoQuery(cmd); -- cgit v1.1 From 780ee4f99146a21f6d70bf9be4528a6dc39cfe14 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 1 Mar 2010 23:04:45 +0900 Subject: Fix a few compiler warnings. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 4 ---- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 3 --- 2 files changed, 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 698bf52..7d3593c 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -39,10 +39,6 @@ namespace OpenSim.Data.MySQL { public class MySQLGenericTableHandler : MySqlFramework where T: class, new() { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Dictionary m_Fields = new Dictionary(); diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index b5866cb..307a4c7 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -41,9 +41,6 @@ namespace OpenSim.Data.MySQL /// public class MySQLXInventoryData : IXInventoryData { - private static readonly ILog m_log = LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - private MySQLGenericTableHandler m_Folders; private MySqlItemHandler m_Items; -- cgit v1.1 From a1643c78beddf6e96d6bf124cdee8ef8c96cab51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Mar 2010 22:43:30 +0000 Subject: remove test presence from NullPresenceData since this appears to stop existing sessions with home locations from being picked up only tested for a single user so this may still fail for multiple users this may well be all academic anyway since standalone need to persistently store home location in presence data in some way --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index fcbe3d6..68a68af 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); cmd.Parameters.AddWithValue("?UserID", userID); -; + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -131,7 +131,6 @@ namespace OpenSim.Data.MySQL using (IDataReader reader = cmd.ExecuteReader()) { - List deleteSessions = new List(); int online = 0; @@ -143,6 +142,7 @@ namespace OpenSim.Data.MySQL deleteSessions.Add(new UUID(reader["SessionID"].ToString())); } + // Leave one session behind so that we can pick up details such as home location if (online == 0 && deleteSessions.Count > 0) deleteSessions.RemoveAt(0); -- cgit v1.1 From e906dd3d28a3cb4dfada36daccfd8900f0e844b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Mar 2010 22:29:51 +0000 Subject: add initial UserGrid service classes as per diva's direction this will initially store home location data instead of the presence service compiles but not enough to actually test yet --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 3 +- OpenSim/Data/MySQL/MySQLUserGridData.cs | 64 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Data/MySQL/MySQLUserGridData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index b170dde..756b42d 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -197,8 +197,7 @@ namespace OpenSim.Data.MySQL public virtual T[] Get(string where) { using (MySqlCommand cmd = new MySqlCommand()) - { - + { string query = String.Format("select * from {0} where {1}", m_Realm, where); diff --git a/OpenSim/Data/MySQL/MySQLUserGridData.cs b/OpenSim/Data/MySQL/MySQLUserGridData.cs new file mode 100644 index 0000000..7209b18 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserGridData.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for user grid data + /// + public class MySQLUserGridData : MySQLGenericTableHandler, IUserGridData + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySQLUserGridData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} + + public UserGridData GetUserGridData(string userID) + { + UserGridData[] ret = Get("UserID", userID); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public bool StoreUserGridData(UserGridData data) + { + return Store(data); + } + } +} \ No newline at end of file -- cgit v1.1 From 5171464ac199f958a9a8a11664958260a88e863d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 5 Mar 2010 21:36:45 -0800 Subject: Justin, I must have been dyslexic when I wrote UserGridService as the name for it. GridUserService makes more sense; it's the user of the grid, "grid user". I changed it everywhere. --- OpenSim/Data/MySQL/MySQLGridUserData.cs | 64 +++++++++++++++++++++++++++++++++ OpenSim/Data/MySQL/MySQLUserGridData.cs | 64 --------------------------------- 2 files changed, 64 insertions(+), 64 deletions(-) create mode 100644 OpenSim/Data/MySQL/MySQLGridUserData.cs delete mode 100644 OpenSim/Data/MySQL/MySQLUserGridData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs new file mode 100644 index 0000000..15834d2 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for user grid data + /// + public class MySQLGridUserData : MySQLGenericTableHandler, IGridUserData + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} + + public GridUserData GetGridUserData(string userID) + { + GridUserData[] ret = Get("UserID", userID); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public bool StoreGridUserData(GridUserData data) + { + return Store(data); + } + } +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLUserGridData.cs b/OpenSim/Data/MySQL/MySQLUserGridData.cs deleted file mode 100644 index 7209b18..0000000 --- a/OpenSim/Data/MySQL/MySQLUserGridData.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Data; -using System.Reflection; -using System.Threading; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using MySql.Data.MySqlClient; - -namespace OpenSim.Data.MySQL -{ - /// - /// A MySQL Interface for user grid data - /// - public class MySQLUserGridData : MySQLGenericTableHandler, IUserGridData - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public MySQLUserGridData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} - - public UserGridData GetUserGridData(string userID) - { - UserGridData[] ret = Get("UserID", userID); - - if (ret.Length == 0) - return null; - - return ret[0]; - } - - public bool StoreUserGridData(UserGridData data) - { - return Store(data); - } - } -} \ No newline at end of file -- cgit v1.1 From f58a0394edf3c0e4d46faf1f3053b940ba0a1c8c Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 10 Mar 2010 13:15:36 +0900 Subject: Formatting cleanup. Add copyright notices. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 2 +- OpenSim/Data/MySQL/MySQLGridUserData.cs | 2 +- OpenSim/Data/MySQL/MySQLPresenceData.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 756b42d..1253e0b 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -197,7 +197,7 @@ namespace OpenSim.Data.MySQL public virtual T[] Get(string where) { using (MySqlCommand cmd = new MySqlCommand()) - { + { string query = String.Format("select * from {0} where {1}", m_Realm, where); diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index 15834d2..df29ecd 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -54,7 +54,7 @@ namespace OpenSim.Data.MySQL return null; return ret[0]; - } + } public bool StoreGridUserData(GridUserData data) { diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 68a68af..143dbe3 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -134,7 +134,7 @@ namespace OpenSim.Data.MySQL List deleteSessions = new List(); int online = 0; - while(reader.Read()) + while (reader.Read()) { if (bool.Parse(reader["Online"].ToString())) online++; -- cgit v1.1 From 70b0e07d1ea99f8bd88f2be12bf9b53a39187f60 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Mar 2010 18:49:56 +0000 Subject: Remove the reading of estate_settings.xml and the associated processing of defaults. Adding code to facilitate estate creation / managemment as part of first time start up --- OpenSim/Data/MySQL/MySQLEstateData.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 2eae2d8..e94dcda 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -121,7 +121,7 @@ namespace OpenSim.Data.MySQL } } - public EstateSettings LoadEstateSettings(UUID regionID) + public EstateSettings LoadEstateSettings(UUID regionID, bool create) { EstateSettings es = new EstateSettings(); es.OnSave += StoreEstateSettings; @@ -129,12 +129,12 @@ namespace OpenSim.Data.MySQL string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; - bool migration = true; - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); + bool found = false; + using (MySqlCommand cmd = dbcon.CreateCommand()) { cmd.CommandText = sql; @@ -144,7 +144,7 @@ namespace OpenSim.Data.MySQL { if (r.Read()) { - migration = false; + found = true; foreach (string name in FieldList) { @@ -172,7 +172,7 @@ namespace OpenSim.Data.MySQL } } - if (migration) + if (!found && create) { // Migration case List names = new List(FieldList); @@ -220,14 +220,6 @@ namespace OpenSim.Data.MySQL try { cmd.ExecuteNonQuery(); } catch (Exception) { } - // Munge and transfer the ban list - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - - try { cmd.ExecuteNonQuery(); } - catch (Exception) { } - es.Save(); } } -- cgit v1.1 From 07a6b37001080ce197a4715776d100bcb9b2bb54 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Mar 2010 20:38:27 +0000 Subject: Somehow the starting estate number in MySQL was lost. This adds a migration to start estates at 100. Existing databases having autcreated estates below 100 will see a gap in estate numbering. Other database implementors need to ensure that no estates with numbers less that 100 are autocreated, unless they are prepared to deal with the viewer's built-in notions of Linden Mainland --- OpenSim/Data/MySQL/Resources/032_RegionStore.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/032_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql new file mode 100644 index 0000000..dca5de7 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE estate_settings AUTO_INCREMENT = 100; +COMMIT; -- cgit v1.1 From dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 23 Mar 2010 02:05:56 +0000 Subject: First stage of the new interactive region creation. This will allow creation of a region and joining it to an existing estate or creating a new estate, as well as creating an estate owner if in standalone, and assigning estate owners. In Grid mode, existing users must be used. MySQL ONLY!!!! so far, as I can't develop or test for either SQLite or MSSQL. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 175 +++++++++++++++++++++++++--------- 1 file changed, 130 insertions(+), 45 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e94dcda..7fe1fcc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -123,50 +123,57 @@ namespace OpenSim.Data.MySQL public EstateSettings LoadEstateSettings(UUID regionID, bool create) { - EstateSettings es = new EstateSettings(); - es.OnSave += StoreEstateSettings; - string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + return DoLoad(cmd, regionID, create); + } + } + + private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create) + { + EstateSettings es = new EstateSettings(); + es.OnSave += StoreEstateSettings; + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); + cmd.Connection = dbcon; + bool found = false; - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (IDataReader r = cmd.ExecuteReader()) { - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - - using (IDataReader r = cmd.ExecuteReader()) + if (r.Read()) { - if (r.Read()) - { - found = true; + found = true; - foreach (string name in FieldList) + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) { - if (m_FieldMap[name].GetValue(es) is bool) - { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); - } - else if (m_FieldMap[name].GetValue(es) is UUID) - { - UUID uuid = UUID.Zero; - - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); - } + int v = Convert.ToInt32(r[name]); + if (v != 0) + m_FieldMap[name].SetValue(es, true); else - { - m_FieldMap[name].SetValue(es, r[name]); - } + m_FieldMap[name].SetValue(es, false); + } + else if (m_FieldMap[name].GetValue(es) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(r[name].ToString(), out uuid); + m_FieldMap[name].SetValue(es, uuid); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); } } } @@ -179,45 +186,45 @@ namespace OpenSim.Data.MySQL names.Remove("EstateID"); - sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; + string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlCommand cmd2 = dbcon.CreateCommand()) { - cmd.CommandText = sql; - cmd.Parameters.Clear(); + cmd2.CommandText = sql; + cmd2.Parameters.Clear(); foreach (string name in FieldList) { if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); + cmd2.Parameters.AddWithValue("?" + name, "1"); else - cmd.Parameters.AddWithValue("?" + name, "0"); + cmd2.Parameters.AddWithValue("?" + name, "0"); } else { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } } - cmd.ExecuteNonQuery(); + cmd2.ExecuteNonQuery(); - cmd.CommandText = "select LAST_INSERT_ID() as id"; - cmd.Parameters.Clear(); + cmd2.CommandText = "select LAST_INSERT_ID() as id"; + cmd2.Parameters.Clear(); - using (IDataReader r = cmd.ExecuteReader()) + using (IDataReader r = cmd2.ExecuteReader()) { r.Read(); es.EstateID = Convert.ToUInt32(r["id"]); } - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); // This will throw on dupe key - try { cmd.ExecuteNonQuery(); } + try { cmd2.ExecuteNonQuery(); } catch (Exception) { } es.Save(); @@ -390,5 +397,83 @@ namespace OpenSim.Data.MySQL return uuids.ToArray(); } + + public EstateSettings LoadEstateSettings(int estateID) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = ?EstateID"; + + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?EstateID", estateID); + + return DoLoad(cmd, UUID.Zero, false); + } + } + + public List GetEstates(string search) + { + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select estateID from estate_settings where EstateName = ?EstateName"; + cmd.Parameters.AddWithValue("?EstateName", search); + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(Convert.ToInt32(reader["EstateID"])); + } + reader.Close(); + } + } + + + dbcon.Close(); + } + + return result; + } + + public bool LinkRegion(UUID regionID, int estateID) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID); + cmd.Parameters.AddWithValue("?EstateID", estateID); + + if (cmd.ExecuteNonQuery() == 0) + { + dbcon.Close(); + return false; + } + } + + dbcon.Close(); + } + + return true; + } + + public List GetRegions(int estateID) + { + return new List(); + } + + public bool DeleteEstate(int estateID) + { + return false; + } } } -- cgit v1.1 From d6a64bf732ee88bdf9b62ad4f4303514f3215283 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 26 Mar 2010 13:50:25 -0700 Subject: * Catch exceptions thrown when MySQLEstateData.LinkRegion() is called. This won't fix the bug I'm seeing with regions not realizing they are already part of an estate, but it will fix the OpenSim crash if that situation ever comes up --- OpenSim/Data/MySQL/MySQLEstateData.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 7fe1fcc..d0c02f0 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -447,23 +447,29 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - using (MySqlCommand cmd = dbcon.CreateCommand()) + try { - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID); - cmd.Parameters.AddWithValue("?EstateID", estateID); - - if (cmd.ExecuteNonQuery() == 0) + using (MySqlCommand cmd = dbcon.CreateCommand()) { + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID); + cmd.Parameters.AddWithValue("?EstateID", estateID); + + int ret = cmd.ExecuteNonQuery(); dbcon.Close(); - return false; + + return (ret != 0); } } + catch (MySqlException ex) + { + m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message); + } dbcon.Close(); } - return true; + return false; } public List GetRegions(int estateID) -- cgit v1.1 From ec637e2b8c089efc16bbb9faae0a1e3cf939db41 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 31 Mar 2010 04:20:20 +0100 Subject: Committing the LightShare code, which was developed by TomMeta of Meta7. This allows scripts to set WindLight parameters for clients connecting to a region. Currently, this is only supported by the Meta7 viewer. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 199 ++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a06eec3..a395ddc 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -711,6 +711,102 @@ namespace OpenSim.Data.MySQL } } + public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) + { + RegionLightShareData nWP = new RegionLightShareData(); + nWP.OnSave += StoreRegionWindlightSettings; + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + string command = "select * from `regionwindlight` where region_id = ?regionID"; + + using(MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) + { + //No result, so store our default windlight profile and return it + nWP.regionID = regionUUID; + StoreRegionWindlightSettings(nWP); + return nWP; + } + else + { + UUID.TryParse(result["region_id"].ToString(), out nWP.regionID); + nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); + nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); + nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); + nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); + nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); + nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); + nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); + nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); + nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); + nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); + nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); + nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); + nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); + nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); + nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); + nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); + nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); + UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); + nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); + nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); + nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); + nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); + nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); + nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); + nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); + nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); + nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); + nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); + nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); + nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); + nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); + nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); + nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); + nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); + nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); + nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); + nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); + nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); + nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); + nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); + nWP.eastAngle = Convert.ToSingle(result["east_angle"]); + nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); + nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); + nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); + nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); + nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); + nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); + nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); + nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); + nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); + nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); + nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); + nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); + nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); + nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); + nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); + nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); + nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); + nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); + nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); + nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); + nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); + } + } + } + return nWP; + } + public RegionSettings LoadRegionSettings(UUID regionUUID) { RegionSettings rs = null; @@ -749,6 +845,109 @@ namespace OpenSim.Data.MySQL return rs; } + public void StoreRegionWindlightSettings(RegionLightShareData wl) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; + cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; + cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; + cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; + cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; + cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; + cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; + cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; + cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; + cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; + cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; + cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; + cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; + cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; + cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; + cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; + cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; + cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; + cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; + cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; + cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; + cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; + cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; + cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; + cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; + + cmd.Parameters.AddWithValue("region_id", wl.regionID); + cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); + cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); + cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); + cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); + cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); + cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); + cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); + cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); + cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); + cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); + cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); + cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); + cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); + cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); + cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); + cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); + cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); + cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); + cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); + cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); + cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); + cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); + cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); + cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); + cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); + cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); + cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); + cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); + cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); + cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); + cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); + cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); + cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); + cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); + cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); + cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); + cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); + cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); + cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); + cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); + cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); + cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); + cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); + cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); + cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); + cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); + cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); + cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); + cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); + cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); + cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); + cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); + cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); + cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); + cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); + + ExecuteNonQuery(cmd); + } + } + } + public void StoreRegionSettings(RegionSettings rs) { lock (m_dbLock) -- cgit v1.1 From 8b75302a1e33f1f5cee166dd22d1de44172da509 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Tue, 27 Apr 2010 10:05:17 +0300 Subject: Just a bit of spellchecking in the comments --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 192deb2..e0e9b9c 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -145,7 +145,7 @@ namespace OpenSim.Data.MySQL /// /// Returns a list of the root folders within a users inventory /// - /// The user whos inventory is to be searched + /// The user whose inventory is to be searched /// A list of folder objects public List getUserRootFolders(UUID user) { @@ -284,7 +284,7 @@ namespace OpenSim.Data.MySQL { InventoryItemBase item = new InventoryItemBase(); - // TODO: this is to handle a case where NULLs creep in there, which we are not sure is indemic to the system, or legacy. It would be nice to live fix these. + // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. if (reader["creatorID"] == null) { item.CreatorId = UUID.Zero.ToString(); -- cgit v1.1 From 92dff5edb1333a798e21f956ea6291b357dd0c20 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 3 May 2010 23:45:05 +0200 Subject: Add folder version incrementing to XInventoryService. Fixes offline give for avatar->avatar --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 307a4c7..a3b728b 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -160,5 +160,36 @@ namespace OpenSim.Data.MySQL } } } + + public override bool Store(XInventoryItem item) + { + if (base.Store(item)) + return false; + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.Connection = dbcon; + + cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); + cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception e) + { + return false; + } + cmd.Dispose(); + } + dbcon.Close(); + } + return true; + } } } -- cgit v1.1 From 23d7a942ea88c597768430c09f7ff42331ac9c96 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 3 May 2010 23:53:49 +0200 Subject: Refix the fix --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index a3b728b..0fe801d 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -163,7 +163,7 @@ namespace OpenSim.Data.MySQL public override bool Store(XInventoryItem item) { - if (base.Store(item)) + if (!base.Store(item)) return false; using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) -- cgit v1.1 From 9635af61f082ab1619a9ca482c76e2e01b0a4c55 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 4 May 2010 17:56:30 +0200 Subject: Allow regions to get the list of the other regions in the estate --- OpenSim/Data/MySQL/MySQLEstateData.cs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index d0c02f0..08e2144 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -474,7 +474,36 @@ namespace OpenSim.Data.MySQL public List GetRegions(int estateID) { - return new List(); + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + try + { + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select RegionID from estate_map where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", estateID.ToString()); + + using (IDataReader reader = cmd.ExecuteReader()) + { + while(reader.Read()) + result.Add(new UUID(reader["RegionID"].ToString())); + reader.Close(); + } + } + } + catch (Exception e) + { + m_log.Error("[REGION DB]: Error reading estate map. " + e.ToString()); + return result; + } + dbcon.Close(); + } + + return result; } public bool DeleteEstate(int estateID) -- cgit v1.1 From a58859a0d4206c194c9c56212218e2cafc2cc373 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 7 May 2010 21:29:56 -0700 Subject: GridUserService in place. Replaces the contrived concept of storing user's home and position info in the presence service. WARNING: I violated a taboo by deleting 2 migration files and simplifying the original table creation for Presence. This should not cause any problems to anyone, though. Things will work with the new simplified table, as well as with the previous contrived one. If there are any problems, solving them is as easy as dropping the presence table and deleting its row in the migrations table. The presence info only exists during a user's session anyway. BTW, the Meshing files want to be committed too -- EOFs. --- OpenSim/Data/MySQL/MySQLGridUserData.cs | 9 ++-- OpenSim/Data/MySQL/MySQLPresenceData.cs | 66 ++------------------------- OpenSim/Data/MySQL/Resources/001_Presence.sql | 10 ++-- OpenSim/Data/MySQL/Resources/002_Presence.sql | 7 --- OpenSim/Data/MySQL/Resources/003_Presence.sql | 6 --- 5 files changed, 10 insertions(+), 88 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/002_Presence.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_Presence.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index df29ecd..a9ce94d 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -44,9 +44,9 @@ namespace OpenSim.Data.MySQL { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} + public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} - public GridUserData GetGridUserData(string userID) + public GridUserData Get(string userID) { GridUserData[] ret = Get("UserID", userID); @@ -56,9 +56,6 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public bool StoreGridUserData(GridUserData data) - { - return Store(data); - } + } } \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 143dbe3..71caa1a 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -65,15 +65,14 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set Online='false' where `RegionID`=?RegionID", m_Realm); + cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); ExecuteNonQuery(cmd); } - public bool ReportAgent(UUID sessionID, UUID regionID, string position, - string lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { PresenceData[] pd = Get("SessionID", sessionID.ToString()); if (pd.Length == 0) @@ -81,12 +80,10 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?Position", position.ToString()); - cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString()); if (ExecuteNonQuery(cmd) == 0) return false; @@ -94,62 +91,5 @@ namespace OpenSim.Data.MySQL return true; } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - PresenceData[] pd = Get("UserID", userID); - if (pd.Length == 0) - return false; - - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); - - cmd.Parameters.AddWithValue("?UserID", userID); - cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?HomePosition", position); - cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); - - if (ExecuteNonQuery(cmd) == 0) - return false; - - return true; - } - - public void Prune(string userID) - { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); - - cmd.Parameters.AddWithValue("?UserID", userID); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - cmd.Connection = dbcon; - - using (IDataReader reader = cmd.ExecuteReader()) - { - List deleteSessions = new List(); - int online = 0; - - while (reader.Read()) - { - if (bool.Parse(reader["Online"].ToString())) - online++; - else - deleteSessions.Add(new UUID(reader["SessionID"].ToString())); - } - - // Leave one session behind so that we can pick up details such as home location - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); - - foreach (UUID s in deleteSessions) - Delete("SessionID", s.ToString()); - } - } - } } } diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql index b8abaf7..84fa057 100644 --- a/OpenSim/Data/MySQL/Resources/001_Presence.sql +++ b/OpenSim/Data/MySQL/Resources/001_Presence.sql @@ -4,12 +4,10 @@ CREATE TABLE `Presence` ( `UserID` VARCHAR(255) NOT NULL, `RegionID` CHAR(36) NOT NULL, `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `Online` CHAR(5) NOT NULL DEFAULT 'false', - `Login` CHAR(16) NOT NULL DEFAULT '0', - `Logout` CHAR(16) NOT NULL DEFAULT '0', - `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' + `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' ) ENGINE=InnoDB; +CREATE UNIQUE INDEX SessionID ON Presence(SessionID); +CREATE INDEX UserID ON Presence(UserID); + COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_Presence.sql b/OpenSim/Data/MySQL/Resources/002_Presence.sql deleted file mode 100644 index e65f105..0000000 --- a/OpenSim/Data/MySQL/Resources/002_Presence.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; -ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; -ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_Presence.sql b/OpenSim/Data/MySQL/Resources/003_Presence.sql deleted file mode 100644 index 0efefa8..0000000 --- a/OpenSim/Data/MySQL/Resources/003_Presence.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -CREATE UNIQUE INDEX SessionID ON Presence(SessionID); -CREATE INDEX UserID ON Presence(UserID); - -COMMIT; -- cgit v1.1 From 15562017f220e2474b548f860ce1174541d7e22f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 7 May 2010 21:32:02 -0700 Subject: These files are part of the GridUserService write-up. --- OpenSim/Data/MySQL/Resources/001_GridUserStore.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/001_GridUserStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql b/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql new file mode 100644 index 0000000..ce4ab96 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql @@ -0,0 +1,17 @@ +BEGIN; + +CREATE TABLE `GridUser` ( + `UserID` VARCHAR(255) NOT NULL, + `HomeRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LastRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `LastPosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LastLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `Online` CHAR(5) NOT NULL DEFAULT 'false', + `Login` CHAR(16) NOT NULL DEFAULT '0', + `Logout` CHAR(16) NOT NULL DEFAULT '0', + PRIMARY KEY (`UserID`) +) ENGINE=InnoDB; + +COMMIT; -- cgit v1.1 From 9b22393cf308507dc751704c8b0d3e65ac1d4323 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 May 2010 17:02:22 +0100 Subject: Add a field asset_flags and a corresponding enum to the asset database. This CHANGES THE ASSET SERVER PROTOCOL and means you CAN NOT MIX PRIOR VERSIONS WITH LATER ONES. It may also eat your babies, yada, yada, yada. The usual cautions for migrations to the assets table apply. Coding: Can not guarantee nut free. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 +++++--- OpenSim/Data/MySQL/Resources/007_AssetStore.sql | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/007_AssetStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index d55369a..5a2af4f 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -161,8 +161,8 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand( - "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?data)", dbcon); string assetName = asset.Name; @@ -194,6 +194,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); cmd.Dispose(); @@ -302,7 +303,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", dbcon); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags FROM assets LIMIT ?start, ?count", dbcon); cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?count", count); @@ -317,6 +318,7 @@ namespace OpenSim.Data.MySQL metadata.Description = (string)dbReader["description"]; metadata.Type = (sbyte)dbReader["assetType"]; metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); metadata.FullID = new UUID((string)dbReader["id"]); // Current SHA1s are not stored/computed. diff --git a/OpenSim/Data/MySQL/Resources/007_AssetStore.sql b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql new file mode 100644 index 0000000..f06121a --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; + +COMMIT; -- cgit v1.1 From 60357d3778c95a47481f790803b7af39c70cde9c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 May 2010 17:56:52 +0100 Subject: Implement the "delete" path for assets. Adds a new option to allow remote asset deletion in robust handler. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 5a2af4f..35eed56 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -338,6 +338,24 @@ namespace OpenSim.Data.MySQL return retList; } + public override bool Delete(string id) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id"); + cmd.Parameters.AddWithValue("?id", id); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + } + } + + return true; + } + #endregion } } -- cgit v1.1 From b233a4b2cab3a39f9edc17130cd7c2f2f807d6bb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 13:39:56 -0700 Subject: * Fixed spamming the assets table with map tiles. The tile image ID is now stored in regionsettings. Upon generation of a new tile image, the old one is deleted. Tested for SQLite and MySql standalone. * Fixed small bug with map search where the local sim regions weren't found. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +++-- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 6 +++++- OpenSim/Data/MySQL/Resources/033_RegionStore.sql | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/033_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 35eed56..13f5fa2 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -111,7 +111,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + "SELECT name, description, assetType, local, temporary, asset_flags, data FROM assets WHERE id=?id", dbcon)) { cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -133,6 +133,7 @@ namespace OpenSim.Data.MySQL asset.Local = false; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); } } } @@ -345,7 +346,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id"); + MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon); cmd.Parameters.AddWithValue("?id", id); cmd.ExecuteNonQuery(); diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a395ddc..8c83ef1 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -989,7 +989,8 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)"; + "?LoadedCreationDateTime, ?LoadedCreationID)" + + "?map_tile_ID, ?TerrainImageID"; FillRegionSettingsCommand(cmd, rs); @@ -1276,6 +1277,8 @@ namespace OpenSim.Data.MySQL else newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; + newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); + return newSettings; } @@ -1596,6 +1599,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); + cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); } diff --git a/OpenSim/Data/MySQL/Resources/033_RegionStore.sql b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql new file mode 100644 index 0000000..2832b41 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +COMMIT; -- cgit v1.1 From 9cf6b81256b6c92cb5d5fb7a6db697f7784191e4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 14:02:02 -0700 Subject: Yey for unit tests. The previous commit had a couple of bugs on SQL statements. Fixed here. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 8c83ef1..d2892e9 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -989,8 +989,8 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)" + - "?map_tile_ID, ?TerrainImageID"; + "?LoadedCreationDateTime, ?LoadedCreationID, " + + "?map_tile_ID)"; FillRegionSettingsCommand(cmd, rs); -- cgit v1.1 From 6f2f0fa0cad4c2668826f2684f5b8c2d9b30f243 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 14:12:59 -0700 Subject: OK, this really fixes it, I promise. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index d2892e9..07371e7 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -975,7 +975,7 @@ namespace OpenSim.Data.MySQL "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + + "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + @@ -990,7 +990,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?map_tile_ID)"; + "?TerrainImageID)"; FillRegionSettingsCommand(cmd, rs); -- cgit v1.1 From b49fb3db7ca665abf9753c74aa1e2b28eeb70946 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Wed, 5 May 2010 22:34:41 +0300 Subject: Added MySqlMigrations.cs (supports stored proc/funcs) Uses MySqlScript class to correctly run proc/func definitions that need delimiter change. Requires MySql.Data.dll 6.2 or later. --- OpenSim/Data/MySQL/MySQLMigrations.cs | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLMigrations.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs new file mode 100644 index 0000000..b16655d --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -0,0 +1,85 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; +using log4net; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// This is a MySQL-customized migration processor. The only difference is in how + /// it executes SQL scripts (using MySqlScript instead of MyCommand) + /// + /// + public class MySqlMigration : Migration + { + public MySqlMigration() + : base() + { + } + + public MySqlMigration(DbConnection conn, Assembly assem, string subtype, string type) : + base(conn, assem, subtype, type) + { + } + + public MySqlMigration(DbConnection conn, Assembly assem, string type) : + base(conn, assem, type) + { + } + + protected override void ExecuteScript(DbConnection conn, string[] script) + { + if (!(conn is MySqlConnection)) + { + base.ExecuteScript(conn, script); + return; + } + + MySqlScript scr = new MySqlScript((MySqlConnection)conn); + { + foreach (string sql in script) + { + scr.Query = sql; + scr.Error += delegate(object sender, MySqlScriptErrorEventArgs args) + { + m_log.ErrorFormat("[MySQL MIGRATION]: Error {0}", args.Exception.Message); + m_log.ErrorFormat("[MySQL MIGRATION]: In SQL: {0}", args.StatementText); + throw args.Exception; + }; + scr.Execute(); + } + } + } + } +} -- cgit v1.1 From ee713cb253c1ef2d09de235964e02e7621649dd8 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Sat, 1 May 2010 17:43:10 +0300 Subject: Converted MySQL migration history to the new format Replaced all NNN_StoreName.sql migration resources with a more readable, single-file-per-store --- OpenSim/Data/MySQL/Resources/001_AssetStore.sql | 15 - OpenSim/Data/MySQL/Resources/001_AuthStore.sql | 21 - OpenSim/Data/MySQL/Resources/001_Avatar.sql | 5 - OpenSim/Data/MySQL/Resources/001_Friends.sql | 9 - OpenSim/Data/MySQL/Resources/001_FriendsStore.sql | 5 - OpenSim/Data/MySQL/Resources/001_GridStore.sql | 32 - .../Data/MySQL/Resources/001_InventoryStore.sql | 40 - OpenSim/Data/MySQL/Resources/001_LogStore.sql | 10 - OpenSim/Data/MySQL/Resources/001_Presence.sql | 13 - OpenSim/Data/MySQL/Resources/001_RegionStore.sql | 154 ---- OpenSim/Data/MySQL/Resources/001_UserAccount.sql | 13 - OpenSim/Data/MySQL/Resources/001_UserStore.sql | 107 --- OpenSim/Data/MySQL/Resources/002_AssetStore.sql | 9 - OpenSim/Data/MySQL/Resources/002_AuthStore.sql | 5 - OpenSim/Data/MySQL/Resources/002_Friends.sql | 5 - OpenSim/Data/MySQL/Resources/002_FriendsStore.sql | 5 - OpenSim/Data/MySQL/Resources/002_GridStore.sql | 5 - .../Data/MySQL/Resources/002_InventoryStore.sql | 31 - OpenSim/Data/MySQL/Resources/002_RegionStore.sql | 6 - OpenSim/Data/MySQL/Resources/002_UserAccount.sql | 5 - OpenSim/Data/MySQL/Resources/002_UserStore.sql | 5 - OpenSim/Data/MySQL/Resources/003_AssetStore.sql | 9 - OpenSim/Data/MySQL/Resources/003_AuthStore.sql | 5 - OpenSim/Data/MySQL/Resources/003_GridStore.sql | 7 - .../Data/MySQL/Resources/003_InventoryStore.sql | 5 - OpenSim/Data/MySQL/Resources/003_RegionStore.sql | 5 - OpenSim/Data/MySQL/Resources/003_UserAccount.sql | 9 - OpenSim/Data/MySQL/Resources/003_UserStore.sql | 6 - OpenSim/Data/MySQL/Resources/004_AssetStore.sql | 5 - OpenSim/Data/MySQL/Resources/004_GridStore.sql | 6 - .../Data/MySQL/Resources/004_InventoryStore.sql | 7 - OpenSim/Data/MySQL/Resources/004_RegionStore.sql | 5 - OpenSim/Data/MySQL/Resources/004_UserAccount.sql | 8 - OpenSim/Data/MySQL/Resources/004_UserStore.sql | 6 - OpenSim/Data/MySQL/Resources/005_AssetStore.sql | 6 - OpenSim/Data/MySQL/Resources/005_GridStore.sql | 6 - OpenSim/Data/MySQL/Resources/005_RegionStore.sql | 40 - OpenSim/Data/MySQL/Resources/005_UserStore.sql | 5 - OpenSim/Data/MySQL/Resources/006_AssetStore.sql | 1 - OpenSim/Data/MySQL/Resources/006_GridStore.sql | 5 - OpenSim/Data/MySQL/Resources/006_RegionStore.sql | 12 - OpenSim/Data/MySQL/Resources/006_UserStore.sql | 5 - OpenSim/Data/MySQL/Resources/007_GridStore.sql | 7 - OpenSim/Data/MySQL/Resources/007_RegionStore.sql | 25 - OpenSim/Data/MySQL/Resources/007_UserStore.sql | 5 - OpenSim/Data/MySQL/Resources/008_RegionStore.sql | 9 - OpenSim/Data/MySQL/Resources/008_UserStore.sql | 5 - OpenSim/Data/MySQL/Resources/009_RegionStore.sql | 31 - OpenSim/Data/MySQL/Resources/010_RegionStore.sql | 9 - OpenSim/Data/MySQL/Resources/011_RegionStore.sql | 9 - OpenSim/Data/MySQL/Resources/012_RegionStore.sql | 5 - OpenSim/Data/MySQL/Resources/013_RegionStore.sql | 103 --- OpenSim/Data/MySQL/Resources/014_RegionStore.sql | 8 - OpenSim/Data/MySQL/Resources/015_RegionStore.sql | 6 - OpenSim/Data/MySQL/Resources/016_RegionStore.sql | 27 - OpenSim/Data/MySQL/Resources/017_RegionStore.sql | 9 - OpenSim/Data/MySQL/Resources/018_RegionStore.sql | 6 - OpenSim/Data/MySQL/Resources/019_RegionStore.sql | 6 - OpenSim/Data/MySQL/Resources/020_RegionStore.sql | 7 - OpenSim/Data/MySQL/Resources/021_RegionStore.sql | 8 - OpenSim/Data/MySQL/Resources/022_RegionStore.sql | 6 - OpenSim/Data/MySQL/Resources/023_RegionStore.sql | 6 - OpenSim/Data/MySQL/Resources/024_RegionStore.sql | 18 - OpenSim/Data/MySQL/Resources/025_RegionStore.sql | 46 -- OpenSim/Data/MySQL/Resources/026_RegionStore.sql | 41 -- OpenSim/Data/MySQL/Resources/027_RegionStore.sql | 5 - OpenSim/Data/MySQL/Resources/028_RegionStore.sql | 79 -- OpenSim/Data/MySQL/Resources/029_RegionStore.sql | 5 - OpenSim/Data/MySQL/Resources/030_RegionStore.sql | 7 - OpenSim/Data/MySQL/Resources/031_RegionStore.sql | 7 - OpenSim/Data/MySQL/Resources/032_RegionStore.sql | 3 - OpenSim/Data/MySQL/Resources/AssetStore.migrations | 69 ++ OpenSim/Data/MySQL/Resources/AuthStore.migrations | 39 + OpenSim/Data/MySQL/Resources/Avatar.migrations | 12 + .../Data/MySQL/Resources/FriendsStore.migrations | 25 + OpenSim/Data/MySQL/Resources/GridStore.migrations | 89 +++ .../Data/MySQL/Resources/InventoryStore.migrations | 93 +++ OpenSim/Data/MySQL/Resources/LogStore.migrations | 13 + OpenSim/Data/MySQL/Resources/Presence.migrations | 36 + .../Data/MySQL/Resources/RegionStore.migrations | 806 +++++++++++++++++++++ .../Data/MySQL/Resources/UserAccount.migrations | 47 ++ OpenSim/Data/MySQL/Resources/UserStore.migrations | 168 +++++ 82 files changed, 1397 insertions(+), 1171 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/001_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_AuthStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_Avatar.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_Friends.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_FriendsStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_InventoryStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_LogStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_Presence.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_UserAccount.sql delete mode 100644 OpenSim/Data/MySQL/Resources/001_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_AuthStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_Friends.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_FriendsStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_InventoryStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_UserAccount.sql delete mode 100644 OpenSim/Data/MySQL/Resources/002_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_AuthStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_InventoryStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_UserAccount.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/004_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/004_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/004_InventoryStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/004_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/004_UserAccount.sql delete mode 100644 OpenSim/Data/MySQL/Resources/004_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/005_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/005_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/005_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/005_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/006_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/006_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/006_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/006_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/007_GridStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/007_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/007_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/008_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/008_UserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/009_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/010_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/011_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/012_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/013_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/014_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/015_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/016_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/017_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/018_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/019_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/020_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/021_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/022_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/023_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/024_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/025_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/026_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/027_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/028_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/029_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/030_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/031_RegionStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/032_RegionStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/AssetStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/AuthStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/Avatar.migrations create mode 100644 OpenSim/Data/MySQL/Resources/FriendsStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/GridStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/InventoryStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/LogStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/Presence.migrations create mode 100644 OpenSim/Data/MySQL/Resources/RegionStore.migrations create mode 100644 OpenSim/Data/MySQL/Resources/UserAccount.migrations create mode 100644 OpenSim/Data/MySQL/Resources/UserStore.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_AssetStore.sql b/OpenSim/Data/MySQL/Resources/001_AssetStore.sql deleted file mode 100644 index 6a9a127..0000000 --- a/OpenSim/Data/MySQL/Resources/001_AssetStore.sql +++ /dev/null @@ -1,15 +0,0 @@ -BEGIN; - -CREATE TABLE `assets` ( - `id` binary(16) NOT NULL, - `name` varchar(64) NOT NULL, - `description` varchar(64) NOT NULL, - `assetType` tinyint(4) NOT NULL, - `invType` tinyint(4) NOT NULL, - `local` tinyint(1) NOT NULL, - `temporary` tinyint(1) NOT NULL, - `data` longblob NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_AuthStore.sql b/OpenSim/Data/MySQL/Resources/001_AuthStore.sql deleted file mode 100644 index c7e16fb..0000000 --- a/OpenSim/Data/MySQL/Resources/001_AuthStore.sql +++ /dev/null @@ -1,21 +0,0 @@ -begin; - -CREATE TABLE `auth` ( - `UUID` char(36) NOT NULL, - `passwordHash` char(32) NOT NULL default '', - `passwordSalt` char(32) NOT NULL default '', - `webLoginKey` varchar(255) NOT NULL default '', - PRIMARY KEY (`UUID`) -) ENGINE=InnoDB; - -CREATE TABLE `tokens` ( - `UUID` char(36) NOT NULL, - `token` varchar(255) NOT NULL, - `validity` datetime NOT NULL, - UNIQUE KEY `uuid_token` (`UUID`,`token`), - KEY `UUID` (`UUID`), - KEY `token` (`token`), - KEY `validity` (`validity`) -) ENGINE=InnoDB; - -commit; diff --git a/OpenSim/Data/MySQL/Resources/001_Avatar.sql b/OpenSim/Data/MySQL/Resources/001_Avatar.sql deleted file mode 100644 index 27a3072..0000000 --- a/OpenSim/Data/MySQL/Resources/001_Avatar.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -CREATE TABLE Avatars (PrincipalID CHAR(36) NOT NULL, Name VARCHAR(32) NOT NULL, Value VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY(PrincipalID, Name), KEY(PrincipalID)); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/001_Friends.sql b/OpenSim/Data/MySQL/Resources/001_Friends.sql deleted file mode 100644 index e158a2c..0000000 --- a/OpenSim/Data/MySQL/Resources/001_Friends.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -CREATE TABLE `Friends` ( - `PrincipalID` CHAR(36) NOT NULL, - `FriendID` VARCHAR(255) NOT NULL, - `Flags` CHAR(16) NOT NULL DEFAULT '0' -) ENGINE=InnoDB; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql deleted file mode 100644 index da2c59c..0000000 --- a/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -CREATE TABLE `Friends` (`PrincipalID` CHAR(36) NOT NULL, `Friend` VARCHAR(255) NOT NULL, `Flags` VARCHAR(16) NOT NULL DEFAULT 0, `Offered` VARCHAR(32) NOT NULL DEFAULT 0, PRIMARY KEY(`PrincipalID`, `Friend`), KEY(`PrincipalID`)); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/001_GridStore.sql b/OpenSim/Data/MySQL/Resources/001_GridStore.sql deleted file mode 100644 index cb0f9bd..0000000 --- a/OpenSim/Data/MySQL/Resources/001_GridStore.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE `regions` ( - `uuid` varchar(36) NOT NULL, - `regionHandle` bigint(20) unsigned NOT NULL, - `regionName` varchar(32) default NULL, - `regionRecvKey` varchar(128) default NULL, - `regionSendKey` varchar(128) default NULL, - `regionSecret` varchar(128) default NULL, - `regionDataURI` varchar(255) default NULL, - `serverIP` varchar(64) default NULL, - `serverPort` int(10) unsigned default NULL, - `serverURI` varchar(255) default NULL, - `locX` int(10) unsigned default NULL, - `locY` int(10) unsigned default NULL, - `locZ` int(10) unsigned default NULL, - `eastOverrideHandle` bigint(20) unsigned default NULL, - `westOverrideHandle` bigint(20) unsigned default NULL, - `southOverrideHandle` bigint(20) unsigned default NULL, - `northOverrideHandle` bigint(20) unsigned default NULL, - `regionAssetURI` varchar(255) default NULL, - `regionAssetRecvKey` varchar(128) default NULL, - `regionAssetSendKey` varchar(128) default NULL, - `regionUserURI` varchar(255) default NULL, - `regionUserRecvKey` varchar(128) default NULL, - `regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL, - `serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL, - `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, - `originUUID` varchar(36), - PRIMARY KEY (`uuid`), - KEY `regionName` (`regionName`), - KEY `regionHandle` (`regionHandle`), - KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; diff --git a/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql deleted file mode 100644 index 40dc91c..0000000 --- a/OpenSim/Data/MySQL/Resources/001_InventoryStore.sql +++ /dev/null @@ -1,40 +0,0 @@ -BEGIN; - -CREATE TABLE `inventoryfolders` ( - `folderID` varchar(36) NOT NULL default '', - `agentID` varchar(36) default NULL, - `parentFolderID` varchar(36) default NULL, - `folderName` varchar(64) default NULL, - `type` smallint NOT NULL default 0, - `version` int NOT NULL default 0, - PRIMARY KEY (`folderID`), - KEY `owner` (`agentID`), - KEY `parent` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TABLE `inventoryitems` ( - `inventoryID` varchar(36) NOT NULL default '', - `assetID` varchar(36) default NULL, - `assetType` int(11) default NULL, - `parentFolderID` varchar(36) default NULL, - `avatarID` varchar(36) default NULL, - `inventoryName` varchar(64) default NULL, - `inventoryDescription` varchar(128) default NULL, - `inventoryNextPermissions` int(10) unsigned default NULL, - `inventoryCurrentPermissions` int(10) unsigned default NULL, - `invType` int(11) default NULL, - `creatorID` varchar(36) default NULL, - `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, - `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, - `salePrice` int(11) NOT NULL default 0, - `saleType` tinyint(4) NOT NULL default 0, - `creationDate` int(11) NOT NULL default 0, - `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - `groupOwned` tinyint(4) NOT NULL default 0, - `flags` int(11) unsigned NOT NULL default 0, - PRIMARY KEY (`inventoryID`), - KEY `owner` (`avatarID`), - KEY `folder` (`parentFolderID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_LogStore.sql b/OpenSim/Data/MySQL/Resources/001_LogStore.sql deleted file mode 100644 index b4c29fb..0000000 --- a/OpenSim/Data/MySQL/Resources/001_LogStore.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `logs` ( - `logID` int(10) unsigned NOT NULL auto_increment, - `target` varchar(36) default NULL, - `server` varchar(64) default NULL, - `method` varchar(64) default NULL, - `arguments` varchar(255) default NULL, - `priority` int(11) default NULL, - `message` text, - PRIMARY KEY (`logID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql deleted file mode 100644 index 84fa057..0000000 --- a/OpenSim/Data/MySQL/Resources/001_Presence.sql +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN; - -CREATE TABLE `Presence` ( - `UserID` VARCHAR(255) NOT NULL, - `RegionID` CHAR(36) NOT NULL, - `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' -) ENGINE=InnoDB; - -CREATE UNIQUE INDEX SessionID ON Presence(SessionID); -CREATE INDEX UserID ON Presence(UserID); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/001_RegionStore.sql b/OpenSim/Data/MySQL/Resources/001_RegionStore.sql deleted file mode 100644 index 31164b3..0000000 --- a/OpenSim/Data/MySQL/Resources/001_RegionStore.sql +++ /dev/null @@ -1,154 +0,0 @@ -BEGIN; - -CREATE TABLE `prims` ( - `UUID` varchar(255) NOT NULL, - `RegionUUID` varchar(255) default NULL, - `ParentID` int(11) default NULL, - `CreationDate` int(11) default NULL, - `Name` varchar(255) default NULL, - `SceneGroupID` varchar(255) default NULL, - `Text` varchar(255) default NULL, - `Description` varchar(255) default NULL, - `SitName` varchar(255) default NULL, - `TouchName` varchar(255) default NULL, - `ObjectFlags` int(11) default NULL, - `CreatorID` varchar(255) default NULL, - `OwnerID` varchar(255) default NULL, - `GroupID` varchar(255) default NULL, - `LastOwnerID` varchar(255) default NULL, - `OwnerMask` int(11) default NULL, - `NextOwnerMask` int(11) default NULL, - `GroupMask` int(11) default NULL, - `EveryoneMask` int(11) default NULL, - `BaseMask` int(11) default NULL, - `PositionX` float default NULL, - `PositionY` float default NULL, - `PositionZ` float default NULL, - `GroupPositionX` float default NULL, - `GroupPositionY` float default NULL, - `GroupPositionZ` float default NULL, - `VelocityX` float default NULL, - `VelocityY` float default NULL, - `VelocityZ` float default NULL, - `AngularVelocityX` float default NULL, - `AngularVelocityY` float default NULL, - `AngularVelocityZ` float default NULL, - `AccelerationX` float default NULL, - `AccelerationY` float default NULL, - `AccelerationZ` float default NULL, - `RotationX` float default NULL, - `RotationY` float default NULL, - `RotationZ` float default NULL, - `RotationW` float default NULL, - `SitTargetOffsetX` float default NULL, - `SitTargetOffsetY` float default NULL, - `SitTargetOffsetZ` float default NULL, - `SitTargetOrientW` float default NULL, - `SitTargetOrientX` float default NULL, - `SitTargetOrientY` float default NULL, - `SitTargetOrientZ` float default NULL, - PRIMARY KEY (`UUID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -CREATE TABLE `primshapes` ( - `UUID` varchar(255) NOT NULL, - `Shape` int(11) default NULL, - `ScaleX` float default NULL, - `ScaleY` float default NULL, - `ScaleZ` float default NULL, - `PCode` int(11) default NULL, - `PathBegin` int(11) default NULL, - `PathEnd` int(11) default NULL, - `PathScaleX` int(11) default NULL, - `PathScaleY` int(11) default NULL, - `PathShearX` int(11) default NULL, - `PathShearY` int(11) default NULL, - `PathSkew` int(11) default NULL, - `PathCurve` int(11) default NULL, - `PathRadiusOffset` int(11) default NULL, - `PathRevolutions` int(11) default NULL, - `PathTaperX` int(11) default NULL, - `PathTaperY` int(11) default NULL, - `PathTwist` int(11) default NULL, - `PathTwistBegin` int(11) default NULL, - `ProfileBegin` int(11) default NULL, - `ProfileEnd` int(11) default NULL, - `ProfileCurve` int(11) default NULL, - `ProfileHollow` int(11) default NULL, - `State` int(11) default NULL, - `Texture` longblob, - `ExtraParams` longblob, - PRIMARY KEY (`UUID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -CREATE TABLE `primitems` ( - `itemID` varchar(255) NOT NULL, - `primID` varchar(255) default NULL, - `assetID` varchar(255) default NULL, - `parentFolderID` varchar(255) default NULL, - `invType` int(11) default NULL, - `assetType` int(11) default NULL, - `name` varchar(255) default NULL, - `description` varchar(255) default NULL, - `creationDate` bigint(20) default NULL, - `creatorID` varchar(255) default NULL, - `ownerID` varchar(255) default NULL, - `lastOwnerID` varchar(255) default NULL, - `groupID` varchar(255) default NULL, - `nextPermissions` int(11) default NULL, - `currentPermissions` int(11) default NULL, - `basePermissions` int(11) default NULL, - `everyonePermissions` int(11) default NULL, - `groupPermissions` int(11) default NULL, - PRIMARY KEY (`itemID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -CREATE TABLE `terrain` ( - `RegionUUID` varchar(255) default NULL, - `Revision` int(11) default NULL, - `Heightfield` longblob -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -CREATE TABLE `land` ( - `UUID` varchar(255) NOT NULL, - `RegionUUID` varchar(255) default NULL, - `LocalLandID` int(11) default NULL, - `Bitmap` longblob, - `Name` varchar(255) default NULL, - `Description` varchar(255) default NULL, - `OwnerUUID` varchar(255) default NULL, - `IsGroupOwned` int(11) default NULL, - `Area` int(11) default NULL, - `AuctionID` int(11) default NULL, - `Category` int(11) default NULL, - `ClaimDate` int(11) default NULL, - `ClaimPrice` int(11) default NULL, - `GroupUUID` varchar(255) default NULL, - `SalePrice` int(11) default NULL, - `LandStatus` int(11) default NULL, - `LandFlags` int(11) default NULL, - `LandingType` int(11) default NULL, - `MediaAutoScale` int(11) default NULL, - `MediaTextureUUID` varchar(255) default NULL, - `MediaURL` varchar(255) default NULL, - `MusicURL` varchar(255) default NULL, - `PassHours` float default NULL, - `PassPrice` int(11) default NULL, - `SnapshotUUID` varchar(255) default NULL, - `UserLocationX` float default NULL, - `UserLocationY` float default NULL, - `UserLocationZ` float default NULL, - `UserLookAtX` float default NULL, - `UserLookAtY` float default NULL, - `UserLookAtZ` float default NULL, - `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - PRIMARY KEY (`UUID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TABLE `landaccesslist` ( - `LandUUID` varchar(255) default NULL, - `AccessUUID` varchar(255) default NULL, - `Flags` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql deleted file mode 100644 index 07da571..0000000 --- a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN; - -CREATE TABLE `UserAccounts` ( - `PrincipalID` CHAR(36) NOT NULL, - `ScopeID` CHAR(36) NOT NULL, - `FirstName` VARCHAR(64) NOT NULL, - `LastName` VARCHAR(64) NOT NULL, - `Email` VARCHAR(64), - `ServiceURLs` TEXT, - `Created` INT(11) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/001_UserStore.sql b/OpenSim/Data/MySQL/Resources/001_UserStore.sql deleted file mode 100644 index 29ebc7d..0000000 --- a/OpenSim/Data/MySQL/Resources/001_UserStore.sql +++ /dev/null @@ -1,107 +0,0 @@ -BEGIN; - -SET FOREIGN_KEY_CHECKS=0; --- ---------------------------- --- Table structure for agents --- ---------------------------- -CREATE TABLE `agents` ( - `UUID` varchar(36) NOT NULL, - `sessionID` varchar(36) NOT NULL, - `secureSessionID` varchar(36) NOT NULL, - `agentIP` varchar(16) NOT NULL, - `agentPort` int(11) NOT NULL, - `agentOnline` tinyint(4) NOT NULL, - `loginTime` int(11) NOT NULL, - `logoutTime` int(11) NOT NULL, - `currentRegion` varchar(36) NOT NULL, - `currentHandle` bigint(20) unsigned NOT NULL, - `currentPos` varchar(64) NOT NULL, - PRIMARY KEY (`UUID`), - UNIQUE KEY `session` (`sessionID`), - UNIQUE KEY `ssession` (`secureSessionID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- Create schema avatar_appearance --- - -CREATE TABLE `avatarappearance` ( - Owner char(36) NOT NULL, - Serial int(10) unsigned NOT NULL, - Visual_Params blob NOT NULL, - Texture blob NOT NULL, - Avatar_Height float NOT NULL, - Body_Item char(36) NOT NULL, - Body_Asset char(36) NOT NULL, - Skin_Item char(36) NOT NULL, - Skin_Asset char(36) NOT NULL, - Hair_Item char(36) NOT NULL, - Hair_Asset char(36) NOT NULL, - Eyes_Item char(36) NOT NULL, - Eyes_Asset char(36) NOT NULL, - Shirt_Item char(36) NOT NULL, - Shirt_Asset char(36) NOT NULL, - Pants_Item char(36) NOT NULL, - Pants_Asset char(36) NOT NULL, - Shoes_Item char(36) NOT NULL, - Shoes_Asset char(36) NOT NULL, - Socks_Item char(36) NOT NULL, - Socks_Asset char(36) NOT NULL, - Jacket_Item char(36) NOT NULL, - Jacket_Asset char(36) NOT NULL, - Gloves_Item char(36) NOT NULL, - Gloves_Asset char(36) NOT NULL, - Undershirt_Item char(36) NOT NULL, - Undershirt_Asset char(36) NOT NULL, - Underpants_Item char(36) NOT NULL, - Underpants_Asset char(36) NOT NULL, - Skirt_Item char(36) NOT NULL, - Skirt_Asset char(36) NOT NULL, - PRIMARY KEY (`Owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -SET FOREIGN_KEY_CHECKS=0; --- ---------------------------- --- Table structure for users --- ---------------------------- -CREATE TABLE `userfriends` ( - `ownerID` VARCHAR(37) NOT NULL, - `friendID` VARCHAR(37) NOT NULL, - `friendPerms` INT NOT NULL, - `datetimestamp` INT NOT NULL, - UNIQUE KEY (`ownerID`, `friendID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------- --- Table structure for users --- ---------------------------- -CREATE TABLE `users` ( - `UUID` varchar(36) NOT NULL default '', - `username` varchar(32) NOT NULL, - `lastname` varchar(32) NOT NULL, - `passwordHash` varchar(32) NOT NULL, - `passwordSalt` varchar(32) NOT NULL, - `homeRegion` bigint(20) unsigned default NULL, - `homeLocationX` float default NULL, - `homeLocationY` float default NULL, - `homeLocationZ` float default NULL, - `homeLookAtX` float default NULL, - `homeLookAtY` float default NULL, - `homeLookAtZ` float default NULL, - `created` int(11) NOT NULL, - `lastLogin` int(11) NOT NULL, - `userInventoryURI` varchar(255) default NULL, - `userAssetURI` varchar(255) default NULL, - `profileCanDoMask` int(10) unsigned default NULL, - `profileWantDoMask` int(10) unsigned default NULL, - `profileAboutText` text, - `profileFirstText` text, - `profileImage` varchar(36) default NULL, - `profileFirstImage` varchar(36) default NULL, - `webLoginKey` varchar(36) default NULL, - PRIMARY KEY (`UUID`), - UNIQUE KEY `usernames` (`username`,`lastname`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- ---------------------------- --- Records --- ---------------------------- -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/002_AssetStore.sql b/OpenSim/Data/MySQL/Resources/002_AssetStore.sql deleted file mode 100644 index a7d7fca..0000000 --- a/OpenSim/Data/MySQL/Resources/002_AssetStore.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -ALTER TABLE assets change id oldid binary(16); -ALTER TABLE assets add id varchar(36) not null default ''; -UPDATE assets set id = concat(substr(hex(oldid),1,8),"-",substr(hex(oldid),9,4),"-",substr(hex(oldid),13,4),"-",substr(hex(oldid),17,4),"-",substr(hex(oldid),21,12)); -ALTER TABLE assets drop oldid; -ALTER TABLE assets add constraint primary key(id); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/002_AuthStore.sql b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql deleted file mode 100644 index dc7dfe0..0000000 --- a/OpenSim/Data/MySQL/Resources/002_AuthStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_Friends.sql b/OpenSim/Data/MySQL/Resources/002_Friends.sql deleted file mode 100644 index 5ff6438..0000000 --- a/OpenSim/Data/MySQL/Resources/002_Friends.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -INSERT INTO Friends (PrincipalID, FriendID, Flags) SELECT ownerID, friendID, friendPerms FROM userfriends; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql deleted file mode 100644 index a363867..0000000 --- a/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_GridStore.sql b/OpenSim/Data/MySQL/Resources/002_GridStore.sql deleted file mode 100644 index 35b9be1..0000000 --- a/OpenSim/Data/MySQL/Resources/002_GridStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE regions add column access integer unsigned default 1; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/002_InventoryStore.sql deleted file mode 100644 index c161a68..0000000 --- a/OpenSim/Data/MySQL/Resources/002_InventoryStore.sql +++ /dev/null @@ -1,31 +0,0 @@ -BEGIN; - -ALTER TABLE inventoryfolders change folderID folderIDold varchar(36); -ALTER TABLE inventoryfolders change agentID agentIDold varchar(36); -ALTER TABLE inventoryfolders change parentFolderID parentFolderIDold varchar(36); -ALTER TABLE inventoryfolders add folderID char(36) not null default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE inventoryfolders add agentID char(36) default NULL; -ALTER TABLE inventoryfolders add parentFolderID char(36) default NULL; -UPDATE inventoryfolders set folderID = folderIDold, agentID = agentIDold, parentFolderID = parentFolderIDold; -ALTER TABLE inventoryfolders drop folderIDold; -ALTER TABLE inventoryfolders drop agentIDold; -ALTER TABLE inventoryfolders drop parentFolderIDold; -ALTER TABLE inventoryfolders add constraint primary key(folderID); -ALTER TABLE inventoryfolders add index inventoryfolders_agentid(agentID); -ALTER TABLE inventoryfolders add index inventoryfolders_parentFolderid(parentFolderID); - -ALTER TABLE inventoryitems change inventoryID inventoryIDold varchar(36); -ALTER TABLE inventoryitems change avatarID avatarIDold varchar(36); -ALTER TABLE inventoryitems change parentFolderID parentFolderIDold varchar(36); -ALTER TABLE inventoryitems add inventoryID char(36) not null default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE inventoryitems add avatarID char(36) default NULL; -ALTER TABLE inventoryitems add parentFolderID char(36) default NULL; -UPDATE inventoryitems set inventoryID = inventoryIDold, avatarID = avatarIDold, parentFolderID = parentFolderIDold; -ALTER TABLE inventoryitems drop inventoryIDold; -ALTER TABLE inventoryitems drop avatarIDold; -ALTER TABLE inventoryitems drop parentFolderIDold; -ALTER TABLE inventoryitems add constraint primary key(inventoryID); -ALTER TABLE inventoryitems add index inventoryitems_avatarid(avatarID); -ALTER TABLE inventoryitems add index inventoryitems_parentFolderid(parentFolderID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/002_RegionStore.sql b/OpenSim/Data/MySQL/Resources/002_RegionStore.sql deleted file mode 100644 index 45bf959..0000000 --- a/OpenSim/Data/MySQL/Resources/002_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -CREATE index prims_regionuuid on prims(RegionUUID); -CREATE index primitems_primid on primitems(primID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql deleted file mode 100644 index ad2ddda..0000000 --- a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_UserStore.sql b/OpenSim/Data/MySQL/Resources/002_UserStore.sql deleted file mode 100644 index 393cea0..0000000 --- a/OpenSim/Data/MySQL/Resources/002_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE users add homeRegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_AssetStore.sql b/OpenSim/Data/MySQL/Resources/003_AssetStore.sql deleted file mode 100644 index d489278..0000000 --- a/OpenSim/Data/MySQL/Resources/003_AssetStore.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -ALTER TABLE assets change id oldid varchar(36); -ALTER TABLE assets add id char(36) not null default '00000000-0000-0000-0000-000000000000'; -UPDATE assets set id = oldid; -ALTER TABLE assets drop oldid; -ALTER TABLE assets add constraint primary key(id); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/003_AuthStore.sql b/OpenSim/Data/MySQL/Resources/003_AuthStore.sql deleted file mode 100644 index af9ffe6..0000000 --- a/OpenSim/Data/MySQL/Resources/003_AuthStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE `auth` ADD COLUMN `accountType` VARCHAR(32) NOT NULL DEFAULT 'UserAccount'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_GridStore.sql b/OpenSim/Data/MySQL/Resources/003_GridStore.sql deleted file mode 100644 index bc3fe7d..0000000 --- a/OpenSim/Data/MySQL/Resources/003_GridStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE regions add column ScopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; - -create index ScopeID on regions(ScopeID); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/003_InventoryStore.sql deleted file mode 100644 index 4c6da91..0000000 --- a/OpenSim/Data/MySQL/Resources/003_InventoryStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -alter table inventoryitems add column inventoryGroupPermissions integer unsigned not null default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_RegionStore.sql b/OpenSim/Data/MySQL/Resources/003_RegionStore.sql deleted file mode 100644 index cb0a614..0000000 --- a/OpenSim/Data/MySQL/Resources/003_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - - CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/003_UserAccount.sql b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql deleted file mode 100644 index e42d93b..0000000 --- a/OpenSim/Data/MySQL/Resources/003_UserAccount.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); -CREATE INDEX Email ON UserAccounts(Email); -CREATE INDEX FirstName ON UserAccounts(FirstName); -CREATE INDEX LastName ON UserAccounts(LastName); -CREATE INDEX Name ON UserAccounts(FirstName,LastName); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_UserStore.sql b/OpenSim/Data/MySQL/Resources/003_UserStore.sql deleted file mode 100644 index 6f890ee..0000000 --- a/OpenSim/Data/MySQL/Resources/003_UserStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE users add userFlags integer NOT NULL default 0; -ALTER TABLE users add godLevel integer NOT NULL default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/004_AssetStore.sql b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql deleted file mode 100644 index ae1951d..0000000 --- a/OpenSim/Data/MySQL/Resources/004_AssetStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE assets drop InvType; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/004_GridStore.sql b/OpenSim/Data/MySQL/Resources/004_GridStore.sql deleted file mode 100644 index 2238a88..0000000 --- a/OpenSim/Data/MySQL/Resources/004_GridStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE regions add column sizeX integer not null default 0; -ALTER TABLE regions add column sizeY integer not null default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/004_InventoryStore.sql b/OpenSim/Data/MySQL/Resources/004_InventoryStore.sql deleted file mode 100644 index c45f773..0000000 --- a/OpenSim/Data/MySQL/Resources/004_InventoryStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID is NULL; -update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID = ''; -alter table inventoryitems modify column creatorID varchar(36) not NULL default '00000000-0000-0000-0000-000000000000'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/004_RegionStore.sql b/OpenSim/Data/MySQL/Resources/004_RegionStore.sql deleted file mode 100644 index 4db2f75..0000000 --- a/OpenSim/Data/MySQL/Resources/004_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE primitems add flags integer not null default 0; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/004_UserAccount.sql b/OpenSim/Data/MySQL/Resources/004_UserAccount.sql deleted file mode 100644 index 8abcd53..0000000 --- a/OpenSim/Data/MySQL/Resources/004_UserAccount.sql +++ /dev/null @@ -1,8 +0,0 @@ -BEGIN; - -ALTER TABLE UserAccounts ADD COLUMN UserLevel integer NOT NULL DEFAULT 0; -ALTER TABLE UserAccounts ADD COLUMN UserFlags integer NOT NULL DEFAULT 0; -ALTER TABLE UserAccounts ADD COLUMN UserTitle varchar(64) NOT NULL DEFAULT ''; - -COMMIT; - diff --git a/OpenSim/Data/MySQL/Resources/004_UserStore.sql b/OpenSim/Data/MySQL/Resources/004_UserStore.sql deleted file mode 100644 index 03142af..0000000 --- a/OpenSim/Data/MySQL/Resources/004_UserStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE users add customType varchar(32) not null default ''; -ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/005_AssetStore.sql b/OpenSim/Data/MySQL/Resources/005_AssetStore.sql deleted file mode 100644 index bfeb652..0000000 --- a/OpenSim/Data/MySQL/Resources/005_AssetStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE assets add create_time integer default 0; -ALTER TABLE assets add access_time integer default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/005_GridStore.sql b/OpenSim/Data/MySQL/Resources/005_GridStore.sql deleted file mode 100644 index 835ba89..0000000 --- a/OpenSim/Data/MySQL/Resources/005_GridStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE `regions` ADD COLUMN `flags` integer NOT NULL DEFAULT 0; -CREATE INDEX flags ON regions(flags); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/005_RegionStore.sql b/OpenSim/Data/MySQL/Resources/005_RegionStore.sql deleted file mode 100644 index c4a9527..0000000 --- a/OpenSim/Data/MySQL/Resources/005_RegionStore.sql +++ /dev/null @@ -1,40 +0,0 @@ -BEGIN; - -create table regionsettings ( - regionUUID char(36) not null, - block_terraform integer not null, - block_fly integer not null, - allow_damage integer not null, - restrict_pushing integer not null, - allow_land_resell integer not null, - allow_land_join_divide integer not null, - block_show_in_search integer not null, - agent_limit integer not null, - object_bonus float not null, - maturity integer not null, - disable_scripts integer not null, - disable_collisions integer not null, - disable_physics integer not null, - terrain_texture_1 char(36) not null, - terrain_texture_2 char(36) not null, - terrain_texture_3 char(36) not null, - terrain_texture_4 char(36) not null, - elevation_1_nw float not null, - elevation_2_nw float not null, - elevation_1_ne float not null, - elevation_2_ne float not null, - elevation_1_se float not null, - elevation_2_se float not null, - elevation_1_sw float not null, - elevation_2_sw float not null, - water_height float not null, - terrain_raise_limit float not null, - terrain_lower_limit float not null, - use_estate_sun integer not null, - fixed_sun integer not null, - sun_position float not null, - covenant char(36), - primary key(regionUUID) -); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/005_UserStore.sql b/OpenSim/Data/MySQL/Resources/005_UserStore.sql deleted file mode 100644 index 55896bc..0000000 --- a/OpenSim/Data/MySQL/Resources/005_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=InnoDB; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/006_AssetStore.sql b/OpenSim/Data/MySQL/Resources/006_AssetStore.sql deleted file mode 100644 index 3104353..0000000 --- a/OpenSim/Data/MySQL/Resources/006_AssetStore.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621' diff --git a/OpenSim/Data/MySQL/Resources/006_GridStore.sql b/OpenSim/Data/MySQL/Resources/006_GridStore.sql deleted file mode 100644 index 91322d6..0000000 --- a/OpenSim/Data/MySQL/Resources/006_GridStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE `regions` ADD COLUMN `last_seen` integer NOT NULL DEFAULT 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/006_RegionStore.sql b/OpenSim/Data/MySQL/Resources/006_RegionStore.sql deleted file mode 100644 index c1ba5b8..0000000 --- a/OpenSim/Data/MySQL/Resources/006_RegionStore.sql +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN; - -alter table landaccesslist ENGINE = InnoDB; -alter table migrations ENGINE = InnoDB; -alter table primitems ENGINE = InnoDB; -alter table prims ENGINE = InnoDB; -alter table primshapes ENGINE = InnoDB; -alter table regionsettings ENGINE = InnoDB; -alter table terrain ENGINE = InnoDB; - -COMMIT; - diff --git a/OpenSim/Data/MySQL/Resources/006_UserStore.sql b/OpenSim/Data/MySQL/Resources/006_UserStore.sql deleted file mode 100644 index 10b321e..0000000 --- a/OpenSim/Data/MySQL/Resources/006_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE agents add currentLookAt varchar(36) not null default ''; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/007_GridStore.sql b/OpenSim/Data/MySQL/Resources/007_GridStore.sql deleted file mode 100644 index dbec584..0000000 --- a/OpenSim/Data/MySQL/Resources/007_GridStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; -ALTER TABLE `regions` ADD COLUMN `Token` varchar(255) NOT NULL; - -COMMIT; - diff --git a/OpenSim/Data/MySQL/Resources/007_RegionStore.sql b/OpenSim/Data/MySQL/Resources/007_RegionStore.sql deleted file mode 100644 index 404d248..0000000 --- a/OpenSim/Data/MySQL/Resources/007_RegionStore.sql +++ /dev/null @@ -1,25 +0,0 @@ -BEGIN; - -ALTER TABLE prims change UUID UUIDold varchar(255); -ALTER TABLE prims change RegionUUID RegionUUIDold varchar(255); -ALTER TABLE prims change CreatorID CreatorIDold varchar(255); -ALTER TABLE prims change OwnerID OwnerIDold varchar(255); -ALTER TABLE prims change GroupID GroupIDold varchar(255); -ALTER TABLE prims change LastOwnerID LastOwnerIDold varchar(255); -ALTER TABLE prims add UUID char(36); -ALTER TABLE prims add RegionUUID char(36); -ALTER TABLE prims add CreatorID char(36); -ALTER TABLE prims add OwnerID char(36); -ALTER TABLE prims add GroupID char(36); -ALTER TABLE prims add LastOwnerID char(36); -UPDATE prims set UUID = UUIDold, RegionUUID = RegionUUIDold, CreatorID = CreatorIDold, OwnerID = OwnerIDold, GroupID = GroupIDold, LastOwnerID = LastOwnerIDold; -ALTER TABLE prims drop UUIDold; -ALTER TABLE prims drop RegionUUIDold; -ALTER TABLE prims drop CreatorIDold; -ALTER TABLE prims drop OwnerIDold; -ALTER TABLE prims drop GroupIDold; -ALTER TABLE prims drop LastOwnerIDold; -ALTER TABLE prims add constraint primary key(UUID); -ALTER TABLE prims add index prims_regionuuid(RegionUUID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/007_UserStore.sql b/OpenSim/Data/MySQL/Resources/007_UserStore.sql deleted file mode 100644 index 3ab5261..0000000 --- a/OpenSim/Data/MySQL/Resources/007_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE users add email varchar(250); - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/008_RegionStore.sql b/OpenSim/Data/MySQL/Resources/008_RegionStore.sql deleted file mode 100644 index 7bc61c0..0000000 --- a/OpenSim/Data/MySQL/Resources/008_RegionStore.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -ALTER TABLE primshapes change UUID UUIDold varchar(255); -ALTER TABLE primshapes add UUID char(36); -UPDATE primshapes set UUID = UUIDold; -ALTER TABLE primshapes drop UUIDold; -ALTER TABLE primshapes add constraint primary key(UUID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/008_UserStore.sql b/OpenSim/Data/MySQL/Resources/008_UserStore.sql deleted file mode 100644 index 4500bd5..0000000 --- a/OpenSim/Data/MySQL/Resources/008_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE users add scopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/009_RegionStore.sql b/OpenSim/Data/MySQL/Resources/009_RegionStore.sql deleted file mode 100644 index 284732a..0000000 --- a/OpenSim/Data/MySQL/Resources/009_RegionStore.sql +++ /dev/null @@ -1,31 +0,0 @@ -BEGIN; - -ALTER TABLE primitems change itemID itemIDold varchar(255); -ALTER TABLE primitems change primID primIDold varchar(255); -ALTER TABLE primitems change assetID assetIDold varchar(255); -ALTER TABLE primitems change parentFolderID parentFolderIDold varchar(255); -ALTER TABLE primitems change creatorID creatorIDold varchar(255); -ALTER TABLE primitems change ownerID ownerIDold varchar(255); -ALTER TABLE primitems change groupID groupIDold varchar(255); -ALTER TABLE primitems change lastOwnerID lastOwnerIDold varchar(255); -ALTER TABLE primitems add itemID char(36); -ALTER TABLE primitems add primID char(36); -ALTER TABLE primitems add assetID char(36); -ALTER TABLE primitems add parentFolderID char(36); -ALTER TABLE primitems add creatorID char(36); -ALTER TABLE primitems add ownerID char(36); -ALTER TABLE primitems add groupID char(36); -ALTER TABLE primitems add lastOwnerID char(36); -UPDATE primitems set itemID = itemIDold, primID = primIDold, assetID = assetIDold, parentFolderID = parentFolderIDold, creatorID = creatorIDold, ownerID = ownerIDold, groupID = groupIDold, lastOwnerID = lastOwnerIDold; -ALTER TABLE primitems drop itemIDold; -ALTER TABLE primitems drop primIDold; -ALTER TABLE primitems drop assetIDold; -ALTER TABLE primitems drop parentFolderIDold; -ALTER TABLE primitems drop creatorIDold; -ALTER TABLE primitems drop ownerIDold; -ALTER TABLE primitems drop groupIDold; -ALTER TABLE primitems drop lastOwnerIDold; -ALTER TABLE primitems add constraint primary key(itemID); -ALTER TABLE primitems add index primitems_primid(primID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/010_RegionStore.sql b/OpenSim/Data/MySQL/Resources/010_RegionStore.sql deleted file mode 100644 index 031a746..0000000 --- a/OpenSim/Data/MySQL/Resources/010_RegionStore.sql +++ /dev/null @@ -1,9 +0,0 @@ -# 1 "010_RegionStore.sql" -# 1 "" -# 1 "" -# 1 "010_RegionStore.sql" -BEGIN; - -DELETE FROM regionsettings; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/011_RegionStore.sql b/OpenSim/Data/MySQL/Resources/011_RegionStore.sql deleted file mode 100644 index ab01969..0000000 --- a/OpenSim/Data/MySQL/Resources/011_RegionStore.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -ALTER TABLE prims change SceneGroupID SceneGroupIDold varchar(255); -ALTER TABLE prims add SceneGroupID char(36); -UPDATE prims set SceneGroupID = SceneGroupIDold; -ALTER TABLE prims drop SceneGroupIDold; -ALTER TABLE prims add index prims_scenegroupid(SceneGroupID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/012_RegionStore.sql b/OpenSim/Data/MySQL/Resources/012_RegionStore.sql deleted file mode 100644 index 95c2757..0000000 --- a/OpenSim/Data/MySQL/Resources/012_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE prims add index prims_parentid(ParentID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/013_RegionStore.sql b/OpenSim/Data/MySQL/Resources/013_RegionStore.sql deleted file mode 100644 index a6bd30d..0000000 --- a/OpenSim/Data/MySQL/Resources/013_RegionStore.sql +++ /dev/null @@ -1,103 +0,0 @@ -begin; - -drop table regionsettings; - -CREATE TABLE `regionsettings` ( - `regionUUID` char(36) NOT NULL, - `block_terraform` int(11) NOT NULL, - `block_fly` int(11) NOT NULL, - `allow_damage` int(11) NOT NULL, - `restrict_pushing` int(11) NOT NULL, - `allow_land_resell` int(11) NOT NULL, - `allow_land_join_divide` int(11) NOT NULL, - `block_show_in_search` int(11) NOT NULL, - `agent_limit` int(11) NOT NULL, - `object_bonus` float NOT NULL, - `maturity` int(11) NOT NULL, - `disable_scripts` int(11) NOT NULL, - `disable_collisions` int(11) NOT NULL, - `disable_physics` int(11) NOT NULL, - `terrain_texture_1` char(36) NOT NULL, - `terrain_texture_2` char(36) NOT NULL, - `terrain_texture_3` char(36) NOT NULL, - `terrain_texture_4` char(36) NOT NULL, - `elevation_1_nw` float NOT NULL, - `elevation_2_nw` float NOT NULL, - `elevation_1_ne` float NOT NULL, - `elevation_2_ne` float NOT NULL, - `elevation_1_se` float NOT NULL, - `elevation_2_se` float NOT NULL, - `elevation_1_sw` float NOT NULL, - `elevation_2_sw` float NOT NULL, - `water_height` float NOT NULL, - `terrain_raise_limit` float NOT NULL, - `terrain_lower_limit` float NOT NULL, - `use_estate_sun` int(11) NOT NULL, - `fixed_sun` int(11) NOT NULL, - `sun_position` float NOT NULL, - `covenant` char(36) default NULL, - `Sandbox` tinyint(4) NOT NULL, - PRIMARY KEY (`regionUUID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_managers` ( - `EstateID` int(10) unsigned NOT NULL, - `uuid` char(36) NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_groups` ( - `EstateID` int(10) unsigned NOT NULL, - `uuid` char(36) NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_users` ( - `EstateID` int(10) unsigned NOT NULL, - `uuid` char(36) NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estateban` ( - `EstateID` int(10) unsigned NOT NULL, - `bannedUUID` varchar(36) NOT NULL, - `bannedIp` varchar(16) NOT NULL, - `bannedIpHostMask` varchar(16) NOT NULL, - `bannedNameMask` varchar(64) default NULL, - KEY `estateban_EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_settings` ( - `EstateID` int(10) unsigned NOT NULL auto_increment, - `EstateName` varchar(64) default NULL, - `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, - `DenyAnonymous` tinyint(4) NOT NULL, - `ResetHomeOnTeleport` tinyint(4) NOT NULL, - `FixedSun` tinyint(4) NOT NULL, - `DenyTransacted` tinyint(4) NOT NULL, - `BlockDwell` tinyint(4) NOT NULL, - `DenyIdentified` tinyint(4) NOT NULL, - `AllowVoice` tinyint(4) NOT NULL, - `UseGlobalTime` tinyint(4) NOT NULL, - `PricePerMeter` int(11) NOT NULL, - `TaxFree` tinyint(4) NOT NULL, - `AllowDirectTeleport` tinyint(4) NOT NULL, - `RedirectGridX` int(11) NOT NULL, - `RedirectGridY` int(11) NOT NULL, - `ParentEstateID` int(10) unsigned NOT NULL, - `SunPosition` double NOT NULL, - `EstateSkipScripts` tinyint(4) NOT NULL, - `BillableFactor` float NOT NULL, - `PublicAccess` tinyint(4) NOT NULL, - PRIMARY KEY (`EstateID`) -) ENGINE=InnoDB AUTO_INCREMENT=100; - -CREATE TABLE `estate_map` ( - `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - `EstateID` int(11) NOT NULL, - PRIMARY KEY (`RegionID`), - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/014_RegionStore.sql b/OpenSim/Data/MySQL/Resources/014_RegionStore.sql deleted file mode 100644 index 788fd63..0000000 --- a/OpenSim/Data/MySQL/Resources/014_RegionStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -begin; - -alter table estate_settings add column AbuseEmail varchar(255) not null; - -alter table estate_settings add column EstateOwner varchar(36) not null; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/015_RegionStore.sql b/OpenSim/Data/MySQL/Resources/015_RegionStore.sql deleted file mode 100644 index 6d4f9f3..0000000 --- a/OpenSim/Data/MySQL/Resources/015_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -begin; - -alter table estate_settings add column DenyMinors tinyint not null; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/016_RegionStore.sql b/OpenSim/Data/MySQL/Resources/016_RegionStore.sql deleted file mode 100644 index 9bc265e..0000000 --- a/OpenSim/Data/MySQL/Resources/016_RegionStore.sql +++ /dev/null @@ -1,27 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN PayPrice integer not null default 0; -ALTER TABLE prims ADD COLUMN PayButton1 integer not null default 0; -ALTER TABLE prims ADD COLUMN PayButton2 integer not null default 0; -ALTER TABLE prims ADD COLUMN PayButton3 integer not null default 0; -ALTER TABLE prims ADD COLUMN PayButton4 integer not null default 0; -ALTER TABLE prims ADD COLUMN LoopedSound char(36) not null default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE prims ADD COLUMN LoopedSoundGain float not null default 0.0; -ALTER TABLE prims ADD COLUMN TextureAnimation blob; -ALTER TABLE prims ADD COLUMN OmegaX float not null default 0.0; -ALTER TABLE prims ADD COLUMN OmegaY float not null default 0.0; -ALTER TABLE prims ADD COLUMN OmegaZ float not null default 0.0; -ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float not null default 0.0; -ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float not null default 0.0; -ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float not null default 0.0; -ALTER TABLE prims ADD COLUMN CameraAtOffsetX float not null default 0.0; -ALTER TABLE prims ADD COLUMN CameraAtOffsetY float not null default 0.0; -ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float not null default 0.0; -ALTER TABLE prims ADD COLUMN ForceMouselook tinyint not null default 0; -ALTER TABLE prims ADD COLUMN ScriptAccessPin integer not null default 0; -ALTER TABLE prims ADD COLUMN AllowedDrop tinyint not null default 0; -ALTER TABLE prims ADD COLUMN DieAtEdge tinyint not null default 0; -ALTER TABLE prims ADD COLUMN SalePrice integer not null default 10; -ALTER TABLE prims ADD COLUMN SaleType tinyint not null default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/017_RegionStore.sql b/OpenSim/Data/MySQL/Resources/017_RegionStore.sql deleted file mode 100644 index 0304f30..0000000 --- a/OpenSim/Data/MySQL/Resources/017_RegionStore.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN ColorR integer not null default 0; -ALTER TABLE prims ADD COLUMN ColorG integer not null default 0; -ALTER TABLE prims ADD COLUMN ColorB integer not null default 0; -ALTER TABLE prims ADD COLUMN ColorA integer not null default 0; -ALTER TABLE prims ADD COLUMN ParticleSystem blob; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/018_RegionStore.sql b/OpenSim/Data/MySQL/Resources/018_RegionStore.sql deleted file mode 100644 index 68c489c..0000000 --- a/OpenSim/Data/MySQL/Resources/018_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -begin; - -ALTER TABLE prims ADD COLUMN ClickAction tinyint NOT NULL default 0; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/019_RegionStore.sql b/OpenSim/Data/MySQL/Resources/019_RegionStore.sql deleted file mode 100644 index 4c14f2a..0000000 --- a/OpenSim/Data/MySQL/Resources/019_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -begin; - -ALTER TABLE prims ADD COLUMN Material tinyint NOT NULL default 3; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/020_RegionStore.sql b/OpenSim/Data/MySQL/Resources/020_RegionStore.sql deleted file mode 100644 index 814ef48..0000000 --- a/OpenSim/Data/MySQL/Resources/020_RegionStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -begin; - -ALTER TABLE land ADD COLUMN OtherCleanTime integer NOT NULL default 0; -ALTER TABLE land ADD COLUMN Dwell integer NOT NULL default 0; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/021_RegionStore.sql b/OpenSim/Data/MySQL/Resources/021_RegionStore.sql deleted file mode 100644 index c59b27e..0000000 --- a/OpenSim/Data/MySQL/Resources/021_RegionStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -begin; - -ALTER TABLE regionsettings ADD COLUMN sunvectorx double NOT NULL default 0; -ALTER TABLE regionsettings ADD COLUMN sunvectory double NOT NULL default 0; -ALTER TABLE regionsettings ADD COLUMN sunvectorz double NOT NULL default 0; - -commit; - diff --git a/OpenSim/Data/MySQL/Resources/022_RegionStore.sql b/OpenSim/Data/MySQL/Resources/022_RegionStore.sql deleted file mode 100644 index df0bb7d..0000000 --- a/OpenSim/Data/MySQL/Resources/022_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE prims ADD COLUMN CollisionSoundVolume float not null default 0.0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/023_RegionStore.sql b/OpenSim/Data/MySQL/Resources/023_RegionStore.sql deleted file mode 100644 index 559591f..0000000 --- a/OpenSim/Data/MySQL/Resources/023_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN LinkNumber integer not null default 0; - -COMMIT; - diff --git a/OpenSim/Data/MySQL/Resources/024_RegionStore.sql b/OpenSim/Data/MySQL/Resources/024_RegionStore.sql deleted file mode 100644 index defbf5c..0000000 --- a/OpenSim/Data/MySQL/Resources/024_RegionStore.sql +++ /dev/null @@ -1,18 +0,0 @@ -BEGIN; - -alter table regionsettings change column `object_bonus` `object_bonus` double NOT NULL; -alter table regionsettings change column `elevation_1_nw` `elevation_1_nw` double NOT NULL; -alter table regionsettings change column `elevation_2_nw` `elevation_2_nw` double NOT NULL; -alter table regionsettings change column `elevation_1_ne` `elevation_1_ne` double NOT NULL; -alter table regionsettings change column `elevation_2_ne` `elevation_2_ne` double NOT NULL; -alter table regionsettings change column `elevation_1_se` `elevation_1_se` double NOT NULL; -alter table regionsettings change column `elevation_2_se` `elevation_2_se` double NOT NULL; -alter table regionsettings change column `elevation_1_sw` `elevation_1_sw` double NOT NULL; -alter table regionsettings change column `elevation_2_sw` `elevation_2_sw` double NOT NULL; -alter table regionsettings change column `water_height` `water_height` double NOT NULL; -alter table regionsettings change column `terrain_raise_limit` `terrain_raise_limit` double NOT NULL; -alter table regionsettings change column `terrain_lower_limit` `terrain_lower_limit` double NOT NULL; -alter table regionsettings change column `sun_position` `sun_position` double NOT NULL; - -COMMIT; - diff --git a/OpenSim/Data/MySQL/Resources/025_RegionStore.sql b/OpenSim/Data/MySQL/Resources/025_RegionStore.sql deleted file mode 100644 index e8f5d70..0000000 --- a/OpenSim/Data/MySQL/Resources/025_RegionStore.sql +++ /dev/null @@ -1,46 +0,0 @@ -BEGIN; - -alter table prims change column `PositionX` `PositionX` double default NULL; -alter table prims change column `PositionY` `PositionY` double default NULL; -alter table prims change column `PositionZ` `PositionZ` double default NULL; -alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL; -alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL; -alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL; -alter table prims change column `VelocityX` `VelocityX` double default NULL; -alter table prims change column `VelocityY` `VelocityY` double default NULL; -alter table prims change column `VelocityZ` `VelocityZ` double default NULL; -alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL; -alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL; -alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL; -alter table prims change column `AccelerationX` `AccelerationX` double default NULL; -alter table prims change column `AccelerationY` `AccelerationY` double default NULL; -alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL; -alter table prims change column `RotationX` `RotationX` double default NULL; -alter table prims change column `RotationY` `RotationY` double default NULL; -alter table prims change column `RotationZ` `RotationZ` double default NULL; -alter table prims change column `RotationW` `RotationW` double default NULL; -alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL; -alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL; -alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL; -alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL; -alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL; -alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL; -alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL; -alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0'; -alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0'; -alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0'; -alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0'; -alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0'; -alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0'; -alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0'; -alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0'; - -alter table primshapes change column `ScaleX` `ScaleX` double NOT NULL default '0'; -alter table primshapes change column `ScaleY` `ScaleY` double NOT NULL default '0'; -alter table primshapes change column `ScaleZ` `ScaleZ` double NOT NULL default '0'; - -COMMIT; - diff --git a/OpenSim/Data/MySQL/Resources/026_RegionStore.sql b/OpenSim/Data/MySQL/Resources/026_RegionStore.sql deleted file mode 100644 index 91af8a8..0000000 --- a/OpenSim/Data/MySQL/Resources/026_RegionStore.sql +++ /dev/null @@ -1,41 +0,0 @@ -begin; - -alter table prims change column `PositionX` `PositionX` double default NULL; -alter table prims change column `PositionY` `PositionY` double default NULL; -alter table prims change column `PositionZ` `PositionZ` double default NULL; -alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL; -alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL; -alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL; -alter table prims change column `VelocityX` `VelocityX` double default NULL; -alter table prims change column `VelocityY` `VelocityY` double default NULL; -alter table prims change column `VelocityZ` `VelocityZ` double default NULL; -alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL; -alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL; -alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL; -alter table prims change column `AccelerationX` `AccelerationX` double default NULL; -alter table prims change column `AccelerationY` `AccelerationY` double default NULL; -alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL; -alter table prims change column `RotationX` `RotationX` double default NULL; -alter table prims change column `RotationY` `RotationY` double default NULL; -alter table prims change column `RotationZ` `RotationZ` double default NULL; -alter table prims change column `RotationW` `RotationW` double default NULL; -alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL; -alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL; -alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL; -alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL; -alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL; -alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL; -alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL; -alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0'; -alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0'; -alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0'; -alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0'; -alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0'; -alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0'; -alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0'; -alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0'; -alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0'; - -commit; diff --git a/OpenSim/Data/MySQL/Resources/027_RegionStore.sql b/OpenSim/Data/MySQL/Resources/027_RegionStore.sql deleted file mode 100644 index e1efab3..0000000 --- a/OpenSim/Data/MySQL/Resources/027_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE prims DROP COLUMN ParentID; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/028_RegionStore.sql b/OpenSim/Data/MySQL/Resources/028_RegionStore.sql deleted file mode 100644 index 078394f..0000000 --- a/OpenSim/Data/MySQL/Resources/028_RegionStore.sql +++ /dev/null @@ -1,79 +0,0 @@ -BEGIN; - -update terrain - set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) - where RegionUUID not like '%-%'; - - -update landaccesslist - set LandUUID = concat(substr(LandUUID, 1, 8), "-", substr(LandUUID, 9, 4), "-", substr(LandUUID, 13, 4), "-", substr(LandUUID, 17, 4), "-", substr(LandUUID, 21, 12)) - where LandUUID not like '%-%'; - -update landaccesslist - set AccessUUID = concat(substr(AccessUUID, 1, 8), "-", substr(AccessUUID, 9, 4), "-", substr(AccessUUID, 13, 4), "-", substr(AccessUUID, 17, 4), "-", substr(AccessUUID, 21, 12)) - where AccessUUID not like '%-%'; - - -update prims - set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) - where UUID not like '%-%'; - -update prims - set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) - where RegionUUID not like '%-%'; - -update prims - set SceneGroupID = concat(substr(SceneGroupID, 1, 8), "-", substr(SceneGroupID, 9, 4), "-", substr(SceneGroupID, 13, 4), "-", substr(SceneGroupID, 17, 4), "-", substr(SceneGroupID, 21, 12)) - where SceneGroupID not like '%-%'; - -update prims - set CreatorID = concat(substr(CreatorID, 1, 8), "-", substr(CreatorID, 9, 4), "-", substr(CreatorID, 13, 4), "-", substr(CreatorID, 17, 4), "-", substr(CreatorID, 21, 12)) - where CreatorID not like '%-%'; - -update prims - set OwnerID = concat(substr(OwnerID, 1, 8), "-", substr(OwnerID, 9, 4), "-", substr(OwnerID, 13, 4), "-", substr(OwnerID, 17, 4), "-", substr(OwnerID, 21, 12)) - where OwnerID not like '%-%'; - -update prims - set GroupID = concat(substr(GroupID, 1, 8), "-", substr(GroupID, 9, 4), "-", substr(GroupID, 13, 4), "-", substr(GroupID, 17, 4), "-", substr(GroupID, 21, 12)) - where GroupID not like '%-%'; - -update prims - set LastOwnerID = concat(substr(LastOwnerID, 1, 8), "-", substr(LastOwnerID, 9, 4), "-", substr(LastOwnerID, 13, 4), "-", substr(LastOwnerID, 17, 4), "-", substr(LastOwnerID, 21, 12)) - where LastOwnerID not like '%-%'; - - -update primshapes - set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) - where UUID not like '%-%'; - - -update land - set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) - where UUID not like '%-%'; - -update land - set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) - where RegionUUID not like '%-%'; - -update land - set OwnerUUID = concat(substr(OwnerUUID, 1, 8), "-", substr(OwnerUUID, 9, 4), "-", substr(OwnerUUID, 13, 4), "-", substr(OwnerUUID, 17, 4), "-", substr(OwnerUUID, 21, 12)) - where OwnerUUID not like '%-%'; - -update land - set GroupUUID = concat(substr(GroupUUID, 1, 8), "-", substr(GroupUUID, 9, 4), "-", substr(GroupUUID, 13, 4), "-", substr(GroupUUID, 17, 4), "-", substr(GroupUUID, 21, 12)) - where GroupUUID not like '%-%'; - -update land - set MediaTextureUUID = concat(substr(MediaTextureUUID, 1, 8), "-", substr(MediaTextureUUID, 9, 4), "-", substr(MediaTextureUUID, 13, 4), "-", substr(MediaTextureUUID, 17, 4), "-", substr(MediaTextureUUID, 21, 12)) - where MediaTextureUUID not like '%-%'; - -update land - set SnapshotUUID = concat(substr(SnapshotUUID, 1, 8), "-", substr(SnapshotUUID, 9, 4), "-", substr(SnapshotUUID, 13, 4), "-", substr(SnapshotUUID, 17, 4), "-", substr(SnapshotUUID, 21, 12)) - where SnapshotUUID not like '%-%'; - -update land - set AuthbuyerID = concat(substr(AuthbuyerID, 1, 8), "-", substr(AuthbuyerID, 9, 4), "-", substr(AuthbuyerID, 13, 4), "-", substr(AuthbuyerID, 17, 4), "-", substr(AuthbuyerID, 21, 12)) - where AuthbuyerID not like '%-%'; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/029_RegionStore.sql b/OpenSim/Data/MySQL/Resources/029_RegionStore.sql deleted file mode 100644 index b5962a2..0000000 --- a/OpenSim/Data/MySQL/Resources/029_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN PassTouches tinyint not null default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/030_RegionStore.sql b/OpenSim/Data/MySQL/Resources/030_RegionStore.sql deleted file mode 100644 index dfdcf6d..0000000 --- a/OpenSim/Data/MySQL/Resources/030_RegionStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE regionsettings ADD COLUMN loaded_creation_date varchar(20) default NULL; -ALTER TABLE regionsettings ADD COLUMN loaded_creation_time varchar(20) default NULL; -ALTER TABLE regionsettings ADD COLUMN loaded_creation_id varchar(64) default NULL; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/031_RegionStore.sql b/OpenSim/Data/MySQL/Resources/031_RegionStore.sql deleted file mode 100644 index d069296..0000000 --- a/OpenSim/Data/MySQL/Resources/031_RegionStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE regionsettings DROP COLUMN loaded_creation_date; -ALTER TABLE regionsettings DROP COLUMN loaded_creation_time; -ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT NULL default 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql deleted file mode 100644 index dca5de7..0000000 --- a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql +++ /dev/null @@ -1,3 +0,0 @@ -BEGIN; -ALTER TABLE estate_settings AUTO_INCREMENT = 100; -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations new file mode 100644 index 0000000..b9595f0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations @@ -0,0 +1,69 @@ +# ----------------- +:VERSION 1 + +BEGIN; + +CREATE TABLE `assets` ( + `id` binary(16) NOT NULL, + `name` varchar(64) NOT NULL, + `description` varchar(64) NOT NULL, + `assetType` tinyint(4) NOT NULL, + `invType` tinyint(4) NOT NULL, + `local` tinyint(1) NOT NULL, + `temporary` tinyint(1) NOT NULL, + `data` longblob NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; + +COMMIT; + +# ----------------- +:VERSION 2 + +BEGIN; + +ALTER TABLE assets change id oldid binary(16); +ALTER TABLE assets add id varchar(36) not null default ''; +UPDATE assets set id = concat(substr(hex(oldid),1,8),"-",substr(hex(oldid),9,4),"-",substr(hex(oldid),13,4),"-",substr(hex(oldid),17,4),"-",substr(hex(oldid),21,12)); +ALTER TABLE assets drop oldid; +ALTER TABLE assets add constraint primary key(id); + +COMMIT; + +# ----------------- +:VERSION 3 + +BEGIN; + +ALTER TABLE assets change id oldid varchar(36); +ALTER TABLE assets add id char(36) not null default '00000000-0000-0000-0000-000000000000'; +UPDATE assets set id = oldid; +ALTER TABLE assets drop oldid; +ALTER TABLE assets add constraint primary key(id); + +COMMIT; + +# ----------------- +:VERSION 4 + +BEGIN; + +ALTER TABLE assets drop InvType; + +COMMIT; + +# ----------------- +:VERSION 5 + +BEGIN; + +ALTER TABLE assets add create_time integer default 0; +ALTER TABLE assets add access_time integer default 0; + +COMMIT; + +# ----------------- +:VERSION 6 + +DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621' + diff --git a/OpenSim/Data/MySQL/Resources/AuthStore.migrations b/OpenSim/Data/MySQL/Resources/AuthStore.migrations new file mode 100644 index 0000000..023c786 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/AuthStore.migrations @@ -0,0 +1,39 @@ +:VERSION 1 # ------------------------------- + +begin; + +CREATE TABLE `auth` ( + `UUID` char(36) NOT NULL, + `passwordHash` char(32) NOT NULL default '', + `passwordSalt` char(32) NOT NULL default '', + `webLoginKey` varchar(255) NOT NULL default '', + PRIMARY KEY (`UUID`) +) ENGINE=InnoDB; + +CREATE TABLE `tokens` ( + `UUID` char(36) NOT NULL, + `token` varchar(255) NOT NULL, + `validity` datetime NOT NULL, + UNIQUE KEY `uuid_token` (`UUID`,`token`), + KEY `UUID` (`UUID`), + KEY `token` (`token`), + KEY `validity` (`validity`) +) ENGINE=InnoDB; + +commit; + +:VERSION 2 # ------------------------------- + +BEGIN; + +INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; + +COMMIT; + +:VERSION 3 # ------------------------------- + +BEGIN; + +ALTER TABLE `auth` ADD COLUMN `accountType` VARCHAR(32) NOT NULL DEFAULT 'UserAccount'; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/Avatar.migrations b/OpenSim/Data/MySQL/Resources/Avatar.migrations new file mode 100644 index 0000000..8d0eee6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/Avatar.migrations @@ -0,0 +1,12 @@ +:VERSION 1 + +BEGIN; + +CREATE TABLE Avatars ( + PrincipalID CHAR(36) NOT NULL, + Name VARCHAR(32) NOT NULL, + Value VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY(PrincipalID, Name), + KEY(PrincipalID)); + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations new file mode 100644 index 0000000..ce713bd --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -0,0 +1,25 @@ +:VERSION 1 # ------------------------- + +BEGIN; + +CREATE TABLE `Friends` ( + `PrincipalID` CHAR(36) NOT NULL, + `Friend` VARCHAR(255) NOT NULL, + `Flags` VARCHAR(16) NOT NULL DEFAULT 0, + `Offered` VARCHAR(32) NOT NULL DEFAULT 0, + PRIMARY KEY(`PrincipalID`, `Friend`), + KEY(`PrincipalID`) +); + +COMMIT; + +:VERSION 2 # ------------------------- + +BEGIN; + +INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; + +COMMIT; + + + diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations new file mode 100644 index 0000000..523a8ac --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations @@ -0,0 +1,89 @@ +:VERSION 1 + +CREATE TABLE `regions` ( + `uuid` varchar(36) NOT NULL, + `regionHandle` bigint(20) unsigned NOT NULL, + `regionName` varchar(32) default NULL, + `regionRecvKey` varchar(128) default NULL, + `regionSendKey` varchar(128) default NULL, + `regionSecret` varchar(128) default NULL, + `regionDataURI` varchar(255) default NULL, + `serverIP` varchar(64) default NULL, + `serverPort` int(10) unsigned default NULL, + `serverURI` varchar(255) default NULL, + `locX` int(10) unsigned default NULL, + `locY` int(10) unsigned default NULL, + `locZ` int(10) unsigned default NULL, + `eastOverrideHandle` bigint(20) unsigned default NULL, + `westOverrideHandle` bigint(20) unsigned default NULL, + `southOverrideHandle` bigint(20) unsigned default NULL, + `northOverrideHandle` bigint(20) unsigned default NULL, + `regionAssetURI` varchar(255) default NULL, + `regionAssetRecvKey` varchar(128) default NULL, + `regionAssetSendKey` varchar(128) default NULL, + `regionUserURI` varchar(255) default NULL, + `regionUserRecvKey` varchar(128) default NULL, + `regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL, + `serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL, + `owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null, + `originUUID` varchar(36), + PRIMARY KEY (`uuid`), + KEY `regionName` (`regionName`), + KEY `regionHandle` (`regionHandle`), + KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; + +:VERSION 2 + +BEGIN; + +ALTER TABLE regions add column access integer unsigned default 1; + +COMMIT; + +:VERSION 3 + +BEGIN; + +ALTER TABLE regions add column ScopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; + +create index ScopeID on regions(ScopeID); + +COMMIT; + +:VERSION 4 + +BEGIN; + +ALTER TABLE regions add column sizeX integer not null default 0; +ALTER TABLE regions add column sizeY integer not null default 0; + +COMMIT; + +:VERSION 5 + +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `flags` integer NOT NULL DEFAULT 0; +CREATE INDEX flags ON regions(flags); + +COMMIT; + +:VERSION 6 + +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `last_seen` integer NOT NULL DEFAULT 0; + +COMMIT; + +:VERSION 7 + +BEGIN; + +ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +ALTER TABLE `regions` ADD COLUMN `Token` varchar(255) NOT NULL; + +COMMIT; + + diff --git a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations new file mode 100644 index 0000000..8c5864e --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations @@ -0,0 +1,93 @@ +:VERSION 1 # ------------ +BEGIN; + +CREATE TABLE `inventoryfolders` ( + `folderID` varchar(36) NOT NULL default '', + `agentID` varchar(36) default NULL, + `parentFolderID` varchar(36) default NULL, + `folderName` varchar(64) default NULL, + `type` smallint NOT NULL default 0, + `version` int NOT NULL default 0, + PRIMARY KEY (`folderID`), + KEY `owner` (`agentID`), + KEY `parent` (`parentFolderID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `inventoryitems` ( + `inventoryID` varchar(36) NOT NULL default '', + `assetID` varchar(36) default NULL, + `assetType` int(11) default NULL, + `parentFolderID` varchar(36) default NULL, + `avatarID` varchar(36) default NULL, + `inventoryName` varchar(64) default NULL, + `inventoryDescription` varchar(128) default NULL, + `inventoryNextPermissions` int(10) unsigned default NULL, + `inventoryCurrentPermissions` int(10) unsigned default NULL, + `invType` int(11) default NULL, + `creatorID` varchar(36) default NULL, + `inventoryBasePermissions` int(10) unsigned NOT NULL default 0, + `inventoryEveryOnePermissions` int(10) unsigned NOT NULL default 0, + `salePrice` int(11) NOT NULL default 0, + `saleType` tinyint(4) NOT NULL default 0, + `creationDate` int(11) NOT NULL default 0, + `groupID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `groupOwned` tinyint(4) NOT NULL default 0, + `flags` int(11) unsigned NOT NULL default 0, + PRIMARY KEY (`inventoryID`), + KEY `owner` (`avatarID`), + KEY `folder` (`parentFolderID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; + +:VERSION 2 # ------------ + +BEGIN; + +ALTER TABLE inventoryfolders change folderID folderIDold varchar(36); +ALTER TABLE inventoryfolders change agentID agentIDold varchar(36); +ALTER TABLE inventoryfolders change parentFolderID parentFolderIDold varchar(36); +ALTER TABLE inventoryfolders add folderID char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE inventoryfolders add agentID char(36) default NULL; +ALTER TABLE inventoryfolders add parentFolderID char(36) default NULL; +UPDATE inventoryfolders set folderID = folderIDold, agentID = agentIDold, parentFolderID = parentFolderIDold; +ALTER TABLE inventoryfolders drop folderIDold; +ALTER TABLE inventoryfolders drop agentIDold; +ALTER TABLE inventoryfolders drop parentFolderIDold; +ALTER TABLE inventoryfolders add constraint primary key(folderID); +ALTER TABLE inventoryfolders add index inventoryfolders_agentid(agentID); +ALTER TABLE inventoryfolders add index inventoryfolders_parentFolderid(parentFolderID); + +ALTER TABLE inventoryitems change inventoryID inventoryIDold varchar(36); +ALTER TABLE inventoryitems change avatarID avatarIDold varchar(36); +ALTER TABLE inventoryitems change parentFolderID parentFolderIDold varchar(36); +ALTER TABLE inventoryitems add inventoryID char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE inventoryitems add avatarID char(36) default NULL; +ALTER TABLE inventoryitems add parentFolderID char(36) default NULL; +UPDATE inventoryitems set inventoryID = inventoryIDold, avatarID = avatarIDold, parentFolderID = parentFolderIDold; +ALTER TABLE inventoryitems drop inventoryIDold; +ALTER TABLE inventoryitems drop avatarIDold; +ALTER TABLE inventoryitems drop parentFolderIDold; +ALTER TABLE inventoryitems add constraint primary key(inventoryID); +ALTER TABLE inventoryitems add index inventoryitems_avatarid(avatarID); +ALTER TABLE inventoryitems add index inventoryitems_parentFolderid(parentFolderID); + +COMMIT; + +:VERSION 3 # ------------ + +BEGIN; + +alter table inventoryitems add column inventoryGroupPermissions integer unsigned not null default 0; + +COMMIT; + +:VERSION 4 # ------------ + +BEGIN; + +update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID is NULL; +update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' where creatorID = ''; +alter table inventoryitems modify column creatorID varchar(36) not NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/LogStore.migrations b/OpenSim/Data/MySQL/Resources/LogStore.migrations new file mode 100644 index 0000000..9ac26ac --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/LogStore.migrations @@ -0,0 +1,13 @@ + +:VERSION 1 + +CREATE TABLE `logs` ( + `logID` int(10) unsigned NOT NULL auto_increment, + `target` varchar(36) default NULL, + `server` varchar(64) default NULL, + `method` varchar(64) default NULL, + `arguments` varchar(255) default NULL, + `priority` int(11) default NULL, + `message` text, + PRIMARY KEY (`logID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations new file mode 100644 index 0000000..d513024 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations @@ -0,0 +1,36 @@ +:VERSION 1 # -------------------------- + +BEGIN; + +CREATE TABLE `Presence` ( + `UserID` VARCHAR(255) NOT NULL, + `RegionID` CHAR(36) NOT NULL, + `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `Online` CHAR(5) NOT NULL DEFAULT 'false', + `Login` CHAR(16) NOT NULL DEFAULT '0', + `Logout` CHAR(16) NOT NULL DEFAULT '0', + `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' +) ENGINE=InnoDB; + +COMMIT; + +:VERSION 2 # -------------------------- + +BEGIN; + +ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; +ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; +ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; + +COMMIT; + +:VERSION 3 # -------------------------- + +BEGIN; + +CREATE UNIQUE INDEX SessionID ON Presence(SessionID); +CREATE INDEX UserID ON Presence(UserID); + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations new file mode 100644 index 0000000..3dab67e --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -0,0 +1,806 @@ + +:VERSION 1 #--------------------- + +BEGIN; + +CREATE TABLE `prims` ( + `UUID` varchar(255) NOT NULL, + `RegionUUID` varchar(255) default NULL, + `ParentID` int(11) default NULL, + `CreationDate` int(11) default NULL, + `Name` varchar(255) default NULL, + `SceneGroupID` varchar(255) default NULL, + `Text` varchar(255) default NULL, + `Description` varchar(255) default NULL, + `SitName` varchar(255) default NULL, + `TouchName` varchar(255) default NULL, + `ObjectFlags` int(11) default NULL, + `CreatorID` varchar(255) default NULL, + `OwnerID` varchar(255) default NULL, + `GroupID` varchar(255) default NULL, + `LastOwnerID` varchar(255) default NULL, + `OwnerMask` int(11) default NULL, + `NextOwnerMask` int(11) default NULL, + `GroupMask` int(11) default NULL, + `EveryoneMask` int(11) default NULL, + `BaseMask` int(11) default NULL, + `PositionX` float default NULL, + `PositionY` float default NULL, + `PositionZ` float default NULL, + `GroupPositionX` float default NULL, + `GroupPositionY` float default NULL, + `GroupPositionZ` float default NULL, + `VelocityX` float default NULL, + `VelocityY` float default NULL, + `VelocityZ` float default NULL, + `AngularVelocityX` float default NULL, + `AngularVelocityY` float default NULL, + `AngularVelocityZ` float default NULL, + `AccelerationX` float default NULL, + `AccelerationY` float default NULL, + `AccelerationZ` float default NULL, + `RotationX` float default NULL, + `RotationY` float default NULL, + `RotationZ` float default NULL, + `RotationW` float default NULL, + `SitTargetOffsetX` float default NULL, + `SitTargetOffsetY` float default NULL, + `SitTargetOffsetZ` float default NULL, + `SitTargetOrientW` float default NULL, + `SitTargetOrientX` float default NULL, + `SitTargetOrientY` float default NULL, + `SitTargetOrientZ` float default NULL, + PRIMARY KEY (`UUID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE `primshapes` ( + `UUID` varchar(255) NOT NULL, + `Shape` int(11) default NULL, + `ScaleX` float default NULL, + `ScaleY` float default NULL, + `ScaleZ` float default NULL, + `PCode` int(11) default NULL, + `PathBegin` int(11) default NULL, + `PathEnd` int(11) default NULL, + `PathScaleX` int(11) default NULL, + `PathScaleY` int(11) default NULL, + `PathShearX` int(11) default NULL, + `PathShearY` int(11) default NULL, + `PathSkew` int(11) default NULL, + `PathCurve` int(11) default NULL, + `PathRadiusOffset` int(11) default NULL, + `PathRevolutions` int(11) default NULL, + `PathTaperX` int(11) default NULL, + `PathTaperY` int(11) default NULL, + `PathTwist` int(11) default NULL, + `PathTwistBegin` int(11) default NULL, + `ProfileBegin` int(11) default NULL, + `ProfileEnd` int(11) default NULL, + `ProfileCurve` int(11) default NULL, + `ProfileHollow` int(11) default NULL, + `State` int(11) default NULL, + `Texture` longblob, + `ExtraParams` longblob, + PRIMARY KEY (`UUID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE `primitems` ( + `itemID` varchar(255) NOT NULL, + `primID` varchar(255) default NULL, + `assetID` varchar(255) default NULL, + `parentFolderID` varchar(255) default NULL, + `invType` int(11) default NULL, + `assetType` int(11) default NULL, + `name` varchar(255) default NULL, + `description` varchar(255) default NULL, + `creationDate` bigint(20) default NULL, + `creatorID` varchar(255) default NULL, + `ownerID` varchar(255) default NULL, + `lastOwnerID` varchar(255) default NULL, + `groupID` varchar(255) default NULL, + `nextPermissions` int(11) default NULL, + `currentPermissions` int(11) default NULL, + `basePermissions` int(11) default NULL, + `everyonePermissions` int(11) default NULL, + `groupPermissions` int(11) default NULL, + PRIMARY KEY (`itemID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE `terrain` ( + `RegionUUID` varchar(255) default NULL, + `Revision` int(11) default NULL, + `Heightfield` longblob +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE `land` ( + `UUID` varchar(255) NOT NULL, + `RegionUUID` varchar(255) default NULL, + `LocalLandID` int(11) default NULL, + `Bitmap` longblob, + `Name` varchar(255) default NULL, + `Description` varchar(255) default NULL, + `OwnerUUID` varchar(255) default NULL, + `IsGroupOwned` int(11) default NULL, + `Area` int(11) default NULL, + `AuctionID` int(11) default NULL, + `Category` int(11) default NULL, + `ClaimDate` int(11) default NULL, + `ClaimPrice` int(11) default NULL, + `GroupUUID` varchar(255) default NULL, + `SalePrice` int(11) default NULL, + `LandStatus` int(11) default NULL, + `LandFlags` int(11) default NULL, + `LandingType` int(11) default NULL, + `MediaAutoScale` int(11) default NULL, + `MediaTextureUUID` varchar(255) default NULL, + `MediaURL` varchar(255) default NULL, + `MusicURL` varchar(255) default NULL, + `PassHours` float default NULL, + `PassPrice` int(11) default NULL, + `SnapshotUUID` varchar(255) default NULL, + `UserLocationX` float default NULL, + `UserLocationY` float default NULL, + `UserLocationZ` float default NULL, + `UserLookAtX` float default NULL, + `UserLookAtY` float default NULL, + `UserLookAtZ` float default NULL, + `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + PRIMARY KEY (`UUID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `landaccesslist` ( + `LandUUID` varchar(255) default NULL, + `AccessUUID` varchar(255) default NULL, + `Flags` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +COMMIT; + +:VERSION 2 #--------------------- + +BEGIN; + +CREATE index prims_regionuuid on prims(RegionUUID); +CREATE index primitems_primid on primitems(primID); + +COMMIT; + +:VERSION 3 #--------------------- + +BEGIN; + CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; +COMMIT; + +:VERSION 4 #--------------------- + +BEGIN; + +ALTER TABLE primitems add flags integer not null default 0; + +COMMIT; + +:VERSION 5 #--------------------- +BEGIN; + +create table regionsettings ( + regionUUID char(36) not null, + block_terraform integer not null, + block_fly integer not null, + allow_damage integer not null, + restrict_pushing integer not null, + allow_land_resell integer not null, + allow_land_join_divide integer not null, + block_show_in_search integer not null, + agent_limit integer not null, + object_bonus float not null, + maturity integer not null, + disable_scripts integer not null, + disable_collisions integer not null, + disable_physics integer not null, + terrain_texture_1 char(36) not null, + terrain_texture_2 char(36) not null, + terrain_texture_3 char(36) not null, + terrain_texture_4 char(36) not null, + elevation_1_nw float not null, + elevation_2_nw float not null, + elevation_1_ne float not null, + elevation_2_ne float not null, + elevation_1_se float not null, + elevation_2_se float not null, + elevation_1_sw float not null, + elevation_2_sw float not null, + water_height float not null, + terrain_raise_limit float not null, + terrain_lower_limit float not null, + use_estate_sun integer not null, + fixed_sun integer not null, + sun_position float not null, + covenant char(36), + primary key(regionUUID) +); + +COMMIT; + + +:VERSION 6 #--------------------- + +BEGIN; + +alter table landaccesslist ENGINE = InnoDB; +alter table migrations ENGINE = InnoDB; +alter table primitems ENGINE = InnoDB; +alter table prims ENGINE = InnoDB; +alter table primshapes ENGINE = InnoDB; +alter table regionsettings ENGINE = InnoDB; +alter table terrain ENGINE = InnoDB; + +COMMIT; + +:VERSION 7 #--------------------- + +BEGIN; + +ALTER TABLE prims change UUID UUIDold varchar(255); +ALTER TABLE prims change RegionUUID RegionUUIDold varchar(255); +ALTER TABLE prims change CreatorID CreatorIDold varchar(255); +ALTER TABLE prims change OwnerID OwnerIDold varchar(255); +ALTER TABLE prims change GroupID GroupIDold varchar(255); +ALTER TABLE prims change LastOwnerID LastOwnerIDold varchar(255); +ALTER TABLE prims add UUID char(36); +ALTER TABLE prims add RegionUUID char(36); +ALTER TABLE prims add CreatorID char(36); +ALTER TABLE prims add OwnerID char(36); +ALTER TABLE prims add GroupID char(36); +ALTER TABLE prims add LastOwnerID char(36); +UPDATE prims set UUID = UUIDold, RegionUUID = RegionUUIDold, CreatorID = CreatorIDold, OwnerID = OwnerIDold, GroupID = GroupIDold, LastOwnerID = LastOwnerIDold; +ALTER TABLE prims drop UUIDold; +ALTER TABLE prims drop RegionUUIDold; +ALTER TABLE prims drop CreatorIDold; +ALTER TABLE prims drop OwnerIDold; +ALTER TABLE prims drop GroupIDold; +ALTER TABLE prims drop LastOwnerIDold; +ALTER TABLE prims add constraint primary key(UUID); +ALTER TABLE prims add index prims_regionuuid(RegionUUID); + +COMMIT; + +:VERSION 8 #--------------------- + +BEGIN; + +ALTER TABLE primshapes change UUID UUIDold varchar(255); +ALTER TABLE primshapes add UUID char(36); +UPDATE primshapes set UUID = UUIDold; +ALTER TABLE primshapes drop UUIDold; +ALTER TABLE primshapes add constraint primary key(UUID); + +COMMIT; + +:VERSION 9 #--------------------- + +BEGIN; + +ALTER TABLE primitems change itemID itemIDold varchar(255); +ALTER TABLE primitems change primID primIDold varchar(255); +ALTER TABLE primitems change assetID assetIDold varchar(255); +ALTER TABLE primitems change parentFolderID parentFolderIDold varchar(255); +ALTER TABLE primitems change creatorID creatorIDold varchar(255); +ALTER TABLE primitems change ownerID ownerIDold varchar(255); +ALTER TABLE primitems change groupID groupIDold varchar(255); +ALTER TABLE primitems change lastOwnerID lastOwnerIDold varchar(255); +ALTER TABLE primitems add itemID char(36); +ALTER TABLE primitems add primID char(36); +ALTER TABLE primitems add assetID char(36); +ALTER TABLE primitems add parentFolderID char(36); +ALTER TABLE primitems add creatorID char(36); +ALTER TABLE primitems add ownerID char(36); +ALTER TABLE primitems add groupID char(36); +ALTER TABLE primitems add lastOwnerID char(36); +UPDATE primitems set itemID = itemIDold, primID = primIDold, assetID = assetIDold, parentFolderID = parentFolderIDold, creatorID = creatorIDold, ownerID = ownerIDold, groupID = groupIDold, lastOwnerID = lastOwnerIDold; +ALTER TABLE primitems drop itemIDold; +ALTER TABLE primitems drop primIDold; +ALTER TABLE primitems drop assetIDold; +ALTER TABLE primitems drop parentFolderIDold; +ALTER TABLE primitems drop creatorIDold; +ALTER TABLE primitems drop ownerIDold; +ALTER TABLE primitems drop groupIDold; +ALTER TABLE primitems drop lastOwnerIDold; +ALTER TABLE primitems add constraint primary key(itemID); +ALTER TABLE primitems add index primitems_primid(primID); + +COMMIT; + +:VERSION 10 #--------------------- + +# 1 "010_RegionStore.sql" +# 1 "" +# 1 "" +# 1 "010_RegionStore.sql" +BEGIN; + +DELETE FROM regionsettings; + +COMMIT; + + +:VERSION 11 #--------------------- + +BEGIN; + +ALTER TABLE prims change SceneGroupID SceneGroupIDold varchar(255); +ALTER TABLE prims add SceneGroupID char(36); +UPDATE prims set SceneGroupID = SceneGroupIDold; +ALTER TABLE prims drop SceneGroupIDold; +ALTER TABLE prims add index prims_scenegroupid(SceneGroupID); + +COMMIT; + +:VERSION 12 #--------------------- + +BEGIN; + +ALTER TABLE prims add index prims_parentid(ParentID); + +COMMIT; + +:VERSION 13 #--------------------- +begin; + +drop table regionsettings; + +CREATE TABLE `regionsettings` ( + `regionUUID` char(36) NOT NULL, + `block_terraform` int(11) NOT NULL, + `block_fly` int(11) NOT NULL, + `allow_damage` int(11) NOT NULL, + `restrict_pushing` int(11) NOT NULL, + `allow_land_resell` int(11) NOT NULL, + `allow_land_join_divide` int(11) NOT NULL, + `block_show_in_search` int(11) NOT NULL, + `agent_limit` int(11) NOT NULL, + `object_bonus` float NOT NULL, + `maturity` int(11) NOT NULL, + `disable_scripts` int(11) NOT NULL, + `disable_collisions` int(11) NOT NULL, + `disable_physics` int(11) NOT NULL, + `terrain_texture_1` char(36) NOT NULL, + `terrain_texture_2` char(36) NOT NULL, + `terrain_texture_3` char(36) NOT NULL, + `terrain_texture_4` char(36) NOT NULL, + `elevation_1_nw` float NOT NULL, + `elevation_2_nw` float NOT NULL, + `elevation_1_ne` float NOT NULL, + `elevation_2_ne` float NOT NULL, + `elevation_1_se` float NOT NULL, + `elevation_2_se` float NOT NULL, + `elevation_1_sw` float NOT NULL, + `elevation_2_sw` float NOT NULL, + `water_height` float NOT NULL, + `terrain_raise_limit` float NOT NULL, + `terrain_lower_limit` float NOT NULL, + `use_estate_sun` int(11) NOT NULL, + `fixed_sun` int(11) NOT NULL, + `sun_position` float NOT NULL, + `covenant` char(36) default NULL, + `Sandbox` tinyint(4) NOT NULL, + PRIMARY KEY (`regionUUID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_managers` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_groups` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_users` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estateban` ( + `EstateID` int(10) unsigned NOT NULL, + `bannedUUID` varchar(36) NOT NULL, + `bannedIp` varchar(16) NOT NULL, + `bannedIpHostMask` varchar(16) NOT NULL, + `bannedNameMask` varchar(64) default NULL, + KEY `estateban_EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_settings` ( + `EstateID` int(10) unsigned NOT NULL auto_increment, + `EstateName` varchar(64) default NULL, + `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, + `DenyAnonymous` tinyint(4) NOT NULL, + `ResetHomeOnTeleport` tinyint(4) NOT NULL, + `FixedSun` tinyint(4) NOT NULL, + `DenyTransacted` tinyint(4) NOT NULL, + `BlockDwell` tinyint(4) NOT NULL, + `DenyIdentified` tinyint(4) NOT NULL, + `AllowVoice` tinyint(4) NOT NULL, + `UseGlobalTime` tinyint(4) NOT NULL, + `PricePerMeter` int(11) NOT NULL, + `TaxFree` tinyint(4) NOT NULL, + `AllowDirectTeleport` tinyint(4) NOT NULL, + `RedirectGridX` int(11) NOT NULL, + `RedirectGridY` int(11) NOT NULL, + `ParentEstateID` int(10) unsigned NOT NULL, + `SunPosition` double NOT NULL, + `EstateSkipScripts` tinyint(4) NOT NULL, + `BillableFactor` float NOT NULL, + `PublicAccess` tinyint(4) NOT NULL, + PRIMARY KEY (`EstateID`) +) ENGINE=InnoDB AUTO_INCREMENT=100; + +CREATE TABLE `estate_map` ( + `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `EstateID` int(11) NOT NULL, + PRIMARY KEY (`RegionID`), + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +commit; + +:VERSION 14 #--------------------- + +begin; + +alter table estate_settings add column AbuseEmail varchar(255) not null; + +alter table estate_settings add column EstateOwner varchar(36) not null; + +commit; + + +:VERSION 15 #--------------------- + +begin; + +alter table estate_settings add column DenyMinors tinyint not null; + +commit; + +:VERSION 16 #--------------------- + +BEGIN; + +ALTER TABLE prims ADD COLUMN PayPrice integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton1 integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton2 integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton3 integer not null default 0; +ALTER TABLE prims ADD COLUMN PayButton4 integer not null default 0; +ALTER TABLE prims ADD COLUMN LoopedSound char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE prims ADD COLUMN LoopedSoundGain float not null default 0.0; +ALTER TABLE prims ADD COLUMN TextureAnimation blob; +ALTER TABLE prims ADD COLUMN OmegaX float not null default 0.0; +ALTER TABLE prims ADD COLUMN OmegaY float not null default 0.0; +ALTER TABLE prims ADD COLUMN OmegaZ float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraAtOffsetX float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraAtOffsetY float not null default 0.0; +ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float not null default 0.0; +ALTER TABLE prims ADD COLUMN ForceMouselook tinyint not null default 0; +ALTER TABLE prims ADD COLUMN ScriptAccessPin integer not null default 0; +ALTER TABLE prims ADD COLUMN AllowedDrop tinyint not null default 0; +ALTER TABLE prims ADD COLUMN DieAtEdge tinyint not null default 0; +ALTER TABLE prims ADD COLUMN SalePrice integer not null default 10; +ALTER TABLE prims ADD COLUMN SaleType tinyint not null default 0; + +COMMIT; + + +:VERSION 17 #--------------------- + +BEGIN; + +ALTER TABLE prims ADD COLUMN ColorR integer not null default 0; +ALTER TABLE prims ADD COLUMN ColorG integer not null default 0; +ALTER TABLE prims ADD COLUMN ColorB integer not null default 0; +ALTER TABLE prims ADD COLUMN ColorA integer not null default 0; +ALTER TABLE prims ADD COLUMN ParticleSystem blob; + +COMMIT; + + +:VERSION 18 #--------------------- + +begin; + +ALTER TABLE prims ADD COLUMN ClickAction tinyint NOT NULL default 0; + +commit; + +:VERSION 19 #--------------------- + +begin; + +ALTER TABLE prims ADD COLUMN Material tinyint NOT NULL default 3; + +commit; + + +:VERSION 20 #--------------------- + +begin; + +ALTER TABLE land ADD COLUMN OtherCleanTime integer NOT NULL default 0; +ALTER TABLE land ADD COLUMN Dwell integer NOT NULL default 0; + +commit; + +:VERSION 21 #--------------------- + +begin; + +ALTER TABLE regionsettings ADD COLUMN sunvectorx double NOT NULL default 0; +ALTER TABLE regionsettings ADD COLUMN sunvectory double NOT NULL default 0; +ALTER TABLE regionsettings ADD COLUMN sunvectorz double NOT NULL default 0; + +commit; + + +:VERSION 22 #--------------------- + +BEGIN; + +ALTER TABLE prims ADD COLUMN CollisionSound char(36) not null default '00000000-0000-0000-0000-000000000000'; +ALTER TABLE prims ADD COLUMN CollisionSoundVolume float not null default 0.0; + +COMMIT; + +:VERSION 23 #--------------------- + +BEGIN; + +ALTER TABLE prims ADD COLUMN LinkNumber integer not null default 0; + +COMMIT; + +:VERSION 24 #--------------------- + +BEGIN; + +alter table regionsettings change column `object_bonus` `object_bonus` double NOT NULL; +alter table regionsettings change column `elevation_1_nw` `elevation_1_nw` double NOT NULL; +alter table regionsettings change column `elevation_2_nw` `elevation_2_nw` double NOT NULL; +alter table regionsettings change column `elevation_1_ne` `elevation_1_ne` double NOT NULL; +alter table regionsettings change column `elevation_2_ne` `elevation_2_ne` double NOT NULL; +alter table regionsettings change column `elevation_1_se` `elevation_1_se` double NOT NULL; +alter table regionsettings change column `elevation_2_se` `elevation_2_se` double NOT NULL; +alter table regionsettings change column `elevation_1_sw` `elevation_1_sw` double NOT NULL; +alter table regionsettings change column `elevation_2_sw` `elevation_2_sw` double NOT NULL; +alter table regionsettings change column `water_height` `water_height` double NOT NULL; +alter table regionsettings change column `terrain_raise_limit` `terrain_raise_limit` double NOT NULL; +alter table regionsettings change column `terrain_lower_limit` `terrain_lower_limit` double NOT NULL; +alter table regionsettings change column `sun_position` `sun_position` double NOT NULL; + +COMMIT; + + +:VERSION 25 #--------------------- + +BEGIN; + +alter table prims change column `PositionX` `PositionX` double default NULL; +alter table prims change column `PositionY` `PositionY` double default NULL; +alter table prims change column `PositionZ` `PositionZ` double default NULL; +alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL; +alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL; +alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL; +alter table prims change column `VelocityX` `VelocityX` double default NULL; +alter table prims change column `VelocityY` `VelocityY` double default NULL; +alter table prims change column `VelocityZ` `VelocityZ` double default NULL; +alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL; +alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL; +alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL; +alter table prims change column `AccelerationX` `AccelerationX` double default NULL; +alter table prims change column `AccelerationY` `AccelerationY` double default NULL; +alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL; +alter table prims change column `RotationX` `RotationX` double default NULL; +alter table prims change column `RotationY` `RotationY` double default NULL; +alter table prims change column `RotationZ` `RotationZ` double default NULL; +alter table prims change column `RotationW` `RotationW` double default NULL; +alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL; +alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL; +alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL; +alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL; +alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL; +alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL; +alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL; +alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0'; +alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0'; +alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0'; +alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0'; +alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0'; + +alter table primshapes change column `ScaleX` `ScaleX` double NOT NULL default '0'; +alter table primshapes change column `ScaleY` `ScaleY` double NOT NULL default '0'; +alter table primshapes change column `ScaleZ` `ScaleZ` double NOT NULL default '0'; + +COMMIT; + +:VERSION 26 #--------------------- + +begin; + +alter table prims change column `PositionX` `PositionX` double default NULL; +alter table prims change column `PositionY` `PositionY` double default NULL; +alter table prims change column `PositionZ` `PositionZ` double default NULL; +alter table prims change column `GroupPositionX` `GroupPositionX` double default NULL; +alter table prims change column `GroupPositionY` `GroupPositionY` double default NULL; +alter table prims change column `GroupPositionZ` `GroupPositionZ` double default NULL; +alter table prims change column `VelocityX` `VelocityX` double default NULL; +alter table prims change column `VelocityY` `VelocityY` double default NULL; +alter table prims change column `VelocityZ` `VelocityZ` double default NULL; +alter table prims change column `AngularVelocityX` `AngularVelocityX` double default NULL; +alter table prims change column `AngularVelocityY` `AngularVelocityY` double default NULL; +alter table prims change column `AngularVelocityZ` `AngularVelocityZ` double default NULL; +alter table prims change column `AccelerationX` `AccelerationX` double default NULL; +alter table prims change column `AccelerationY` `AccelerationY` double default NULL; +alter table prims change column `AccelerationZ` `AccelerationZ` double default NULL; +alter table prims change column `RotationX` `RotationX` double default NULL; +alter table prims change column `RotationY` `RotationY` double default NULL; +alter table prims change column `RotationZ` `RotationZ` double default NULL; +alter table prims change column `RotationW` `RotationW` double default NULL; +alter table prims change column `SitTargetOffsetX` `SitTargetOffsetX` double default NULL; +alter table prims change column `SitTargetOffsetY` `SitTargetOffsetY` double default NULL; +alter table prims change column `SitTargetOffsetZ` `SitTargetOffsetZ` double default NULL; +alter table prims change column `SitTargetOrientW` `SitTargetOrientW` double default NULL; +alter table prims change column `SitTargetOrientX` `SitTargetOrientX` double default NULL; +alter table prims change column `SitTargetOrientY` `SitTargetOrientY` double default NULL; +alter table prims change column `SitTargetOrientZ` `SitTargetOrientZ` double default NULL; +alter table prims change column `LoopedSoundGain` `LoopedSoundGain` double NOT NULL default '0'; +alter table prims change column `OmegaX` `OmegaX` double NOT NULL default '0'; +alter table prims change column `OmegaY` `OmegaY` double NOT NULL default '0'; +alter table prims change column `OmegaZ` `OmegaZ` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetX` `CameraEyeOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetY` `CameraEyeOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraEyeOffsetZ` `CameraEyeOffsetZ` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetX` `CameraAtOffsetX` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetY` `CameraAtOffsetY` double NOT NULL default '0'; +alter table prims change column `CameraAtOffsetZ` `CameraAtOffsetZ` double NOT NULL default '0'; +alter table prims change column `CollisionSoundVolume` `CollisionSoundVolume` double NOT NULL default '0'; + +commit; + +:VERSION 27 #--------------------- + +BEGIN; + +ALTER TABLE prims DROP COLUMN ParentID; + +COMMIT; + +:VERSION 28 #--------------------- + +BEGIN; + +update terrain + set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) + where RegionUUID not like '%-%'; + + +update landaccesslist + set LandUUID = concat(substr(LandUUID, 1, 8), "-", substr(LandUUID, 9, 4), "-", substr(LandUUID, 13, 4), "-", substr(LandUUID, 17, 4), "-", substr(LandUUID, 21, 12)) + where LandUUID not like '%-%'; + +update landaccesslist + set AccessUUID = concat(substr(AccessUUID, 1, 8), "-", substr(AccessUUID, 9, 4), "-", substr(AccessUUID, 13, 4), "-", substr(AccessUUID, 17, 4), "-", substr(AccessUUID, 21, 12)) + where AccessUUID not like '%-%'; + + +update prims + set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) + where UUID not like '%-%'; + +update prims + set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) + where RegionUUID not like '%-%'; + +update prims + set SceneGroupID = concat(substr(SceneGroupID, 1, 8), "-", substr(SceneGroupID, 9, 4), "-", substr(SceneGroupID, 13, 4), "-", substr(SceneGroupID, 17, 4), "-", substr(SceneGroupID, 21, 12)) + where SceneGroupID not like '%-%'; + +update prims + set CreatorID = concat(substr(CreatorID, 1, 8), "-", substr(CreatorID, 9, 4), "-", substr(CreatorID, 13, 4), "-", substr(CreatorID, 17, 4), "-", substr(CreatorID, 21, 12)) + where CreatorID not like '%-%'; + +update prims + set OwnerID = concat(substr(OwnerID, 1, 8), "-", substr(OwnerID, 9, 4), "-", substr(OwnerID, 13, 4), "-", substr(OwnerID, 17, 4), "-", substr(OwnerID, 21, 12)) + where OwnerID not like '%-%'; + +update prims + set GroupID = concat(substr(GroupID, 1, 8), "-", substr(GroupID, 9, 4), "-", substr(GroupID, 13, 4), "-", substr(GroupID, 17, 4), "-", substr(GroupID, 21, 12)) + where GroupID not like '%-%'; + +update prims + set LastOwnerID = concat(substr(LastOwnerID, 1, 8), "-", substr(LastOwnerID, 9, 4), "-", substr(LastOwnerID, 13, 4), "-", substr(LastOwnerID, 17, 4), "-", substr(LastOwnerID, 21, 12)) + where LastOwnerID not like '%-%'; + + +update primshapes + set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) + where UUID not like '%-%'; + + +update land + set UUID = concat(substr(UUID, 1, 8), "-", substr(UUID, 9, 4), "-", substr(UUID, 13, 4), "-", substr(UUID, 17, 4), "-", substr(UUID, 21, 12)) + where UUID not like '%-%'; + +update land + set RegionUUID = concat(substr(RegionUUID, 1, 8), "-", substr(RegionUUID, 9, 4), "-", substr(RegionUUID, 13, 4), "-", substr(RegionUUID, 17, 4), "-", substr(RegionUUID, 21, 12)) + where RegionUUID not like '%-%'; + +update land + set OwnerUUID = concat(substr(OwnerUUID, 1, 8), "-", substr(OwnerUUID, 9, 4), "-", substr(OwnerUUID, 13, 4), "-", substr(OwnerUUID, 17, 4), "-", substr(OwnerUUID, 21, 12)) + where OwnerUUID not like '%-%'; + +update land + set GroupUUID = concat(substr(GroupUUID, 1, 8), "-", substr(GroupUUID, 9, 4), "-", substr(GroupUUID, 13, 4), "-", substr(GroupUUID, 17, 4), "-", substr(GroupUUID, 21, 12)) + where GroupUUID not like '%-%'; + +update land + set MediaTextureUUID = concat(substr(MediaTextureUUID, 1, 8), "-", substr(MediaTextureUUID, 9, 4), "-", substr(MediaTextureUUID, 13, 4), "-", substr(MediaTextureUUID, 17, 4), "-", substr(MediaTextureUUID, 21, 12)) + where MediaTextureUUID not like '%-%'; + +update land + set SnapshotUUID = concat(substr(SnapshotUUID, 1, 8), "-", substr(SnapshotUUID, 9, 4), "-", substr(SnapshotUUID, 13, 4), "-", substr(SnapshotUUID, 17, 4), "-", substr(SnapshotUUID, 21, 12)) + where SnapshotUUID not like '%-%'; + +update land + set AuthbuyerID = concat(substr(AuthbuyerID, 1, 8), "-", substr(AuthbuyerID, 9, 4), "-", substr(AuthbuyerID, 13, 4), "-", substr(AuthbuyerID, 17, 4), "-", substr(AuthbuyerID, 21, 12)) + where AuthbuyerID not like '%-%'; + +COMMIT; + +:VERSION 29 #--------------------- + +BEGIN; + +ALTER TABLE prims ADD COLUMN PassTouches tinyint not null default 0; + +COMMIT; + +:VERSION 30 #--------------------- + +BEGIN; + +ALTER TABLE regionsettings ADD COLUMN loaded_creation_date varchar(20) default NULL; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_time varchar(20) default NULL; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_id varchar(64) default NULL; + +COMMIT; + +:VERSION 31 #--------------------- + +BEGIN; + +ALTER TABLE regionsettings DROP COLUMN loaded_creation_date; +ALTER TABLE regionsettings DROP COLUMN loaded_creation_time; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT NULL default 0; + +COMMIT; + +:VERSION 32 #--------------------- + +BEGIN; +ALTER TABLE estate_settings AUTO_INCREMENT = 100; +COMMIT; + + + + diff --git a/OpenSim/Data/MySQL/Resources/UserAccount.migrations b/OpenSim/Data/MySQL/Resources/UserAccount.migrations new file mode 100644 index 0000000..84011e6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UserAccount.migrations @@ -0,0 +1,47 @@ +:VERSION 1 # ------------------------- + +BEGIN; + +CREATE TABLE `UserAccounts` ( + `PrincipalID` CHAR(36) NOT NULL, + `ScopeID` CHAR(36) NOT NULL, + `FirstName` VARCHAR(64) NOT NULL, + `LastName` VARCHAR(64) NOT NULL, + `Email` VARCHAR(64), + `ServiceURLs` TEXT, + `Created` INT(11) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; + +:VERSION 2 # ------------------------- + +BEGIN; + +INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; + +COMMIT; + +:VERSION 3 # ------------------------- + +BEGIN; + +CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); +CREATE INDEX Email ON UserAccounts(Email); +CREATE INDEX FirstName ON UserAccounts(FirstName); +CREATE INDEX LastName ON UserAccounts(LastName); +CREATE INDEX Name ON UserAccounts(FirstName,LastName); + +COMMIT; + +:VERSION 4 # ------------------------- + +BEGIN; + +ALTER TABLE UserAccounts ADD COLUMN UserLevel integer NOT NULL DEFAULT 0; +ALTER TABLE UserAccounts ADD COLUMN UserFlags integer NOT NULL DEFAULT 0; +ALTER TABLE UserAccounts ADD COLUMN UserTitle varchar(64) NOT NULL DEFAULT ''; + +COMMIT; + + diff --git a/OpenSim/Data/MySQL/Resources/UserStore.migrations b/OpenSim/Data/MySQL/Resources/UserStore.migrations new file mode 100644 index 0000000..f054611 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UserStore.migrations @@ -0,0 +1,168 @@ +:VERSION 1 # ----------------------------- + +BEGIN; + +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for agents +-- ---------------------------- +CREATE TABLE `agents` ( + `UUID` varchar(36) NOT NULL, + `sessionID` varchar(36) NOT NULL, + `secureSessionID` varchar(36) NOT NULL, + `agentIP` varchar(16) NOT NULL, + `agentPort` int(11) NOT NULL, + `agentOnline` tinyint(4) NOT NULL, + `loginTime` int(11) NOT NULL, + `logoutTime` int(11) NOT NULL, + `currentRegion` varchar(36) NOT NULL, + `currentHandle` bigint(20) unsigned NOT NULL, + `currentPos` varchar(64) NOT NULL, + PRIMARY KEY (`UUID`), + UNIQUE KEY `session` (`sessionID`), + UNIQUE KEY `ssession` (`secureSessionID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Create schema avatar_appearance +-- + +CREATE TABLE `avatarappearance` ( + Owner char(36) NOT NULL, + Serial int(10) unsigned NOT NULL, + Visual_Params blob NOT NULL, + Texture blob NOT NULL, + Avatar_Height float NOT NULL, + Body_Item char(36) NOT NULL, + Body_Asset char(36) NOT NULL, + Skin_Item char(36) NOT NULL, + Skin_Asset char(36) NOT NULL, + Hair_Item char(36) NOT NULL, + Hair_Asset char(36) NOT NULL, + Eyes_Item char(36) NOT NULL, + Eyes_Asset char(36) NOT NULL, + Shirt_Item char(36) NOT NULL, + Shirt_Asset char(36) NOT NULL, + Pants_Item char(36) NOT NULL, + Pants_Asset char(36) NOT NULL, + Shoes_Item char(36) NOT NULL, + Shoes_Asset char(36) NOT NULL, + Socks_Item char(36) NOT NULL, + Socks_Asset char(36) NOT NULL, + Jacket_Item char(36) NOT NULL, + Jacket_Asset char(36) NOT NULL, + Gloves_Item char(36) NOT NULL, + Gloves_Asset char(36) NOT NULL, + Undershirt_Item char(36) NOT NULL, + Undershirt_Asset char(36) NOT NULL, + Underpants_Item char(36) NOT NULL, + Underpants_Asset char(36) NOT NULL, + Skirt_Item char(36) NOT NULL, + Skirt_Asset char(36) NOT NULL, + PRIMARY KEY (`Owner`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +CREATE TABLE `userfriends` ( + `ownerID` VARCHAR(37) NOT NULL, + `friendID` VARCHAR(37) NOT NULL, + `friendPerms` INT NOT NULL, + `datetimestamp` INT NOT NULL, + UNIQUE KEY (`ownerID`, `friendID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +CREATE TABLE `users` ( + `UUID` varchar(36) NOT NULL default '', + `username` varchar(32) NOT NULL, + `lastname` varchar(32) NOT NULL, + `passwordHash` varchar(32) NOT NULL, + `passwordSalt` varchar(32) NOT NULL, + `homeRegion` bigint(20) unsigned default NULL, + `homeLocationX` float default NULL, + `homeLocationY` float default NULL, + `homeLocationZ` float default NULL, + `homeLookAtX` float default NULL, + `homeLookAtY` float default NULL, + `homeLookAtZ` float default NULL, + `created` int(11) NOT NULL, + `lastLogin` int(11) NOT NULL, + `userInventoryURI` varchar(255) default NULL, + `userAssetURI` varchar(255) default NULL, + `profileCanDoMask` int(10) unsigned default NULL, + `profileWantDoMask` int(10) unsigned default NULL, + `profileAboutText` text, + `profileFirstText` text, + `profileImage` varchar(36) default NULL, + `profileFirstImage` varchar(36) default NULL, + `webLoginKey` varchar(36) default NULL, + PRIMARY KEY (`UUID`), + UNIQUE KEY `usernames` (`username`,`lastname`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records +-- ---------------------------- +COMMIT; + +:VERSION 2 # ----------------------------- + +BEGIN; + +ALTER TABLE users add homeRegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; + +:VERSION 3 # ----------------------------- + +BEGIN; + +ALTER TABLE users add userFlags integer NOT NULL default 0; +ALTER TABLE users add godLevel integer NOT NULL default 0; + +COMMIT; + +:VERSION 4 # ----------------------------- + +BEGIN; + +ALTER TABLE users add customType varchar(32) not null default ''; +ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; + +:VERSION 5 # ----------------------------- + +BEGIN; + +CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=InnoDB; + +COMMIT; + +:VERSION 6 # ----------------------------- + +BEGIN; + +ALTER TABLE agents add currentLookAt varchar(36) not null default ''; + +COMMIT; + +:VERSION 7 # ----------------------------- + +BEGIN; + +ALTER TABLE users add email varchar(250); + +COMMIT; + +:VERSION 8 # ----------------------------- + +BEGIN; + +ALTER TABLE users add scopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; + -- cgit v1.1 From 8a0c5d14d45571c3e7529fdacea6f0483af482e5 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Tue, 18 May 2010 14:28:12 +0300 Subject: All (?) MySQL stores fixed to use DBGuid.FromDB() This was needed if we want to update to the latest MySQL connector dll. It automatically converts CHAR(36) to Guids, so getting them as strings no longer works. By using DBGuid.FromDB(), we unlink from any particular storage format of GUIDs, could even make them BINARY(16) if we like. Actually not all MySql units are touched, but the remaining ones don't seem to be affected (they don't read GUIDs from DB) --- OpenSim/Data/MySQL/MySQLEstateData.cs | 24 +++----- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 11 ++-- OpenSim/Data/MySQL/MySQLInventoryData.cs | 33 ++++------- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 82 +++++++++++++------------- OpenSim/Data/MySQL/MySQLRegionData.cs | 10 ++-- 5 files changed, 68 insertions(+), 92 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 08e2144..9158f7a 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -34,6 +34,7 @@ using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Data; namespace OpenSim.Data.MySQL { @@ -156,20 +157,13 @@ namespace OpenSim.Data.MySQL foreach (string name in FieldList) { - if (m_FieldMap[name].GetValue(es) is bool) + if (m_FieldMap[name].FieldType == typeof(bool)) { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); + m_FieldMap[name].SetValue(es, Convert.ToInt32(r[name]) != 0); } - else if (m_FieldMap[name].GetValue(es) is UUID) + else if (m_FieldMap[name].FieldType == typeof(UUID)) { - UUID uuid = UUID.Zero; - - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); + m_FieldMap[name].SetValue(es, DBGuid.FromDB(r[name])); } else { @@ -385,11 +379,7 @@ namespace OpenSim.Data.MySQL while (r.Read()) { // EstateBan eb = new EstateBan(); - - UUID uuid = new UUID(); - UUID.TryParse(r["uuid"].ToString(), out uuid); - - uuids.Add(uuid); + uuids.Add(DBGuid.FromDB(r["uuid"])); } } } @@ -490,7 +480,7 @@ namespace OpenSim.Data.MySQL using (IDataReader reader = cmd.ExecuteReader()) { while(reader.Read()) - result.Add(new UUID(reader["RegionID"].ToString())); + result.Add(DBGuid.FromDB(reader["RegionID"])); reader.Close(); } } diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 1253e0b..6cbb2ee 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -148,19 +148,16 @@ namespace OpenSim.Data.MySQL foreach (string name in m_Fields.Keys) { - if (m_Fields[name].GetValue(row) is bool) + if (m_Fields[name].FieldType == typeof(bool)) { int v = Convert.ToInt32(reader[name]); m_Fields[name].SetValue(row, v != 0 ? true : false); } - else if (m_Fields[name].GetValue(row) is UUID) + else if (m_Fields[name].FieldType == typeof(UUID)) { - UUID uuid = UUID.Zero; - - UUID.TryParse(reader[name].ToString(), out uuid); - m_Fields[name].SetValue(row, uuid); + m_Fields[name].SetValue(row, DBGuid.FromDB(reader[name])); } - else if (m_Fields[name].GetValue(row) is int) + else if (m_Fields[name].FieldType == typeof(int)) { int v = Convert.ToInt32(reader[name]); m_Fields[name].SetValue(row, v); diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index e0e9b9c..8fbe7a8 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -32,6 +32,7 @@ using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Data; namespace OpenSim.Data.MySQL { @@ -285,31 +286,23 @@ namespace OpenSim.Data.MySQL InventoryItemBase item = new InventoryItemBase(); // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. - if (reader["creatorID"] == null) - { - item.CreatorId = UUID.Zero.ToString(); - } - else - { - item.CreatorId = (string)reader["creatorID"]; - } + // ( DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero ) + item.CreatorId = DBGuid.FromDB(reader["creatorID"]).ToString(); // Be a bit safer in parsing these because the // database doesn't enforce them to be not null, and // the inventory still works if these are weird in the // db - UUID Owner = UUID.Zero; - UUID GroupID = UUID.Zero; - UUID.TryParse((string)reader["avatarID"], out Owner); - UUID.TryParse((string)reader["groupID"], out GroupID); - item.Owner = Owner; - item.GroupID = GroupID; + + // (Empty is Ok, but "weird" will throw!) + item.Owner = DBGuid.FromDB(reader["avatarID"]); + item.GroupID = DBGuid.FromDB(reader["groupID"]); // Rest of the parsing. If these UUID's fail, we're dead anyway - item.ID = new UUID((string) reader["inventoryID"]); - item.AssetID = new UUID((string) reader["assetID"]); + item.ID = DBGuid.FromDB(reader["inventoryID"]); + item.AssetID = DBGuid.FromDB(reader["assetID"]); item.AssetType = (int) reader["assetType"]; - item.Folder = new UUID((string) reader["parentFolderID"]); + item.Folder = DBGuid.FromDB(reader["parentFolderID"]); item.Name = (string)(reader["inventoryName"] ?? String.Empty); item.Description = (string)(reader["inventoryDescription"] ?? String.Empty); item.NextPermissions = (uint) reader["inventoryNextPermissions"]; @@ -382,9 +375,9 @@ namespace OpenSim.Data.MySQL try { InventoryFolderBase folder = new InventoryFolderBase(); - folder.Owner = new UUID((string) reader["agentID"]); - folder.ParentID = new UUID((string) reader["parentFolderID"]); - folder.ID = new UUID((string) reader["folderID"]); + folder.Owner = DBGuid.FromDB(reader["agentID"]); + folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]); + folder.ID = DBGuid.FromDB(reader["folderID"]); folder.Name = (string) reader["folderName"]; folder.Type = (short) reader["type"]; folder.Version = (ushort) ((int) reader["version"]); diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 07371e7..bfeae12 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -38,6 +38,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Data; namespace OpenSim.Data.MySQL { @@ -269,7 +270,7 @@ namespace OpenSim.Data.MySQL using (IDataReader reader = ExecuteReader(cmd)) { while (reader.Read()) - uuids.Add(new UUID(reader["UUID"].ToString())); + uuids.Add(DBGuid.FromDB(reader["UUID"].ToString())); } // delete the main prims @@ -422,7 +423,7 @@ namespace OpenSim.Data.MySQL else prim.Shape = BuildShape(reader); - UUID parentID = new UUID(reader["SceneGroupID"].ToString()); + UUID parentID = DBGuid.FromDB(reader["SceneGroupID"].ToString()); if (parentID != prim.UUID) prim.ParentUUID = parentID; @@ -500,7 +501,7 @@ namespace OpenSim.Data.MySQL { if (!(itemReader["primID"] is DBNull)) { - UUID primID = new UUID(itemReader["primID"].ToString()); + UUID primID = DBGuid.FromDB(itemReader["primID"].ToString()); if (prims.ContainsKey(primID)) primsWithInventory.Add(prims[primID]); } @@ -738,7 +739,7 @@ namespace OpenSim.Data.MySQL } else { - UUID.TryParse(result["region_id"].ToString(), out nWP.regionID); + nWP.regionID = DBGuid.FromDB(result["region_id"]); nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); @@ -1055,7 +1056,14 @@ namespace OpenSim.Data.MySQL private SceneObjectPart BuildPrim(IDataReader row) { SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new UUID((string)row["UUID"]); + + // depending on the MySQL connector version, CHAR(36) may be already converted to Guid! + prim.UUID = DBGuid.FromDB(row["UUID"]); + prim.CreatorID = DBGuid.FromDB(row["CreatorID"]); + prim.OwnerID = DBGuid.FromDB(row["OwnerID"]); + prim.GroupID = DBGuid.FromDB(row["GroupID"]); + prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]); + // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. prim.CreationDate = (int)row["CreationDate"]; @@ -1074,15 +1082,12 @@ namespace OpenSim.Data.MySQL prim.TouchName = (string)row["TouchName"]; // Permissions prim.ObjectFlags = (uint)(int)row["ObjectFlags"]; - prim.CreatorID = new UUID((string)row["CreatorID"]); - prim.OwnerID = new UUID((string)row["OwnerID"]); - prim.GroupID = new UUID((string)row["GroupID"]); - prim.LastOwnerID = new UUID((string)row["LastOwnerID"]); prim.OwnerMask = (uint)(int)row["OwnerMask"]; prim.NextOwnerMask = (uint)(int)row["NextOwnerMask"]; prim.GroupMask = (uint)(int)row["GroupMask"]; prim.EveryoneMask = (uint)(int)row["EveryoneMask"]; prim.BaseMask = (uint)(int)row["BaseMask"]; + // Vectors prim.OffsetPosition = new Vector3( (float)(double)row["PositionX"], @@ -1134,7 +1139,7 @@ namespace OpenSim.Data.MySQL prim.PayPrice[3] = (int)row["PayButton3"]; prim.PayPrice[4] = (int)row["PayButton4"]; - prim.Sound = new UUID(row["LoopedSound"].ToString()); + prim.Sound = DBGuid.FromDB(row["LoopedSound"].ToString()); prim.SoundGain = (float)(double)row["LoopedSoundGain"]; prim.SoundFlags = 1; // If it's persisted at all, it's looped @@ -1161,16 +1166,10 @@ namespace OpenSim.Data.MySQL (float)(double)row["CameraAtOffsetZ"] )); - if ((sbyte)row["ForceMouselook"] != 0) - prim.SetForceMouselook(true); - + prim.SetForceMouselook((sbyte)row["ForceMouselook"] != 0); prim.ScriptAccessPin = (int)row["ScriptAccessPin"]; - - if ((sbyte)row["AllowedDrop"] != 0) - prim.AllowedDrop = true; - - if ((sbyte)row["DieAtEdge"] != 0) - prim.DIE_AT_EDGE = true; + prim.AllowedDrop = ((sbyte)row["AllowedDrop"] != 0); + prim.DIE_AT_EDGE = ((sbyte)row["DieAtEdge"] != 0); prim.SalePrice = (int)row["SalePrice"]; prim.ObjectSaleType = unchecked((byte)(sbyte)row["SaleType"]); @@ -1180,11 +1179,10 @@ namespace OpenSim.Data.MySQL if (!(row["ClickAction"] is DBNull)) prim.ClickAction = unchecked((byte)(sbyte)row["ClickAction"]); - prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); + prim.CollisionSound = DBGuid.FromDB(row["CollisionSound"]); prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; - if ((sbyte)row["PassTouches"] != 0) - prim.PassTouches = true; + prim.PassTouches = ((sbyte)row["PassTouches"] != 0); prim.LinkNum = (int)row["LinkNumber"]; return prim; @@ -1200,10 +1198,10 @@ namespace OpenSim.Data.MySQL { TaskInventoryItem taskItem = new TaskInventoryItem(); - taskItem.ItemID = new UUID((String)row["itemID"]); - taskItem.ParentPartID = new UUID((String)row["primID"]); - taskItem.AssetID = new UUID((String)row["assetID"]); - taskItem.ParentID = new UUID((String)row["parentFolderID"]); + taskItem.ItemID = DBGuid.FromDB(row["itemID"]); + taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); + taskItem.AssetID = DBGuid.FromDB(row["assetID"]); + taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); taskItem.InvType = Convert.ToInt32(row["invType"]); taskItem.Type = Convert.ToInt32(row["assetType"]); @@ -1211,10 +1209,10 @@ namespace OpenSim.Data.MySQL taskItem.Name = (String)row["name"]; taskItem.Description = (String)row["description"]; taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorID = new UUID((String)row["creatorID"]); - taskItem.OwnerID = new UUID((String)row["ownerID"]); - taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]); - taskItem.GroupID = new UUID((String)row["groupID"]); + taskItem.CreatorID = DBGuid.FromDB(row["creatorID"]); + taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); + taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); + taskItem.GroupID = DBGuid.FromDB(row["groupID"]); taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); @@ -1230,7 +1228,7 @@ namespace OpenSim.Data.MySQL { RegionSettings newSettings = new RegionSettings(); - newSettings.RegionUUID = new UUID((string) row["regionUUID"]); + newSettings.RegionUUID = DBGuid.FromDB(row["regionUUID"]); newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); @@ -1244,10 +1242,10 @@ namespace OpenSim.Data.MySQL newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); - newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]); - newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]); - newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]); - newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]); + newSettings.TerrainTexture1 = DBGuid.FromDB(row["terrain_texture_1"]); + newSettings.TerrainTexture2 = DBGuid.FromDB(row["terrain_texture_2"]); + newSettings.TerrainTexture3 = DBGuid.FromDB(row["terrain_texture_3"]); + newSettings.TerrainTexture4 = DBGuid.FromDB(row["terrain_texture_4"]); newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); @@ -1268,7 +1266,7 @@ namespace OpenSim.Data.MySQL ); newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); - newSettings.Covenant = new UUID((String) row["covenant"]); + newSettings.Covenant = DBGuid.FromDB(row["covenant"]); newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); @@ -1277,7 +1275,7 @@ namespace OpenSim.Data.MySQL else newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; - newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); + newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); return newSettings; } @@ -1291,7 +1289,7 @@ namespace OpenSim.Data.MySQL { LandData newData = new LandData(); - newData.GlobalID = new UUID((String) row["UUID"]); + newData.GlobalID = DBGuid.FromDB(row["UUID"]); newData.LocalID = Convert.ToInt32(row["LocalLandID"]); // Bitmap is a byte[512] @@ -1299,7 +1297,7 @@ namespace OpenSim.Data.MySQL newData.Name = (String) row["Name"]; newData.Description = (String) row["Description"]; - newData.OwnerID = new UUID((String)row["OwnerUUID"]); + newData.OwnerID = DBGuid.FromDB(row["OwnerUUID"]); newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); newData.Area = Convert.ToInt32(row["Area"]); newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented @@ -1307,14 +1305,14 @@ namespace OpenSim.Data.MySQL //Enum libsecondlife.Parcel.ParcelCategory newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.GroupID = new UUID((String) row["GroupUUID"]); + newData.GroupID = DBGuid.FromDB(row["GroupUUID"]); newData.SalePrice = Convert.ToInt32(row["SalePrice"]); newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus newData.Flags = Convert.ToUInt32(row["LandFlags"]); newData.LandingType = Convert.ToByte(row["LandingType"]); newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.MediaID = new UUID((String) row["MediaTextureUUID"]); + newData.MediaID = DBGuid.FromDB(row["MediaTextureUUID"]); newData.MediaURL = (String) row["MediaURL"]; newData.MusicURL = (String) row["MusicURL"]; newData.PassHours = Convert.ToSingle(row["PassHours"]); @@ -1358,7 +1356,7 @@ namespace OpenSim.Data.MySQL private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new UUID((string) row["AccessUUID"]); + entry.AgentID = DBGuid.FromDB(row["AccessUUID"]); entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); entry.Time = new DateTime(); return entry; diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index aa9a104..c7bddac 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Data; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Data; using MySql.Data.MySqlClient; namespace OpenSim.Data.MySQL @@ -143,12 +144,9 @@ namespace OpenSim.Data.MySQL RegionData ret = new RegionData(); ret.Data = new Dictionary(); - UUID regionID; - UUID.TryParse(result["uuid"].ToString(), out regionID); - ret.RegionID = regionID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; + ret.RegionID = DBGuid.FromDB(result["uuid"]); + ret.ScopeID = DBGuid.FromDB(result["ScopeID"]); + ret.RegionName = result["regionName"].ToString(); ret.posX = Convert.ToInt32(result["locX"]); ret.posY = Convert.ToInt32(result["locY"]); -- cgit v1.1 From deae0301456a169540aafc4ff1a574e1304e327d Mon Sep 17 00:00:00 2001 From: AlexRa Date: Wed, 19 May 2010 02:28:19 +0300 Subject: Some more corrections after MySQL connector update --- OpenSim/Data/MySQL/MySQLAssetData.cs | 3 ++- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 13f5fa2..ec18c28 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -33,6 +33,7 @@ using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Data; namespace OpenSim.Data.MySQL { @@ -320,7 +321,7 @@ namespace OpenSim.Data.MySQL metadata.Type = (sbyte)dbReader["assetType"]; metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); - metadata.FullID = new UUID((string)dbReader["id"]); + metadata.FullID = DBGuid.FromDB(dbReader["id"]); // Current SHA1s are not stored/computed. metadata.SHA1 = new byte[] { }; diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 8fbe7a8..0aea30f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -287,7 +287,7 @@ namespace OpenSim.Data.MySQL // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. // ( DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero ) - item.CreatorId = DBGuid.FromDB(reader["creatorID"]).ToString(); + item.CreatorId = reader["creatorID"].ToString(); // Be a bit safer in parsing these because the // database doesn't enforce them to be not null, and -- cgit v1.1 From d2bc6736675f0418903f70a649808ccabbfb3fd9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 May 2010 23:33:05 +0100 Subject: Make m_log in migrations private. Define new m_log in derived class --- OpenSim/Data/MySQL/MySQLMigrations.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index b16655d..959b5d0 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -43,6 +43,8 @@ namespace OpenSim.Data.MySQL /// public class MySqlMigration : Migration { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public MySqlMigration() : base() { -- cgit v1.1 From 167db502593de5f535d8c322005c63ef263940ed Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 May 2010 02:33:23 +0100 Subject: Allow migration steps to fail again without bringing down the house --- OpenSim/Data/MySQL/MySQLMigrations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index 959b5d0..a1f7844 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL { m_log.ErrorFormat("[MySQL MIGRATION]: Error {0}", args.Exception.Message); m_log.ErrorFormat("[MySQL MIGRATION]: In SQL: {0}", args.StatementText); - throw args.Exception; + m_log.Error("[MySQL MIGRATION]: The above migration failed to complete. This may cause errors in your install, but could also be normal. Continuing."); }; scr.Execute(); } -- cgit v1.1 From dedc0c0bd4ebdf6f8af056c63c7aeeed70b39627 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 May 2010 02:47:31 +0100 Subject: Revert "Allow migration steps to fail again without bringing down the house" This reverts commit 167db502593de5f535d8c322005c63ef263940ed. --- OpenSim/Data/MySQL/MySQLMigrations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index a1f7844..959b5d0 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL { m_log.ErrorFormat("[MySQL MIGRATION]: Error {0}", args.Exception.Message); m_log.ErrorFormat("[MySQL MIGRATION]: In SQL: {0}", args.StatementText); - m_log.Error("[MySQL MIGRATION]: The above migration failed to complete. This may cause errors in your install, but could also be normal. Continuing."); + throw args.Exception; }; scr.Execute(); } -- cgit v1.1 From 0c209a469b54a52ac7d54a7bddd2bdcf02a80522 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 May 2010 03:48:03 +0100 Subject: Clean up output a bit --- OpenSim/Data/MySQL/MySQLMigrations.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index 959b5d0..81a0e83 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -43,8 +43,6 @@ namespace OpenSim.Data.MySQL /// public class MySqlMigration : Migration { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public MySqlMigration() : base() { @@ -75,9 +73,7 @@ namespace OpenSim.Data.MySQL scr.Query = sql; scr.Error += delegate(object sender, MySqlScriptErrorEventArgs args) { - m_log.ErrorFormat("[MySQL MIGRATION]: Error {0}", args.Exception.Message); - m_log.ErrorFormat("[MySQL MIGRATION]: In SQL: {0}", args.StatementText); - throw args.Exception; + throw new Exception(sql); }; scr.Execute(); } -- cgit v1.1 From eacd8d0263fa41c4d45c880b02f5be709eaab32f Mon Sep 17 00:00:00 2001 From: AlexRa Date: Wed, 19 May 2010 10:16:56 +0300 Subject: MySQL: added CreatorID, moved asset_flag to migration script --- OpenSim/Data/MySQL/Resources/AssetStore.migrations | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index b9595f0..3fd58b7 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations @@ -67,3 +67,11 @@ COMMIT; DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621' +:VERSION 7 + +ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; + +:VERSION 8 + +alter table assets add CreatorID varchar(36) not null default '' + -- cgit v1.1 From 64fe823b9255f0314277f80926435d5525039a2d Mon Sep 17 00:00:00 2001 From: AlexRa Date: Wed, 19 May 2010 21:30:16 +0300 Subject: MySQLAssetData.cs now supports asset_flags, CreatorID --- OpenSim/Data/MySQL/MySQLAssetData.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index ec18c28..fe5152a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, asset_flags, data FROM assets WHERE id=?id", + "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", dbcon)) { cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -123,7 +123,7 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], UUID.Zero.ToString()); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); asset.Data = (byte[])dbReader["data"]; asset.Description = (string)dbReader["description"]; @@ -163,8 +163,8 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand( - "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?data)", + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", dbcon); string assetName = asset.Name; @@ -196,6 +196,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); @@ -305,7 +306,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags FROM assets LIMIT ?start, ?count", dbcon); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", dbcon); cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?count", count); @@ -322,6 +323,7 @@ namespace OpenSim.Data.MySQL metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); metadata.FullID = DBGuid.FromDB(dbReader["id"]); + metadata.CreatorID = dbReader["CreatorID"].ToString(); // Current SHA1s are not stored/computed. metadata.SHA1 = new byte[] { }; -- cgit v1.1 From 213e372253eb8a59f0afb627e11b0a5b6f6b088f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 20 May 2010 20:24:50 -0700 Subject: Cleaned up MySql migrations a bit more, got rid of all old-form migration files. Restored Presence table to its taboo-breaking form. --- OpenSim/Data/MySQL/Resources/001_GridUserStore.sql | 17 --------------- OpenSim/Data/MySQL/Resources/007_AssetStore.sql | 5 ----- OpenSim/Data/MySQL/Resources/033_RegionStore.sql | 3 --- .../Data/MySQL/Resources/GridUserStore.migrations | 19 ++++++++++++++++ OpenSim/Data/MySQL/Resources/Presence.migrations | 25 ++-------------------- .../Data/MySQL/Resources/RegionStore.migrations | 5 ++++- 6 files changed, 25 insertions(+), 49 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/001_GridUserStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/007_AssetStore.sql delete mode 100644 OpenSim/Data/MySQL/Resources/033_RegionStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/GridUserStore.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql b/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql deleted file mode 100644 index ce4ab96..0000000 --- a/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql +++ /dev/null @@ -1,17 +0,0 @@ -BEGIN; - -CREATE TABLE `GridUser` ( - `UserID` VARCHAR(255) NOT NULL, - `HomeRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `LastRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `LastPosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `LastLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `Online` CHAR(5) NOT NULL DEFAULT 'false', - `Login` CHAR(16) NOT NULL DEFAULT '0', - `Logout` CHAR(16) NOT NULL DEFAULT '0', - PRIMARY KEY (`UserID`) -) ENGINE=InnoDB; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/007_AssetStore.sql b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql deleted file mode 100644 index f06121a..0000000 --- a/OpenSim/Data/MySQL/Resources/007_AssetStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/033_RegionStore.sql b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql deleted file mode 100644 index 2832b41..0000000 --- a/OpenSim/Data/MySQL/Resources/033_RegionStore.sql +++ /dev/null @@ -1,3 +0,0 @@ -BEGIN; -ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations new file mode 100644 index 0000000..32b85ee --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations @@ -0,0 +1,19 @@ +:VERSION 1 # -------------------------- + +BEGIN; + +CREATE TABLE `GridUser` ( + `UserID` VARCHAR(255) NOT NULL, + `HomeRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LastRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `LastPosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LastLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `Online` CHAR(5) NOT NULL DEFAULT 'false', + `Login` CHAR(16) NOT NULL DEFAULT '0', + `Logout` CHAR(16) NOT NULL DEFAULT '0', + PRIMARY KEY (`UserID`) +) ENGINE=InnoDB; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index d513024..91f7de5 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations @@ -4,32 +4,11 @@ BEGIN; CREATE TABLE `Presence` ( `UserID` VARCHAR(255) NOT NULL, - `RegionID` CHAR(36) NOT NULL, + `RegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `Online` CHAR(5) NOT NULL DEFAULT 'false', - `Login` CHAR(16) NOT NULL DEFAULT '0', - `Logout` CHAR(16) NOT NULL DEFAULT '0', - `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' + `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' ) ENGINE=InnoDB; -COMMIT; - -:VERSION 2 # -------------------------- - -BEGIN; - -ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; -ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; -ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; - -COMMIT; - -:VERSION 3 # -------------------------- - -BEGIN; - CREATE UNIQUE INDEX SessionID ON Presence(SessionID); CREATE INDEX UserID ON Presence(UserID); diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 3dab67e..baeeedd 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -801,6 +801,9 @@ BEGIN; ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; +:VERSION 33 #--------------------- - +BEGIN; +ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +COMMIT; -- cgit v1.1 From 7f70ae0ebd686507bc15ac6fc7eeb75ed0b9b64a Mon Sep 17 00:00:00 2001 From: AlexRa Date: Mon, 17 May 2010 15:54:43 +0300 Subject: All data tests made DBMS-independent --- OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs | 116 ------------------------- OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 99 --------------------- OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs | 112 ------------------------ 3 files changed, 327 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs b/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs deleted file mode 100644 index 01afcae..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLEstateTest.cs +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; -using OpenSim.Data.Tests; -using log4net; -using System.Reflection; -using OpenSim.Tests.Common; -using MySql.Data.MySqlClient; - - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture, DatabaseTest] - public class MySQLEstateTest : BasicEstateTest - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string file; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - // clear db incase to ensure we are in a clean state - ClearDB(); - - regionDb = new MySQLDataStore(); - regionDb.Initialise(connect); - db = new MySQLEstateStore(); - db.Initialise(connect); - } - catch (Exception e) - { - m_log.Error("Exception {0}", e); - Assert.Ignore(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - if (regionDb != null) - { - regionDb.Dispose(); - } - ClearDB(); - } - - private void ClearDB() - { - // if a new table is added, it has to be dropped here - ExecuteSql("drop table if exists migrations"); - ExecuteSql("drop table if exists prims"); - ExecuteSql("drop table if exists primshapes"); - ExecuteSql("drop table if exists primitems"); - ExecuteSql("drop table if exists terrain"); - ExecuteSql("drop table if exists land"); - ExecuteSql("drop table if exists landaccesslist"); - ExecuteSql("drop table if exists regionban"); - ExecuteSql("drop table if exists regionsettings"); - ExecuteSql("drop table if exists estate_managers"); - ExecuteSql("drop table if exists estate_groups"); - ExecuteSql("drop table if exists estate_users"); - ExecuteSql("drop table if exists estateban"); - ExecuteSql("drop table if exists estate_settings"); - ExecuteSql("drop table if exists estate_map"); - } - - /// - /// Execute a MySqlCommand - /// - /// sql string to execute - private void ExecuteSql(string sql) - { - using (MySqlConnection dbcon = new MySqlConnection(connect)) - { - dbcon.Open(); - - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); - } - } - } -} diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs deleted file mode 100644 index 4575493..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; -using OpenSim.Data.Tests; -using log4net; -using System.Reflection; -using OpenSim.Tests.Common; -using MySql.Data.MySqlClient; - - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture, DatabaseTest] - public class MySQLInventoryTest : BasicInventoryTest - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string file; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - DropTables(); - db = new MySQLInventoryData(); - db.Initialise(connect); - } - catch (Exception e) - { - m_log.Error("Exception {0}", e); - Assert.Ignore(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - if (db != null) - { - db.Dispose(); - } - DropTables(); - } - - private void DropTables() - { - ExecuteSql("drop table IF EXISTS inventoryitems"); - ExecuteSql("drop table IF EXISTS inventoryfolders"); - ExecuteSql("drop table IF EXISTS migrations"); - } - - /// - /// Execute a MySqlCommand - /// - /// sql string to execute - private void ExecuteSql(string sql) - { - using (MySqlConnection dbcon = new MySqlConnection(connect)) - { - dbcon.Open(); - - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); - } - } - } -} diff --git a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs b/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs deleted file mode 100644 index e7e57e4..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLRegionTest.cs +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; -using OpenSim.Data.Tests; -using log4net; -using System.Reflection; -using OpenSim.Tests.Common; -using MySql.Data.MySqlClient; - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture, DatabaseTest] - public class MySQLRegionTest : BasicRegionTest - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string file; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - // this is important in case a previous run ended badly - ClearDB(); - - db = new MySQLDataStore(); - db.Initialise(connect); - } - catch (Exception e) - { - m_log.Error("Exception {0}", e); - Assert.Ignore(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - if (db != null) - { - db.Dispose(); - } - ClearDB(); - } - - private void ClearDB() - { - ExecuteSql("drop table if exists migrations"); - ExecuteSql("drop table if exists prims"); - ExecuteSql("drop table if exists primshapes"); - ExecuteSql("drop table if exists primitems"); - ExecuteSql("drop table if exists terrain"); - ExecuteSql("drop table if exists land"); - ExecuteSql("drop table if exists landaccesslist"); - ExecuteSql("drop table if exists regionban"); - ExecuteSql("drop table if exists regionsettings"); - ExecuteSql("drop table if exists estate_managers"); - ExecuteSql("drop table if exists estate_groups"); - ExecuteSql("drop table if exists estate_users"); - ExecuteSql("drop table if exists estateban"); - ExecuteSql("drop table if exists estate_settings"); - ExecuteSql("drop table if exists estate_map"); - } - - /// - /// Execute a MySqlCommand - /// - /// sql string to execute - private void ExecuteSql(string sql) - { - using (MySqlConnection dbcon = new MySqlConnection(connect)) - { - dbcon.Open(); - - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); - } - } - } -} -- cgit v1.1 From 40031e6d379916c507591f4c5032b22afe851020 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Fri, 21 May 2010 14:00:41 +0300 Subject: Removed MySql and SQLite-specific asset test files --- OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs | 92 ------------------------------ 1 file changed, 92 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs b/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs deleted file mode 100644 index a46fdf8..0000000 --- a/OpenSim/Data/MySQL/Tests/MySQLAssetTest.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; -using OpenSim.Data.Tests; -using log4net; -using System.Reflection; -using OpenSim.Tests.Common; -using MySql.Data.MySqlClient; - -namespace OpenSim.Data.MySQL.Tests -{ - [TestFixture, DatabaseTest] - public class MySQLAssetTest : BasicAssetTest - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string file; - private string m_connectionString; - public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;"; - - [TestFixtureSetUp] - public void Init() - { - SuperInit(); - // If we manage to connect to the database with the user - // and password above it is our test database, and run - // these tests. If anything goes wrong, ignore these - // tests. - try - { - db = new MySQLAssetData(); - db.Initialise(connect); - } - catch (Exception e) - { - m_log.Error(e.ToString()); - Assert.Ignore(); - } - } - - [TestFixtureTearDown] - public void Cleanup() - { - if (db != null) - { - db.Dispose(); - } - ExecuteSql("drop table migrations"); - ExecuteSql("drop table assets"); - } - - /// - /// Execute a MySqlCommand - /// - /// sql string to execute - private void ExecuteSql(string sql) - { - using (MySqlConnection dbcon = new MySqlConnection(connect)) - { - dbcon.Open(); - - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); - } - } - } -} -- cgit v1.1 From ebc2b6d4f6ebb0392ec0081bea913d24e9753786 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Mon, 17 May 2010 17:37:16 +0200 Subject: Split migrations for RegionStore and EstateStore (see WARNING!) ok, so the estate stores now want their own migration files, but as it happened the SQL definition were inside the Region migrations. It seems better/cleaner to keep each 'store' separately updatable. WARNING: any editing in the middle of the migration scripts (as opposite to just appending to them) has the potential of messing up updates of existing databases. As far as I can see, this one is (probably) safe, the worst that could happen is the EstateStore migration silently fail if the estate the tables are already there. --- .../Data/MySQL/Resources/EstateStore.migrations | 69 +++++++++++++++++++ .../Data/MySQL/Resources/RegionStore.migrations | 78 ---------------------- 2 files changed, 69 insertions(+), 78 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/EstateStore.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations new file mode 100644 index 0000000..2e0d658 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -0,0 +1,69 @@ +:VERSION 13 + +# The estate migrations used to be in Region store + +CREATE TABLE IF NOT EXISTS `estate_managers` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE IF NOT EXISTS `estate_groups` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE IF NOT EXISTS `estate_users` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE IF NOT EXISTS `estateban` ( + `EstateID` int(10) unsigned NOT NULL, + `bannedUUID` varchar(36) NOT NULL, + `bannedIp` varchar(16) NOT NULL, + `bannedIpHostMask` varchar(16) NOT NULL, + `bannedNameMask` varchar(64) default NULL, + KEY `estateban_EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE IF NOT EXISTS `estate_settings` ( + `EstateID` int(10) unsigned NOT NULL auto_increment, + `EstateName` varchar(64) default NULL, + `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, + `DenyAnonymous` tinyint(4) NOT NULL, + `ResetHomeOnTeleport` tinyint(4) NOT NULL, + `FixedSun` tinyint(4) NOT NULL, + `DenyTransacted` tinyint(4) NOT NULL, + `BlockDwell` tinyint(4) NOT NULL, + `DenyIdentified` tinyint(4) NOT NULL, + `AllowVoice` tinyint(4) NOT NULL, + `UseGlobalTime` tinyint(4) NOT NULL, + `PricePerMeter` int(11) NOT NULL, + `TaxFree` tinyint(4) NOT NULL, + `AllowDirectTeleport` tinyint(4) NOT NULL, + `RedirectGridX` int(11) NOT NULL, + `RedirectGridY` int(11) NOT NULL, + `ParentEstateID` int(10) unsigned NOT NULL, + `SunPosition` double NOT NULL, + `EstateSkipScripts` tinyint(4) NOT NULL, + `BillableFactor` float NOT NULL, + `PublicAccess` tinyint(4) NOT NULL, + `AbuseEmail` varchar(255) not null, + `EstateOwner` varchar(36) not null, + `DenyMinors` tinyint not null, + + PRIMARY KEY (`EstateID`) +) ENGINE=InnoDB AUTO_INCREMENT=100; + +CREATE TABLE IF NOT EXISTS `estate_map` ( + `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `EstateID` int(11) NOT NULL, + PRIMARY KEY (`RegionID`), + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + + + diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index baeeedd..383c328 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -386,84 +386,6 @@ CREATE TABLE `regionsettings` ( PRIMARY KEY (`regionUUID`) ) ENGINE=InnoDB; -CREATE TABLE `estate_managers` ( - `EstateID` int(10) unsigned NOT NULL, - `uuid` char(36) NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_groups` ( - `EstateID` int(10) unsigned NOT NULL, - `uuid` char(36) NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_users` ( - `EstateID` int(10) unsigned NOT NULL, - `uuid` char(36) NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estateban` ( - `EstateID` int(10) unsigned NOT NULL, - `bannedUUID` varchar(36) NOT NULL, - `bannedIp` varchar(16) NOT NULL, - `bannedIpHostMask` varchar(16) NOT NULL, - `bannedNameMask` varchar(64) default NULL, - KEY `estateban_EstateID` (`EstateID`) -) ENGINE=InnoDB; - -CREATE TABLE `estate_settings` ( - `EstateID` int(10) unsigned NOT NULL auto_increment, - `EstateName` varchar(64) default NULL, - `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, - `DenyAnonymous` tinyint(4) NOT NULL, - `ResetHomeOnTeleport` tinyint(4) NOT NULL, - `FixedSun` tinyint(4) NOT NULL, - `DenyTransacted` tinyint(4) NOT NULL, - `BlockDwell` tinyint(4) NOT NULL, - `DenyIdentified` tinyint(4) NOT NULL, - `AllowVoice` tinyint(4) NOT NULL, - `UseGlobalTime` tinyint(4) NOT NULL, - `PricePerMeter` int(11) NOT NULL, - `TaxFree` tinyint(4) NOT NULL, - `AllowDirectTeleport` tinyint(4) NOT NULL, - `RedirectGridX` int(11) NOT NULL, - `RedirectGridY` int(11) NOT NULL, - `ParentEstateID` int(10) unsigned NOT NULL, - `SunPosition` double NOT NULL, - `EstateSkipScripts` tinyint(4) NOT NULL, - `BillableFactor` float NOT NULL, - `PublicAccess` tinyint(4) NOT NULL, - PRIMARY KEY (`EstateID`) -) ENGINE=InnoDB AUTO_INCREMENT=100; - -CREATE TABLE `estate_map` ( - `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - `EstateID` int(11) NOT NULL, - PRIMARY KEY (`RegionID`), - KEY `EstateID` (`EstateID`) -) ENGINE=InnoDB; - -commit; - -:VERSION 14 #--------------------- - -begin; - -alter table estate_settings add column AbuseEmail varchar(255) not null; - -alter table estate_settings add column EstateOwner varchar(36) not null; - -commit; - - -:VERSION 15 #--------------------- - -begin; - -alter table estate_settings add column DenyMinors tinyint not null; - commit; :VERSION 16 #--------------------- -- cgit v1.1 From 05d9ca1b26baaae3e9ab106665163f5beeecd11d Mon Sep 17 00:00:00 2001 From: AlexRa Date: Sun, 23 May 2010 11:36:40 +0300 Subject: MySQL Migrations: Minor correcton to Region/Estate split (some Estate SQL left behind in the Region migration) --- OpenSim/Data/MySQL/Resources/EstateStore.migrations | 12 ++++++++++++ OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 ------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index 2e0d658..df82a2e 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -1,6 +1,10 @@ :VERSION 13 # The estate migrations used to be in Region store +# here they will do nothing (bad) if the tables are already there, +# just update the store version. + +BEGIN; CREATE TABLE IF NOT EXISTS `estate_managers` ( `EstateID` int(10) unsigned NOT NULL, @@ -65,5 +69,13 @@ CREATE TABLE IF NOT EXISTS `estate_map` ( KEY `EstateID` (`EstateID`) ) ENGINE=InnoDB; +COMMIT; + +:VERSION 32 #--------------------- (moved from RegionStore migr, just in case) + +BEGIN; +ALTER TABLE estate_settings AUTO_INCREMENT = 100; +COMMIT; + diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 383c328..d8a279d 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -717,12 +717,6 @@ ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT COMMIT; -:VERSION 32 #--------------------- - -BEGIN; -ALTER TABLE estate_settings AUTO_INCREMENT = 100; -COMMIT; - :VERSION 33 #--------------------- BEGIN; -- cgit v1.1 From 1ab826d67c218947bb89cbc781a589babcaf2666 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 23 May 2010 12:22:47 -0700 Subject: The 8th migration statement in AssetStore.migrations didn't look right. --- OpenSim/Data/MySQL/Resources/AssetStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index 3fd58b7..9c55630 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations @@ -73,5 +73,5 @@ ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; :VERSION 8 -alter table assets add CreatorID varchar(36) not null default '' +ALTER TABLE assets ADD COLUMN CreatorID varchar(36) NOT NULL DEFAULT ''; -- cgit v1.1 From a246cbce8dca64ff31482632aaeff0b34650a723 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jun 2010 00:37:38 +0100 Subject: Add a migration to adjust types in the WL table. The new connector likes that better --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index d8a279d..45ab4a7 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -723,3 +723,9 @@ BEGIN; ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; +:VERSION 34 #--------------------- + +BEGIN; +ALTER TABLE `regionwindlight` CHANGE COLUMN `cloud_scroll_x` `cloud_scroll_x` FLOAT(4,2) NOT NULL DEFAULT '0.20' AFTER `cloud_detail_density`, CHANGE COLUMN `cloud_scroll_y` `cloud_scroll_y` FLOAT(4,2) NOT NULL DEFAULT '0.01' AFTER `cloud_scroll_x_lock`; +COMMIT; + -- cgit v1.1 From 9b9804a498a3d48e7356c0a2cd12bf98887f5a53 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 8 Jun 2010 15:47:14 -0700 Subject: * Changed CreatorIDs consistently to varchar(128) * Deleted redundant migration for assets in SQLite * Rewrote XInventory migrations in SQLite in the new style --- OpenSim/Data/MySQL/Resources/AssetStore.migrations | 2 +- OpenSim/Data/MySQL/Resources/InventoryStore.migrations | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index 9c55630..e0526fe 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations @@ -73,5 +73,5 @@ ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; :VERSION 8 -ALTER TABLE assets ADD COLUMN CreatorID varchar(36) NOT NULL DEFAULT ''; +ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; diff --git a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations index 8c5864e..3e9bad5 100644 --- a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations @@ -91,3 +91,11 @@ update inventoryitems set creatorID = '00000000-0000-0000-0000-000000000000' whe alter table inventoryitems modify column creatorID varchar(36) not NULL default '00000000-0000-0000-0000-000000000000'; COMMIT; + +:VERSION 5 # ------------ + +BEGIN; + +alter table inventoryitems modify column creatorID varchar(128) not NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; -- cgit v1.1 From 668c3b4062d6d9a86ade27ee797b9816a95d0396 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jun 2010 16:34:18 +0100 Subject: Re-add Migration version 32, which apparently got dropped completely. --- .../Data/MySQL/Resources/RegionStore.migrations | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 45ab4a7..b08b096 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -717,6 +717,78 @@ ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT COMMIT; +:VERSION 32 + +CREATE TABLE `regionwindlight` ( + `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000', + `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000', + `water_color_g` float(9,6) unsigned NOT NULL DEFAULT '38.000000', + `water_color_b` float(9,6) unsigned NOT NULL DEFAULT '64.000000', + `water_fog_density_exponent` float(3,1) unsigned NOT NULL DEFAULT '4.0', + `underwater_fog_modifier` float(3,2) unsigned NOT NULL DEFAULT '0.25', + `reflection_wavelet_scale_1` float(3,1) unsigned NOT NULL DEFAULT '2.0', + `reflection_wavelet_scale_2` float(3,1) unsigned NOT NULL DEFAULT '2.0', + `reflection_wavelet_scale_3` float(3,1) unsigned NOT NULL DEFAULT '2.0', + `fresnel_scale` float(3,2) unsigned NOT NULL DEFAULT '0.40', + `fresnel_offset` float(3,2) unsigned NOT NULL DEFAULT '0.50', + `refract_scale_above` float(3,2) unsigned NOT NULL DEFAULT '0.03', + `refract_scale_below` float(3,2) unsigned NOT NULL DEFAULT '0.20', + `blur_multiplier` float(4,3) unsigned NOT NULL DEFAULT '0.040', + `big_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.05', + `big_wave_direction_y` float(3,2) NOT NULL DEFAULT '-0.42', + `little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11', + `little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16', + `normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4', + `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.25', + `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.25', + `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.32', + `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.32', + `haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19', + `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.12', + `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.22', + `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.38', + `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.38', + `haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70', + `density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18', + `distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8', + `max_altitude` int(4) unsigned NOT NULL DEFAULT '1605', + `sun_moon_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.24', + `sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26', + `sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30', + `sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30', + `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.317', + `ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35', + `ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35', + `ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35', + `ambient_i` float(3,2) unsigned NOT NULL DEFAULT '0.35', + `east_angle` float(3,2) unsigned NOT NULL DEFAULT '0.00', + `sun_glow_focus` float(3,2) unsigned NOT NULL DEFAULT '0.10', + `sun_glow_size` float(3,2) unsigned NOT NULL DEFAULT '1.75', + `scene_gamma` float(4,2) unsigned NOT NULL DEFAULT '1.00', + `star_brightness` float(3,2) unsigned NOT NULL DEFAULT '0.00', + `cloud_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.41', + `cloud_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.41', + `cloud_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.41', + `cloud_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.41', + `cloud_x` float(3,2) unsigned NOT NULL DEFAULT '1.00', + `cloud_y` float(3,2) unsigned NOT NULL DEFAULT '0.53', + `cloud_density` float(3,2) unsigned NOT NULL DEFAULT '1.00', + `cloud_coverage` float(3,2) unsigned NOT NULL DEFAULT '0.27', + `cloud_scale` float(3,2) unsigned NOT NULL DEFAULT '0.42', + `cloud_detail_x` float(3,2) unsigned NOT NULL DEFAULT '1.00', + `cloud_detail_y` float(3,2) unsigned NOT NULL DEFAULT '0.53', + `cloud_detail_density` float(3,2) unsigned NOT NULL DEFAULT '0.12', + `cloud_scroll_x` float(3,2) unsigned NOT NULL DEFAULT '0.20', + `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', + `cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01', + `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', + `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`region_id`) +); + +ALTER TABLE estate_settings AUTO_INCREMENT = 100; +COMMIT; + :VERSION 33 #--------------------- BEGIN; -- cgit v1.1 From 008e840cf2b81d5af1f8b64fa2fe44a190da2d77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jun 2010 16:37:20 +0100 Subject: Add the BEGIN; I had missed --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index b08b096..bdb3558 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -719,6 +719,7 @@ COMMIT; :VERSION 32 +BEGIN; CREATE TABLE `regionwindlight` ( `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000', `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000', -- cgit v1.1 From 9c9ce9e8dd19c887ba91ff9b70f1b0e4f6a3f8df Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 14 Jun 2010 11:50:42 -0700 Subject: * Deleted duplicated migration that was failing anyway. * Added an error message in initial estate owner creation that makes it clear what needs to happen. --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index bdb3558..3f644f9 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -787,8 +787,6 @@ CREATE TABLE `regionwindlight` ( PRIMARY KEY (`region_id`) ); -ALTER TABLE estate_settings AUTO_INCREMENT = 100; -COMMIT; :VERSION 33 #--------------------- -- cgit v1.1 From 51d30fd34a950e0cd71d61ce0666a6d1e90bf233 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 17 Jun 2010 17:43:40 +0100 Subject: Set command timeout to infinity on migrations --- OpenSim/Data/MySQL/MySQLMigrations.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index 81a0e83..4ad0e9b 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL { throw new Exception(sql); }; + scr.CommandTimeout = 0; scr.Execute(); } } -- cgit v1.1 From e3432b8f63a8fc17e506033fe4e1c568c8f88b9a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 17 Jun 2010 17:48:34 +0100 Subject: Revert "Set command timeout to infinity on migrations" This reverts commit 51d30fd34a950e0cd71d61ce0666a6d1e90bf233. --- OpenSim/Data/MySQL/MySQLMigrations.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index 4ad0e9b..81a0e83 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -75,7 +75,6 @@ namespace OpenSim.Data.MySQL { throw new Exception(sql); }; - scr.CommandTimeout = 0; scr.Execute(); } } -- cgit v1.1 From 8643db3ef0c4dca709d85fc37240a18fd9049520 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Jun 2010 22:48:43 +0100 Subject: This is a HACK! Downright nasty. For some reason, the devs of the mysql connector have decided that their vision of timeouts is the only valid one. This uses reflection to show them the finger. Please test. --- OpenSim/Data/MySQL/MySQLMigrations.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index 81a0e83..b6f714c 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -66,6 +66,12 @@ namespace OpenSim.Data.MySQL return; } + MySqlConnection c = (MySqlConnection)conn; + + Type tc = c.GetType(); + MethodInfo miSetCommandTimeout = tc.GetMethod("SetCommandTimeout", BindingFlags.NonPublic | BindingFlags.Instance); + MethodInfo miClearCommandTimeout = tc.GetMethod("ClearCommandTimeout", BindingFlags.NonPublic | BindingFlags.Instance); + miSetCommandTimeout.Invoke(c, new Object[] { 2147483 }); // INT_MAX / 1000; MySqlScript scr = new MySqlScript((MySqlConnection)conn); { foreach (string sql in script) @@ -78,6 +84,7 @@ namespace OpenSim.Data.MySQL scr.Execute(); } } + miClearCommandTimeout.Invoke(c, new Object[] { }); } } } -- cgit v1.1 From a3ebd4db3fce78544a7d0f0069b4aa386ff605e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Jun 2010 23:45:56 +0100 Subject: Revert "This is a HACK! Downright nasty. For some reason, the devs of the mysql" Didn't do what it said on the package! This reverts commit 8643db3ef0c4dca709d85fc37240a18fd9049520. --- OpenSim/Data/MySQL/MySQLMigrations.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLMigrations.cs b/OpenSim/Data/MySQL/MySQLMigrations.cs index b6f714c..81a0e83 100644 --- a/OpenSim/Data/MySQL/MySQLMigrations.cs +++ b/OpenSim/Data/MySQL/MySQLMigrations.cs @@ -66,12 +66,6 @@ namespace OpenSim.Data.MySQL return; } - MySqlConnection c = (MySqlConnection)conn; - - Type tc = c.GetType(); - MethodInfo miSetCommandTimeout = tc.GetMethod("SetCommandTimeout", BindingFlags.NonPublic | BindingFlags.Instance); - MethodInfo miClearCommandTimeout = tc.GetMethod("ClearCommandTimeout", BindingFlags.NonPublic | BindingFlags.Instance); - miSetCommandTimeout.Invoke(c, new Object[] { 2147483 }); // INT_MAX / 1000; MySqlScript scr = new MySqlScript((MySqlConnection)conn); { foreach (string sql in script) @@ -84,7 +78,6 @@ namespace OpenSim.Data.MySQL scr.Execute(); } } - miClearCommandTimeout.Invoke(c, new Object[] { }); } } } -- cgit v1.1 From b0129b35f8dbe24b8e857223b3ac8ba4cb7cc830 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Jun 2010 12:37:16 -0700 Subject: Added checks to XInventory DB layer to truncate names and descriptions. --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 0fe801d..3c73095 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -64,14 +64,22 @@ namespace OpenSim.Data.MySQL public bool StoreFolder(XInventoryFolder folder) { + if (folder.folderName.Length > 64) + folder.folderName = folder.folderName.Substring(0, 64); + return m_Folders.Store(folder); } public bool StoreItem(XInventoryItem item) { + if (item.inventoryName.Length > 64) + item.inventoryName = item.inventoryName.Substring(0, 64); + if (item.inventoryDescription.Length > 128) + item.inventoryDescription = item.inventoryDescription.Substring(0, 128); + return m_Items.Store(item); } - + public bool DeleteFolders(string field, string val) { return m_Folders.Delete(field, val); -- cgit v1.1 From 849fc0483f02984abf03994967168d6c38174732 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 23:19:31 +0100 Subject: add mysql support for media on a prim --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 ++++++-- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index bfeae12..f17e8ae 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -222,7 +222,7 @@ namespace OpenSim.Data.MySQL "PathTaperX, PathTaperY, PathTwist, " + "PathTwistBegin, ProfileBegin, ProfileEnd, " + "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State) values (?UUID, " + + "ExtraParams, State, Media) values (?UUID, " + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + "?PCode, ?PathBegin, ?PathEnd, " + "?PathScaleX, ?PathScaleY, " + @@ -233,7 +233,7 @@ namespace OpenSim.Data.MySQL "?PathTwistBegin, ?ProfileBegin, " + "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State)"; + "?State, ?Media)"; FillShapeCommand(cmd, prim); @@ -1700,6 +1700,9 @@ namespace OpenSim.Data.MySQL s.ExtraParams = (byte[])row["ExtraParams"]; s.State = (byte)(int)row["State"]; + + if (!(row["Media"] is System.DBNull)) + s.MediaRaw = (string)row["Media"]; return s; } @@ -1743,6 +1746,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); + cmd.Parameters.AddWithValue("Media", s.MediaRaw); } public void StorePrimInventory(UUID primID, ICollection items) diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 3f644f9..1369704 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -1,4 +1,4 @@ - + :VERSION 1 #--------------------- BEGIN; @@ -800,3 +800,10 @@ BEGIN; ALTER TABLE `regionwindlight` CHANGE COLUMN `cloud_scroll_x` `cloud_scroll_x` FLOAT(4,2) NOT NULL DEFAULT '0.20' AFTER `cloud_detail_density`, CHANGE COLUMN `cloud_scroll_y` `cloud_scroll_y` FLOAT(4,2) NOT NULL DEFAULT '0.01' AFTER `cloud_scroll_x_lock`; COMMIT; +:VERSION 35 #--------------------- +-- Added post 0.7 + +BEGIN; +ALTER TABLE prims ADD COLUMN MediaURL varchar(255); +ALTER TABLE primshapes ADD COLUMN Media TEXT; +COMMIT; \ No newline at end of file -- cgit v1.1 From f91ec192247d64786b3eeab66512fdf319273d68 Mon Sep 17 00:00:00 2001 From: Marck Date: Sat, 31 Jul 2010 20:16:39 +0200 Subject: Implemented console command "show hyperlinks". --- OpenSim/Data/MySQL/MySQLRegionData.cs | 49 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c7bddac..6dc62c6 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -280,32 +280,35 @@ namespace OpenSim.Data.MySQL } return false; - } + } + public List GetDefaultRegions(UUID scopeID) - { - string command = "select * from `"+m_Realm+"` where (flags & 1) <> 0"; - if (scopeID != UUID.Zero) - command += " and ScopeID = ?scopeID"; - - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - return RunCommand(cmd); + { + return Get((int)RegionFlags.DefaultRegion, scopeID); } public List GetFallbackRegions(UUID scopeID, int x, int y) - { - string command = "select * from `"+m_Realm+"` where (flags & 2) <> 0"; - if (scopeID != UUID.Zero) - command += " and ScopeID = ?scopeID"; - - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - // TODO: distance-sort results - return RunCommand(cmd); - } + { + // TODO: distance-sort results + return Get((int)RegionFlags.FallbackRegion, scopeID); + } + + public List GetHyperlinks(UUID scopeID) + { + return Get((int)RegionFlags.Hyperlink, scopeID); + } + + private List Get(int regionFlags, UUID scopeID) + { + string command = "select * from `" + m_Realm + "` where (flags & " + regionFlags.ToString() + ") <> 0"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; + + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); + } } } -- cgit v1.1 From c4ecbd1fb1ce5450b66a7de41a0e34cc3474e04a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 31 Jul 2010 16:40:58 -0700 Subject: White space from previous commit. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 6dc62c6..aec37e2 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -280,35 +280,35 @@ namespace OpenSim.Data.MySQL } return false; - } - + } + public List GetDefaultRegions(UUID scopeID) - { - return Get((int)RegionFlags.DefaultRegion, scopeID); + { + return Get((int)RegionFlags.DefaultRegion, scopeID); } public List GetFallbackRegions(UUID scopeID, int x, int y) - { - // TODO: distance-sort results + { + // TODO: distance-sort results return Get((int)RegionFlags.FallbackRegion, scopeID); - } - - public List GetHyperlinks(UUID scopeID) - { - return Get((int)RegionFlags.Hyperlink, scopeID); - } - - private List Get(int regionFlags, UUID scopeID) - { - string command = "select * from `" + m_Realm + "` where (flags & " + regionFlags.ToString() + ") <> 0"; - if (scopeID != UUID.Zero) - command += " and ScopeID = ?scopeID"; - - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - return RunCommand(cmd); - } + } + + public List GetHyperlinks(UUID scopeID) + { + return Get((int)RegionFlags.Hyperlink, scopeID); + } + + private List Get(int regionFlags, UUID scopeID) + { + string command = "select * from `" + m_Realm + "` where (flags & " + regionFlags.ToString() + ") <> 0"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; + + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); + } } } -- cgit v1.1 From 9d8a67fe1348419c41374d1be77737bfa048106c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 16:26:27 +0100 Subject: get rid of PrimitiveBaseShape.MediaRaw staging post using an OSD serialization rather than auto forces serialization code to be placed in OpenSim.Framework this makes the media texture raw data staging post in PrimitiveBaseShape redundant, now we just directly call the code in PrimitiveBaseShape.MediaList itself --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index f17e8ae..50fcd96 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -1701,8 +1701,8 @@ namespace OpenSim.Data.MySQL s.State = (byte)(int)row["State"]; - if (!(row["Media"] is System.DBNull)) - s.MediaRaw = (string)row["Media"]; + if (!(row["Media"] is System.DBNull)) + s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); return s; } @@ -1746,7 +1746,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); - cmd.Parameters.AddWithValue("Media", s.MediaRaw); + + if (s.Media != null) + cmd.Parameters.AddWithValue("Media", s.Media.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) -- cgit v1.1 From 2a0254f2da3b92f22289815c05bcd03a4032dd40 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 17:54:40 +0100 Subject: Implement MediaUrl persistence for MySQL and MsSQL Not sure how I forgot this. This may resolve problems with media textures not persisting over restart for these databases. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 50fcd96..9c67e3a 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -174,7 +174,7 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber) values (" + "?UUID, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + @@ -205,7 +205,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -1184,6 +1184,9 @@ namespace OpenSim.Data.MySQL prim.PassTouches = ((sbyte)row["PassTouches"] != 0); prim.LinkNum = (int)row["LinkNumber"]; + + if (!(row["MediaURL"] is System.DBNull)) + prim.MediaUrl = (string)row["MediaURL"]; return prim; } @@ -1521,6 +1524,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("PassTouches", 0); cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); + + if (prim.MediaUrl != null) + cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); } /// -- cgit v1.1 From 7f3f1bfe885a373d4a74fc13d49236113a69f727 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Aug 2010 20:23:18 +0100 Subject: fix mysql/mssql prim serialization problem --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 9c67e3a..d8debc5 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -1524,9 +1524,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("PassTouches", 0); cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); - - if (prim.MediaUrl != null) - cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); } /// @@ -1752,9 +1750,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); - - if (s.Media != null) - cmd.Parameters.AddWithValue("Media", s.Media.ToXml()); + cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) -- cgit v1.1 From 1f25b9e8dbf500d22df55fa2a8f7f9b7bf873aa3 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 8 Aug 2010 17:51:43 +0200 Subject: Thank you, Marck00, for a patch that implemented region distance sorting for fallback regions. Applied with changes. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index aec37e2..878b8e8 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -289,8 +289,10 @@ namespace OpenSim.Data.MySQL public List GetFallbackRegions(UUID scopeID, int x, int y) { - // TODO: distance-sort results - return Get((int)RegionFlags.FallbackRegion, scopeID); + List regions = Get((int)RegionFlags.FallbackRegion, scopeID); + RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y); + regions.Sort(distanceComparer); + return regions; } public List GetHyperlinks(UUID scopeID) -- cgit v1.1 From 7741143fb5c7c62355170a2f795561d28b9f589f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 10 Aug 2010 11:14:24 -0700 Subject: Enforce DB limits on region name to 32 chars, or else (not good). Removed a piece of code from Hyperlinker that didn't work anyway. Shortened the hyperlink region name. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 878b8e8..baa948e 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -210,6 +210,9 @@ namespace OpenSim.Data.MySQL if (data.Data.ContainsKey("locY")) data.Data.Remove("locY"); + if (data.RegionName.Length > 32) + data.RegionName = data.RegionName.Substring(0, 32); + string[] fields = new List(data.Data.Keys).ToArray(); using (MySqlCommand cmd = new MySqlCommand()) -- cgit v1.1 From 39a748b47a5eb8020f167287c84a91bee0881cca Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Aug 2010 20:23:53 +0100 Subject: refactor: Use SOP.Flags rather than SOP.ObjectFlags --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index d8debc5..1edcb5d 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -1081,7 +1081,7 @@ namespace OpenSim.Data.MySQL prim.SitName = (string)row["SitName"]; prim.TouchName = (string)row["TouchName"]; // Permissions - prim.ObjectFlags = (uint)(int)row["ObjectFlags"]; + prim.Flags = (PrimFlags)(int)row["ObjectFlags"]; prim.OwnerMask = (uint)(int)row["OwnerMask"]; prim.NextOwnerMask = (uint)(int)row["NextOwnerMask"]; prim.GroupMask = (uint)(int)row["GroupMask"]; @@ -1414,7 +1414,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("SitName", prim.SitName); cmd.Parameters.AddWithValue("TouchName", prim.TouchName); // permissions - cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags); + cmd.Parameters.AddWithValue("ObjectFlags", (uint)prim.Flags); cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); -- cgit v1.1 From f58a809536d318fbd788378c54776b053919ea14 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 19 Aug 2010 12:01:40 +0200 Subject: Skip conversion if fields that are null in the database. This may uncover errors elsewhere. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 6cbb2ee..7c23a47 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -148,6 +148,10 @@ namespace OpenSim.Data.MySQL foreach (string name in m_Fields.Keys) { + if (reader[name] is DBNull) + { + continue; + } if (m_Fields[name].FieldType == typeof(bool)) { int v = Convert.ToInt32(reader[name]); -- cgit v1.1 From 8031f8ec09df4f654c86a9c7bc498664f7b9d9dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Aug 2010 00:08:53 +0100 Subject: Improve consistency of locking for SOG.m_parts in order to avoid race conditions in linking and unlinking --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 210 ++++++++++++++-------------- 1 file changed, 107 insertions(+), 103 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 1edcb5d..b756b4f 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -135,111 +135,115 @@ namespace OpenSim.Data.MySQL dbcon.Open(); MySqlCommand cmd = dbcon.CreateCommand(); - foreach (SceneObjectPart prim in obj.Children.Values) + lock (obj.Children) { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims (" + - "UUID, CreationDate, " + - "Name, Text, Description, " + - "SitName, TouchName, ObjectFlags, " + - "OwnerMask, NextOwnerMask, GroupMask, " + - "EveryoneMask, BaseMask, PositionX, " + - "PositionY, PositionZ, GroupPositionX, " + - "GroupPositionY, GroupPositionZ, VelocityX, " + - "VelocityY, VelocityZ, AngularVelocityX, " + - "AngularVelocityY, AngularVelocityZ, " + - "AccelerationX, AccelerationY, " + - "AccelerationZ, RotationX, " + - "RotationY, RotationZ, " + - "RotationW, SitTargetOffsetX, " + - "SitTargetOffsetY, SitTargetOffsetZ, " + - "SitTargetOrientW, SitTargetOrientX, " + - "SitTargetOrientY, SitTargetOrientZ, " + - "RegionUUID, CreatorID, " + - "OwnerID, GroupID, " + - "LastOwnerID, SceneGroupID, " + - "PayPrice, PayButton1, " + - "PayButton2, PayButton3, " + - "PayButton4, LoopedSound, " + - "LoopedSoundGain, TextureAnimation, " + - "OmegaX, OmegaY, OmegaZ, " + - "CameraEyeOffsetX, CameraEyeOffsetY, " + - "CameraEyeOffsetZ, CameraAtOffsetX, " + - "CameraAtOffsetY, CameraAtOffsetZ, " + - "ForceMouselook, ScriptAccessPin, " + - "AllowedDrop, DieAtEdge, " + - "SalePrice, SaleType, " + - "ColorR, ColorG, ColorB, ColorA, " + - "ParticleSystem, ClickAction, Material, " + - "CollisionSound, CollisionSoundVolume, " + - "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + - "?CreationDate, ?Name, ?Text, " + - "?Description, ?SitName, ?TouchName, " + - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + - "?GroupMask, ?EveryoneMask, ?BaseMask, " + - "?PositionX, ?PositionY, ?PositionZ, " + - "?GroupPositionX, ?GroupPositionY, " + - "?GroupPositionZ, ?VelocityX, " + - "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + - "?AngularVelocityY, ?AngularVelocityZ, " + - "?AccelerationX, ?AccelerationY, " + - "?AccelerationZ, ?RotationX, " + - "?RotationY, ?RotationZ, " + - "?RotationW, ?SitTargetOffsetX, " + - "?SitTargetOffsetY, ?SitTargetOffsetZ, " + - "?SitTargetOrientW, ?SitTargetOrientX, " + - "?SitTargetOrientY, ?SitTargetOrientZ, " + - "?RegionUUID, ?CreatorID, ?OwnerID, " + - "?GroupID, ?LastOwnerID, ?SceneGroupID, " + - "?PayPrice, ?PayButton1, ?PayButton2, " + - "?PayButton3, ?PayButton4, ?LoopedSound, " + - "?LoopedSoundGain, ?TextureAnimation, " + - "?OmegaX, ?OmegaY, ?OmegaZ, " + - "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + - "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + - "?CameraAtOffsetY, ?CameraAtOffsetZ, " + - "?ForceMouselook, ?ScriptAccessPin, " + - "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + - "?SaleType, ?ColorR, ?ColorG, " + - "?ColorB, ?ColorA, ?ParticleSystem, " + - "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes (" + - "UUID, Shape, ScaleX, ScaleY, " + - "ScaleZ, PCode, PathBegin, PathEnd, " + - "PathScaleX, PathScaleY, PathShearX, " + - "PathShearY, PathSkew, PathCurve, " + - "PathRadiusOffset, PathRevolutions, " + - "PathTaperX, PathTaperY, PathTwist, " + - "PathTwistBegin, ProfileBegin, ProfileEnd, " + - "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) values (?UUID, " + - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + - "?PCode, ?PathBegin, ?PathEnd, " + - "?PathScaleX, ?PathScaleY, " + - "?PathShearX, ?PathShearY, " + - "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + - "?PathRevolutions, ?PathTaperX, " + - "?PathTaperY, ?PathTwist, " + - "?PathTwistBegin, ?ProfileBegin, " + - "?ProfileEnd, ?ProfileCurve, " + - "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); + foreach (SceneObjectPart prim in obj.Children.Values) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims (" + + "UUID, CreationDate, " + + "Name, Text, Description, " + + "SitName, TouchName, ObjectFlags, " + + "OwnerMask, NextOwnerMask, GroupMask, " + + "EveryoneMask, BaseMask, PositionX, " + + "PositionY, PositionZ, GroupPositionX, " + + "GroupPositionY, GroupPositionZ, VelocityX, " + + "VelocityY, VelocityZ, AngularVelocityX, " + + "AngularVelocityY, AngularVelocityZ, " + + "AccelerationX, AccelerationY, " + + "AccelerationZ, RotationX, " + + "RotationY, RotationZ, " + + "RotationW, SitTargetOffsetX, " + + "SitTargetOffsetY, SitTargetOffsetZ, " + + "SitTargetOrientW, SitTargetOrientX, " + + "SitTargetOrientY, SitTargetOrientZ, " + + "RegionUUID, CreatorID, " + + "OwnerID, GroupID, " + + "LastOwnerID, SceneGroupID, " + + "PayPrice, PayButton1, " + + "PayButton2, PayButton3, " + + "PayButton4, LoopedSound, " + + "LoopedSoundGain, TextureAnimation, " + + "OmegaX, OmegaY, OmegaZ, " + + "CameraEyeOffsetX, CameraEyeOffsetY, " + + "CameraEyeOffsetZ, CameraAtOffsetX, " + + "CameraAtOffsetY, CameraAtOffsetZ, " + + "ForceMouselook, ScriptAccessPin, " + + "AllowedDrop, DieAtEdge, " + + "SalePrice, SaleType, " + + "ColorR, ColorG, ColorB, ColorA, " + + "ParticleSystem, ClickAction, Material, " + + "CollisionSound, CollisionSoundVolume, " + + "PassTouches, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + + "?CreationDate, ?Name, ?Text, " + + "?Description, ?SitName, ?TouchName, " + + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + + "?GroupMask, ?EveryoneMask, ?BaseMask, " + + "?PositionX, ?PositionY, ?PositionZ, " + + "?GroupPositionX, ?GroupPositionY, " + + "?GroupPositionZ, ?VelocityX, " + + "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + + "?AngularVelocityY, ?AngularVelocityZ, " + + "?AccelerationX, ?AccelerationY, " + + "?AccelerationZ, ?RotationX, " + + "?RotationY, ?RotationZ, " + + "?RotationW, ?SitTargetOffsetX, " + + "?SitTargetOffsetY, ?SitTargetOffsetZ, " + + "?SitTargetOrientW, ?SitTargetOrientX, " + + "?SitTargetOrientY, ?SitTargetOrientZ, " + + "?RegionUUID, ?CreatorID, ?OwnerID, " + + "?GroupID, ?LastOwnerID, ?SceneGroupID, " + + "?PayPrice, ?PayButton1, ?PayButton2, " + + "?PayButton3, ?PayButton4, ?LoopedSound, " + + "?LoopedSoundGain, ?TextureAnimation, " + + "?OmegaX, ?OmegaY, ?OmegaZ, " + + "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + + "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + + "?CameraAtOffsetY, ?CameraAtOffsetZ, " + + "?ForceMouselook, ?ScriptAccessPin, " + + "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + + "?SaleType, ?ColorR, ?ColorG, " + + "?ColorB, ?ColorA, ?ParticleSystem, " + + "?ClickAction, ?Material, ?CollisionSound, " + + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes (" + + "UUID, Shape, ScaleX, ScaleY, " + + "ScaleZ, PCode, PathBegin, PathEnd, " + + "PathScaleX, PathScaleY, PathShearX, " + + "PathShearY, PathSkew, PathCurve, " + + "PathRadiusOffset, PathRevolutions, " + + "PathTaperX, PathTaperY, PathTwist, " + + "PathTwistBegin, ProfileBegin, ProfileEnd, " + + "ProfileCurve, ProfileHollow, Texture, " + + "ExtraParams, State, Media) values (?UUID, " + + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + + "?PCode, ?PathBegin, ?PathEnd, " + + "?PathScaleX, ?PathScaleY, " + + "?PathShearX, ?PathShearY, " + + "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + + "?PathRevolutions, ?PathTaperX, " + + "?PathTaperY, ?PathTwist, " + + "?PathTwistBegin, ?ProfileBegin, " + + "?ProfileEnd, ?ProfileCurve, " + + "?ProfileHollow, ?Texture, ?ExtraParams, " + + "?State, ?Media)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); + } + + cmd.Dispose(); } - cmd.Dispose(); } } } -- cgit v1.1 From 692cf3c657aaa74645722491c997f23b4d6f8f76 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Aug 2010 00:17:26 +0100 Subject: Remove parts locking from data classes since these are using a copy of the scene object --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 211 ++++++++++++++-------------- 1 file changed, 104 insertions(+), 107 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index b756b4f..37d7a88 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -135,115 +135,112 @@ namespace OpenSim.Data.MySQL dbcon.Open(); MySqlCommand cmd = dbcon.CreateCommand(); - lock (obj.Children) + foreach (SceneObjectPart prim in obj.Children.Values) { - foreach (SceneObjectPart prim in obj.Children.Values) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims (" + - "UUID, CreationDate, " + - "Name, Text, Description, " + - "SitName, TouchName, ObjectFlags, " + - "OwnerMask, NextOwnerMask, GroupMask, " + - "EveryoneMask, BaseMask, PositionX, " + - "PositionY, PositionZ, GroupPositionX, " + - "GroupPositionY, GroupPositionZ, VelocityX, " + - "VelocityY, VelocityZ, AngularVelocityX, " + - "AngularVelocityY, AngularVelocityZ, " + - "AccelerationX, AccelerationY, " + - "AccelerationZ, RotationX, " + - "RotationY, RotationZ, " + - "RotationW, SitTargetOffsetX, " + - "SitTargetOffsetY, SitTargetOffsetZ, " + - "SitTargetOrientW, SitTargetOrientX, " + - "SitTargetOrientY, SitTargetOrientZ, " + - "RegionUUID, CreatorID, " + - "OwnerID, GroupID, " + - "LastOwnerID, SceneGroupID, " + - "PayPrice, PayButton1, " + - "PayButton2, PayButton3, " + - "PayButton4, LoopedSound, " + - "LoopedSoundGain, TextureAnimation, " + - "OmegaX, OmegaY, OmegaZ, " + - "CameraEyeOffsetX, CameraEyeOffsetY, " + - "CameraEyeOffsetZ, CameraAtOffsetX, " + - "CameraAtOffsetY, CameraAtOffsetZ, " + - "ForceMouselook, ScriptAccessPin, " + - "AllowedDrop, DieAtEdge, " + - "SalePrice, SaleType, " + - "ColorR, ColorG, ColorB, ColorA, " + - "ParticleSystem, ClickAction, Material, " + - "CollisionSound, CollisionSoundVolume, " + - "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + - "?CreationDate, ?Name, ?Text, " + - "?Description, ?SitName, ?TouchName, " + - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + - "?GroupMask, ?EveryoneMask, ?BaseMask, " + - "?PositionX, ?PositionY, ?PositionZ, " + - "?GroupPositionX, ?GroupPositionY, " + - "?GroupPositionZ, ?VelocityX, " + - "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + - "?AngularVelocityY, ?AngularVelocityZ, " + - "?AccelerationX, ?AccelerationY, " + - "?AccelerationZ, ?RotationX, " + - "?RotationY, ?RotationZ, " + - "?RotationW, ?SitTargetOffsetX, " + - "?SitTargetOffsetY, ?SitTargetOffsetZ, " + - "?SitTargetOrientW, ?SitTargetOrientX, " + - "?SitTargetOrientY, ?SitTargetOrientZ, " + - "?RegionUUID, ?CreatorID, ?OwnerID, " + - "?GroupID, ?LastOwnerID, ?SceneGroupID, " + - "?PayPrice, ?PayButton1, ?PayButton2, " + - "?PayButton3, ?PayButton4, ?LoopedSound, " + - "?LoopedSoundGain, ?TextureAnimation, " + - "?OmegaX, ?OmegaY, ?OmegaZ, " + - "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + - "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + - "?CameraAtOffsetY, ?CameraAtOffsetZ, " + - "?ForceMouselook, ?ScriptAccessPin, " + - "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + - "?SaleType, ?ColorR, ?ColorG, " + - "?ColorB, ?ColorA, ?ParticleSystem, " + - "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes (" + - "UUID, Shape, ScaleX, ScaleY, " + - "ScaleZ, PCode, PathBegin, PathEnd, " + - "PathScaleX, PathScaleY, PathShearX, " + - "PathShearY, PathSkew, PathCurve, " + - "PathRadiusOffset, PathRevolutions, " + - "PathTaperX, PathTaperY, PathTwist, " + - "PathTwistBegin, ProfileBegin, ProfileEnd, " + - "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) values (?UUID, " + - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + - "?PCode, ?PathBegin, ?PathEnd, " + - "?PathScaleX, ?PathScaleY, " + - "?PathShearX, ?PathShearY, " + - "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + - "?PathRevolutions, ?PathTaperX, " + - "?PathTaperY, ?PathTwist, " + - "?PathTwistBegin, ?ProfileBegin, " + - "?ProfileEnd, ?ProfileCurve, " + - "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); - } - - cmd.Dispose(); + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims (" + + "UUID, CreationDate, " + + "Name, Text, Description, " + + "SitName, TouchName, ObjectFlags, " + + "OwnerMask, NextOwnerMask, GroupMask, " + + "EveryoneMask, BaseMask, PositionX, " + + "PositionY, PositionZ, GroupPositionX, " + + "GroupPositionY, GroupPositionZ, VelocityX, " + + "VelocityY, VelocityZ, AngularVelocityX, " + + "AngularVelocityY, AngularVelocityZ, " + + "AccelerationX, AccelerationY, " + + "AccelerationZ, RotationX, " + + "RotationY, RotationZ, " + + "RotationW, SitTargetOffsetX, " + + "SitTargetOffsetY, SitTargetOffsetZ, " + + "SitTargetOrientW, SitTargetOrientX, " + + "SitTargetOrientY, SitTargetOrientZ, " + + "RegionUUID, CreatorID, " + + "OwnerID, GroupID, " + + "LastOwnerID, SceneGroupID, " + + "PayPrice, PayButton1, " + + "PayButton2, PayButton3, " + + "PayButton4, LoopedSound, " + + "LoopedSoundGain, TextureAnimation, " + + "OmegaX, OmegaY, OmegaZ, " + + "CameraEyeOffsetX, CameraEyeOffsetY, " + + "CameraEyeOffsetZ, CameraAtOffsetX, " + + "CameraAtOffsetY, CameraAtOffsetZ, " + + "ForceMouselook, ScriptAccessPin, " + + "AllowedDrop, DieAtEdge, " + + "SalePrice, SaleType, " + + "ColorR, ColorG, ColorB, ColorA, " + + "ParticleSystem, ClickAction, Material, " + + "CollisionSound, CollisionSoundVolume, " + + "PassTouches, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + + "?CreationDate, ?Name, ?Text, " + + "?Description, ?SitName, ?TouchName, " + + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + + "?GroupMask, ?EveryoneMask, ?BaseMask, " + + "?PositionX, ?PositionY, ?PositionZ, " + + "?GroupPositionX, ?GroupPositionY, " + + "?GroupPositionZ, ?VelocityX, " + + "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + + "?AngularVelocityY, ?AngularVelocityZ, " + + "?AccelerationX, ?AccelerationY, " + + "?AccelerationZ, ?RotationX, " + + "?RotationY, ?RotationZ, " + + "?RotationW, ?SitTargetOffsetX, " + + "?SitTargetOffsetY, ?SitTargetOffsetZ, " + + "?SitTargetOrientW, ?SitTargetOrientX, " + + "?SitTargetOrientY, ?SitTargetOrientZ, " + + "?RegionUUID, ?CreatorID, ?OwnerID, " + + "?GroupID, ?LastOwnerID, ?SceneGroupID, " + + "?PayPrice, ?PayButton1, ?PayButton2, " + + "?PayButton3, ?PayButton4, ?LoopedSound, " + + "?LoopedSoundGain, ?TextureAnimation, " + + "?OmegaX, ?OmegaY, ?OmegaZ, " + + "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + + "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + + "?CameraAtOffsetY, ?CameraAtOffsetZ, " + + "?ForceMouselook, ?ScriptAccessPin, " + + "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + + "?SaleType, ?ColorR, ?ColorG, " + + "?ColorB, ?ColorA, ?ParticleSystem, " + + "?ClickAction, ?Material, ?CollisionSound, " + + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes (" + + "UUID, Shape, ScaleX, ScaleY, " + + "ScaleZ, PCode, PathBegin, PathEnd, " + + "PathScaleX, PathScaleY, PathShearX, " + + "PathShearY, PathSkew, PathCurve, " + + "PathRadiusOffset, PathRevolutions, " + + "PathTaperX, PathTaperY, PathTwist, " + + "PathTwistBegin, ProfileBegin, ProfileEnd, " + + "ProfileCurve, ProfileHollow, Texture, " + + "ExtraParams, State, Media) values (?UUID, " + + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + + "?PCode, ?PathBegin, ?PathEnd, " + + "?PathScaleX, ?PathScaleY, " + + "?PathShearX, ?PathShearY, " + + "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + + "?PathRevolutions, ?PathTaperX, " + + "?PathTaperY, ?PathTwist, " + + "?PathTwistBegin, ?ProfileBegin, " + + "?ProfileEnd, ?ProfileCurve, " + + "?ProfileHollow, ?Texture, ?ExtraParams, " + + "?State, ?Media)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); } + + cmd.Dispose(); } } } -- cgit v1.1 From 0a83fde85c8cffa1da46ef0a17390399ae74fa61 Mon Sep 17 00:00:00 2001 From: Jonathan Freedman Date: Sun, 29 Aug 2010 21:28:31 -0400 Subject: Implements parcel media setting persistence and packet / CAPS handling properly for the new media settings. Signed-off-by: Melanie --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 22 ++++++++++++++++++++-- .../Data/MySQL/Resources/RegionStore.migrations | 14 ++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 37d7a88..04446ce 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -677,7 +677,8 @@ namespace OpenSim.Data.MySQL "MusicURL, PassHours, PassPrice, SnapshotUUID, " + "UserLocationX, UserLocationY, UserLocationZ, " + "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, Dwell) values (" + + "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + + "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + "?UUID, ?RegionUUID, " + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + @@ -687,7 +688,8 @@ namespace OpenSim.Data.MySQL "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; + "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ + "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); @@ -1347,6 +1349,14 @@ namespace OpenSim.Data.MySQL m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); } + newData.MediaDescription = (string) row["MediaDescription"]; + newData.MediaType = (string) row["MediaType"]; + newData.MediaWidth = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[0]); + newData.MediaHeight = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[1]); + newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); + newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); + newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); + newData.ParcelAccessList = new List(); return newData; @@ -1651,6 +1661,14 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); cmd.Parameters.AddWithValue("Dwell", land.Dwell); + cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); + cmd.Parameters.AddWithValue("MediaType", land.MediaType); + cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); + cmd.Parameters.AddWithValue("MediaHeight", land.MediaHeight); + cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); + cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); + cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); + } /// diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 1369704..1405207 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -801,9 +801,19 @@ ALTER TABLE `regionwindlight` CHANGE COLUMN `cloud_scroll_x` `cloud_scroll_x` F COMMIT; :VERSION 35 #--------------------- --- Added post 0.7 BEGIN; ALTER TABLE prims ADD COLUMN MediaURL varchar(255); ALTER TABLE primshapes ADD COLUMN Media TEXT; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 36 #--------------------- + +BEGIN; +ALTER TABLE `land` ADD COLUMN `MediaType` VARCHAR(32) NOT NULL DEFAULT 'none/none' ; +ALTER TABLE `land` ADD COLUMN `MediaDescription` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `land` ADD COLUMN `MediaSize` VARCHAR(16) NOT NULL DEFAULT '0,0'; +ALTER TABLE `land` ADD COLUMN `MediaLoop` BOOLEAN NOT NULL DEFAULT FALSE; +ALTER TABLE `land` ADD COLUMN `ObscureMusic` BOOLEAN NOT NULL DEFAULT FALSE; +ALTER TABLE `land` ADD COLUMN `ObscureMedia` BOOLEAN NOT NULL DEFAULT FALSE; +COMMIT; -- cgit v1.1 From 6a0a878f7c268c6f248588895e232e3d14eb6eb3 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 5 Sep 2010 14:16:42 +0200 Subject: Remove "Dwell" support from core and replace it with calls to methods on IDwellModule --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 04446ce..30253c3 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -677,7 +677,7 @@ namespace OpenSim.Data.MySQL "MusicURL, PassHours, PassPrice, SnapshotUUID, " + "UserLocationX, UserLocationY, UserLocationZ, " + "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + + "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + "?UUID, ?RegionUUID, " + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + @@ -688,7 +688,7 @@ namespace OpenSim.Data.MySQL "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ + "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); @@ -1329,7 +1329,6 @@ namespace OpenSim.Data.MySQL UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); - newData.Dwell = Convert.ToInt32(row["Dwell"]); newData.AuthBuyerID = authedbuyer; newData.SnapshotID = snapshotID; @@ -1660,7 +1659,6 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); - cmd.Parameters.AddWithValue("Dwell", land.Dwell); cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); cmd.Parameters.AddWithValue("MediaType", land.MediaType); cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); -- cgit v1.1 From 11f4a65f42dea66091cb08423479fa6ae46c98aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 7 Sep 2010 00:34:06 +0100 Subject: Fix deletion persistence when freshly delinked prims are removed Previously, Scene.Inventory.DeRezObjects() forced the persistence of prims before deletion. This is necessary so that freshly delinked prims can be deleted (otherwise they remain as parts of their old group and reappear on server restart). However, DeRezObjects() deleted to user inventory, which is required by llDie() or direct region module unlink and deletion. Therefore, forced persistence has been pushed down into Scene.UnlinkSceneObject() to be more general, this is still on the DeRezObjects() path. Uncommented TestDelinkPersistence() since this now passes. Tests required considerable elaboration of MockRegionDataPlugin to reflect underlying storing of parts. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 30253c3..a39e68d 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -247,6 +247,8 @@ namespace OpenSim.Data.MySQL public void RemoveObject(UUID obj, UUID regionUUID) { +// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); + List uuids = new List(); // Formerly, this used to check the region UUID. -- cgit v1.1 From 47ac9f97b11ae9de535550ba7e6c836ee81dab55 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sat, 11 Sep 2010 18:29:38 -0700 Subject: Re-enabled asset last access time logging in MySQL --- OpenSim/Data/MySQL/MySQLAssetData.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index fe5152a..ed92f3e 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -214,9 +214,6 @@ namespace OpenSim.Data.MySQL private void UpdateAccessTime(AssetBase asset) { - // Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph - return; - lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) -- cgit v1.1 From 109b51758398d24a96a16900e8feb24361aee29d Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sat, 11 Sep 2010 20:43:06 -0700 Subject: Fixed the naming mess around data connectors for simulation data --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 1820 --------------------------- OpenSim/Data/MySQL/MySQLSimulationData.cs | 1820 +++++++++++++++++++++++++++ 2 files changed, 1820 insertions(+), 1820 deletions(-) delete mode 100644 OpenSim/Data/MySQL/MySQLLegacyRegionData.cs create mode 100644 OpenSim/Data/MySQL/MySQLSimulationData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs deleted file mode 100644 index a39e68d..0000000 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ /dev/null @@ -1,1820 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Data; -using System.Drawing; -using System.IO; -using System.Reflection; -using System.Threading; -using log4net; -using MySql.Data.MySqlClient; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Data; - -namespace OpenSim.Data.MySQL -{ - /// - /// A MySQL Interface for the Region Server - /// - public class MySQLDataStore : IRegionDataStore - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string m_connectionString; - private object m_dbLock = new object(); - - public void Initialise(string connectionString) - { - m_connectionString = connectionString; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - // Apply new Migrations - // - Assembly assem = GetType().Assembly; - Migration m = new Migration(dbcon, assem, "RegionStore"); - m.Update(); - - // Clean dropped attachments - // - try - { - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from prims, primshapes using prims " + - "left join primshapes on prims.uuid = primshapes.uuid " + - "where PCode = 9 and State <> 0"; - ExecuteNonQuery(cmd); - } - } - catch (MySqlException ex) - { - m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); - } - } - } - - private IDataReader ExecuteReader(MySqlCommand c) - { - IDataReader r = null; - - try - { - r = c.ExecuteReader(); - } - catch (Exception e) - { - m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); - throw; - } - - return r; - } - - private void ExecuteNonQuery(MySqlCommand c) - { - try - { - c.ExecuteNonQuery(); - } - catch (Exception e) - { - m_log.Error("[REGION DB]: MySQL error in ExecuteNonQuery: " + e.Message); - throw; - } - } - - public void Dispose() {} - - public void StoreObject(SceneObjectGroup obj, UUID regionUUID) - { - uint flags = obj.RootPart.GetEffectiveObjectFlags(); - - // Eligibility check - // - if ((flags & (uint)PrimFlags.Temporary) != 0) - return; - if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) - return; - - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - MySqlCommand cmd = dbcon.CreateCommand(); - - foreach (SceneObjectPart prim in obj.Children.Values) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims (" + - "UUID, CreationDate, " + - "Name, Text, Description, " + - "SitName, TouchName, ObjectFlags, " + - "OwnerMask, NextOwnerMask, GroupMask, " + - "EveryoneMask, BaseMask, PositionX, " + - "PositionY, PositionZ, GroupPositionX, " + - "GroupPositionY, GroupPositionZ, VelocityX, " + - "VelocityY, VelocityZ, AngularVelocityX, " + - "AngularVelocityY, AngularVelocityZ, " + - "AccelerationX, AccelerationY, " + - "AccelerationZ, RotationX, " + - "RotationY, RotationZ, " + - "RotationW, SitTargetOffsetX, " + - "SitTargetOffsetY, SitTargetOffsetZ, " + - "SitTargetOrientW, SitTargetOrientX, " + - "SitTargetOrientY, SitTargetOrientZ, " + - "RegionUUID, CreatorID, " + - "OwnerID, GroupID, " + - "LastOwnerID, SceneGroupID, " + - "PayPrice, PayButton1, " + - "PayButton2, PayButton3, " + - "PayButton4, LoopedSound, " + - "LoopedSoundGain, TextureAnimation, " + - "OmegaX, OmegaY, OmegaZ, " + - "CameraEyeOffsetX, CameraEyeOffsetY, " + - "CameraEyeOffsetZ, CameraAtOffsetX, " + - "CameraAtOffsetY, CameraAtOffsetZ, " + - "ForceMouselook, ScriptAccessPin, " + - "AllowedDrop, DieAtEdge, " + - "SalePrice, SaleType, " + - "ColorR, ColorG, ColorB, ColorA, " + - "ParticleSystem, ClickAction, Material, " + - "CollisionSound, CollisionSoundVolume, " + - "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + - "?CreationDate, ?Name, ?Text, " + - "?Description, ?SitName, ?TouchName, " + - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + - "?GroupMask, ?EveryoneMask, ?BaseMask, " + - "?PositionX, ?PositionY, ?PositionZ, " + - "?GroupPositionX, ?GroupPositionY, " + - "?GroupPositionZ, ?VelocityX, " + - "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + - "?AngularVelocityY, ?AngularVelocityZ, " + - "?AccelerationX, ?AccelerationY, " + - "?AccelerationZ, ?RotationX, " + - "?RotationY, ?RotationZ, " + - "?RotationW, ?SitTargetOffsetX, " + - "?SitTargetOffsetY, ?SitTargetOffsetZ, " + - "?SitTargetOrientW, ?SitTargetOrientX, " + - "?SitTargetOrientY, ?SitTargetOrientZ, " + - "?RegionUUID, ?CreatorID, ?OwnerID, " + - "?GroupID, ?LastOwnerID, ?SceneGroupID, " + - "?PayPrice, ?PayButton1, ?PayButton2, " + - "?PayButton3, ?PayButton4, ?LoopedSound, " + - "?LoopedSoundGain, ?TextureAnimation, " + - "?OmegaX, ?OmegaY, ?OmegaZ, " + - "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + - "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + - "?CameraAtOffsetY, ?CameraAtOffsetZ, " + - "?ForceMouselook, ?ScriptAccessPin, " + - "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + - "?SaleType, ?ColorR, ?ColorG, " + - "?ColorB, ?ColorA, ?ParticleSystem, " + - "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes (" + - "UUID, Shape, ScaleX, ScaleY, " + - "ScaleZ, PCode, PathBegin, PathEnd, " + - "PathScaleX, PathScaleY, PathShearX, " + - "PathShearY, PathSkew, PathCurve, " + - "PathRadiusOffset, PathRevolutions, " + - "PathTaperX, PathTaperY, PathTwist, " + - "PathTwistBegin, ProfileBegin, ProfileEnd, " + - "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) values (?UUID, " + - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + - "?PCode, ?PathBegin, ?PathEnd, " + - "?PathScaleX, ?PathScaleY, " + - "?PathShearX, ?PathShearY, " + - "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + - "?PathRevolutions, ?PathTaperX, " + - "?PathTaperY, ?PathTwist, " + - "?PathTwistBegin, ?ProfileBegin, " + - "?ProfileEnd, ?ProfileCurve, " + - "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); - } - - cmd.Dispose(); - } - } - } - - public void RemoveObject(UUID obj, UUID regionUUID) - { -// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); - - List uuids = new List(); - - // Formerly, this used to check the region UUID. - // That makes no sense, as we remove the contents of a prim - // unconditionally, but the prim dependent on the region ID. - // So, we would destroy an object and cause hard to detect - // issues if we delete the contents only. Deleting it all may - // cause the loss of a prim, but is cleaner. - // It's also faster because it uses the primary key. - // - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; - cmd.Parameters.AddWithValue("UUID", obj.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) - { - while (reader.Read()) - uuids.Add(DBGuid.FromDB(reader["UUID"].ToString())); - } - - // delete the main prims - cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; - ExecuteNonQuery(cmd); - } - } - } - - // there is no way this should be < 1 unless there is - // a very corrupt database, but in that case be extra - // safe anyway. - if (uuids.Count > 0) - { - RemoveShapes(uuids); - RemoveItems(uuids); - } - } - - /// - /// Remove all persisted items of the given prim. - /// The caller must acquire the necessrary synchronization locks - /// - /// the Item UUID - private void RemoveItems(UUID uuid) - { - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; - cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); - - ExecuteNonQuery(cmd); - } - } - } - } - - /// - /// Remove all persisted shapes for a list of prims - /// The caller must acquire the necessrary synchronization locks - /// - /// the list of UUIDs - private void RemoveShapes(List uuids) - { - lock (m_dbLock) - { - string sql = "delete from primshapes where "; - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - for (int i = 0; i < uuids.Count; i++) - { - if ((i + 1) == uuids.Count) - {// end of the list - sql += "(UUID = ?UUID" + i + ")"; - } - else - { - sql += "(UUID = ?UUID" + i + ") or "; - } - } - cmd.CommandText = sql; - - for (int i = 0; i < uuids.Count; i++) - cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); - - ExecuteNonQuery(cmd); - } - } - } - } - - /// - /// Remove all persisted items for a list of prims - /// The caller must acquire the necessrary synchronization locks - /// - /// the list of UUIDs - private void RemoveItems(List uuids) - { - lock (m_dbLock) - { - string sql = "delete from primitems where "; - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - for (int i = 0; i < uuids.Count; i++) - { - if ((i + 1) == uuids.Count) - { - // end of the list - sql += "(PrimID = ?PrimID" + i + ")"; - } - else - { - sql += "(PrimID = ?PrimID" + i + ") or "; - } - } - cmd.CommandText = sql; - - for (int i = 0; i < uuids.Count; i++) - cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); - - ExecuteNonQuery(cmd); - } - } - } - } - - public List LoadObjects(UUID regionID) - { - const int ROWS_PER_QUERY = 5000; - - Dictionary prims = new Dictionary(ROWS_PER_QUERY); - Dictionary objects = new Dictionary(); - int count = 0; - - #region Prim Loading - - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = - "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) - { - while (reader.Read()) - { - SceneObjectPart prim = BuildPrim(reader); - if (reader["Shape"] is DBNull) - prim.Shape = PrimitiveBaseShape.Default; - else - prim.Shape = BuildShape(reader); - - UUID parentID = DBGuid.FromDB(reader["SceneGroupID"].ToString()); - if (parentID != prim.UUID) - prim.ParentUUID = parentID; - - prims[prim.UUID] = prim; - - ++count; - if (count % ROWS_PER_QUERY == 0) - m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); - } - } - } - } - } - - #endregion Prim Loading - - #region SceneObjectGroup Creation - - // Create all of the SOGs from the root prims first - foreach (SceneObjectPart prim in prims.Values) - { - if (prim.ParentUUID == UUID.Zero) - objects[prim.UUID] = new SceneObjectGroup(prim); - } - - // Add all of the children objects to the SOGs - foreach (SceneObjectPart prim in prims.Values) - { - SceneObjectGroup sog; - if (prim.UUID != prim.ParentUUID) - { - if (objects.TryGetValue(prim.ParentUUID, out sog)) - { - int originalLinkNum = prim.LinkNum; - - sog.AddPart(prim); - - // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. - // We override that here - if (originalLinkNum != 0) - prim.LinkNum = originalLinkNum; - } - else - { - m_log.WarnFormat( - "[REGION DB]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.", - prim.Name, prim.UUID, regionID, prim.ParentUUID); - } - } - } - - #endregion SceneObjectGroup Creation - - m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); - - #region Prim Inventory Loading - - // Instead of attempting to LoadItems on every prim, - // most of which probably have no items... get a - // list from DB of all prims which have items and - // LoadItems only on those - List primsWithInventory = new List(); - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand itemCmd = dbcon.CreateCommand()) - { - itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; - using (IDataReader itemReader = ExecuteReader(itemCmd)) - { - while (itemReader.Read()) - { - if (!(itemReader["primID"] is DBNull)) - { - UUID primID = DBGuid.FromDB(itemReader["primID"].ToString()); - if (prims.ContainsKey(primID)) - primsWithInventory.Add(prims[primID]); - } - } - } - } - } - } - - foreach (SceneObjectPart prim in primsWithInventory) - { - LoadItems(prim); - } - - #endregion Prim Inventory Loading - - m_log.DebugFormat("[REGION DB]: Loaded inventory from {0} objects", primsWithInventory.Count); - - return new List(objects.Values); - } - - /// - /// Load in a prim's persisted inventory. - /// - /// The prim - private void LoadItems(SceneObjectPart prim) - { - lock (m_dbLock) - { - List inventory = new List(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; - cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) - { - while (reader.Read()) - { - TaskInventoryItem item = BuildItem(reader); - - item.ParentID = prim.UUID; // Values in database are often wrong - inventory.Add(item); - } - } - } - } - - prim.Inventory.RestoreInventoryItems(inventory); - } - } - - public void StoreTerrain(double[,] ter, UUID regionID) - { - m_log.Info("[REGION DB]: Storing terrain"); - - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - - ExecuteNonQuery(cmd); - - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; - - cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); - - ExecuteNonQuery(cmd); - } - } - } - } - - public double[,] LoadTerrain(UUID regionID) - { - double[,] terrain = null; - - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "select RegionUUID, Revision, Heightfield " + - "from terrain where RegionUUID = ?RegionUUID " + - "order by Revision desc limit 1"; - cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) - { - while (reader.Read()) - { - int rev = Convert.ToInt32(reader["Revision"]); - - terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; - terrain.Initialize(); - - using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) - { - using (BinaryReader br = new BinaryReader(mstr)) - { - for (int x = 0; x < (int)Constants.RegionSize; x++) - { - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - terrain[x, y] = br.ReadDouble(); - } - } - } - - m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); - } - } - } - } - } - } - - return terrain; - } - - public void RemoveLandObject(UUID globalID) - { - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from land where UUID = ?UUID"; - cmd.Parameters.AddWithValue("UUID", globalID.ToString()); - - ExecuteNonQuery(cmd); - } - } - } - } - - public void StoreLandObject(ILandObject parcel) - { - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "replace into land (UUID, RegionUUID, " + - "LocalLandID, Bitmap, Name, Description, " + - "OwnerUUID, IsGroupOwned, Area, AuctionID, " + - "Category, ClaimDate, ClaimPrice, GroupUUID, " + - "SalePrice, LandStatus, LandFlags, LandingType, " + - "MediaAutoScale, MediaTextureUUID, MediaURL, " + - "MusicURL, PassHours, PassPrice, SnapshotUUID, " + - "UserLocationX, UserLocationY, UserLocationZ, " + - "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + - "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + - "?UUID, ?RegionUUID, " + - "?LocalLandID, ?Bitmap, ?Name, ?Description, " + - "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + - "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + - "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + - "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + - "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + - "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + - "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ - "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; - - FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); - - ExecuteNonQuery(cmd); - - cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; - - foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) - { - FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); - ExecuteNonQuery(cmd); - cmd.Parameters.Clear(); - } - } - } - } - } - - public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) - { - RegionLightShareData nWP = new RegionLightShareData(); - nWP.OnSave += StoreRegionWindlightSettings; - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - string command = "select * from `regionwindlight` where region_id = ?regionID"; - - using(MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Connection = dbcon; - - cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); - - IDataReader result = ExecuteReader(cmd); - if (!result.Read()) - { - //No result, so store our default windlight profile and return it - nWP.regionID = regionUUID; - StoreRegionWindlightSettings(nWP); - return nWP; - } - else - { - nWP.regionID = DBGuid.FromDB(result["region_id"]); - nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); - nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); - nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); - nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); - nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); - nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); - nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); - nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); - nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); - nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); - nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); - nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); - nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); - nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); - nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); - nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); - nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); - UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); - nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); - nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); - nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); - nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); - nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); - nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); - nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); - nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); - nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); - nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); - nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); - nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); - nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); - nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); - nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); - nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); - nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); - nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); - nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); - nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); - nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); - nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); - nWP.eastAngle = Convert.ToSingle(result["east_angle"]); - nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); - nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); - nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); - nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); - nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); - nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); - nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); - nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); - nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); - nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); - nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); - nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); - nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); - nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); - nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); - nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); - nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); - nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); - nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); - nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); - nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); - } - } - } - return nWP; - } - - public RegionSettings LoadRegionSettings(UUID regionUUID) - { - RegionSettings rs = null; - - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("regionUUID", regionUUID); - - using (IDataReader reader = ExecuteReader(cmd)) - { - if (reader.Read()) - { - rs = BuildRegionSettings(reader); - rs.OnSave += StoreRegionSettings; - } - else - { - rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; - - StoreRegionSettings(rs); - } - } - } - } - } - - return rs; - } - - public void StoreRegionWindlightSettings(RegionLightShareData wl) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; - cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; - cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; - cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; - cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; - cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; - cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; - cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; - cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; - cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; - cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; - cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; - cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; - cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; - cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; - cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; - cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; - cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; - cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; - cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; - cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; - cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; - cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; - cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; - cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; - - cmd.Parameters.AddWithValue("region_id", wl.regionID); - cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); - cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); - cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); - cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); - cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); - cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); - cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); - cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); - cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); - cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); - cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); - cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); - cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); - cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); - cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); - cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); - cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); - cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); - cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); - cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); - cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); - cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); - cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); - cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); - cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); - cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); - cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); - cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); - cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); - cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); - cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); - cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); - cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); - cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); - cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); - cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); - cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); - cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); - cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); - cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); - cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); - cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); - cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); - cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); - cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); - cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); - cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); - cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); - cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); - cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); - cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); - cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); - cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); - cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); - cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); - cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); - cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); - cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); - cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); - - ExecuteNonQuery(cmd); - } - } - } - - public void StoreRegionSettings(RegionSettings rs) - { - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "replace into regionsettings (regionUUID, " + - "block_terraform, block_fly, allow_damage, " + - "restrict_pushing, allow_land_resell, " + - "allow_land_join_divide, block_show_in_search, " + - "agent_limit, object_bonus, maturity, " + - "disable_scripts, disable_collisions, " + - "disable_physics, terrain_texture_1, " + - "terrain_texture_2, terrain_texture_3, " + - "terrain_texture_4, elevation_1_nw, " + - "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, " + - "elevation_2_se, elevation_1_sw, " + - "elevation_2_sw, water_height, " + - "terrain_raise_limit, terrain_lower_limit, " + - "use_estate_sun, fixed_sun, sun_position, " + - "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + - "?BlockFly, ?AllowDamage, ?RestrictPushing, " + - "?AllowLandResell, ?AllowLandJoinDivide, " + - "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + - "?Maturity, ?DisableScripts, ?DisableCollisions, " + - "?DisablePhysics, ?TerrainTexture1, " + - "?TerrainTexture2, ?TerrainTexture3, " + - "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + - "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + - "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + - "?WaterHeight, ?TerrainRaiseLimit, " + - "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID)"; - - FillRegionSettingsCommand(cmd, rs); - - ExecuteNonQuery(cmd); - } - } - } - } - - public List LoadLandObjects(UUID regionUUID) - { - List landData = new List(); - - lock (m_dbLock) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) - { - while (reader.Read()) - { - LandData newLand = BuildLandData(reader); - landData.Add(newLand); - } - } - } - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - foreach (LandData land in landData) - { - cmd.Parameters.Clear(); - cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; - cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); - - using (IDataReader reader = ExecuteReader(cmd)) - { - while (reader.Read()) - { - land.ParcelAccessList.Add(BuildLandAccessData(reader)); - } - } - } - } - } - } - - return landData; - } - - public void Shutdown() - { - } - - private SceneObjectPart BuildPrim(IDataReader row) - { - SceneObjectPart prim = new SceneObjectPart(); - - // depending on the MySQL connector version, CHAR(36) may be already converted to Guid! - prim.UUID = DBGuid.FromDB(row["UUID"]); - prim.CreatorID = DBGuid.FromDB(row["CreatorID"]); - prim.OwnerID = DBGuid.FromDB(row["OwnerID"]); - prim.GroupID = DBGuid.FromDB(row["GroupID"]); - prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]); - - // explicit conversion of integers is required, which sort - // of sucks. No idea if there is a shortcut here or not. - prim.CreationDate = (int)row["CreationDate"]; - if (row["Name"] != DBNull.Value) - prim.Name = (string)row["Name"]; - else - prim.Name = String.Empty; - // Various text fields - prim.Text = (string)row["Text"]; - prim.Color = Color.FromArgb((int)row["ColorA"], - (int)row["ColorR"], - (int)row["ColorG"], - (int)row["ColorB"]); - prim.Description = (string)row["Description"]; - prim.SitName = (string)row["SitName"]; - prim.TouchName = (string)row["TouchName"]; - // Permissions - prim.Flags = (PrimFlags)(int)row["ObjectFlags"]; - prim.OwnerMask = (uint)(int)row["OwnerMask"]; - prim.NextOwnerMask = (uint)(int)row["NextOwnerMask"]; - prim.GroupMask = (uint)(int)row["GroupMask"]; - prim.EveryoneMask = (uint)(int)row["EveryoneMask"]; - prim.BaseMask = (uint)(int)row["BaseMask"]; - - // Vectors - prim.OffsetPosition = new Vector3( - (float)(double)row["PositionX"], - (float)(double)row["PositionY"], - (float)(double)row["PositionZ"] - ); - prim.GroupPosition = new Vector3( - (float)(double)row["GroupPositionX"], - (float)(double)row["GroupPositionY"], - (float)(double)row["GroupPositionZ"] - ); - prim.Velocity = new Vector3( - (float)(double)row["VelocityX"], - (float)(double)row["VelocityY"], - (float)(double)row["VelocityZ"] - ); - prim.AngularVelocity = new Vector3( - (float)(double)row["AngularVelocityX"], - (float)(double)row["AngularVelocityY"], - (float)(double)row["AngularVelocityZ"] - ); - prim.Acceleration = new Vector3( - (float)(double)row["AccelerationX"], - (float)(double)row["AccelerationY"], - (float)(double)row["AccelerationZ"] - ); - // quaternions - prim.RotationOffset = new Quaternion( - (float)(double)row["RotationX"], - (float)(double)row["RotationY"], - (float)(double)row["RotationZ"], - (float)(double)row["RotationW"] - ); - prim.SitTargetPositionLL = new Vector3( - (float)(double)row["SitTargetOffsetX"], - (float)(double)row["SitTargetOffsetY"], - (float)(double)row["SitTargetOffsetZ"] - ); - prim.SitTargetOrientationLL = new Quaternion( - (float)(double)row["SitTargetOrientX"], - (float)(double)row["SitTargetOrientY"], - (float)(double)row["SitTargetOrientZ"], - (float)(double)row["SitTargetOrientW"] - ); - - prim.PayPrice[0] = (int)row["PayPrice"]; - prim.PayPrice[1] = (int)row["PayButton1"]; - prim.PayPrice[2] = (int)row["PayButton2"]; - prim.PayPrice[3] = (int)row["PayButton3"]; - prim.PayPrice[4] = (int)row["PayButton4"]; - - prim.Sound = DBGuid.FromDB(row["LoopedSound"].ToString()); - prim.SoundGain = (float)(double)row["LoopedSoundGain"]; - prim.SoundFlags = 1; // If it's persisted at all, it's looped - - if (!(row["TextureAnimation"] is DBNull)) - prim.TextureAnimation = (byte[])row["TextureAnimation"]; - if (!(row["ParticleSystem"] is DBNull)) - prim.ParticleSystem = (byte[])row["ParticleSystem"]; - - prim.AngularVelocity = new Vector3( - (float)(double)row["OmegaX"], - (float)(double)row["OmegaY"], - (float)(double)row["OmegaZ"] - ); - - prim.SetCameraEyeOffset(new Vector3( - (float)(double)row["CameraEyeOffsetX"], - (float)(double)row["CameraEyeOffsetY"], - (float)(double)row["CameraEyeOffsetZ"] - )); - - prim.SetCameraAtOffset(new Vector3( - (float)(double)row["CameraAtOffsetX"], - (float)(double)row["CameraAtOffsetY"], - (float)(double)row["CameraAtOffsetZ"] - )); - - prim.SetForceMouselook((sbyte)row["ForceMouselook"] != 0); - prim.ScriptAccessPin = (int)row["ScriptAccessPin"]; - prim.AllowedDrop = ((sbyte)row["AllowedDrop"] != 0); - prim.DIE_AT_EDGE = ((sbyte)row["DieAtEdge"] != 0); - - prim.SalePrice = (int)row["SalePrice"]; - prim.ObjectSaleType = unchecked((byte)(sbyte)row["SaleType"]); - - prim.Material = unchecked((byte)(sbyte)row["Material"]); - - if (!(row["ClickAction"] is DBNull)) - prim.ClickAction = unchecked((byte)(sbyte)row["ClickAction"]); - - prim.CollisionSound = DBGuid.FromDB(row["CollisionSound"]); - prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; - - prim.PassTouches = ((sbyte)row["PassTouches"] != 0); - prim.LinkNum = (int)row["LinkNumber"]; - - if (!(row["MediaURL"] is System.DBNull)) - prim.MediaUrl = (string)row["MediaURL"]; - - return prim; - } - - - /// - /// Build a prim inventory item from the persisted data. - /// - /// - /// - private static TaskInventoryItem BuildItem(IDataReader row) - { - TaskInventoryItem taskItem = new TaskInventoryItem(); - - taskItem.ItemID = DBGuid.FromDB(row["itemID"]); - taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); - taskItem.AssetID = DBGuid.FromDB(row["assetID"]); - taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); - - taskItem.InvType = Convert.ToInt32(row["invType"]); - taskItem.Type = Convert.ToInt32(row["assetType"]); - - taskItem.Name = (String)row["name"]; - taskItem.Description = (String)row["description"]; - taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorID = DBGuid.FromDB(row["creatorID"]); - taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); - taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); - taskItem.GroupID = DBGuid.FromDB(row["groupID"]); - - taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); - taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); - taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); - taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); - taskItem.Flags = Convert.ToUInt32(row["flags"]); - - return taskItem; - } - - private static RegionSettings BuildRegionSettings(IDataReader row) - { - RegionSettings newSettings = new RegionSettings(); - - newSettings.RegionUUID = DBGuid.FromDB(row["regionUUID"]); - newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); - newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); - newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); - newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); - newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); - newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); - newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); - newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); - newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); - newSettings.Maturity = Convert.ToInt32(row["maturity"]); - newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); - newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); - newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); - newSettings.TerrainTexture1 = DBGuid.FromDB(row["terrain_texture_1"]); - newSettings.TerrainTexture2 = DBGuid.FromDB(row["terrain_texture_2"]); - newSettings.TerrainTexture3 = DBGuid.FromDB(row["terrain_texture_3"]); - newSettings.TerrainTexture4 = DBGuid.FromDB(row["terrain_texture_4"]); - newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); - newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); - newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); - newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); - newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); - newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); - newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); - newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); - newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); - newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); - newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); - newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); - newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); - newSettings.SunVector = new Vector3 ( - Convert.ToSingle(row["sunvectorx"]), - Convert.ToSingle(row["sunvectory"]), - Convert.ToSingle(row["sunvectorz"]) - ); - newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); - newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); - newSettings.Covenant = DBGuid.FromDB(row["covenant"]); - - newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); - - if (row["loaded_creation_id"] is DBNull) - newSettings.LoadedCreationID = ""; - else - newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; - - newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); - - return newSettings; - } - - /// - /// - /// - /// - /// - private static LandData BuildLandData(IDataReader row) - { - LandData newData = new LandData(); - - newData.GlobalID = DBGuid.FromDB(row["UUID"]); - newData.LocalID = Convert.ToInt32(row["LocalLandID"]); - - // Bitmap is a byte[512] - newData.Bitmap = (Byte[]) row["Bitmap"]; - - newData.Name = (String) row["Name"]; - newData.Description = (String) row["Description"]; - newData.OwnerID = DBGuid.FromDB(row["OwnerUUID"]); - newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); - newData.Area = Convert.ToInt32(row["Area"]); - newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented - newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]); - //Enum libsecondlife.Parcel.ParcelCategory - newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); - newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.GroupID = DBGuid.FromDB(row["GroupUUID"]); - newData.SalePrice = Convert.ToInt32(row["SalePrice"]); - newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); - //Enum. libsecondlife.Parcel.ParcelStatus - newData.Flags = Convert.ToUInt32(row["LandFlags"]); - newData.LandingType = Convert.ToByte(row["LandingType"]); - newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.MediaID = DBGuid.FromDB(row["MediaTextureUUID"]); - newData.MediaURL = (String) row["MediaURL"]; - newData.MusicURL = (String) row["MusicURL"]; - newData.PassHours = Convert.ToSingle(row["PassHours"]); - newData.PassPrice = Convert.ToInt32(row["PassPrice"]); - UUID authedbuyer = UUID.Zero; - UUID snapshotID = UUID.Zero; - - UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); - UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); - newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); - - newData.AuthBuyerID = authedbuyer; - newData.SnapshotID = snapshotID; - try - { - newData.UserLocation = - new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), - Convert.ToSingle(row["UserLocationZ"])); - newData.UserLookAt = - new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), - Convert.ToSingle(row["UserLookAtZ"])); - } - catch (InvalidCastException) - { - newData.UserLocation = Vector3.Zero; - newData.UserLookAt = Vector3.Zero; - m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); - } - - newData.MediaDescription = (string) row["MediaDescription"]; - newData.MediaType = (string) row["MediaType"]; - newData.MediaWidth = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[0]); - newData.MediaHeight = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[1]); - newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); - newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); - newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); - - newData.ParcelAccessList = new List(); - - return newData; - } - - /// - /// - /// - /// - /// - private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) - { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = DBGuid.FromDB(row["AccessUUID"]); - entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); - entry.Time = new DateTime(); - return entry; - } - - /// - /// - /// - /// - /// - private static Array SerializeTerrain(double[,] val) - { - MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); - BinaryWriter bw = new BinaryWriter(str); - - // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < (int)Constants.RegionSize; x++) - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - double height = val[x, y]; - if (height == 0.0) - height = double.Epsilon; - - bw.Write(height); - } - - return str.ToArray(); - } - - /// - /// Fill the prim command with prim values - /// - /// - /// - /// - /// - private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) - { - cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); - cmd.Parameters.AddWithValue("Name", prim.Name); - cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString()); - // the UUID of the root part for this SceneObjectGroup - // various text fields - cmd.Parameters.AddWithValue("Text", prim.Text); - cmd.Parameters.AddWithValue("ColorR", prim.Color.R); - cmd.Parameters.AddWithValue("ColorG", prim.Color.G); - cmd.Parameters.AddWithValue("ColorB", prim.Color.B); - cmd.Parameters.AddWithValue("ColorA", prim.Color.A); - cmd.Parameters.AddWithValue("Description", prim.Description); - cmd.Parameters.AddWithValue("SitName", prim.SitName); - cmd.Parameters.AddWithValue("TouchName", prim.TouchName); - // permissions - cmd.Parameters.AddWithValue("ObjectFlags", (uint)prim.Flags); - cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); - cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); - cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); - cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); - cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); - cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); - cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); - cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask); - cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask); - // vectors - cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X); - cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y); - cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z); - cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X); - cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y); - cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z); - cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X); - cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y); - cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z); - cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X); - cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y); - cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z); - cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X); - cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y); - cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z); - // quaternions - cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X); - cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y); - cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z); - cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W); - - // Sit target - Vector3 sitTargetPos = prim.SitTargetPositionLL; - cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X); - cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y); - cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z); - - Quaternion sitTargetOrient = prim.SitTargetOrientationLL; - cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W); - cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X); - cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y); - cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z); - - cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]); - cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]); - cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]); - cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]); - cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]); - - if ((prim.SoundFlags & 1) != 0) // Looped - { - cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString()); - cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain); - } - else - { - cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero); - cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f); - } - - cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); - cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); - - cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X); - cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y); - cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z); - - cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); - cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); - cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z); - - cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X); - cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y); - cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z); - - if (prim.GetForceMouselook()) - cmd.Parameters.AddWithValue("ForceMouselook", 1); - else - cmd.Parameters.AddWithValue("ForceMouselook", 0); - - cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin); - - if (prim.AllowedDrop) - cmd.Parameters.AddWithValue("AllowedDrop", 1); - else - cmd.Parameters.AddWithValue("AllowedDrop", 0); - - if (prim.DIE_AT_EDGE) - cmd.Parameters.AddWithValue("DieAtEdge", 1); - else - cmd.Parameters.AddWithValue("DieAtEdge", 0); - - cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); - cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType))); - - byte clickAction = prim.ClickAction; - cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction))); - - cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material))); - - cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); - cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); - - if (prim.PassTouches) - cmd.Parameters.AddWithValue("PassTouches", 1); - else - cmd.Parameters.AddWithValue("PassTouches", 0); - - cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); - cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); - } - - /// - /// - /// - /// - /// - private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem) - { - cmd.Parameters.AddWithValue("itemID", taskItem.ItemID); - cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID); - cmd.Parameters.AddWithValue("assetID", taskItem.AssetID); - cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID); - - cmd.Parameters.AddWithValue("invType", taskItem.InvType); - cmd.Parameters.AddWithValue("assetType", taskItem.Type); - - cmd.Parameters.AddWithValue("name", taskItem.Name); - cmd.Parameters.AddWithValue("description", taskItem.Description); - cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate); - cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID); - cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID); - cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID); - cmd.Parameters.AddWithValue("groupID", taskItem.GroupID); - cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions); - cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions); - cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions); - cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions); - cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions); - cmd.Parameters.AddWithValue("flags", taskItem.Flags); - } - - /// - /// - /// - private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings) - { - cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString()); - cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform); - cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly); - cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage); - cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing); - cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell); - cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide); - cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch); - cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit); - cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus); - cmd.Parameters.AddWithValue("Maturity", settings.Maturity); - cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts); - cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions); - cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics); - cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString()); - cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString()); - cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString()); - cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString()); - cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW); - cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW); - cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE); - cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE); - cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE); - cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE); - cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW); - cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW); - cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight); - cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit); - cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit); - cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun); - cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox); - cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X); - cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y); - cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z); - cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); - cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); - cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); - cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); - cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); - cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); - - } - - /// - /// - /// - /// - /// - /// - private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID) - { - cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString()); - cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); - cmd.Parameters.AddWithValue("LocalLandID", land.LocalID); - - // Bitmap is a byte[512] - cmd.Parameters.AddWithValue("Bitmap", land.Bitmap); - - cmd.Parameters.AddWithValue("Name", land.Name); - cmd.Parameters.AddWithValue("Description", land.Description); - cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString()); - cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned); - cmd.Parameters.AddWithValue("Area", land.Area); - cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented - cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory - cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate); - cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice); - cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString()); - cmd.Parameters.AddWithValue("SalePrice", land.SalePrice); - cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus - cmd.Parameters.AddWithValue("LandFlags", land.Flags); - cmd.Parameters.AddWithValue("LandingType", land.LandingType); - cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale); - cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString()); - cmd.Parameters.AddWithValue("MediaURL", land.MediaURL); - cmd.Parameters.AddWithValue("MusicURL", land.MusicURL); - cmd.Parameters.AddWithValue("PassHours", land.PassHours); - cmd.Parameters.AddWithValue("PassPrice", land.PassPrice); - cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString()); - cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X); - cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y); - cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z); - cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X); - cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y); - cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); - cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); - cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); - cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); - cmd.Parameters.AddWithValue("MediaType", land.MediaType); - cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); - cmd.Parameters.AddWithValue("MediaHeight", land.MediaHeight); - cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); - cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); - cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); - - } - - /// - /// - /// - /// - /// - /// - private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) - { - cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); - cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); - cmd.Parameters.AddWithValue("Flags", entry.Flags); - } - - /// - /// - /// - /// - /// - private PrimitiveBaseShape BuildShape(IDataReader row) - { - PrimitiveBaseShape s = new PrimitiveBaseShape(); - s.Scale = new Vector3( - (float)(double)row["ScaleX"], - (float)(double)row["ScaleY"], - (float)(double)row["ScaleZ"] - ); - // paths - s.PCode = (byte)(int)row["PCode"]; - s.PathBegin = (ushort)(int)row["PathBegin"]; - s.PathEnd = (ushort)(int)row["PathEnd"]; - s.PathScaleX = (byte)(int)row["PathScaleX"]; - s.PathScaleY = (byte)(int)row["PathScaleY"]; - s.PathShearX = (byte)(int)row["PathShearX"]; - s.PathShearY = (byte)(int)row["PathShearY"]; - s.PathSkew = (sbyte)(int)row["PathSkew"]; - s.PathCurve = (byte)(int)row["PathCurve"]; - s.PathRadiusOffset = (sbyte)(int)row["PathRadiusOffset"]; - s.PathRevolutions = (byte)(int)row["PathRevolutions"]; - s.PathTaperX = (sbyte)(int)row["PathTaperX"]; - s.PathTaperY = (sbyte)(int)row["PathTaperY"]; - s.PathTwist = (sbyte)(int)row["PathTwist"]; - s.PathTwistBegin = (sbyte)(int)row["PathTwistBegin"]; - // profile - s.ProfileBegin = (ushort)(int)row["ProfileBegin"]; - s.ProfileEnd = (ushort)(int)row["ProfileEnd"]; - s.ProfileCurve = (byte)(int)row["ProfileCurve"]; - s.ProfileHollow = (ushort)(int)row["ProfileHollow"]; - s.TextureEntry = (byte[])row["Texture"]; - - s.ExtraParams = (byte[])row["ExtraParams"]; - - s.State = (byte)(int)row["State"]; - - if (!(row["Media"] is System.DBNull)) - s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); - - return s; - } - - /// - /// - /// - /// - /// - private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim) - { - PrimitiveBaseShape s = prim.Shape; - cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); - // shape is an enum - cmd.Parameters.AddWithValue("Shape", 0); - // vectors - cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X); - cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y); - cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z); - // paths - cmd.Parameters.AddWithValue("PCode", s.PCode); - cmd.Parameters.AddWithValue("PathBegin", s.PathBegin); - cmd.Parameters.AddWithValue("PathEnd", s.PathEnd); - cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX); - cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY); - cmd.Parameters.AddWithValue("PathShearX", s.PathShearX); - cmd.Parameters.AddWithValue("PathShearY", s.PathShearY); - cmd.Parameters.AddWithValue("PathSkew", s.PathSkew); - cmd.Parameters.AddWithValue("PathCurve", s.PathCurve); - cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset); - cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions); - cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX); - cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY); - cmd.Parameters.AddWithValue("PathTwist", s.PathTwist); - cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin); - // profile - cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin); - cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd); - cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve); - cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow); - cmd.Parameters.AddWithValue("Texture", s.TextureEntry); - cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); - cmd.Parameters.AddWithValue("State", s.State); - cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); - } - - public void StorePrimInventory(UUID primID, ICollection items) - { - lock (m_dbLock) - { - RemoveItems(primID); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - MySqlCommand cmd = dbcon.CreateCommand(); - - if (items.Count == 0) - return; - - cmd.CommandText = "insert into primitems (" + - "invType, assetType, name, " + - "description, creationDate, nextPermissions, " + - "currentPermissions, basePermissions, " + - "everyonePermissions, groupPermissions, " + - "flags, itemID, primID, assetID, " + - "parentFolderID, creatorID, ownerID, " + - "groupID, lastOwnerID) values (?invType, " + - "?assetType, ?name, ?description, " + - "?creationDate, ?nextPermissions, " + - "?currentPermissions, ?basePermissions, " + - "?everyonePermissions, ?groupPermissions, " + - "?flags, ?itemID, ?primID, ?assetID, " + - "?parentFolderID, ?creatorID, ?ownerID, " + - "?groupID, ?lastOwnerID)"; - - foreach (TaskInventoryItem item in items) - { - cmd.Parameters.Clear(); - - FillItemCommand(cmd, item); - - ExecuteNonQuery(cmd); - } - - cmd.Dispose(); - } - } - } - } -} diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs new file mode 100644 index 0000000..36f73ef --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -0,0 +1,1820 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Threading; +using log4net; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Data; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for the Region Server + /// + public class MySQLSimulationData : ISimulationDataStore + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_connectionString; + private object m_dbLock = new object(); + + public void Initialise(string connectionString) + { + m_connectionString = connectionString; + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + // Apply new Migrations + // + Assembly assem = GetType().Assembly; + Migration m = new Migration(dbcon, assem, "RegionStore"); + m.Update(); + + // Clean dropped attachments + // + try + { + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from prims, primshapes using prims " + + "left join primshapes on prims.uuid = primshapes.uuid " + + "where PCode = 9 and State <> 0"; + ExecuteNonQuery(cmd); + } + } + catch (MySqlException ex) + { + m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); + } + } + } + + private IDataReader ExecuteReader(MySqlCommand c) + { + IDataReader r = null; + + try + { + r = c.ExecuteReader(); + } + catch (Exception e) + { + m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); + throw; + } + + return r; + } + + private void ExecuteNonQuery(MySqlCommand c) + { + try + { + c.ExecuteNonQuery(); + } + catch (Exception e) + { + m_log.Error("[REGION DB]: MySQL error in ExecuteNonQuery: " + e.Message); + throw; + } + } + + public void Dispose() {} + + public void StoreObject(SceneObjectGroup obj, UUID regionUUID) + { + uint flags = obj.RootPart.GetEffectiveObjectFlags(); + + // Eligibility check + // + if ((flags & (uint)PrimFlags.Temporary) != 0) + return; + if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) + return; + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = dbcon.CreateCommand(); + + foreach (SceneObjectPart prim in obj.Children.Values) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims (" + + "UUID, CreationDate, " + + "Name, Text, Description, " + + "SitName, TouchName, ObjectFlags, " + + "OwnerMask, NextOwnerMask, GroupMask, " + + "EveryoneMask, BaseMask, PositionX, " + + "PositionY, PositionZ, GroupPositionX, " + + "GroupPositionY, GroupPositionZ, VelocityX, " + + "VelocityY, VelocityZ, AngularVelocityX, " + + "AngularVelocityY, AngularVelocityZ, " + + "AccelerationX, AccelerationY, " + + "AccelerationZ, RotationX, " + + "RotationY, RotationZ, " + + "RotationW, SitTargetOffsetX, " + + "SitTargetOffsetY, SitTargetOffsetZ, " + + "SitTargetOrientW, SitTargetOrientX, " + + "SitTargetOrientY, SitTargetOrientZ, " + + "RegionUUID, CreatorID, " + + "OwnerID, GroupID, " + + "LastOwnerID, SceneGroupID, " + + "PayPrice, PayButton1, " + + "PayButton2, PayButton3, " + + "PayButton4, LoopedSound, " + + "LoopedSoundGain, TextureAnimation, " + + "OmegaX, OmegaY, OmegaZ, " + + "CameraEyeOffsetX, CameraEyeOffsetY, " + + "CameraEyeOffsetZ, CameraAtOffsetX, " + + "CameraAtOffsetY, CameraAtOffsetZ, " + + "ForceMouselook, ScriptAccessPin, " + + "AllowedDrop, DieAtEdge, " + + "SalePrice, SaleType, " + + "ColorR, ColorG, ColorB, ColorA, " + + "ParticleSystem, ClickAction, Material, " + + "CollisionSound, CollisionSoundVolume, " + + "PassTouches, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + + "?CreationDate, ?Name, ?Text, " + + "?Description, ?SitName, ?TouchName, " + + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + + "?GroupMask, ?EveryoneMask, ?BaseMask, " + + "?PositionX, ?PositionY, ?PositionZ, " + + "?GroupPositionX, ?GroupPositionY, " + + "?GroupPositionZ, ?VelocityX, " + + "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + + "?AngularVelocityY, ?AngularVelocityZ, " + + "?AccelerationX, ?AccelerationY, " + + "?AccelerationZ, ?RotationX, " + + "?RotationY, ?RotationZ, " + + "?RotationW, ?SitTargetOffsetX, " + + "?SitTargetOffsetY, ?SitTargetOffsetZ, " + + "?SitTargetOrientW, ?SitTargetOrientX, " + + "?SitTargetOrientY, ?SitTargetOrientZ, " + + "?RegionUUID, ?CreatorID, ?OwnerID, " + + "?GroupID, ?LastOwnerID, ?SceneGroupID, " + + "?PayPrice, ?PayButton1, ?PayButton2, " + + "?PayButton3, ?PayButton4, ?LoopedSound, " + + "?LoopedSoundGain, ?TextureAnimation, " + + "?OmegaX, ?OmegaY, ?OmegaZ, " + + "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + + "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + + "?CameraAtOffsetY, ?CameraAtOffsetZ, " + + "?ForceMouselook, ?ScriptAccessPin, " + + "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + + "?SaleType, ?ColorR, ?ColorG, " + + "?ColorB, ?ColorA, ?ParticleSystem, " + + "?ClickAction, ?Material, ?CollisionSound, " + + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes (" + + "UUID, Shape, ScaleX, ScaleY, " + + "ScaleZ, PCode, PathBegin, PathEnd, " + + "PathScaleX, PathScaleY, PathShearX, " + + "PathShearY, PathSkew, PathCurve, " + + "PathRadiusOffset, PathRevolutions, " + + "PathTaperX, PathTaperY, PathTwist, " + + "PathTwistBegin, ProfileBegin, ProfileEnd, " + + "ProfileCurve, ProfileHollow, Texture, " + + "ExtraParams, State, Media) values (?UUID, " + + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + + "?PCode, ?PathBegin, ?PathEnd, " + + "?PathScaleX, ?PathScaleY, " + + "?PathShearX, ?PathShearY, " + + "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + + "?PathRevolutions, ?PathTaperX, " + + "?PathTaperY, ?PathTwist, " + + "?PathTwistBegin, ?ProfileBegin, " + + "?ProfileEnd, ?ProfileCurve, " + + "?ProfileHollow, ?Texture, ?ExtraParams, " + + "?State, ?Media)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); + } + + cmd.Dispose(); + } + } + } + + public void RemoveObject(UUID obj, UUID regionUUID) + { +// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); + + List uuids = new List(); + + // Formerly, this used to check the region UUID. + // That makes no sense, as we remove the contents of a prim + // unconditionally, but the prim dependent on the region ID. + // So, we would destroy an object and cause hard to detect + // issues if we delete the contents only. Deleting it all may + // cause the loss of a prim, but is cleaner. + // It's also faster because it uses the primary key. + // + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; + cmd.Parameters.AddWithValue("UUID", obj.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + uuids.Add(DBGuid.FromDB(reader["UUID"].ToString())); + } + + // delete the main prims + cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; + ExecuteNonQuery(cmd); + } + } + } + + // there is no way this should be < 1 unless there is + // a very corrupt database, but in that case be extra + // safe anyway. + if (uuids.Count > 0) + { + RemoveShapes(uuids); + RemoveItems(uuids); + } + } + + /// + /// Remove all persisted items of the given prim. + /// The caller must acquire the necessrary synchronization locks + /// + /// the Item UUID + private void RemoveItems(UUID uuid) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; + cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); + + ExecuteNonQuery(cmd); + } + } + } + } + + /// + /// Remove all persisted shapes for a list of prims + /// The caller must acquire the necessrary synchronization locks + /// + /// the list of UUIDs + private void RemoveShapes(List uuids) + { + lock (m_dbLock) + { + string sql = "delete from primshapes where "; + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + for (int i = 0; i < uuids.Count; i++) + { + if ((i + 1) == uuids.Count) + {// end of the list + sql += "(UUID = ?UUID" + i + ")"; + } + else + { + sql += "(UUID = ?UUID" + i + ") or "; + } + } + cmd.CommandText = sql; + + for (int i = 0; i < uuids.Count; i++) + cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); + + ExecuteNonQuery(cmd); + } + } + } + } + + /// + /// Remove all persisted items for a list of prims + /// The caller must acquire the necessrary synchronization locks + /// + /// the list of UUIDs + private void RemoveItems(List uuids) + { + lock (m_dbLock) + { + string sql = "delete from primitems where "; + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + for (int i = 0; i < uuids.Count; i++) + { + if ((i + 1) == uuids.Count) + { + // end of the list + sql += "(PrimID = ?PrimID" + i + ")"; + } + else + { + sql += "(PrimID = ?PrimID" + i + ") or "; + } + } + cmd.CommandText = sql; + + for (int i = 0; i < uuids.Count; i++) + cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); + + ExecuteNonQuery(cmd); + } + } + } + } + + public List LoadObjects(UUID regionID) + { + const int ROWS_PER_QUERY = 5000; + + Dictionary prims = new Dictionary(ROWS_PER_QUERY); + Dictionary objects = new Dictionary(); + int count = 0; + + #region Prim Loading + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = + "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + { + SceneObjectPart prim = BuildPrim(reader); + if (reader["Shape"] is DBNull) + prim.Shape = PrimitiveBaseShape.Default; + else + prim.Shape = BuildShape(reader); + + UUID parentID = DBGuid.FromDB(reader["SceneGroupID"].ToString()); + if (parentID != prim.UUID) + prim.ParentUUID = parentID; + + prims[prim.UUID] = prim; + + ++count; + if (count % ROWS_PER_QUERY == 0) + m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); + } + } + } + } + } + + #endregion Prim Loading + + #region SceneObjectGroup Creation + + // Create all of the SOGs from the root prims first + foreach (SceneObjectPart prim in prims.Values) + { + if (prim.ParentUUID == UUID.Zero) + objects[prim.UUID] = new SceneObjectGroup(prim); + } + + // Add all of the children objects to the SOGs + foreach (SceneObjectPart prim in prims.Values) + { + SceneObjectGroup sog; + if (prim.UUID != prim.ParentUUID) + { + if (objects.TryGetValue(prim.ParentUUID, out sog)) + { + int originalLinkNum = prim.LinkNum; + + sog.AddPart(prim); + + // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. + // We override that here + if (originalLinkNum != 0) + prim.LinkNum = originalLinkNum; + } + else + { + m_log.WarnFormat( + "[REGION DB]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.", + prim.Name, prim.UUID, regionID, prim.ParentUUID); + } + } + } + + #endregion SceneObjectGroup Creation + + m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); + + #region Prim Inventory Loading + + // Instead of attempting to LoadItems on every prim, + // most of which probably have no items... get a + // list from DB of all prims which have items and + // LoadItems only on those + List primsWithInventory = new List(); + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand itemCmd = dbcon.CreateCommand()) + { + itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; + using (IDataReader itemReader = ExecuteReader(itemCmd)) + { + while (itemReader.Read()) + { + if (!(itemReader["primID"] is DBNull)) + { + UUID primID = DBGuid.FromDB(itemReader["primID"].ToString()); + if (prims.ContainsKey(primID)) + primsWithInventory.Add(prims[primID]); + } + } + } + } + } + } + + foreach (SceneObjectPart prim in primsWithInventory) + { + LoadItems(prim); + } + + #endregion Prim Inventory Loading + + m_log.DebugFormat("[REGION DB]: Loaded inventory from {0} objects", primsWithInventory.Count); + + return new List(objects.Values); + } + + /// + /// Load in a prim's persisted inventory. + /// + /// The prim + private void LoadItems(SceneObjectPart prim) + { + lock (m_dbLock) + { + List inventory = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; + cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + { + TaskInventoryItem item = BuildItem(reader); + + item.ParentID = prim.UUID; // Values in database are often wrong + inventory.Add(item); + } + } + } + } + + prim.Inventory.RestoreInventoryItems(inventory); + } + } + + public void StoreTerrain(double[,] ter, UUID regionID) + { + m_log.Info("[REGION DB]: Storing terrain"); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "insert into terrain (RegionUUID, " + + "Revision, Heightfield) values (?RegionUUID, " + + "1, ?Heightfield)"; + + cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); + + ExecuteNonQuery(cmd); + } + } + } + } + + public double[,] LoadTerrain(UUID regionID) + { + double[,] terrain = null; + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select RegionUUID, Revision, Heightfield " + + "from terrain where RegionUUID = ?RegionUUID " + + "order by Revision desc limit 1"; + cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + { + int rev = Convert.ToInt32(reader["Revision"]); + + terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; + terrain.Initialize(); + + using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) + { + using (BinaryReader br = new BinaryReader(mstr)) + { + for (int x = 0; x < (int)Constants.RegionSize; x++) + { + for (int y = 0; y < (int)Constants.RegionSize; y++) + { + terrain[x, y] = br.ReadDouble(); + } + } + } + + m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); + } + } + } + } + } + } + + return terrain; + } + + public void RemoveLandObject(UUID globalID) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from land where UUID = ?UUID"; + cmd.Parameters.AddWithValue("UUID", globalID.ToString()); + + ExecuteNonQuery(cmd); + } + } + } + } + + public void StoreLandObject(ILandObject parcel) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into land (UUID, RegionUUID, " + + "LocalLandID, Bitmap, Name, Description, " + + "OwnerUUID, IsGroupOwned, Area, AuctionID, " + + "Category, ClaimDate, ClaimPrice, GroupUUID, " + + "SalePrice, LandStatus, LandFlags, LandingType, " + + "MediaAutoScale, MediaTextureUUID, MediaURL, " + + "MusicURL, PassHours, PassPrice, SnapshotUUID, " + + "UserLocationX, UserLocationY, UserLocationZ, " + + "UserLookAtX, UserLookAtY, UserLookAtZ, " + + "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + + "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + + "?UUID, ?RegionUUID, " + + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + + "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + + "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + + "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + + "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + + "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ + "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; + + FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); + + ExecuteNonQuery(cmd); + + cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + cmd.CommandText = "insert into landaccesslist (LandUUID, " + + "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + + "?Flags)"; + + foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + { + FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); + ExecuteNonQuery(cmd); + cmd.Parameters.Clear(); + } + } + } + } + } + + public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) + { + RegionLightShareData nWP = new RegionLightShareData(); + nWP.OnSave += StoreRegionWindlightSettings; + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + string command = "select * from `regionwindlight` where region_id = ?regionID"; + + using(MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) + { + //No result, so store our default windlight profile and return it + nWP.regionID = regionUUID; + StoreRegionWindlightSettings(nWP); + return nWP; + } + else + { + nWP.regionID = DBGuid.FromDB(result["region_id"]); + nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); + nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); + nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); + nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); + nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); + nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); + nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); + nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); + nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); + nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); + nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); + nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); + nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); + nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); + nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); + nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); + nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); + UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); + nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); + nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); + nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); + nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); + nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); + nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); + nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); + nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); + nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); + nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); + nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); + nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); + nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); + nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); + nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); + nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); + nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); + nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); + nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); + nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); + nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); + nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); + nWP.eastAngle = Convert.ToSingle(result["east_angle"]); + nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); + nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); + nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); + nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); + nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); + nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); + nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); + nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); + nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); + nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); + nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); + nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); + nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); + nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); + nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); + nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); + nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); + nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); + nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); + nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); + nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); + } + } + } + return nWP; + } + + public RegionSettings LoadRegionSettings(UUID regionUUID) + { + RegionSettings rs = null; + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("regionUUID", regionUUID); + + using (IDataReader reader = ExecuteReader(cmd)) + { + if (reader.Read()) + { + rs = BuildRegionSettings(reader); + rs.OnSave += StoreRegionSettings; + } + else + { + rs = new RegionSettings(); + rs.RegionUUID = regionUUID; + rs.OnSave += StoreRegionSettings; + + StoreRegionSettings(rs); + } + } + } + } + } + + return rs; + } + + public void StoreRegionWindlightSettings(RegionLightShareData wl) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; + cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; + cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; + cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; + cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; + cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; + cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; + cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; + cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; + cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; + cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; + cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; + cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; + cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; + cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; + cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; + cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; + cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; + cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; + cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; + cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; + cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; + cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; + cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; + cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; + + cmd.Parameters.AddWithValue("region_id", wl.regionID); + cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); + cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); + cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); + cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); + cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); + cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); + cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); + cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); + cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); + cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); + cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); + cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); + cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); + cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); + cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); + cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); + cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); + cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); + cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); + cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); + cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); + cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); + cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); + cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); + cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); + cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); + cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); + cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); + cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); + cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); + cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); + cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); + cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); + cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); + cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); + cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); + cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); + cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); + cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); + cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); + cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); + cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); + cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); + cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); + cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); + cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); + cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); + cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); + cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); + cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); + cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); + cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); + cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); + cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); + cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); + + ExecuteNonQuery(cmd); + } + } + } + + public void StoreRegionSettings(RegionSettings rs) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, " + + "elevation_2_se, elevation_1_sw, " + + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz, loaded_creation_datetime, " + + "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + + "?LoadedCreationDateTime, ?LoadedCreationID, " + + "?TerrainImageID)"; + + FillRegionSettingsCommand(cmd, rs); + + ExecuteNonQuery(cmd); + } + } + } + } + + public List LoadLandObjects(UUID regionUUID) + { + List landData = new List(); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + { + LandData newLand = BuildLandData(reader); + landData.Add(newLand); + } + } + } + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + foreach (LandData land in landData) + { + cmd.Parameters.Clear(); + cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; + cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); + + using (IDataReader reader = ExecuteReader(cmd)) + { + while (reader.Read()) + { + land.ParcelAccessList.Add(BuildLandAccessData(reader)); + } + } + } + } + } + } + + return landData; + } + + public void Shutdown() + { + } + + private SceneObjectPart BuildPrim(IDataReader row) + { + SceneObjectPart prim = new SceneObjectPart(); + + // depending on the MySQL connector version, CHAR(36) may be already converted to Guid! + prim.UUID = DBGuid.FromDB(row["UUID"]); + prim.CreatorID = DBGuid.FromDB(row["CreatorID"]); + prim.OwnerID = DBGuid.FromDB(row["OwnerID"]); + prim.GroupID = DBGuid.FromDB(row["GroupID"]); + prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]); + + // explicit conversion of integers is required, which sort + // of sucks. No idea if there is a shortcut here or not. + prim.CreationDate = (int)row["CreationDate"]; + if (row["Name"] != DBNull.Value) + prim.Name = (string)row["Name"]; + else + prim.Name = String.Empty; + // Various text fields + prim.Text = (string)row["Text"]; + prim.Color = Color.FromArgb((int)row["ColorA"], + (int)row["ColorR"], + (int)row["ColorG"], + (int)row["ColorB"]); + prim.Description = (string)row["Description"]; + prim.SitName = (string)row["SitName"]; + prim.TouchName = (string)row["TouchName"]; + // Permissions + prim.Flags = (PrimFlags)(int)row["ObjectFlags"]; + prim.OwnerMask = (uint)(int)row["OwnerMask"]; + prim.NextOwnerMask = (uint)(int)row["NextOwnerMask"]; + prim.GroupMask = (uint)(int)row["GroupMask"]; + prim.EveryoneMask = (uint)(int)row["EveryoneMask"]; + prim.BaseMask = (uint)(int)row["BaseMask"]; + + // Vectors + prim.OffsetPosition = new Vector3( + (float)(double)row["PositionX"], + (float)(double)row["PositionY"], + (float)(double)row["PositionZ"] + ); + prim.GroupPosition = new Vector3( + (float)(double)row["GroupPositionX"], + (float)(double)row["GroupPositionY"], + (float)(double)row["GroupPositionZ"] + ); + prim.Velocity = new Vector3( + (float)(double)row["VelocityX"], + (float)(double)row["VelocityY"], + (float)(double)row["VelocityZ"] + ); + prim.AngularVelocity = new Vector3( + (float)(double)row["AngularVelocityX"], + (float)(double)row["AngularVelocityY"], + (float)(double)row["AngularVelocityZ"] + ); + prim.Acceleration = new Vector3( + (float)(double)row["AccelerationX"], + (float)(double)row["AccelerationY"], + (float)(double)row["AccelerationZ"] + ); + // quaternions + prim.RotationOffset = new Quaternion( + (float)(double)row["RotationX"], + (float)(double)row["RotationY"], + (float)(double)row["RotationZ"], + (float)(double)row["RotationW"] + ); + prim.SitTargetPositionLL = new Vector3( + (float)(double)row["SitTargetOffsetX"], + (float)(double)row["SitTargetOffsetY"], + (float)(double)row["SitTargetOffsetZ"] + ); + prim.SitTargetOrientationLL = new Quaternion( + (float)(double)row["SitTargetOrientX"], + (float)(double)row["SitTargetOrientY"], + (float)(double)row["SitTargetOrientZ"], + (float)(double)row["SitTargetOrientW"] + ); + + prim.PayPrice[0] = (int)row["PayPrice"]; + prim.PayPrice[1] = (int)row["PayButton1"]; + prim.PayPrice[2] = (int)row["PayButton2"]; + prim.PayPrice[3] = (int)row["PayButton3"]; + prim.PayPrice[4] = (int)row["PayButton4"]; + + prim.Sound = DBGuid.FromDB(row["LoopedSound"].ToString()); + prim.SoundGain = (float)(double)row["LoopedSoundGain"]; + prim.SoundFlags = 1; // If it's persisted at all, it's looped + + if (!(row["TextureAnimation"] is DBNull)) + prim.TextureAnimation = (byte[])row["TextureAnimation"]; + if (!(row["ParticleSystem"] is DBNull)) + prim.ParticleSystem = (byte[])row["ParticleSystem"]; + + prim.AngularVelocity = new Vector3( + (float)(double)row["OmegaX"], + (float)(double)row["OmegaY"], + (float)(double)row["OmegaZ"] + ); + + prim.SetCameraEyeOffset(new Vector3( + (float)(double)row["CameraEyeOffsetX"], + (float)(double)row["CameraEyeOffsetY"], + (float)(double)row["CameraEyeOffsetZ"] + )); + + prim.SetCameraAtOffset(new Vector3( + (float)(double)row["CameraAtOffsetX"], + (float)(double)row["CameraAtOffsetY"], + (float)(double)row["CameraAtOffsetZ"] + )); + + prim.SetForceMouselook((sbyte)row["ForceMouselook"] != 0); + prim.ScriptAccessPin = (int)row["ScriptAccessPin"]; + prim.AllowedDrop = ((sbyte)row["AllowedDrop"] != 0); + prim.DIE_AT_EDGE = ((sbyte)row["DieAtEdge"] != 0); + + prim.SalePrice = (int)row["SalePrice"]; + prim.ObjectSaleType = unchecked((byte)(sbyte)row["SaleType"]); + + prim.Material = unchecked((byte)(sbyte)row["Material"]); + + if (!(row["ClickAction"] is DBNull)) + prim.ClickAction = unchecked((byte)(sbyte)row["ClickAction"]); + + prim.CollisionSound = DBGuid.FromDB(row["CollisionSound"]); + prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; + + prim.PassTouches = ((sbyte)row["PassTouches"] != 0); + prim.LinkNum = (int)row["LinkNumber"]; + + if (!(row["MediaURL"] is System.DBNull)) + prim.MediaUrl = (string)row["MediaURL"]; + + return prim; + } + + + /// + /// Build a prim inventory item from the persisted data. + /// + /// + /// + private static TaskInventoryItem BuildItem(IDataReader row) + { + TaskInventoryItem taskItem = new TaskInventoryItem(); + + taskItem.ItemID = DBGuid.FromDB(row["itemID"]); + taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); + taskItem.AssetID = DBGuid.FromDB(row["assetID"]); + taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); + + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); + + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorID = DBGuid.FromDB(row["creatorID"]); + taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); + taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); + taskItem.GroupID = DBGuid.FromDB(row["groupID"]); + + taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); + taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); + taskItem.Flags = Convert.ToUInt32(row["flags"]); + + return taskItem; + } + + private static RegionSettings BuildRegionSettings(IDataReader row) + { + RegionSettings newSettings = new RegionSettings(); + + newSettings.RegionUUID = DBGuid.FromDB(row["regionUUID"]); + newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); + newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); + newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); + newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); + newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); + newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); + newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); + newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); + newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); + newSettings.Maturity = Convert.ToInt32(row["maturity"]); + newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); + newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); + newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); + newSettings.TerrainTexture1 = DBGuid.FromDB(row["terrain_texture_1"]); + newSettings.TerrainTexture2 = DBGuid.FromDB(row["terrain_texture_2"]); + newSettings.TerrainTexture3 = DBGuid.FromDB(row["terrain_texture_3"]); + newSettings.TerrainTexture4 = DBGuid.FromDB(row["terrain_texture_4"]); + newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); + newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); + newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); + newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); + newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); + newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); + newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); + newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); + newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); + newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); + newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); + newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); + newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); + newSettings.SunVector = new Vector3 ( + Convert.ToSingle(row["sunvectorx"]), + Convert.ToSingle(row["sunvectory"]), + Convert.ToSingle(row["sunvectorz"]) + ); + newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); + newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); + newSettings.Covenant = DBGuid.FromDB(row["covenant"]); + + newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); + + if (row["loaded_creation_id"] is DBNull) + newSettings.LoadedCreationID = ""; + else + newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; + + newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); + + return newSettings; + } + + /// + /// + /// + /// + /// + private static LandData BuildLandData(IDataReader row) + { + LandData newData = new LandData(); + + newData.GlobalID = DBGuid.FromDB(row["UUID"]); + newData.LocalID = Convert.ToInt32(row["LocalLandID"]); + + // Bitmap is a byte[512] + newData.Bitmap = (Byte[]) row["Bitmap"]; + + newData.Name = (String) row["Name"]; + newData.Description = (String) row["Description"]; + newData.OwnerID = DBGuid.FromDB(row["OwnerUUID"]); + newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); + newData.Area = Convert.ToInt32(row["Area"]); + newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented + newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory + newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); + newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.GroupID = DBGuid.FromDB(row["GroupUUID"]); + newData.SalePrice = Convert.ToInt32(row["SalePrice"]); + newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus + newData.Flags = Convert.ToUInt32(row["LandFlags"]); + newData.LandingType = Convert.ToByte(row["LandingType"]); + newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); + newData.MediaID = DBGuid.FromDB(row["MediaTextureUUID"]); + newData.MediaURL = (String) row["MediaURL"]; + newData.MusicURL = (String) row["MusicURL"]; + newData.PassHours = Convert.ToSingle(row["PassHours"]); + newData.PassPrice = Convert.ToInt32(row["PassPrice"]); + UUID authedbuyer = UUID.Zero; + UUID snapshotID = UUID.Zero; + + UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); + UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); + newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); + + newData.AuthBuyerID = authedbuyer; + newData.SnapshotID = snapshotID; + try + { + newData.UserLocation = + new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.UserLookAt = + new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); + } + catch (InvalidCastException) + { + newData.UserLocation = Vector3.Zero; + newData.UserLookAt = Vector3.Zero; + m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); + } + + newData.MediaDescription = (string) row["MediaDescription"]; + newData.MediaType = (string) row["MediaType"]; + newData.MediaWidth = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[0]); + newData.MediaHeight = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[1]); + newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); + newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); + newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); + + newData.ParcelAccessList = new List(); + + return newData; + } + + /// + /// + /// + /// + /// + private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = DBGuid.FromDB(row["AccessUUID"]); + entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); + entry.Time = new DateTime(); + return entry; + } + + /// + /// + /// + /// + /// + private static Array SerializeTerrain(double[,] val) + { + MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); + BinaryWriter bw = new BinaryWriter(str); + + // TODO: COMPATIBILITY - Add byte-order conversions + for (int x = 0; x < (int)Constants.RegionSize; x++) + for (int y = 0; y < (int)Constants.RegionSize; y++) + { + double height = val[x, y]; + if (height == 0.0) + height = double.Epsilon; + + bw.Write(height); + } + + return str.ToArray(); + } + + /// + /// Fill the prim command with prim values + /// + /// + /// + /// + /// + private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) + { + cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate); + cmd.Parameters.AddWithValue("Name", prim.Name); + cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString()); + // the UUID of the root part for this SceneObjectGroup + // various text fields + cmd.Parameters.AddWithValue("Text", prim.Text); + cmd.Parameters.AddWithValue("ColorR", prim.Color.R); + cmd.Parameters.AddWithValue("ColorG", prim.Color.G); + cmd.Parameters.AddWithValue("ColorB", prim.Color.B); + cmd.Parameters.AddWithValue("ColorA", prim.Color.A); + cmd.Parameters.AddWithValue("Description", prim.Description); + cmd.Parameters.AddWithValue("SitName", prim.SitName); + cmd.Parameters.AddWithValue("TouchName", prim.TouchName); + // permissions + cmd.Parameters.AddWithValue("ObjectFlags", (uint)prim.Flags); + cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); + cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); + cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); + cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); + cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask); + cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask); + cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask); + cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask); + cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask); + // vectors + cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X); + cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y); + cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z); + cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X); + cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y); + cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z); + cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X); + cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y); + cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z); + cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z); + cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X); + cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y); + cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z); + // quaternions + cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X); + cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y); + cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z); + cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W); + + // Sit target + Vector3 sitTargetPos = prim.SitTargetPositionLL; + cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X); + cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y); + cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z); + + Quaternion sitTargetOrient = prim.SitTargetOrientationLL; + cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W); + cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X); + cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y); + cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z); + + cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]); + cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]); + cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]); + cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]); + cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]); + + if ((prim.SoundFlags & 1) != 0) // Looped + { + cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString()); + cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain); + } + else + { + cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero); + cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f); + } + + cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); + cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); + + cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z); + + cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); + cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); + cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z); + + cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X); + cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y); + cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z); + + if (prim.GetForceMouselook()) + cmd.Parameters.AddWithValue("ForceMouselook", 1); + else + cmd.Parameters.AddWithValue("ForceMouselook", 0); + + cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin); + + if (prim.AllowedDrop) + cmd.Parameters.AddWithValue("AllowedDrop", 1); + else + cmd.Parameters.AddWithValue("AllowedDrop", 0); + + if (prim.DIE_AT_EDGE) + cmd.Parameters.AddWithValue("DieAtEdge", 1); + else + cmd.Parameters.AddWithValue("DieAtEdge", 0); + + cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); + cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType))); + + byte clickAction = prim.ClickAction; + cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction))); + + cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material))); + + cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); + cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); + + if (prim.PassTouches) + cmd.Parameters.AddWithValue("PassTouches", 1); + else + cmd.Parameters.AddWithValue("PassTouches", 0); + + cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); + cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + } + + /// + /// + /// + /// + /// + private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem) + { + cmd.Parameters.AddWithValue("itemID", taskItem.ItemID); + cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID); + cmd.Parameters.AddWithValue("assetID", taskItem.AssetID); + cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID); + + cmd.Parameters.AddWithValue("invType", taskItem.InvType); + cmd.Parameters.AddWithValue("assetType", taskItem.Type); + + cmd.Parameters.AddWithValue("name", taskItem.Name); + cmd.Parameters.AddWithValue("description", taskItem.Description); + cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate); + cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID); + cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID); + cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID); + cmd.Parameters.AddWithValue("groupID", taskItem.GroupID); + cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions); + cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions); + cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions); + cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions); + cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions); + cmd.Parameters.AddWithValue("flags", taskItem.Flags); + } + + /// + /// + /// + private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings) + { + cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform); + cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly); + cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage); + cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing); + cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell); + cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide); + cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch); + cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit); + cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus); + cmd.Parameters.AddWithValue("Maturity", settings.Maturity); + cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts); + cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions); + cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics); + cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString()); + cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString()); + cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW); + cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW); + cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE); + cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE); + cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE); + cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE); + cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW); + cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW); + cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight); + cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit); + cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit); + cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun); + cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox); + cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X); + cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y); + cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z); + cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); + cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); + cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); + cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); + cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); + cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); + + } + + /// + /// + /// + /// + /// + /// + private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID) + { + cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString()); + cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); + cmd.Parameters.AddWithValue("LocalLandID", land.LocalID); + + // Bitmap is a byte[512] + cmd.Parameters.AddWithValue("Bitmap", land.Bitmap); + + cmd.Parameters.AddWithValue("Name", land.Name); + cmd.Parameters.AddWithValue("Description", land.Description); + cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString()); + cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned); + cmd.Parameters.AddWithValue("Area", land.Area); + cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented + cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory + cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate); + cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice); + cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString()); + cmd.Parameters.AddWithValue("SalePrice", land.SalePrice); + cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus + cmd.Parameters.AddWithValue("LandFlags", land.Flags); + cmd.Parameters.AddWithValue("LandingType", land.LandingType); + cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale); + cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString()); + cmd.Parameters.AddWithValue("MediaURL", land.MediaURL); + cmd.Parameters.AddWithValue("MusicURL", land.MusicURL); + cmd.Parameters.AddWithValue("PassHours", land.PassHours); + cmd.Parameters.AddWithValue("PassPrice", land.PassPrice); + cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString()); + cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X); + cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y); + cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z); + cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X); + cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y); + cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); + cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); + cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); + cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); + cmd.Parameters.AddWithValue("MediaType", land.MediaType); + cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); + cmd.Parameters.AddWithValue("MediaHeight", land.MediaHeight); + cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); + cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); + cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); + + } + + /// + /// + /// + /// + /// + /// + private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) + { + cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); + cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); + cmd.Parameters.AddWithValue("Flags", entry.Flags); + } + + /// + /// + /// + /// + /// + private PrimitiveBaseShape BuildShape(IDataReader row) + { + PrimitiveBaseShape s = new PrimitiveBaseShape(); + s.Scale = new Vector3( + (float)(double)row["ScaleX"], + (float)(double)row["ScaleY"], + (float)(double)row["ScaleZ"] + ); + // paths + s.PCode = (byte)(int)row["PCode"]; + s.PathBegin = (ushort)(int)row["PathBegin"]; + s.PathEnd = (ushort)(int)row["PathEnd"]; + s.PathScaleX = (byte)(int)row["PathScaleX"]; + s.PathScaleY = (byte)(int)row["PathScaleY"]; + s.PathShearX = (byte)(int)row["PathShearX"]; + s.PathShearY = (byte)(int)row["PathShearY"]; + s.PathSkew = (sbyte)(int)row["PathSkew"]; + s.PathCurve = (byte)(int)row["PathCurve"]; + s.PathRadiusOffset = (sbyte)(int)row["PathRadiusOffset"]; + s.PathRevolutions = (byte)(int)row["PathRevolutions"]; + s.PathTaperX = (sbyte)(int)row["PathTaperX"]; + s.PathTaperY = (sbyte)(int)row["PathTaperY"]; + s.PathTwist = (sbyte)(int)row["PathTwist"]; + s.PathTwistBegin = (sbyte)(int)row["PathTwistBegin"]; + // profile + s.ProfileBegin = (ushort)(int)row["ProfileBegin"]; + s.ProfileEnd = (ushort)(int)row["ProfileEnd"]; + s.ProfileCurve = (byte)(int)row["ProfileCurve"]; + s.ProfileHollow = (ushort)(int)row["ProfileHollow"]; + s.TextureEntry = (byte[])row["Texture"]; + + s.ExtraParams = (byte[])row["ExtraParams"]; + + s.State = (byte)(int)row["State"]; + + if (!(row["Media"] is System.DBNull)) + s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); + + return s; + } + + /// + /// + /// + /// + /// + private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim) + { + PrimitiveBaseShape s = prim.Shape; + cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString()); + // shape is an enum + cmd.Parameters.AddWithValue("Shape", 0); + // vectors + cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X); + cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y); + cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z); + // paths + cmd.Parameters.AddWithValue("PCode", s.PCode); + cmd.Parameters.AddWithValue("PathBegin", s.PathBegin); + cmd.Parameters.AddWithValue("PathEnd", s.PathEnd); + cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX); + cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY); + cmd.Parameters.AddWithValue("PathShearX", s.PathShearX); + cmd.Parameters.AddWithValue("PathShearY", s.PathShearY); + cmd.Parameters.AddWithValue("PathSkew", s.PathSkew); + cmd.Parameters.AddWithValue("PathCurve", s.PathCurve); + cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset); + cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions); + cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX); + cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY); + cmd.Parameters.AddWithValue("PathTwist", s.PathTwist); + cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin); + // profile + cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin); + cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd); + cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve); + cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow); + cmd.Parameters.AddWithValue("Texture", s.TextureEntry); + cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); + cmd.Parameters.AddWithValue("State", s.State); + cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); + } + + public void StorePrimInventory(UUID primID, ICollection items) + { + lock (m_dbLock) + { + RemoveItems(primID); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + MySqlCommand cmd = dbcon.CreateCommand(); + + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems (" + + "invType, assetType, name, " + + "description, creationDate, nextPermissions, " + + "currentPermissions, basePermissions, " + + "everyonePermissions, groupPermissions, " + + "flags, itemID, primID, assetID, " + + "parentFolderID, creatorID, ownerID, " + + "groupID, lastOwnerID) values (?invType, " + + "?assetType, ?name, ?description, " + + "?creationDate, ?nextPermissions, " + + "?currentPermissions, ?basePermissions, " + + "?everyonePermissions, ?groupPermissions, " + + "?flags, ?itemID, ?primID, ?assetID, " + + "?parentFolderID, ?creatorID, ?ownerID, " + + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) + { + cmd.Parameters.Clear(); + + FillItemCommand(cmd, item); + + ExecuteNonQuery(cmd); + } + + cmd.Dispose(); + } + } + } + } +} -- cgit v1.1 From f1f0bc23f4501ba99035283d3407ddad2b21b785 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 12 Sep 2010 13:43:49 -0400 Subject: Formatting cleanup. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- OpenSim/Data/MySQL/MySQLSimulationData.cs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 0aea30f..2dca3eb 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -286,7 +286,7 @@ namespace OpenSim.Data.MySQL InventoryItemBase item = new InventoryItemBase(); // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. - // ( DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero ) + // (DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero) item.CreatorId = reader["creatorID"].ToString(); // Be a bit safer in parsing these because the diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 36f73ef..8201cef 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -680,7 +680,7 @@ namespace OpenSim.Data.MySQL "UserLocationX, UserLocationY, UserLocationZ, " + "UserLookAtX, UserLookAtY, UserLookAtZ, " + "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + - "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + + "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + "?UUID, ?RegionUUID, " + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + @@ -691,7 +691,7 @@ namespace OpenSim.Data.MySQL "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ - "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; + "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); @@ -728,7 +728,7 @@ namespace OpenSim.Data.MySQL string command = "select * from `regionwindlight` where region_id = ?regionID"; - using(MySqlCommand cmd = new MySqlCommand(command)) + using (MySqlCommand cmd = new MySqlCommand(command)) { cmd.Connection = dbcon; @@ -1350,13 +1350,13 @@ namespace OpenSim.Data.MySQL m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); } - newData.MediaDescription = (string) row["MediaDescription"]; - newData.MediaType = (string) row["MediaType"]; - newData.MediaWidth = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[0]); - newData.MediaHeight = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[1]); - newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); - newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); - newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); + newData.MediaDescription = (string) row["MediaDescription"]; + newData.MediaType = (string) row["MediaType"]; + newData.MediaWidth = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[0]); + newData.MediaHeight = Convert.ToInt32((((string) row["MediaSize"]).Split(','))[1]); + newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); + newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); + newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); newData.ParcelAccessList = new List(); @@ -1724,7 +1724,7 @@ namespace OpenSim.Data.MySQL s.State = (byte)(int)row["State"]; - if (!(row["Media"] is System.DBNull)) + if (!(row["Media"] is System.DBNull)) s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); return s; -- cgit v1.1 From 0db1ed0b5a6f5bd104c6008f142d173c84263ce5 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 12 Sep 2010 14:20:26 -0700 Subject: * Added ISimulationDataService and IEstateDataService * Removed StorageManager * CONFIG CHANGE: There are no more database settings in OpenSim.ini. Check the config-include configuration files for region store and estate store database settings --- OpenSim/Data/MySQL/MySQLEstateData.cs | 9 +++++++++ OpenSim/Data/MySQL/MySQLSimulationData.cs | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 9158f7a..c42c687 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -54,6 +54,15 @@ namespace OpenSim.Data.MySQL private Dictionary m_FieldMap = new Dictionary(); + public MySQLEstateStore() + { + } + + public MySQLEstateStore(string connectionString) + { + Initialise(connectionString); + } + public void Initialise(string connectionString) { m_connectionString = connectionString; diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 36f73ef..ac752f6 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -52,6 +52,15 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); + public MySQLSimulationData() + { + } + + public MySQLSimulationData(string connectionString) + { + Initialise(connectionString); + } + public void Initialise(string connectionString) { m_connectionString = connectionString; -- cgit v1.1 From 860b2a502f797e5822c6705d4639f370f3ac5861 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 16 Sep 2010 17:30:46 -0700 Subject: Changed SceneObjectGroup to store parts with the fast and thread-safe MapAndArray collection --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 87f6d07..3450e2f 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -144,7 +144,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); MySqlCommand cmd = dbcon.CreateCommand(); - foreach (SceneObjectPart prim in obj.Children.Values) + foreach (SceneObjectPart prim in obj.Parts) { cmd.Parameters.Clear(); -- cgit v1.1 From 01728fb19e1c23e878197753cb788f94883e5838 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 21 Jun 2010 17:06:05 +0200 Subject: Ensure no UUID.Zero region ID is ever written to presence. Add a Migration to add a LastSeen field of type "Timestamp" to Presence for MySQL --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 4 +++- OpenSim/Data/MySQL/Resources/Presence.migrations | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 71caa1a..7b0016b 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -78,6 +78,9 @@ namespace OpenSim.Data.MySQL if (pd.Length == 0) return false; + if (regionID == UUID.Zero) + return; + MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); @@ -90,6 +93,5 @@ namespace OpenSim.Data.MySQL return true; } - } } diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index 91f7de5..1075a15 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations @@ -13,3 +13,11 @@ CREATE UNIQUE INDEX SessionID ON Presence(SessionID); CREATE INDEX UserID ON Presence(UserID); COMMIT; + +:VERSION 1 # -------------------------- + +BEGIN; + +ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; + +COMMIT; -- cgit v1.1 From ccd5610997020df4ba1aafd73b6717bafecb025b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 21 Jun 2010 23:26:27 +0200 Subject: Correctly update the LastSeen field --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 7b0016b..81a48a8 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -83,7 +83,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); -- cgit v1.1 From aa60c4b129c386ed7518f948435613296cbe65c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Oct 2010 22:18:57 +0100 Subject: fix build break --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 81a48a8..2390feb 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -79,7 +79,7 @@ namespace OpenSim.Data.MySQL return false; if (regionID == UUID.Zero) - return; + return false; MySqlCommand cmd = new MySqlCommand(); -- cgit v1.1 From e039a8c8c23a6a3b2b9a5019de09f758a84c74ec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 15 Oct 2010 15:43:06 -0700 Subject: UPdated the MySql driver to 6.2.4. Also established a much larger MySqlCommand timeout on fetching prims. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3450e2f..e2b6953 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -424,6 +424,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); + cmd.CommandTimeout = 3600; using (IDataReader reader = ExecuteReader(cmd)) { -- cgit v1.1 From 2be93066da042c21d396bb62b58d4d04fa63cbe0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 18 Oct 2010 19:08:26 +0100 Subject: Bump migration version on LastSeen field so it is actually run --- OpenSim/Data/MySQL/Resources/Presence.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index 1075a15..be4030e 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations @@ -14,7 +14,7 @@ CREATE INDEX UserID ON Presence(UserID); COMMIT; -:VERSION 1 # -------------------------- +:VERSION 2 # -------------------------- BEGIN; -- cgit v1.1 From 551015db6382b01d32100e91b569a5717121ccbe Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 18 Oct 2010 20:29:00 +0100 Subject: Alphabetize results on region search by prefix matching --- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index baa948e..efefad9 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -62,6 +62,8 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; + command += " order by regionName"; + using (MySqlCommand cmd = new MySqlCommand(command)) { cmd.Parameters.AddWithValue("?regionName", regionName); -- cgit v1.1 From e98d8d500f5c0dda6e9ef8b9a0e1bddec8510d1d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 30 Oct 2010 19:06:47 +0100 Subject: Fix logins and avatar appearance. Contains a Migration. May contain nuts. This will cause visual params to be persisted along with worn items. With this, alpha and tattoo laters will be saved. Multiple layers MAY work, but not tested because I don't use Viewer 2. --- OpenSim/Data/MySQL/Resources/Avatar.migrations | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/Avatar.migrations b/OpenSim/Data/MySQL/Resources/Avatar.migrations index 8d0eee6..f7cf176 100644 --- a/OpenSim/Data/MySQL/Resources/Avatar.migrations +++ b/OpenSim/Data/MySQL/Resources/Avatar.migrations @@ -10,3 +10,11 @@ CREATE TABLE Avatars ( KEY(PrincipalID)); COMMIT; + +:VERSION 2 + +BEGIN; + +alter table Avatars change column Value Value text; + +COMMIT; -- cgit v1.1 From 4ab9d37a8e556fe7f54d70db922eede861bce812 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 3 Nov 2010 02:04:17 +0000 Subject: When LightShare is enabled, the standard day cycle is bypassed and replaced by midday defaults when no specific LightShare profile is set. This prevents LightShare info being send out when the region has no LightShare profile, allowing normal day/night cycles to happen. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index e2b6953..b53c67b 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -817,6 +817,7 @@ namespace OpenSim.Data.MySQL nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); + nWP.valid = true; } } } -- cgit v1.1 From 6c3b7617b0356f093ef2730f1c517d6228997984 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 3 Nov 2010 02:31:43 +0000 Subject: Add lsClearWindlightScene() to the lightshare module to remove WL settings from a region and allow normal day cycles to be reestablished --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b53c67b..ae78814 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -965,6 +965,21 @@ namespace OpenSim.Data.MySQL } } + public void RemoveRegionWindlightSettings(UUID regionID) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + ExecuteNonQuery(cmd); + } + } + } + public void StoreRegionSettings(RegionSettings rs) { lock (m_dbLock) -- cgit v1.1 From 6a9ae9e7cb71d79e9ec06cf25009e8bf45850dd1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Nov 2010 13:16:52 -0800 Subject: Global creator information working on MySQL DB and on load/save OARs. Creator name properly shown on the viewer as first.last @authority. New option added to save oar -profile=url. Migration on RegionStore making CreatorID be 255 chars. Moved Handling of user UUID -> name requests to a new module UserManagement/UserManagementModule. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 4 ++-- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index ae78814..f630dc1 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1090,7 +1090,7 @@ namespace OpenSim.Data.MySQL // depending on the MySQL connector version, CHAR(36) may be already converted to Guid! prim.UUID = DBGuid.FromDB(row["UUID"]); - prim.CreatorID = DBGuid.FromDB(row["CreatorID"]); + prim.CreatorIdentification = (string)row["CreatorID"]; prim.OwnerID = DBGuid.FromDB(row["OwnerID"]); prim.GroupID = DBGuid.FromDB(row["GroupID"]); prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]); @@ -1453,7 +1453,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("TouchName", prim.TouchName); // permissions cmd.Parameters.AddWithValue("ObjectFlags", (uint)prim.Flags); - cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString()); + cmd.Parameters.AddWithValue("CreatorID", prim.CreatorIdentification.ToString()); cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString()); cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString()); cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString()); diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 1405207..364c4d3 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -817,3 +817,11 @@ ALTER TABLE `land` ADD COLUMN `MediaLoop` BOOLEAN NOT NULL DEFAULT FALSE; ALTER TABLE `land` ADD COLUMN `ObscureMusic` BOOLEAN NOT NULL DEFAULT FALSE; ALTER TABLE `land` ADD COLUMN `ObscureMedia` BOOLEAN NOT NULL DEFAULT FALSE; COMMIT; + +:VERSION 37 #--------------------- + +BEGIN; + +ALTER TABLE `prims` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT ''; + +COMMIT; -- cgit v1.1 From c617d658dda92ad97de678d477a98c3df0659303 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Nov 2010 17:19:24 -0800 Subject: Added creator info across the board -- TaskInventoryItems and InventoryItems themselves. Tested. Seems to be working, main tests pass. Nothing done for IARs or HG transfers yet -- this only works for OARs for the time being. New migration in inventory table in order to make CreatorID varchar(255). --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 4 ++-- OpenSim/Data/MySQL/Resources/InventoryStore.migrations | 8 ++++++++ OpenSim/Data/MySQL/Resources/RegionStore.migrations | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index f630dc1..02997b3 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1243,7 +1243,7 @@ namespace OpenSim.Data.MySQL taskItem.Name = (String)row["name"]; taskItem.Description = (String)row["description"]; taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorID = DBGuid.FromDB(row["creatorID"]); + taskItem.CreatorIdentification = (String)row["creatorID"]; taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); taskItem.GroupID = DBGuid.FromDB(row["groupID"]); @@ -1583,7 +1583,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("name", taskItem.Name); cmd.Parameters.AddWithValue("description", taskItem.Description); cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate); - cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID); + cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorIdentification); cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID); cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID); cmd.Parameters.AddWithValue("groupID", taskItem.GroupID); diff --git a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations index 3e9bad5..993a5a0 100644 --- a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations @@ -99,3 +99,11 @@ BEGIN; alter table inventoryitems modify column creatorID varchar(128) not NULL default '00000000-0000-0000-0000-000000000000'; COMMIT; + +:VERSION 6 # ------------ + +BEGIN; + +alter table inventoryitems modify column creatorID varchar(255) not NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 364c4d3..ba8d538 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -823,5 +823,6 @@ COMMIT; BEGIN; ALTER TABLE `prims` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `primitems` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT ''; COMMIT; -- cgit v1.1 From 72748746d53df1c033207452a4315d93bc780158 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 5 Dec 2010 19:43:24 -0800 Subject: Fixed some inconsistency with trailing /. Made debug messages consistent. Changed the stored region names of HG regions. Increased the size of regionName in DB. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- OpenSim/Data/MySQL/Resources/GridStore.migrations | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index efefad9..d04e3dc 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -212,8 +212,8 @@ namespace OpenSim.Data.MySQL if (data.Data.ContainsKey("locY")) data.Data.Remove("locY"); - if (data.RegionName.Length > 32) - data.RegionName = data.RegionName.Substring(0, 32); + if (data.RegionName.Length > 128) + data.RegionName = data.RegionName.Substring(0, 128); string[] fields = new List(data.Data.Keys).ToArray(); diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations index 523a8ac..eda6dbb 100644 --- a/OpenSim/Data/MySQL/Resources/GridStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations @@ -87,3 +87,10 @@ ALTER TABLE `regions` ADD COLUMN `Token` varchar(255) NOT NULL; COMMIT; +:VERSION 8 # ------------ + +BEGIN; + +alter table regions modify column regionName varchar(128) default NULL; + +COMMIT; -- cgit v1.1 From 75644e0f6e08e5b5866af3a44afcf1308b9513f1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 Jan 2011 00:55:08 +0100 Subject: Prevent activation and deactivation of gestures from clobbering the slam bits --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 2dca3eb..9d70acb 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -867,7 +867,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand sqlCmd = new MySqlCommand( - "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", dbcon)) + "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags & 1", dbcon)) { sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); -- cgit v1.1 From 06e225bc0b881ca38f73b2598263c90c4bd129f2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 Jan 2011 01:31:14 +0000 Subject: Also fix MySQLXInventoryData --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 3c73095..287c4dd 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -130,7 +130,7 @@ namespace OpenSim.Data.MySQL { using (MySqlCommand cmd = new MySqlCommand()) { - cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); + cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags & 1", m_Realm); cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); -- cgit v1.1 From 9923a2ff1002d722ccebea8bf4d71718ed4e2a03 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 8 Mar 2011 09:02:29 -0800 Subject: Pull up Assembly of the MySQL classes as a protected property, so that it can be overwritten in subclasses. That way extensions can decide in which assembly migration resources should be looked up. This is just a refactor -- no functional changes whatsoever. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 10 ++++++---- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 8 +++++++- OpenSim/Data/MySQL/MySQLEstateData.cs | 8 ++++++-- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 7 ++++++- OpenSim/Data/MySQL/MySQLRegionData.cs | 9 ++++++++- OpenSim/Data/MySQL/MySQLSimulationData.cs | 8 ++++++-- 6 files changed, 39 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index ed92f3e..e740232 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -47,6 +47,11 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + #region IPlugin Members public override string Version { get { return "1.0.0.0"; } } @@ -66,13 +71,10 @@ namespace OpenSim.Data.MySQL { m_connectionString = connect; - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, assem, "AssetStore"); + Migration m = new Migration(dbcon, Assembly, "AssetStore"); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 5056aee..8d82f61 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; using System.Data; using OpenMetaverse; using OpenSim.Framework; @@ -42,6 +43,11 @@ namespace OpenSim.Data.MySQL private int m_LastExpire; // private string m_connectionString; + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) { @@ -51,7 +57,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); + Migration m = new Migration(dbcon, Assembly, "AuthStore"); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index c42c687..de72a6a 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -54,6 +54,11 @@ namespace OpenSim.Data.MySQL private Dictionary m_FieldMap = new Dictionary(); + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySQLEstateStore() { } @@ -82,8 +87,7 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - Assembly assem = GetType().Assembly; - Migration m = new Migration(dbcon, assem, "EstateStore"); + Migration m = new Migration(dbcon, Assembly, "EstateStore"); m.Update(); Type t = typeof(EstateSettings); diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 7c23a47..8efe4e9 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -46,6 +46,11 @@ namespace OpenSim.Data.MySQL protected string m_Realm; protected FieldInfo m_DataField = null; + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySQLGenericTableHandler(string connectionString, string realm, string storeName) : base(connectionString) { @@ -57,7 +62,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, storeName); + Migration m = new Migration(dbcon, Assembly, storeName); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index d04e3dc..c20c392 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -29,6 +29,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.Data; +using System.Reflection; + using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; @@ -42,6 +44,11 @@ namespace OpenSim.Data.MySQL private List m_ColumnNames; //private string m_connectionString; + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySqlRegionData(string connectionString, string realm) : base(connectionString) { @@ -51,7 +58,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, "GridStore"); + Migration m = new Migration(dbcon, Assembly, "GridStore"); m.Update(); } } diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 02997b3..e14d775 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -52,6 +52,11 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + public MySQLSimulationData() { } @@ -71,8 +76,7 @@ namespace OpenSim.Data.MySQL // Apply new Migrations // - Assembly assem = GetType().Assembly; - Migration m = new Migration(dbcon, assem, "RegionStore"); + Migration m = new Migration(dbcon, Assembly, "RegionStore"); m.Update(); // Clean dropped attachments -- cgit v1.1 From d3a20a1e9257ecec417e219ebaf079370015f06d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 21:37:06 +0000 Subject: On initial region registration, if the user chooses the option to make the region part of an existing estate, then list the existing region names. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index de72a6a..6d72e82 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -413,6 +413,46 @@ namespace OpenSim.Data.MySQL return DoLoad(cmd, UUID.Zero, false); } } + + public List LoadEstateSettingsAll() + { + List allEstateSettings = new List(); + + List allEstateIds = GetEstatesAll(); + + foreach (int estateId in allEstateIds) + allEstateSettings.Add(LoadEstateSettings(estateId)); + + return allEstateSettings; + } + + public List GetEstatesAll() + { + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select estateID from estate_settings"; + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(Convert.ToInt32(reader["EstateID"])); + } + reader.Close(); + } + } + + dbcon.Close(); + } + + return result; + } public List GetEstates(string search) { -- cgit v1.1 From f58941e89f122c2e1fd54a2f817fb8114e6c80ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 01:30:13 +0100 Subject: Make the "All Estates" option work from the client (this makes chosen changes to all the estates that the user owns). This applies to adding/removing estate users, groups, managers and bans. This is the application of the AllEstates_0.5.patch from http://opensimulator.org/mantis/view.php?id=5420 Thanks very much, Snoopy! --- OpenSim/Data/MySQL/MySQLEstateData.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 6d72e82..86416d1 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -484,6 +484,36 @@ namespace OpenSim.Data.MySQL return result; } + public List GetEstatesByOwner(UUID ownerID) + { + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select estateID from estate_settings where EstateOwner = ?EstateOwner"; + cmd.Parameters.AddWithValue("?EstateOwner", ownerID); + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(Convert.ToInt32(reader["EstateID"])); + } + reader.Close(); + } + } + + + dbcon.Close(); + } + + return result; + } + public bool LinkRegion(UUID regionID, int estateID) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) -- cgit v1.1 From 49d80f5711e1bc1afb6c650038619ade6d9a9e97 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 23:07:56 +0100 Subject: Include code to return more information about the NullReferenceException seen in http://opensimulator.org/mantis/view.php?id=5403 prior to doing something about it. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 8efe4e9..50b6dbe 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -39,6 +39,8 @@ namespace OpenSim.Data.MySQL { public class MySQLGenericTableHandler : MySqlFramework where T: class, new() { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected Dictionary m_Fields = new Dictionary(); @@ -217,7 +219,6 @@ namespace OpenSim.Data.MySQL { using (MySqlCommand cmd = new MySqlCommand()) { - string query = ""; List names = new List(); List values = new List(); @@ -226,6 +227,16 @@ namespace OpenSim.Data.MySQL { names.Add(fi.Name); values.Add("?" + fi.Name); + + // Temporarily return more information about what field is unexpectedly null for + // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the + // InventoryTransferModule or we may be required to substitute a DBNull here. + if (fi.GetValue(row) == null) + throw new NullReferenceException( + string.Format( + "[MYSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null", + fi.Name, row)); + cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); } @@ -268,4 +279,4 @@ namespace OpenSim.Data.MySQL } } } -} +} \ No newline at end of file -- cgit v1.1 From 04ecd748d98e5b66446912debe06af6975e66560 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 May 2011 22:47:41 +0100 Subject: remove further mono compiler warnings --- OpenSim/Data/MySQL/MySQLAvatarData.cs | 2 +- OpenSim/Data/MySQL/MySQLEstateData.cs | 4 ++-- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 2 +- OpenSim/Data/MySQL/MySQLPresenceData.cs | 2 +- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs index 5611302..8c841ab 100644 --- a/OpenSim/Data/MySQL/MySQLAvatarData.cs +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs @@ -43,7 +43,7 @@ namespace OpenSim.Data.MySQL public class MySQLAvatarData : MySQLGenericTableHandler, IAvatarData { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MySQLAvatarData(string connectionString, string realm) : base(connectionString, realm, "Avatar") diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 86416d1..9dcf5e2 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -48,7 +48,7 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private long m_waitTimeout; private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; - private long m_lastConnectionUse; +// private long m_lastConnectionUse; private FieldInfo[] m_Fields; private Dictionary m_FieldMap = @@ -127,7 +127,7 @@ namespace OpenSim.Data.MySQL } } - m_lastConnectionUse = DateTime.Now.Ticks; +// m_lastConnectionUse = DateTime.Now.Ticks; m_log.DebugFormat( "[REGION DB]: Connection wait timeout {0} seconds", diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 50b6dbe..cfffbd8 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL { public class MySQLGenericTableHandler : MySqlFramework where T: class, new() { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_Fields = new Dictionary(); diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 2390feb..fc625f0 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -43,7 +43,7 @@ namespace OpenSim.Data.MySQL public class MySQLPresenceData : MySQLGenericTableHandler, IPresenceData { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MySQLPresenceData(string connectionString, string realm) : base(connectionString, realm, "Presence") diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 287c4dd..481da49 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -189,7 +189,7 @@ namespace OpenSim.Data.MySQL { cmd.ExecuteNonQuery(); } - catch (Exception e) + catch (Exception) { return false; } -- cgit v1.1 From 491279f99afc65860d44765ee7829c7dd5e4e38e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 May 2011 21:49:38 +0100 Subject: Allow item links to be deleted even when other deletes and purges are disabled. If these links are not deleted, then they will build up in the player's inventory until they can no longer log in. Accidental deletion of links due to bugs or other causes is potentially inconvenient but on a par with items being accidentally moved. When a link is deleted, the target of the link is never touched. This is a general solution that accounts for the use of links anywhere in the user's inventory. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 27 ++++++++++++++++++++------ OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 ++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index cfffbd8..754cf72 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -264,18 +264,33 @@ namespace OpenSim.Data.MySQL } } - public virtual bool Delete(string field, string val) + public virtual bool Delete(string field, string key) { + return Delete(new string[] { field }, new string[] { key }); + } + + public virtual bool Delete(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return false; + + List terms = new List(); + using (MySqlCommand cmd = new MySqlCommand()) { + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add("`" + fields[i] + "` = ?" + fields[i]); + } - cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); - cmd.Parameters.AddWithValue(field, val); + string where = String.Join(" and ", terms.ToArray()); - if (ExecuteNonQuery(cmd) > 0) - return true; + string query = String.Format("delete from {0} where {1}", m_Realm, where); - return false; + cmd.CommandText = query; + + return ExecuteNonQuery(cmd) > 0; } } } diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 481da49..caf18a4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -85,11 +85,21 @@ namespace OpenSim.Data.MySQL return m_Folders.Delete(field, val); } + public bool DeleteFolders(string[] fields, string[] vals) + { + return m_Folders.Delete(fields, vals); + } + public bool DeleteItems(string field, string val) { return m_Items.Delete(field, val); } + public bool DeleteItems(string[] fields, string[] vals) + { + return m_Items.Delete(fields, vals); + } + public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); -- cgit v1.1 From 6dcc87b1adeb71a9c83cafa95a95a80c50b62092 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 May 2011 00:23:35 +0100 Subject: Accidentally committed too early Revert "Allow item links to be deleted even when other deletes and purges are disabled." This reverts commit 491279f99afc65860d44765ee7829c7dd5e4e38e. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 27 ++++++-------------------- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 ---------- 2 files changed, 6 insertions(+), 31 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 754cf72..cfffbd8 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -264,33 +264,18 @@ namespace OpenSim.Data.MySQL } } - public virtual bool Delete(string field, string key) + public virtual bool Delete(string field, string val) { - return Delete(new string[] { field }, new string[] { key }); - } - - public virtual bool Delete(string[] fields, string[] keys) - { - if (fields.Length != keys.Length) - return false; - - List terms = new List(); - using (MySqlCommand cmd = new MySqlCommand()) { - for (int i = 0 ; i < fields.Length ; i++) - { - cmd.Parameters.AddWithValue(fields[i], keys[i]); - terms.Add("`" + fields[i] + "` = ?" + fields[i]); - } - - string where = String.Join(" and ", terms.ToArray()); - string query = String.Format("delete from {0} where {1}", m_Realm, where); + cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); + cmd.Parameters.AddWithValue(field, val); - cmd.CommandText = query; + if (ExecuteNonQuery(cmd) > 0) + return true; - return ExecuteNonQuery(cmd) > 0; + return false; } } } diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index caf18a4..481da49 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -85,21 +85,11 @@ namespace OpenSim.Data.MySQL return m_Folders.Delete(field, val); } - public bool DeleteFolders(string[] fields, string[] vals) - { - return m_Folders.Delete(fields, vals); - } - public bool DeleteItems(string field, string val) { return m_Items.Delete(field, val); } - public bool DeleteItems(string[] fields, string[] vals) - { - return m_Items.Delete(fields, vals); - } - public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); -- cgit v1.1 From bdd7849094996392417ea3e5080578a04b69afac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 May 2011 00:51:14 +0100 Subject: Allow item links to be deleted even when other deletes and purges are disabled. If these links are not deleted, then they will build up in the player's inventory until they can no longer log in. Accidental deletion of links due to bugs or other causes is potentially inconvenient but on a par with items being accidentally moved. When a link is deleted, the target of the link is never touched. This is a general solution that accounts for the use of links anywhere in the user's inventory. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 27 ++++++++++++++++++++------ OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 ++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index cfffbd8..754cf72 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -264,18 +264,33 @@ namespace OpenSim.Data.MySQL } } - public virtual bool Delete(string field, string val) + public virtual bool Delete(string field, string key) { + return Delete(new string[] { field }, new string[] { key }); + } + + public virtual bool Delete(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return false; + + List terms = new List(); + using (MySqlCommand cmd = new MySqlCommand()) { + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add("`" + fields[i] + "` = ?" + fields[i]); + } - cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); - cmd.Parameters.AddWithValue(field, val); + string where = String.Join(" and ", terms.ToArray()); - if (ExecuteNonQuery(cmd) > 0) - return true; + string query = String.Format("delete from {0} where {1}", m_Realm, where); - return false; + cmd.CommandText = query; + + return ExecuteNonQuery(cmd) > 0; } } } diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 481da49..caf18a4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -85,11 +85,21 @@ namespace OpenSim.Data.MySQL return m_Folders.Delete(field, val); } + public bool DeleteFolders(string[] fields, string[] vals) + { + return m_Folders.Delete(fields, vals); + } + public bool DeleteItems(string field, string val) { return m_Items.Delete(field, val); } + public bool DeleteItems(string[] fields, string[] vals) + { + return m_Items.Delete(fields, vals); + } + public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); -- cgit v1.1 From d21e9c755f004d8fe03b11bc57b810dbd401435a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 19 May 2011 16:54:46 -0700 Subject: HG Friends working to some extent: friendships offered and accepted correctly handled. Friends list showing correct foreign names. TODO: GrantRights. --- OpenSim/Data/MySQL/Resources/FriendsStore.migrations | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index ce713bd..35e5e93 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -21,5 +21,11 @@ INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userf COMMIT; +:VERSION 3 # ------------------------- +BEGIN; + +ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; + +COMMIT; -- cgit v1.1 From 58c53c41de2cae0bb041a2e8121792e136d1edb2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 21 May 2011 16:48:00 -0700 Subject: Fixed permissions bug related to friends in PermissionsModule. Added FriendsData[] GetFriends(string principalID) to IFriendsData and FriendInfo[] GetFriends(string PrincipalID) to IFriendsService. Refactored some more in the FriendsModule. Made client get notification of local friends permissions upon HGLogin. HG Friends object permissions work. --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 663fad6..69fac9d 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -57,6 +57,11 @@ namespace OpenSim.Data.MySQL public FriendsData[] GetFriends(UUID principalID) { + return GetFriends(principalID.ToString()); + } + + public FriendsData[] GetFriends(string principalID) + { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); -- cgit v1.1 From 336665e03532cf9d7a1ad65d5071e7050bf6ecd0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 22 May 2011 16:51:03 -0700 Subject: More on HG Friends. Added Delete(string, string) across the board. Added security to friendship identifiers so that they can safely be deleted across worlds. Had to change Get(string) to use LIKE because the secret in the identifier is not always known -- affects only HG visitors. BOTTOM LINE SO FAR: HG friendships established and deleted safely across grids, local rights working but not (yet?) being transmitted back. --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 69fac9d..130ba5e 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -44,6 +44,11 @@ namespace OpenSim.Data.MySQL public bool Delete(UUID principalID, string friend) { + return Delete(principalID.ToString(), friend); + } + + public bool Delete(string principalID, string friend) + { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); @@ -57,16 +62,20 @@ namespace OpenSim.Data.MySQL public FriendsData[] GetFriends(UUID principalID) { - return GetFriends(principalID.ToString()); + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + + return DoQuery(cmd); } public FriendsData[] GetFriends(string principalID) { MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); - cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); - + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); return DoQuery(cmd); } } -- cgit v1.1 From 3fa54a156a83e498a7d5d0949a5f848fe82fe86f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 1 Jun 2011 20:02:26 -0700 Subject: Changed Friends table to have 165-sized varchars on PrincipalID and FriendID. The reason for this number is the following: there is a combined key of these 2 fields; apparently MySql can't handle keys larger than 1000 bytes; when the table is created with utf8 encoding, this combined key is bigger than 1000 bytes, and the migration fails. WARNING: this is not a new migration! People who have gone through this migration and failed should update the sizes of these fields manually. --- OpenSim/Data/MySQL/Resources/FriendsStore.migrations | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 35e5e93..5abacf5 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -25,7 +25,8 @@ COMMIT; BEGIN; -ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(165) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +ALTER TABLE `Friends` MODIFY COLUMN Friend varchar(165) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; -- cgit v1.1 From 43ecc46a224d07661af42379f12f394e1bd873fd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 1 Jun 2011 20:09:59 -0700 Subject: It looks like there's a better solution for that problem. Revert "Changed Friends table to have 165-sized varchars on PrincipalID and FriendID. The reason for this number is the following: there is a combined key of these 2 fields; apparently MySql can't handle keys larger than 1000 bytes; when the table is created with utf8 encoding, this combined key is bigger than 1000 bytes, and the migration fails. WARNING: this is not a new migration! People who have gone through this migration and failed should update the sizes of these fields manually." This reverts commit 3fa54a156a83e498a7d5d0949a5f848fe82fe86f. --- OpenSim/Data/MySQL/Resources/FriendsStore.migrations | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 5abacf5..35e5e93 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -25,8 +25,7 @@ COMMIT; BEGIN; -ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(165) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; -ALTER TABLE `Friends` MODIFY COLUMN Friend varchar(165) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; -- cgit v1.1 From c13acdf5a1a94df9b0ef50b7b2739a9256656582 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 1 Jun 2011 20:19:22 -0700 Subject: This is the better solution: make the combined key be only on the first 36 characters of each field -- that's the UUIDs. Thanks coyled. WARNING: Again, people who have gone through this migration and failed need to run it manually. --- OpenSim/Data/MySQL/Resources/FriendsStore.migrations | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 35e5e93..7848e49 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -25,7 +25,8 @@ COMMIT; BEGIN; +ALTER TABLE `Friends` DROP PRIMARY KEY; +ALTER TABLE `Friends` ADD PRIMARY KEY(PrincipalID(36), Friend(36)); ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; - -- cgit v1.1 From 9149ef6c89a5dd5de144022530e5a4facdc91919 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 10 Jun 2011 02:33:50 +0100 Subject: For MySQL, migrate region tables to the MyISAM storage engine rather than InnoDB Using MyISAM proves vastly faster for persisting scene objects. For instance, a scene object that took 9 seconds to persist before now takes 1. This also improves the experience of loading large OARs. We don't use any of the transactional features of InnoDB. The only thing that may have an impact is that InnoDB does row locking on inserts while MyISAM does table locking. However, field reports say there is no noticeable difference. --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index ba8d538..987625b 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -826,3 +826,19 @@ ALTER TABLE `prims` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT ''; ALTER TABLE `primitems` MODIFY COLUMN `CreatorID` VARCHAR(255) NOT NULL DEFAULT ''; COMMIT; + +:VERSION 38 #--------------------- + +BEGIN; + +alter table land ENGINE = MyISAM; +alter table landaccesslist ENGINE = MyISAM; +alter table migrations ENGINE = MyISAM; +alter table primitems ENGINE = MyISAM; +alter table prims ENGINE = MyISAM; +alter table primshapes ENGINE = MyISAM; +alter table regionban ENGINE = MyISAM; +alter table regionsettings ENGINE = MyISAM; +alter table terrain ENGINE = MyISAM; + +COMMIT; \ No newline at end of file -- cgit v1.1 From d99277939750247ad100395394720c73a3580c72 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 11 Jun 2011 09:36:57 -0700 Subject: Switched order of SQL statements in Friends migration -- resulted in the wrong key --- OpenSim/Data/MySQL/Resources/FriendsStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 7848e49..55d82ec 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -25,8 +25,8 @@ COMMIT; BEGIN; +ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; ALTER TABLE `Friends` DROP PRIMARY KEY; ALTER TABLE `Friends` ADD PRIMARY KEY(PrincipalID(36), Friend(36)); -ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; -- cgit v1.1 From 6b51d8a10e44eed7c39b58aab256789ab188ecca Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 23:24:41 +0100 Subject: In the asset service, check that an asset exists before attempting to store it. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index e740232..a743479 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -251,12 +251,14 @@ namespace OpenSim.Data.MySQL } /// - /// check if the asset UUID exist in database + /// Check if the asset exists in the database /// /// The asset UUID - /// true if exist. + /// true if it exists, false otherwise. override public bool ExistsAsset(UUID uuid) { +// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); + bool assetExists = false; lock (m_dbLock) @@ -273,7 +275,10 @@ namespace OpenSim.Data.MySQL using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (dbReader.Read()) + { +// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); assetExists = true; + } } } catch (Exception e) -- cgit v1.1 From 1bf29d60e1a6839a1b81e0afc656a97f252e13cc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 22:05:05 +0100 Subject: Remove code which was automatically deleting non-root prims from scene objects that had previous been attachments. Looks like this code was accidentally uncommented in e1b5c612 from feb 2010. Appears to resolve the rest of http://opensimulator.org/mantis/view.php?id=5664 --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index e14d775..96ecea6 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -78,23 +78,6 @@ namespace OpenSim.Data.MySQL // Migration m = new Migration(dbcon, Assembly, "RegionStore"); m.Update(); - - // Clean dropped attachments - // - try - { - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from prims, primshapes using prims " + - "left join primshapes on prims.uuid = primshapes.uuid " + - "where PCode = 9 and State <> 0"; - ExecuteNonQuery(cmd); - } - } - catch (MySqlException ex) - { - m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); - } } } -- cgit v1.1 From 086bf9f15db05ca2be1cf0dda24f8ee7a368988d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Sep 2011 00:29:59 +0100 Subject: Save the default terrain texture UUIDs for a new region instead of leaving them as UUID.Zero. Leaving them at UUID.Zero meant that when a viewer 2 logged into a region that had been freshly created, it received UUID.Zero for these textures, and hence display the land as plain white. On a simulator restart, the problem would go away since when the database adapators loaded the new region settings, RegionSettings itself has code to use default textures instead of UUID.Zero. This commit resolves the problem by saving the default texture UUIDs instead of Zero. However, we currently have to do this in a roundabout way by resaving once the RegionSettings have been created by the database for the first time. This needless complexity should be addressed. This change will also have the effect of replacing any existing UUID.Zero terrain textures with the default ones. However, this shouldn't have any effect since the UUID.Zeros were already being replaced in memory with those same UUIDs. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 96ecea6..6d14b82 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1209,7 +1209,6 @@ namespace OpenSim.Data.MySQL return prim; } - /// /// Build a prim inventory item from the persisted data. /// -- cgit v1.1 From 1458fab82c4dab9901d81419e6b515f47ea7320f Mon Sep 17 00:00:00 2001 From: Kevin Houlihan Date: Mon, 12 Sep 2011 23:08:16 +0100 Subject: Reattaching a region was failing if the estate name had not changed (issue 5035). Using the RemoteAdmin API to close then recreate a region would fail if the estate name had not changed. If the estate name /was/ changed then the existing estate would be renamed rather than a new one being created. The problem really arose from a lack of distinction in the data storage layer between creating new estates and loading existing ones. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 123 ++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 44 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 9dcf5e2..3d647ca 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -149,6 +149,22 @@ namespace OpenSim.Data.MySQL } } + public EstateSettings CreateNewEstate() + { + EstateSettings es = new EstateSettings(); + es.OnSave += StoreEstateSettings; + + DoCreate(es); + + LoadBanList(es); + + es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); + es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); + es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); + + return es; + } + private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create) { EstateSettings es = new EstateSettings(); @@ -188,63 +204,65 @@ namespace OpenSim.Data.MySQL if (!found && create) { - // Migration case - List names = new List(FieldList); + DoCreate(es); + LinkRegion(regionID, (int)es.EstateID); + } + } - names.Remove("EstateID"); + LoadBanList(es); - string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; + es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); + es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); + es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); + return es; + } - using (MySqlCommand cmd2 = dbcon.CreateCommand()) - { - cmd2.CommandText = sql; - cmd2.Parameters.Clear(); + private void DoCreate(EstateSettings es) + { + // Migration case + List names = new List(FieldList); - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd2.Parameters.AddWithValue("?" + name, "1"); - else - cmd2.Parameters.AddWithValue("?" + name, "0"); - } - else - { - cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); - } - } + names.Remove("EstateID"); - cmd2.ExecuteNonQuery(); + string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - cmd2.CommandText = "select LAST_INSERT_ID() as id"; - cmd2.Parameters.Clear(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd2 = dbcon.CreateCommand()) + { + cmd2.CommandText = sql; + cmd2.Parameters.Clear(); - using (IDataReader r = cmd2.ExecuteReader()) + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd2.Parameters.AddWithValue("?" + name, "1"); + else + cmd2.Parameters.AddWithValue("?" + name, "0"); + } + else { - r.Read(); - es.EstateID = Convert.ToUInt32(r["id"]); + cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } + } - cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd2.ExecuteNonQuery(); - // This will throw on dupe key - try { cmd2.ExecuteNonQuery(); } - catch (Exception) { } + cmd2.CommandText = "select LAST_INSERT_ID() as id"; + cmd2.Parameters.Clear(); - es.Save(); + using (IDataReader r = cmd2.ExecuteReader()) + { + r.Read(); + es.EstateID = Convert.ToUInt32(r["id"]); } + + es.Save(); } } - - LoadBanList(es); - - es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); - es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); - es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); - return es; } public void StoreEstateSettings(EstateSettings es) @@ -477,7 +495,6 @@ namespace OpenSim.Data.MySQL } } - dbcon.Close(); } @@ -507,7 +524,6 @@ namespace OpenSim.Data.MySQL } } - dbcon.Close(); } @@ -519,16 +535,34 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); + MySqlTransaction transaction = dbcon.BeginTransaction(); try { + // Delete any existing association of this region with an estate. + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.Transaction = transaction; + cmd.CommandText = "delete from estate_map where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", regionID); + + cmd.ExecuteNonQuery(); + } + using (MySqlCommand cmd = dbcon.CreateCommand()) { + cmd.Transaction = transaction; cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; cmd.Parameters.AddWithValue("?RegionID", regionID); cmd.Parameters.AddWithValue("?EstateID", estateID); int ret = cmd.ExecuteNonQuery(); + + if (ret != 0) + transaction.Commit(); + else + transaction.Rollback(); + dbcon.Close(); return (ret != 0); @@ -537,6 +571,7 @@ namespace OpenSim.Data.MySQL catch (MySqlException ex) { m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message); + transaction.Rollback(); } dbcon.Close(); -- cgit v1.1 From aadf7dd91cdeb98b48cd81c5db06481593aff993 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Sep 2011 20:56:32 +0100 Subject: Remove vestigal OpenSim.Data mono addins extension points that don't look like they've been active for at least 2 and a half years --- .../MySQL/Resources/OpenSim.Data.MySQL.addin.xml | 23 ---------------------- 1 file changed, 23 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml b/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml deleted file mode 100644 index 9e99547..0000000 --- a/OpenSim/Data/MySQL/Resources/OpenSim.Data.MySQL.addin.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.1 From a9a24062a5622350cd26203f58f14a209d3b6e72 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 31 Oct 2011 10:18:25 +0100 Subject: Plug a security hole in the inventory service --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 9d70acb..1a634e5 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -794,7 +794,8 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", dbcon)) + // System folders can never be deleted. Period. + using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid and type=-1", dbcon)) { cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); -- cgit v1.1 From 32d58d6e3e9a0ea1bfa808567d0f64c0652f8a85 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 21 Jan 2012 23:26:27 -0500 Subject: Telehub Support: Telehub settings now persist to the database and are saved across sim restarts. So-far this only works on MySQL. this is a work in progress, teleport routing is not yet implemented. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 66 +++++++++++++++++++++- .../Data/MySQL/Resources/EstateStore.migrations | 21 +++++++ 2 files changed, 86 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3d647ca..a357268 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -157,6 +157,7 @@ namespace OpenSim.Data.MySQL DoCreate(es); LoadBanList(es); + LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); @@ -210,7 +211,7 @@ namespace OpenSim.Data.MySQL } LoadBanList(es); - + LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); @@ -297,11 +298,74 @@ namespace OpenSim.Data.MySQL } SaveBanList(es); + SaveSpawnPoints(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); } + private void LoadSpawnPoints(EstateSettings es) + { + es.ClearSpawnPoints(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + uint EstateID = es.EstateID; + cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); + + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + Vector3 point = new Vector3(); + + point.X = (float)r["PointX"]; + point.Y = (float)r["PointY"]; + point.Z = (float)r["PointZ"]; + + es.AddSpawnPoint(point); + } + } + } + } + } + + private void SaveSpawnPoints(EstateSettings es) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from spawn_points where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into spawn_points (EstateID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + + foreach (Vector3 p in es.SpawnPoints()) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?PointX", p.X); + cmd.Parameters.AddWithValue("?PointY", p.Y); + cmd.Parameters.AddWithValue("?PointZ", p.Z); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + } + } + private void LoadBanList(EstateSettings es) { es.ClearBans(); diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index df82a2e..591295b 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -78,4 +78,25 @@ ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; +:VERSION 33 #--------------------- ( Supporting Telehubs +BEGIN; +CREATE TABLE IF NOT EXISTS `spawn_points` ( + `EstateID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, + `PointX` float NOT NULL, + `PointY` float NOT NULL, + `PointZ` float NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=Innodb; + +ALTER TABLE `estate_settings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosX` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosY` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosZ` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotX` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotY` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotZ` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotW` float NOT NULL; +COMMIT; \ No newline at end of file -- cgit v1.1 From 68365c20c0b3a3164881398f3bc3710f7960c52d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 11:36:04 +0000 Subject: Move Telehub tables and data from EstateSettings to RegionSettings. This is damage control es EstateSettings is not the place this can be put. EstateSettings is nt unique to a region and therefore would introduce a hard limit of one telehub per estate, completely shutting off the option of having SL style telehubs, e.g. one per region. Whole estate teleport routing can still be implemented id desiresd, this way all options are open while the other way most options get closed off. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 65 -------------------- OpenSim/Data/MySQL/MySQLSimulationData.cs | 70 ++++++++++++++++++++++ .../Data/MySQL/Resources/EstateStore.migrations | 21 ------- .../Data/MySQL/Resources/RegionStore.migrations | 26 +++++++- 4 files changed, 95 insertions(+), 87 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index a357268..3dd46cb 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -157,7 +157,6 @@ namespace OpenSim.Data.MySQL DoCreate(es); LoadBanList(es); - LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); @@ -211,7 +210,6 @@ namespace OpenSim.Data.MySQL } LoadBanList(es); - LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); @@ -298,74 +296,11 @@ namespace OpenSim.Data.MySQL } SaveBanList(es); - SaveSpawnPoints(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); } - private void LoadSpawnPoints(EstateSettings es) - { - es.ClearSpawnPoints(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - uint EstateID = es.EstateID; - cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - - using (IDataReader r = cmd.ExecuteReader()) - { - while (r.Read()) - { - Vector3 point = new Vector3(); - - point.X = (float)r["PointX"]; - point.Y = (float)r["PointY"]; - point.Z = (float)r["PointZ"]; - - es.AddSpawnPoint(point); - } - } - } - } - } - - private void SaveSpawnPoints(EstateSettings es) - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from spawn_points where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into spawn_points (EstateID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; - - foreach (Vector3 p in es.SpawnPoints()) - { - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?PointX", p.X); - cmd.Parameters.AddWithValue("?PointY", p.Y); - cmd.Parameters.AddWithValue("?PointZ", p.Z); - - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } - } - } - } - private void LoadBanList(EstateSettings es) { es.ClearBans(); diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 6d14b82..3883e24 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -846,6 +846,8 @@ namespace OpenSim.Data.MySQL } } + LoadSpawnPoints(rs); + return rs; } @@ -1017,6 +1019,7 @@ namespace OpenSim.Data.MySQL } } } + SaveSpawnPoints(rs); } public List LoadLandObjects(UUID regionUUID) @@ -1828,5 +1831,72 @@ namespace OpenSim.Data.MySQL } } } + + private void LoadSpawnPoints(RegionSettings rs) + { + rs.ClearSpawnPoints(); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); + + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + Vector3 point = new Vector3(); + + point.X = (float)r["PointX"]; + point.Y = (float)r["PointY"]; + point.Z = (float)r["PointZ"]; + + rs.AddSpawnPoint(point); + } + } + } + } + } + } + + private void SaveSpawnPoints(RegionSettings rs) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from spawn_points where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + + foreach (Vector3 p in rs.SpawnPoints()) + { + cmd.Parameters.AddWithValue("?EstateID", rs.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("?PointX", p.X); + cmd.Parameters.AddWithValue("?PointY", p.Y); + cmd.Parameters.AddWithValue("?PointZ", p.Z); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + } + } + } } } diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index 591295b..df82a2e 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -78,25 +78,4 @@ ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; -:VERSION 33 #--------------------- ( Supporting Telehubs -BEGIN; -CREATE TABLE IF NOT EXISTS `spawn_points` ( - `EstateID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, - `PointX` float NOT NULL, - `PointY` float NOT NULL, - `PointZ` float NOT NULL, - KEY `EstateID` (`EstateID`) -) ENGINE=Innodb; - -ALTER TABLE `estate_settings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosX` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosY` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosZ` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotX` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotY` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotZ` float NOT NULL; -ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotW` float NOT NULL; -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 987625b..ce66cfb 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -841,4 +841,28 @@ alter table regionban ENGINE = MyISAM; alter table regionsettings ENGINE = MyISAM; alter table terrain ENGINE = MyISAM; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 39 #--------------- Telehub support + +BEGIN; +CREATE TABLE IF NOT EXISTS `spawn_points` ( + `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, + `PointX` float NOT NULL, + `PointY` float NOT NULL, + `PointZ` float NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=Innodb; + +ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL; +COMMIT; + -- cgit v1.1 From 24b20f6e4b98b5d7049d2db77d8701529eab75ca Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 15:35:14 +0000 Subject: Change the key name I missed in last commit --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index ce66cfb..3132148 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -851,7 +851,7 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( `PointX` float NOT NULL, `PointY` float NOT NULL, `PointZ` float NOT NULL, - KEY `EstateID` (`EstateID`) + KEY `RegionID` (`RegionID`) ) ENGINE=Innodb; ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -- cgit v1.1 From 1cd26ba85ee50c3b1dea8e3519670866985548fd Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 22 Jan 2012 11:46:16 -0500 Subject: Hooking up new telehub data to the database --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3883e24..a2d5435 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1299,6 +1299,20 @@ namespace OpenSim.Data.MySQL newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); + newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]); + newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); + newSettings.TelehubName = (string) row["TelehubName"]; + newSettings.TelehubPos = new Vector3 ( + Convert.ToSingle(row["TelehubPosX"]), + Convert.ToSingle(row["TelehubPosY"]), + Convert.ToSingle(row["TelehubPosZ"]) + ); + newSettings.TelehubRot = new Quaternion ( + Convert.ToSingle(row["TelehubRotX"]), + Convert.ToSingle(row["TelehubRotY"]), + Convert.ToSingle(row["TelehubRotZ"]), + Convert.ToSingle(row["TelehubRotW"]) + ); return newSettings; } -- cgit v1.1 From 74c1ed77a44c96aed5c0b2c0eb828e6383792bfc Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 22 Jan 2012 14:51:15 -0500 Subject: Finish connecting Telehub to database --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index a2d5435..a48b91b 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -996,7 +996,11 @@ namespace OpenSim.Data.MySQL "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + + "loaded_creation_id, map_tile_ID, " + + "TelehubEnabled, TelehubObject, TelehubName, " + + "TelehubPosX, TelehubPosY, TelehubPosZ, " + + "TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " + + "values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + @@ -1011,7 +1015,10 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID)"; + "?TerrainImageID, " + + "?TelehubEnabled, ?TelehubObject, ?TelehubName, " + + "?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " + + "?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )"; FillRegionSettingsCommand(cmd, rs); @@ -1643,7 +1650,16 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); - + cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub); + cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); + cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName); + cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X); + cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y); + cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z); + cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X); + cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y); + cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z); + cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W); } /// -- cgit v1.1 From 7c404375c7eeecc09228d49cca4d0fe162712a8c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 23:20:10 +0000 Subject: Fix up some parameter naming --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index a48b91b..b94f6ac 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1912,11 +1912,11 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); - cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; foreach (Vector3 p in rs.SpawnPoints()) { - cmd.Parameters.AddWithValue("?EstateID", rs.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); cmd.Parameters.AddWithValue("?PointX", p.X); cmd.Parameters.AddWithValue("?PointY", p.Y); cmd.Parameters.AddWithValue("?PointZ", p.Z); -- cgit v1.1 From 48379e644206bf59e5e2059902f1d7dfd1be5e94 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 23 Jan 2012 21:23:55 +0000 Subject: IMPORTANT!!!!! Please READ. DO NOT Use this version or any before it since the Telehub commits! They will eat your babies and corrupt your database while they munch. DO NOT use anything from the first Telehub commit to this one. FIRST GOOD COMMIT is the one FOLLOWING this one. You have been warned. --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 3132148..720e200 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -848,21 +848,12 @@ COMMIT; BEGIN; CREATE TABLE IF NOT EXISTS `spawn_points` ( `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, - `PointX` float NOT NULL, - `PointY` float NOT NULL, - `PointZ` float NOT NULL, + `Yaw` float NOT NULL, + `Pitch` float NOT NULL, + `Distance` float NOT NULL, KEY `RegionID` (`RegionID`) ) ENGINE=Innodb; ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL; -ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL; COMMIT; -- cgit v1.1 From 87799c1f3ddfbc4b0994cac4e54498520899e4d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 00:32:10 +0000 Subject: Change Telehubs to store only the data that is really needed and not additional redundant information. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 53 ++++++++----------------------- 1 file changed, 13 insertions(+), 40 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b94f6ac..ebb41a5 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -997,9 +997,7 @@ namespace OpenSim.Data.MySQL "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id, map_tile_ID, " + - "TelehubEnabled, TelehubObject, TelehubName, " + - "TelehubPosX, TelehubPosY, TelehubPosZ, " + - "TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " + + "TelehubObject) " + "values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + @@ -1015,10 +1013,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, " + - "?TelehubEnabled, ?TelehubObject, ?TelehubName, " + - "?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " + - "?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )"; + "?TerrainImageID) "; FillRegionSettingsCommand(cmd, rs); @@ -1306,20 +1301,7 @@ namespace OpenSim.Data.MySQL newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); - newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]); newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); - newSettings.TelehubName = (string) row["TelehubName"]; - newSettings.TelehubPos = new Vector3 ( - Convert.ToSingle(row["TelehubPosX"]), - Convert.ToSingle(row["TelehubPosY"]), - Convert.ToSingle(row["TelehubPosZ"]) - ); - newSettings.TelehubRot = new Quaternion ( - Convert.ToSingle(row["TelehubRotX"]), - Convert.ToSingle(row["TelehubRotY"]), - Convert.ToSingle(row["TelehubRotZ"]), - Convert.ToSingle(row["TelehubRotW"]) - ); return newSettings; } @@ -1650,16 +1632,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); - cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); - cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName); - cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X); - cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y); - cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z); - cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X); - cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y); - cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z); - cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W); } /// @@ -1874,20 +1847,20 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; + cmd.CommandText = "select Yaw, Pitch, Distance from spawn_points where RegionID = ?RegionID"; cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); using (IDataReader r = cmd.ExecuteReader()) { while (r.Read()) { - Vector3 point = new Vector3(); + SpawnPoint sp = new SpawnPoint(); - point.X = (float)r["PointX"]; - point.Y = (float)r["PointY"]; - point.Z = (float)r["PointZ"]; + sp.Yaw = (float)r["Yaw"]; + sp.Pitch = (float)r["Pitch"]; + sp.Distance = (float)r["Distance"]; - rs.AddSpawnPoint(point); + rs.AddSpawnPoint(sp); } } } @@ -1912,14 +1885,14 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); - cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; + cmd.CommandText = "insert into spawn_points (RegionID, Yaw, Pitch, Distance) values ( ?RegionID, ?Yaw, ?Pitch, ?Distance)"; - foreach (Vector3 p in rs.SpawnPoints()) + foreach (SpawnPoint p in rs.SpawnPoints()) { cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); - cmd.Parameters.AddWithValue("?PointX", p.X); - cmd.Parameters.AddWithValue("?PointY", p.Y); - cmd.Parameters.AddWithValue("?PointZ", p.Z); + cmd.Parameters.AddWithValue("?Yaw", p.Yaw); + cmd.Parameters.AddWithValue("?Pitch", p.Pitch); + cmd.Parameters.AddWithValue("?Distance", p.Distance); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); -- cgit v1.1 From 7bb01a17eee0a35271c312379be9e528338ec08c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 00:38:00 +0000 Subject: Add a forgotten parameter --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index ebb41a5..31d17f1 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1013,7 +1013,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID) "; + "?TerrainImageID, ?TelehubObject) "; FillRegionSettingsCommand(cmd, rs); -- cgit v1.1 From 3de534896efe4014f50b03624d3b9db82cd92cae Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 16:22:21 +0000 Subject: Add ParcelImageID to RegionSettings so we can have that overlay. Warning: Contains a Migration. Warning: May contain nuts. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 6 ++++-- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 31d17f1..3123edf 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -997,7 +997,7 @@ namespace OpenSim.Data.MySQL "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id, map_tile_ID, " + - "TelehubObject) " + + "TelehubObject, parcel_tile_ID) " + "values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + @@ -1013,7 +1013,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, ?TelehubObject) "; + "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; FillRegionSettingsCommand(cmd, rs); @@ -1301,6 +1301,7 @@ namespace OpenSim.Data.MySQL newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); + newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]); newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); return newSettings; @@ -1632,6 +1633,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); + cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); } diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 720e200..f9b5737 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -857,3 +857,9 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; COMMIT; +:VERSION 40 #---------------- Parcels for sale + +BEGIN; +ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +COMMIT; + -- cgit v1.1 From c4cc626dffd87b6ab28f40c847db2def95e189b7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 30 Jan 2012 20:34:32 +0000 Subject: Add the needed column in the regions table and a few tweaks. Warning: Contains a Migration Warning: Cannot guarantee nut free --- OpenSim/Data/MySQL/Resources/GridStore.migrations | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations index eda6dbb..98ba8c5 100644 --- a/OpenSim/Data/MySQL/Resources/GridStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations @@ -94,3 +94,12 @@ BEGIN; alter table regions modify column regionName varchar(128) default NULL; COMMIT; + +:VERSION 9 # ------------ + +BEGIN; + +alter table regions add column `parcelMapTexture` varchar(36) default NULL; + +COMMIT; + -- cgit v1.1 From 447a66d66005c5ec54a786d1d0a532738729251c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 23:40:56 +0000 Subject: Replace ParcelAccessEntry with a new struct, LandAccessEntry, which more accurately reflects the data sent by the viewer. Add times bans and the expiration of timed bans. Warning: Contains a Migration (and nuts) --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 17 +++++++++-------- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3123edf..3275146 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -700,10 +700,10 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; + "AccessUUID, Flags, Expires) values (?LandUUID, ?AccessUUID, " + + "?Flags, ?Expires)"; - foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + foreach (LandAccessEntry entry in parcel.LandData.ParcelAccessList) { FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); ExecuteNonQuery(cmd); @@ -1377,7 +1377,7 @@ namespace OpenSim.Data.MySQL newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); - newData.ParcelAccessList = new List(); + newData.ParcelAccessList = new List(); return newData; } @@ -1387,12 +1387,12 @@ namespace OpenSim.Data.MySQL /// /// /// - private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) + private static LandAccessEntry BuildLandAccessData(IDataReader row) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry entry = new LandAccessEntry(); entry.AgentID = DBGuid.FromDB(row["AccessUUID"]); entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); - entry.Time = new DateTime(); + entry.Expires = Convert.ToInt32(row["Expires"]); return entry; } @@ -1697,11 +1697,12 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) + private static void FillLandAccessCommand(MySqlCommand cmd, LandAccessEntry entry, UUID parcelID) { cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); cmd.Parameters.AddWithValue("Flags", entry.Flags); + cmd.Parameters.AddWithValue("Expires", entry.Expires.ToString()); } /// diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index f9b5737..642e3b7 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -863,3 +863,9 @@ BEGIN; ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; +:VERSION 41 #---------------- Timed bans/access + +BEGIN; +ALTER TABLE `landaccesslist` ADD COLUMN `Expires` INTEGER NOT NULL DEFAULT 0; +COMMIT; + -- cgit v1.1 From 5c545d1d2e0a1862d063a1bdf80d2cd2fa311101 Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Fri, 3 Feb 2012 22:02:36 +0100 Subject: Fix: Covenant changed time not set http://opensimulator.org/mantis/view.php?id=5869 Signed-off-by: BlueWall --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 7 ++++--- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3275146..7c995ad 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -994,7 +994,7 @@ namespace OpenSim.Data.MySQL "elevation_2_sw, water_height, " + "terrain_raise_limit, terrain_lower_limit, " + "use_estate_sun, fixed_sun, sun_position, " + - "covenant, Sandbox, sunvectorx, sunvectory, " + + "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id, map_tile_ID, " + "TelehubObject, parcel_tile_ID) " + @@ -1010,7 +1010,7 @@ namespace OpenSim.Data.MySQL "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + "?WaterHeight, ?TerrainRaiseLimit, " + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?Sandbox, " + + "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; @@ -1292,7 +1292,7 @@ namespace OpenSim.Data.MySQL newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = DBGuid.FromDB(row["covenant"]); - + newSettings.CovenantChangedDateTime = Convert.ToInt32(row["covenant_datetime"]); newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); if (row["loaded_creation_id"] is DBNull) @@ -1630,6 +1630,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); + cmd.Parameters.AddWithValue("CovenantChangedDateTime", settings.CovenantChangedDateTime); cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 642e3b7..9891f4b 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -869,3 +869,8 @@ BEGIN; ALTER TABLE `landaccesslist` ADD COLUMN `Expires` INTEGER NOT NULL DEFAULT 0; COMMIT; +:VERSION 42 #--------------------- Region Covenant changed time + +BEGIN; +ALTER TABLE regionsettings ADD COLUMN covenant_datetime int unsigned NOT NULL DEFAULT '0'; +COMMIT; -- cgit v1.1 From 6034e5d112b0086cfd4768d58289e301358a2c6a Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 4 Feb 2012 00:28:22 -0500 Subject: Add default value to TelehubObject --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 9891f4b..099beaf 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -874,3 +874,13 @@ COMMIT; BEGIN; ALTER TABLE regionsettings ADD COLUMN covenant_datetime int unsigned NOT NULL DEFAULT '0'; COMMIT; + +:VERSION 43 #--------------------- + +BEGIN; + +ALTER TABLE `regionsettings` MODIFY COLUMN `TelehubObject` VARCHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; + +COMMIT; + + -- cgit v1.1 From 40c838896c18a9ee0283386cdcdc13adec5ae3d6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 29 Feb 2012 00:33:17 +0000 Subject: Use correct casing of RegionSettings.Sandbox in the various database modules. MySQL and MSSQL have it as Sandbox, sqlite as sandbox. In various different places in every plugin the wrong casing is used... Consistency, who needs it? Or one day sqlite can change to Sandbox. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 7c995ad..381a514 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1283,7 +1283,7 @@ namespace OpenSim.Data.MySQL newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); - newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); + newSettings.Sandbox = Convert.ToBoolean(row["Sandbox"]); newSettings.SunVector = new Vector3 ( Convert.ToSingle(row["sunvectorx"]), Convert.ToSingle(row["sunvectory"]), -- cgit v1.1 From be4199c3bc2439b0eb4ea5beef7d5702e55809c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Mar 2012 03:57:55 +0000 Subject: Make XAssetService a de-duplicating asset service. This is an extremely crude implemenation which almost works by accident. Nevertheless it does work. It can be tested with the instructions at http://opensimulator.org/wiki/Feature_Proposals/Deduplicating_Asset_Service#Testing It does not interact at all with the existing asset service or any data stored there. This code is subject to change without notice and should not be used for anything other than gawking. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 416 +++++++++++++++++++++ .../Data/MySQL/Resources/XAssetStore.migrations | 27 ++ 2 files changed, 443 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLXAssetData.cs create mode 100644 OpenSim/Data/MySQL/Resources/XAssetStore.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs new file mode 100644 index 0000000..f15a9f3 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -0,0 +1,416 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Data; +using System.Reflection; +using System.Collections.Generic; +using System.Text; +using log4net; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Data; + +namespace OpenSim.Data.MySQL +{ + public class MySQLXAssetData : AssetDataBase + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_connectionString; + private object m_dbLock = new object(); + + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + + #region IPlugin Members + + public override string Version { get { return "1.0.0.0"; } } + + /// + /// Initialises Asset interface + /// + /// + /// Loads and initialises the MySQL storage plugin. + /// Warns and uses the obsolete mysql_connection.ini if connect string is empty. + /// Check for migration + /// + /// + /// + /// connect string + public override void Initialise(string connect) + { + m_connectionString = connect; + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, Assembly, "XAssetStore"); + m.Update(); + } + } + + public override void Initialise() + { + throw new NotImplementedException(); + } + + public override void Dispose() { } + + /// + /// The name of this DB provider + /// + override public string Name + { + get { return "MySQL XAsset storage engine"; } + } + + #endregion + + #region IAssetDataPlugin Members + + /// + /// Fetch Asset from database + /// + /// Asset UUID to fetch + /// Return the asset + /// On failure : throw an exception and attempt to reconnect to database + override public AssetBase GetAsset(UUID assetID) + { + AssetBase asset = null; + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + string hash = null; + + using (MySqlCommand cmd = new MySqlCommand( + "SELECT name, hash, description, asset_type, local, temporary, asset_flags, creator_id FROM xassetsmeta WHERE id=?id", + dbcon)) + { + cmd.Parameters.AddWithValue("?id", assetID.ToString()); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); + hash = (string)dbReader["hash"]; + asset.Description = (string)dbReader["description"]; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); + } + } + } + catch (Exception e) + { + m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); + } + } + + if (asset == null) + return null; + + m_log.DebugFormat( + "[MYSQL XASSET DATA]: Looking for asset {0} {1} with hash {2}", asset.FullID, asset.Name, hash); + + using (MySqlCommand cmd = new MySqlCommand( + "SELECT data FROM xassetsdata WHERE hash=?hash", + dbcon)) + { + cmd.Parameters.AddWithValue("?hash", hash); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + asset.Data = (byte[])dbReader["data"]; + } + } + catch (Exception e) + { + m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset metadata " + assetID + ": " + e.Message); + } + } + } + } + + return asset; + } + + /// + /// Create an asset in database, or update it if existing. + /// + /// Asset UUID to create + /// On failure : Throw an exception and attempt to reconnect to database + override public void StoreAsset(AssetBase asset) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + string assetName = asset.Name; + if (asset.Name.Length > 64) + { + assetName = asset.Name.Substring(0, 64); + m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + } + + string assetDescription = asset.Description; + if (asset.Description.Length > 64) + { + assetDescription = asset.Description.Substring(0, 64); + m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + } + + string hash = Util.SHA1Hash(asset.Data); + + try + { + using (MySqlCommand cmd = + new MySqlCommand( + "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + + "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", + dbcon)) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?name", assetName); + cmd.Parameters.AddWithValue("?description", assetDescription); + cmd.Parameters.AddWithValue("?asset_type", asset.Type); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?create_time", now); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); + } + + try + { + using (MySqlCommand cmd = + new MySqlCommand( + "replace INTO xassetsdata(hash, data) VALUES(?hash, ?data)", + dbcon)) + { + cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); + } + } + } + } + +// private void UpdateAccessTime(AssetBase asset) +// { +// lock (m_dbLock) +// { +// using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) +// { +// dbcon.Open(); +// MySqlCommand cmd = +// new MySqlCommand("update assets set access_time=?access_time where id=?id", +// dbcon); +// +// // need to ensure we dispose +// try +// { +// using (cmd) +// { +// // create unix epoch time +// int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); +// cmd.Parameters.AddWithValue("?id", asset.ID); +// cmd.Parameters.AddWithValue("?access_time", now); +// cmd.ExecuteNonQuery(); +// cmd.Dispose(); +// } +// } +// catch (Exception e) +// { +// m_log.ErrorFormat( +// "[ASSETS DB]: " + +// "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() +// + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); +// } +// } +// } +// +// } + + /// + /// Check if the asset exists in the database + /// + /// The asset UUID + /// true if it exists, false otherwise. + override public bool ExistsAsset(UUID uuid) + { +// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); + + bool assetExists = false; + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon)) + { + cmd.Parameters.AddWithValue("?id", uuid.ToString()); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { +// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); + assetExists = true; + } + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); + } + } + } + } + + return assetExists; + } + + /// + /// Returns a list of AssetMetadata objects. The list is a subset of + /// the entire data set offset by containing + /// elements. + /// + /// The number of results to discard from the total data set. + /// The number of rows the returned list should contain. + /// A list of AssetMetadata objects. + public override List FetchAssetMetadataSet(int start, int count) + { + List retList = new List(count); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader()) + { + while (dbReader.Read()) + { + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string)dbReader["name"]; + metadata.Description = (string)dbReader["description"]; + metadata.Type = (sbyte)dbReader["asset_type"]; + metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); + metadata.FullID = DBGuid.FromDB(dbReader["id"]); + metadata.CreatorID = dbReader["creator_id"].ToString(); + metadata.SHA1 = Encoding.Default.GetBytes((string)dbReader["hash"]); + + retList.Add(metadata); + } + } + } + catch (Exception e) + { + m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + } + } + } + + return retList; + } + + public override bool Delete(string id) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon); + cmd.Parameters.AddWithValue("?id", id); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we + // keep a reference count (?) + } + } + + return true; + } + + #endregion + } +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations new file mode 100644 index 0000000..b89eab2 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -0,0 +1,27 @@ +# ----------------- +:VERSION 1 + +BEGIN; + +CREATE TABLE `xassetsmeta` ( + `id` char(36) NOT NULL, + `hash` char(64) NOT NULL, + `name` varchar(64) NOT NULL, + `description` varchar(64) NOT NULL, + `asset_type` tinyint(4) NOT NULL, + `local` tinyint(1) NOT NULL, + `temporary` tinyint(1) NOT NULL, + `create_time` int(11) NOT NULL, + `access_time` int(11) NOT NULL, + `asset_flags` int(11) NOT NULL, + `creator_id` varchar(128) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; + +CREATE TABLE `xassetsdata` ( + `hash` char(64) NOT NULL, + `data` longblob NOT NULL, + PRIMARY KEY (`hash`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; + +COMMIT; \ No newline at end of file -- cgit v1.1 From e81b3502ef0fef2b5f449b52ea2f016861aa23f4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Mar 2012 23:26:03 +0000 Subject: Make xassetservice execute one query to retrieve the asset, not two --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index f15a9f3..0dadf5e 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -104,6 +104,8 @@ namespace OpenSim.Data.MySQL /// On failure : throw an exception and attempt to reconnect to database override public AssetBase GetAsset(UUID assetID) { +// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); + AssetBase asset = null; lock (m_dbLock) { @@ -114,7 +116,7 @@ namespace OpenSim.Data.MySQL string hash = null; using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, hash, description, asset_type, local, temporary, asset_flags, creator_id FROM xassetsmeta WHERE id=?id", + "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", dbcon)) { cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -126,7 +128,7 @@ namespace OpenSim.Data.MySQL if (dbReader.Read()) { asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); - hash = (string)dbReader["hash"]; + asset.Data = (byte[])dbReader["data"]; asset.Description = (string)dbReader["description"]; string local = dbReader["local"].ToString(); @@ -145,32 +147,6 @@ namespace OpenSim.Data.MySQL m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); } } - - if (asset == null) - return null; - - m_log.DebugFormat( - "[MYSQL XASSET DATA]: Looking for asset {0} {1} with hash {2}", asset.FullID, asset.Name, hash); - - using (MySqlCommand cmd = new MySqlCommand( - "SELECT data FROM xassetsdata WHERE hash=?hash", - dbcon)) - { - cmd.Parameters.AddWithValue("?hash", hash); - - try - { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - if (dbReader.Read()) - asset.Data = (byte[])dbReader["data"]; - } - } - catch (Exception e) - { - m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset metadata " + assetID + ": " + e.Message); - } - } } } -- cgit v1.1 From 94b323d1d87dab168cebb2235f2969c7ca159230 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Mar 2012 23:41:54 +0000 Subject: Perform asset storage transactionally --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 126 +++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 57 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 0dadf5e..778c7f4 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -166,71 +166,83 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - string assetName = asset.Name; - if (asset.Name.Length > 64) + using (MySqlTransaction transaction = dbcon.BeginTransaction()) { - assetName = asset.Name.Substring(0, 64); - m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); - } + + string assetName = asset.Name; + if (asset.Name.Length > 64) + { + assetName = asset.Name.Substring(0, 64); + m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + } + + string assetDescription = asset.Description; + if (asset.Description.Length > 64) + { + assetDescription = asset.Description.Substring(0, 64); + m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + } + + string hash = Util.SHA1Hash(asset.Data); + + try + { + using (MySqlCommand cmd = + new MySqlCommand( + "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + + "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", + dbcon)) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?name", assetName); + cmd.Parameters.AddWithValue("?description", assetDescription); + cmd.Parameters.AddWithValue("?asset_type", asset.Type); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?create_time", now); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); - string assetDescription = asset.Description; - if (asset.Description.Length > 64) - { - assetDescription = asset.Description.Substring(0, 64); - m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); - } + transaction.Rollback(); - string hash = Util.SHA1Hash(asset.Data); + return; + } - try - { - using (MySqlCommand cmd = - new MySqlCommand( - "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + - "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", - dbcon)) + try { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?name", assetName); - cmd.Parameters.AddWithValue("?description", assetDescription); - cmd.Parameters.AddWithValue("?asset_type", asset.Type); - cmd.Parameters.AddWithValue("?local", asset.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Temporary); - cmd.Parameters.AddWithValue("?create_time", now); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); - cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); - cmd.Parameters.AddWithValue("?data", asset.Data); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + using (MySqlCommand cmd = + new MySqlCommand( + "replace INTO xassetsdata(hash, data) VALUES(?hash, ?data)", + dbcon)) + { + cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + } } - } - catch (Exception e) - { - m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", - asset.FullID, asset.Name, e.Message); - } - - try - { - using (MySqlCommand cmd = - new MySqlCommand( - "replace INTO xassetsdata(hash, data) VALUES(?hash, ?data)", - dbcon)) + catch (Exception e) { - cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?data", asset.Data); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); + + transaction.Rollback(); + + return; } - } - catch (Exception e) - { - m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", - asset.FullID, asset.Name, e.Message); + + transaction.Commit(); } } } -- cgit v1.1 From 2535a4cafc45863a9f6bd4d30b90248014a6c2c2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Mar 2012 00:05:02 +0000 Subject: If asset data already exists with the required hash then don't rewrite it --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 76 +++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 17 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 778c7f4..748578b 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -168,7 +168,6 @@ namespace OpenSim.Data.MySQL using (MySqlTransaction transaction = dbcon.BeginTransaction()) { - string assetName = asset.Name; if (asset.Name.Length > 64) { @@ -220,26 +219,29 @@ namespace OpenSim.Data.MySQL return; } - try + if (!ExistsData(dbcon, transaction, hash)) { - using (MySqlCommand cmd = - new MySqlCommand( - "replace INTO xassetsdata(hash, data) VALUES(?hash, ?data)", - dbcon)) + try { - cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?data", asset.Data); - cmd.ExecuteNonQuery(); + using (MySqlCommand cmd = + new MySqlCommand( + "INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)", + dbcon)) + { + cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + } } - } - catch (Exception e) - { - m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", - asset.FullID, asset.Name, e.Message); - - transaction.Rollback(); + catch (Exception e) + { + m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); - return; + transaction.Rollback(); + + return; + } } transaction.Commit(); @@ -285,6 +287,46 @@ namespace OpenSim.Data.MySQL // } /// + /// We assume we already have the m_dbLock. + /// + /// TODO: need to actually use the transaction. + /// + /// + /// + /// + private bool ExistsData(MySqlConnection dbcon, MySqlTransaction transaction, string hash) + { +// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); + + bool exists = false; + + using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) + { + cmd.Parameters.AddWithValue("?hash", hash); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { +// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); + exists = true; + } + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[XASSETS DB]: MySql failure in ExistsData fetching hash {0}. Exception {1}{2}", + hash, e.Message, e.StackTrace); + } + } + + return exists; + } + + /// /// Check if the asset exists in the database /// /// The asset UUID -- cgit v1.1 From 75dc8b1aedbd31f669c657ecc6beb6d8cbc9e037 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Mar 2012 01:28:58 +0000 Subject: Implement basic gzip compression for xassetdata Whether this is worthwhile is debatable since here we are not transmitting data over a network In addition, jpeg2000 (the biggest data hog) is already a compressed image format. May not remain. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 51 ++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 748578b..bb03871 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -26,9 +26,11 @@ */ using System; +using System.Collections.Generic; using System.Data; +using System.IO; +using System.IO.Compression; using System.Reflection; -using System.Collections.Generic; using System.Text; using log4net; using MySql.Data.MySqlClient; @@ -139,6 +141,18 @@ namespace OpenSim.Data.MySQL asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); + + using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) + { + MemoryStream outputStream = new MemoryStream(); + WebUtil.CopyTo(decompressionStream, outputStream, int.MaxValue); +// int compressedLength = asset.Data.Length; + asset.Data = outputStream.ToArray(); + +// m_log.DebugFormat( +// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", +// asset.ID, asset.Name, asset.Data.Length, compressedLength); + } } } } @@ -181,9 +195,24 @@ namespace OpenSim.Data.MySQL assetDescription = asset.Description.Substring(0, 64); m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); } - - string hash = Util.SHA1Hash(asset.Data); - + + byte[] compressedData; + MemoryStream outputStream = new MemoryStream(); + + using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) + { + Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); + // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. + compressionStream.Close(); + compressedData = outputStream.ToArray(); + } + + string hash = Util.SHA1Hash(compressedData); + +// m_log.DebugFormat( +// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", +// asset.ID, asset.Name, hash, compressedData.Length); + try { using (MySqlCommand cmd = @@ -205,7 +234,6 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?access_time", now); cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); - cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); } } @@ -229,7 +257,7 @@ namespace OpenSim.Data.MySQL dbcon)) { cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.Parameters.AddWithValue("?data", compressedData); cmd.ExecuteNonQuery(); } } @@ -422,16 +450,19 @@ namespace OpenSim.Data.MySQL public override bool Delete(string id) { +// m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); + lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon); - cmd.Parameters.AddWithValue("?id", id); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon)) + { + cmd.Parameters.AddWithValue("?id", id); + cmd.ExecuteNonQuery(); + } // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we // keep a reference count (?) -- cgit v1.1 From 3780df8a329c81471c486acab7f641f7742267f4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Mar 2012 01:43:36 +0000 Subject: Make asset compression optional. Currently set to false and not configurable from outside MySQLXAssetData. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 40 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index bb03871..bfc1c55 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -44,6 +44,7 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool m_enableCompression = false; private string m_connectionString; private object m_dbLock = new object(); @@ -142,16 +143,19 @@ namespace OpenSim.Data.MySQL asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); - using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) + if (m_enableCompression) { - MemoryStream outputStream = new MemoryStream(); - WebUtil.CopyTo(decompressionStream, outputStream, int.MaxValue); -// int compressedLength = asset.Data.Length; - asset.Data = outputStream.ToArray(); - -// m_log.DebugFormat( -// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", -// asset.ID, asset.Name, asset.Data.Length, compressedLength); + using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) + { + MemoryStream outputStream = new MemoryStream(); + WebUtil.CopyTo(decompressionStream, outputStream, int.MaxValue); + // int compressedLength = asset.Data.Length; + asset.Data = outputStream.ToArray(); + + // m_log.DebugFormat( + // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", + // asset.ID, asset.Name, asset.Data.Length, compressedLength); + } } } } @@ -199,15 +203,19 @@ namespace OpenSim.Data.MySQL byte[] compressedData; MemoryStream outputStream = new MemoryStream(); - using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) + if (m_enableCompression) { - Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); - // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. - compressionStream.Close(); - compressedData = outputStream.ToArray(); + using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) + { + // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); + // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. + compressionStream.Close(); + compressedData = outputStream.ToArray(); + asset.Data = compressedData; + } } - string hash = Util.SHA1Hash(compressedData); + string hash = Util.SHA1Hash(asset.Data); // m_log.DebugFormat( // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", @@ -257,7 +265,7 @@ namespace OpenSim.Data.MySQL dbcon)) { cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?data", compressedData); + cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); } } -- cgit v1.1 From fd2b285b1bf35d02ce8c901eaccf0b41066fb6d6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Mar 2012 23:50:41 +0000 Subject: remove unnecessary hash local variable --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index bfc1c55..0aff618 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -116,8 +116,6 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - string hash = null; - using (MySqlCommand cmd = new MySqlCommand( "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", dbcon)) -- cgit v1.1 From 441449e240ffceef4322661ad936928d98e3f724 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 Mar 2012 00:14:21 +0000 Subject: Switch to sha256 from sha1 in order to avoid future asset hash collisions. Some successful collision attacks have been carried out on sha1 with speculation that more are possible. http://en.wikipedia.org/wiki/Cryptographic_hash_function#Cryptographic_hash_algorithms No successful attacks have been shown on sha256, which makes it less likely that anybody will be able to engineer an asset hash collision in the future. Tradeoff is more storage required for hashes, and more cpu to hash, though this is neglible compared to db operations and network access. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 22 +++++++++++++++------- .../Data/MySQL/Resources/XAssetStore.migrations | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 0aff618..4cb89fa 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -31,6 +31,7 @@ using System.Data; using System.IO; using System.IO.Compression; using System.Reflection; +using System.Security.Cryptography; using System.Text; using log4net; using MySql.Data.MySqlClient; @@ -44,15 +45,20 @@ namespace OpenSim.Data.MySQL { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private bool m_enableCompression = false; - private string m_connectionString; - private object m_dbLock = new object(); - protected virtual Assembly Assembly { get { return GetType().Assembly; } } + private bool m_enableCompression = false; + private string m_connectionString; + private object m_dbLock = new object(); + + /// + /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock + /// + private HashAlgorithm hasher = new SHA256CryptoServiceProvider(); + #region IPlugin Members public override string Version { get { return "1.0.0.0"; } } @@ -213,7 +219,7 @@ namespace OpenSim.Data.MySQL } } - string hash = Util.SHA1Hash(asset.Data); + byte[] hash = hasher.ComputeHash(asset.Data); // m_log.DebugFormat( // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", @@ -328,7 +334,7 @@ namespace OpenSim.Data.MySQL /// /// /// - private bool ExistsData(MySqlConnection dbcon, MySqlTransaction transaction, string hash) + private bool ExistsData(MySqlConnection dbcon, MySqlTransaction transaction, byte[] hash) { // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); @@ -438,7 +444,9 @@ namespace OpenSim.Data.MySQL metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); metadata.FullID = DBGuid.FromDB(dbReader["id"]); metadata.CreatorID = dbReader["creator_id"].ToString(); - metadata.SHA1 = Encoding.Default.GetBytes((string)dbReader["hash"]); + + // We'll ignore this for now - it appears unused! +// metadata.SHA1 = dbReader["hash"]); retList.Add(metadata); } diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index b89eab2..d3cca5e 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -5,7 +5,7 @@ BEGIN; CREATE TABLE `xassetsmeta` ( `id` char(36) NOT NULL, - `hash` char(64) NOT NULL, + `hash` binary(32) NOT NULL, `name` varchar(64) NOT NULL, `description` varchar(64) NOT NULL, `asset_type` tinyint(4) NOT NULL, @@ -19,7 +19,7 @@ CREATE TABLE `xassetsmeta` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; CREATE TABLE `xassetsdata` ( - `hash` char(64) NOT NULL, + `hash` binary(32) NOT NULL, `data` longblob NOT NULL, PRIMARY KEY (`hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; -- cgit v1.1 From 0cbdf9dad230e24db6cd8277511e8fcc0132cb7b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Mar 2012 00:05:34 +0000 Subject: Put big fat EXPERIMENTAL warning in xassetservice database plugin This should not currently be used in any circumstances except for experimentation. Database tables used by this plugin can still change at any time with no migration path. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 4cb89fa..501cf1a 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -76,6 +76,16 @@ namespace OpenSim.Data.MySQL /// connect string public override void Initialise(string connect) { + m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); + m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); + m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); + m_log.ErrorFormat("[MYSQL XASSETDATA]: THIS PLUGIN IS STRICTLY EXPERIMENTAL."); + m_log.ErrorFormat("[MYSQL XASSETDATA]: DO NOT USE FOR ANY DATA THAT YOU DO NOT MIND LOSING."); + m_log.ErrorFormat("[MYSQL XASSETDATA]: DATABASE TABLES CAN CHANGE AT ANY TIME, CAUSING EXISTING DATA TO BE LOST."); + m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); + m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); + m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); + m_connectionString = connect; using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) -- cgit v1.1 From 3c5bd7c35ab24250f4f65e4ba90b3febaf5edd06 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Mar 2012 00:16:49 +0000 Subject: minor: move some compression related var setup inside compression if/then switch --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 501cf1a..95ef72a 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -214,17 +214,16 @@ namespace OpenSim.Data.MySQL m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); } - byte[] compressedData; - MemoryStream outputStream = new MemoryStream(); - if (m_enableCompression) { + MemoryStream outputStream = new MemoryStream(); + using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) { // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. compressionStream.Close(); - compressedData = outputStream.ToArray(); + byte[] compressedData = outputStream.ToArray(); asset.Data = compressedData; } } -- cgit v1.1 From e0dd38f6722e891cfc91c8d795604b7b78c0bc81 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 12 Mar 2012 10:07:04 -0700 Subject: Rename the stream extension method WebUtil.CopyTo() to WebUtil.CopyStream(). .NET 4.0 added the method Stream.CopyTo(stream, bufferSize). For .NET 3.5 and before, WebUtil defined an extension method for Stream with the signature Stream.CopyTo(stream, maxBytesToCopy). The meaning of the second parameter is different in the two forms and depending on which compiler and/or runtime you use, you could get one form or the other. Crashes ensue. This change renames the WebUtil stream copy method to something that cannot be confused with the new CopyTo method defined in .NET 4.0. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 95ef72a..06fe55a 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -162,7 +162,7 @@ namespace OpenSim.Data.MySQL using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) { MemoryStream outputStream = new MemoryStream(); - WebUtil.CopyTo(decompressionStream, outputStream, int.MaxValue); + WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); // int compressedLength = asset.Data.Length; asset.Data = outputStream.ToArray(); -- cgit v1.1 From ab54ce1907e26935bfb847742d4f5aa95d34aca0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Mar 2012 00:18:04 +0000 Subject: Fix configuration problems where XAssetDatabasePlugin was picked up accidentally. The asset data plugin now implements IXAssetData rather than IAssetData so the ordinary AssetService should no longer pick it up. This replaces the changes in 92b1ade. There is no longer any need to adjust your StandaloneCommon.ini/Robust.ini/Robust.HG.ini files. This may explain very recent issues in the last few weeks where textures have been disappearing or turning white (as they were going to different places). Unfortunately, you will need to rollback to an earlier database backup or reupload the textures. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 06fe55a..e6ac22e 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -41,7 +41,7 @@ using OpenSim.Data; namespace OpenSim.Data.MySQL { - public class MySQLXAssetData : AssetDataBase + public class MySQLXAssetData : IXAssetDataPlugin { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -61,7 +61,7 @@ namespace OpenSim.Data.MySQL #region IPlugin Members - public override string Version { get { return "1.0.0.0"; } } + public string Version { get { return "1.0.0.0"; } } /// /// Initialises Asset interface @@ -74,7 +74,7 @@ namespace OpenSim.Data.MySQL /// /// /// connect string - public override void Initialise(string connect) + public void Initialise(string connect) { m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************"); @@ -96,17 +96,17 @@ namespace OpenSim.Data.MySQL } } - public override void Initialise() + public void Initialise() { throw new NotImplementedException(); } - public override void Dispose() { } + public void Dispose() { } /// /// The name of this DB provider /// - override public string Name + public string Name { get { return "MySQL XAsset storage engine"; } } @@ -121,7 +121,7 @@ namespace OpenSim.Data.MySQL /// Asset UUID to fetch /// Return the asset /// On failure : throw an exception and attempt to reconnect to database - override public AssetBase GetAsset(UUID assetID) + public AssetBase GetAsset(UUID assetID) { // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); @@ -190,7 +190,7 @@ namespace OpenSim.Data.MySQL /// /// Asset UUID to create /// On failure : Throw an exception and attempt to reconnect to database - override public void StoreAsset(AssetBase asset) + public void StoreAsset(AssetBase asset) { lock (m_dbLock) { @@ -380,7 +380,7 @@ namespace OpenSim.Data.MySQL /// /// The asset UUID /// true if it exists, false otherwise. - override public bool ExistsAsset(UUID uuid) + public bool ExistsAsset(UUID uuid) { // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); @@ -426,7 +426,7 @@ namespace OpenSim.Data.MySQL /// The number of results to discard from the total data set. /// The number of rows the returned list should contain. /// A list of AssetMetadata objects. - public override List FetchAssetMetadataSet(int start, int count) + public List FetchAssetMetadataSet(int start, int count) { List retList = new List(count); @@ -471,7 +471,7 @@ namespace OpenSim.Data.MySQL return retList; } - public override bool Delete(string id) + public bool Delete(string id) { // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); -- cgit v1.1 From c70e85a3271aaa9e6d892240964cb55cbc2960c7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:38:21 +0300 Subject: When reading a region, use null objects to represent NULL fields. Previously NULL fields were converted to an empty string due to the use of ToString(). But if the field was an Int (e.g., "locZ"), then the subsequent attempt to convert an empty string to an int caused an exception. Now the field is null so we don't try to convert it, so there's no exception. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c20c392..948cdf3 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -187,7 +187,11 @@ namespace OpenSim.Data.MySQL if (s == "locY") continue; - ret.Data[s] = result[s].ToString(); + object value = result[s]; + if (value is DBNull) + ret.Data[s] = null; + else + ret.Data[s] = result[s].ToString(); } retList.Add(ret); -- cgit v1.1 From da5fd53702ce97d13da2cb50da0753d507e6c11b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:39:23 +0300 Subject: Fixed problem with MySQL: it was possible for one thread to use an incomplete list of column names if another thread was creating the list at the same time. Now this is thread-safe. --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 23 +++++++++++++------- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 6 ++++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 29 ++++++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 8d82f61..664ce84 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -79,14 +79,7 @@ namespace OpenSim.Data.MySQL { ret.PrincipalID = principalID; - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } + CheckColumnNames(result); foreach (string s in m_ColumnNames) { @@ -105,6 +98,20 @@ namespace OpenSim.Data.MySQL } } + private void CheckColumnNames(IDataReader result) + { + if (m_ColumnNames != null) + return; + + List columnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + columnNames.Add(row["ColumnName"].ToString()); + + m_ColumnNames = columnNames; + } + public bool Store(AuthenticationData data) { if (data.Data.ContainsKey("UUID")) diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 754cf72..da8e958 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL if (m_ColumnNames != null) return; - m_ColumnNames = new List(); + List columnNames = new List(); DataTable schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) { if (row["ColumnName"] != null && (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) - m_ColumnNames.Add(row["ColumnName"].ToString()); + columnNames.Add(row["ColumnName"].ToString()); } + + m_ColumnNames = columnNames; } public virtual T[] Get(string field, string key) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 948cdf3..d1f1932 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL ret.sizeX = Convert.ToInt32(result["sizeX"]); ret.sizeY = Convert.ToInt32(result["sizeY"]); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - { - if (row["ColumnName"] != null) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - } + CheckColumnNames(result); foreach (string s in m_ColumnNames) { @@ -202,6 +192,23 @@ namespace OpenSim.Data.MySQL return retList; } + private void CheckColumnNames(IDataReader result) + { + if (m_ColumnNames != null) + return; + + List columnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + { + if (row["ColumnName"] != null) + columnNames.Add(row["ColumnName"].ToString()); + } + + m_ColumnNames = columnNames; + } + public bool Store(RegionData data) { if (data.Data.ContainsKey("uuid")) -- cgit v1.1 From 522eff61383e9a8acfdf34289cd64a8fdc27bb19 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 30 Apr 2012 15:54:35 +0100 Subject: Consistently use using() to make sure we dispose of used MySqlCommands where this is not already being done. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 180 ++++++++--------- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 165 ++++++++-------- OpenSim/Data/MySQL/MySQLAvatarData.cs | 17 +- OpenSim/Data/MySQL/MySQLFriendsData.cs | 36 ++-- OpenSim/Data/MySQL/MySQLInventoryData.cs | 130 +++++++------ OpenSim/Data/MySQL/MySQLPresenceData.cs | 36 ++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 13 +- OpenSim/Data/MySQL/MySQLSimulationData.cs | 267 +++++++++++++------------- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 33 ++-- 9 files changed, 446 insertions(+), 431 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a743479..73de64b 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -163,52 +163,51 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - MySqlCommand cmd = + using (MySqlCommand cmd = new MySqlCommand( "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", - dbcon); - - string assetName = asset.Name; - if (asset.Name.Length > 64) - { - assetName = asset.Name.Substring(0, 64); - m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); - } - - string assetDescription = asset.Description; - if (asset.Description.Length > 64) - { - assetDescription = asset.Description.Substring(0, 64); - m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); - } - - // need to ensure we dispose - try + dbcon)) { - using (cmd) + string assetName = asset.Name; + if (asset.Name.Length > 64) { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?name", assetName); - cmd.Parameters.AddWithValue("?description", assetDescription); - cmd.Parameters.AddWithValue("?assetType", asset.Type); - cmd.Parameters.AddWithValue("?local", asset.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Temporary); - cmd.Parameters.AddWithValue("?create_time", now); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); - cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); - cmd.Parameters.AddWithValue("?data", asset.Data); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + assetName = asset.Name.Substring(0, 64); + m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + } + + string assetDescription = asset.Description; + if (asset.Description.Length > 64) + { + assetDescription = asset.Description.Substring(0, 64); + m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + } + + try + { + using (cmd) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?name", assetName); + cmd.Parameters.AddWithValue("?description", assetDescription); + cmd.Parameters.AddWithValue("?assetType", asset.Type); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?create_time", now); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); } - } - catch (Exception e) - { - m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", - asset.FullID, asset.Name, e.Message); } } } @@ -221,33 +220,31 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand("update assets set access_time=?access_time where id=?id", - dbcon); - // need to ensure we dispose - try + using (MySqlCommand cmd + = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) { - using (cmd) + try { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + using (cmd) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: " + + "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); } - } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: " + - "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); } } } - } /// @@ -310,35 +307,41 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", dbcon); - cmd.Parameters.AddWithValue("?start", start); - cmd.Parameters.AddWithValue("?count", count); - try + using (MySqlCommand cmd + = new MySqlCommand( + "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", + dbcon)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); + + try { - while (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - AssetMetadata metadata = new AssetMetadata(); - metadata.Name = (string)dbReader["name"]; - metadata.Description = (string)dbReader["description"]; - metadata.Type = (sbyte)dbReader["assetType"]; - metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. - metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); - metadata.FullID = DBGuid.FromDB(dbReader["id"]); - metadata.CreatorID = dbReader["CreatorID"].ToString(); - - // Current SHA1s are not stored/computed. - metadata.SHA1 = new byte[] { }; - - retList.Add(metadata); + while (dbReader.Read()) + { + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string)dbReader["name"]; + metadata.Description = (string)dbReader["description"]; + metadata.Type = (sbyte)dbReader["assetType"]; + metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); + metadata.FullID = DBGuid.FromDB(dbReader["id"]); + metadata.CreatorID = dbReader["CreatorID"].ToString(); + + // Current SHA1s are not stored/computed. + metadata.SHA1 = new byte[] { }; + + retList.Add(metadata); + } } } - } - catch (Exception e) - { - m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + catch (Exception e) + { + m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + } } } } @@ -353,11 +356,12 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon); - cmd.Parameters.AddWithValue("?id", id); - cmd.ExecuteNonQuery(); - cmd.Dispose(); + using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) + { + cmd.Parameters.AddWithValue("?id", id); + cmd.ExecuteNonQuery(); + } } } @@ -366,4 +370,4 @@ namespace OpenSim.Data.MySQL #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 664ce84..7627497 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -70,30 +70,34 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - - IDataReader result = cmd.ExecuteReader(); - if (result.Read()) + using (MySqlCommand cmd + = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon)) { - ret.PrincipalID = principalID; - - CheckColumnNames(result); + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - foreach (string s in m_ColumnNames) + IDataReader result = cmd.ExecuteReader(); + + if (result.Read()) { - if (s == "UUID") - continue; - - ret.Data[s] = result[s].ToString(); + ret.PrincipalID = principalID; + + CheckColumnNames(result); + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + return ret; + } + else + { + return null; } - - return ret; - } - else - { - return null; } } } @@ -119,57 +123,53 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - MySqlCommand cmd = new MySqlCommand(); - - string update = "update `"+m_Realm+"` set "; - bool first = true; - foreach (string field in fields) + using (MySqlCommand cmd = new MySqlCommand()) { - if (!first) - update += ", "; - update += "`" + field + "` = ?"+field; - - first = false; - - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); - } - - update += " where UUID = ?principalID"; - - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); - - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `" + - String.Join("`, `", fields) + - "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; - - cmd.CommandText = insert; - + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) + { + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; + + first = false; + + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } + + update += " where UUID = ?principalID"; + + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + if (ExecuteNonQuery(cmd) < 1) { - cmd.Dispose(); - return false; + string insert = "insert into `" + m_Realm + "` (`UUID`, `" + + String.Join("`, `", fields) + + "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + return false; } } - cmd.Dispose(); - return true; } public bool SetDataItem(UUID principalID, string item, string value) { - MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + - "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - - - cmd.Parameters.AddWithValue("?"+item, value); - cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); - - if (ExecuteNonQuery(cmd) > 0) - return true; + using (MySqlCommand cmd + = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where UUID = ?UUID")) + { + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } @@ -179,18 +179,18 @@ namespace OpenSim.Data.MySQL if (System.Environment.TickCount - m_LastExpire > 30000) DoExpire(); - MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"); - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?token", token); - cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); - - if (ExecuteNonQuery(cmd) > 0) + using (MySqlCommand cmd + = new MySqlCommand( + "insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))")) { - cmd.Dispose(); - return true; + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?token", token); + cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; } - cmd.Dispose(); return false; } @@ -199,30 +199,29 @@ namespace OpenSim.Data.MySQL if (System.Environment.TickCount - m_LastExpire > 30000) DoExpire(); - MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"); - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?token", token); - cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); - - if (ExecuteNonQuery(cmd) > 0) + using (MySqlCommand cmd + = new MySqlCommand( + "update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()")) { - cmd.Dispose(); - return true; - } + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?token", token); + cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); - cmd.Dispose(); + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } private void DoExpire() { - MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"); - ExecuteNonQuery(cmd); - - cmd.Dispose(); + using (MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()")) + { + ExecuteNonQuery(cmd); + } m_LastExpire = System.Environment.TickCount; } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs index 8c841ab..6a2f5d8 100644 --- a/OpenSim/Data/MySQL/MySQLAvatarData.cs +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs @@ -52,14 +52,15 @@ namespace OpenSim.Data.MySQL public bool Delete(UUID principalID, string name) { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); - cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?Name", name); - - if (ExecuteNonQuery(cmd) > 0) - return true; + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + + if (ExecuteNonQuery(cmd) > 0) + return true; + } return false; } diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 130ba5e..3cd6b8f 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -49,34 +49,38 @@ namespace OpenSim.Data.MySQL public bool Delete(string principalID, string friend) { - MySqlCommand cmd = new MySqlCommand(); + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?Friend", friend); - cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); - cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?Friend", friend); - - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); + } return true; } public FriendsData[] GetFriends(UUID principalID) { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); - cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); - return DoQuery(cmd); + return DoQuery(cmd); + } } public FriendsData[] GetFriends(string principalID) { - MySqlCommand cmd = new MySqlCommand(); + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); - cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); - cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); - return DoQuery(cmd); + return DoQuery(cmd); + } } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 1a634e5..e9b10f3 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -467,43 +467,43 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - MySqlCommand result = new MySqlCommand(sql, dbcon); - result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); - result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); - result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); - result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); - result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); - result.Parameters.AddWithValue("?inventoryName", itemName); - result.Parameters.AddWithValue("?inventoryDescription", itemDesc); - result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); - result.Parameters.AddWithValue("?inventoryCurrentPermissions", - item.CurrentPermissions.ToString()); - result.Parameters.AddWithValue("?invType", item.InvType); - result.Parameters.AddWithValue("?creatorID", item.CreatorId); - result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); - result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); - result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); - result.Parameters.AddWithValue("?salePrice", item.SalePrice); - result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); - result.Parameters.AddWithValue("?creationDate", item.CreationDate); - result.Parameters.AddWithValue("?groupID", item.GroupID); - result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); - result.Parameters.AddWithValue("?flags", item.Flags); - - lock (m_dbLock) + using (MySqlCommand result = new MySqlCommand(sql, dbcon)) { - result.ExecuteNonQuery(); + result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); + result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); + result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); + result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); + result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); + result.Parameters.AddWithValue("?inventoryName", itemName); + result.Parameters.AddWithValue("?inventoryDescription", itemDesc); + result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); + result.Parameters.AddWithValue("?inventoryCurrentPermissions", + item.CurrentPermissions.ToString()); + result.Parameters.AddWithValue("?invType", item.InvType); + result.Parameters.AddWithValue("?creatorID", item.CreatorId); + result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); + result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); + result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); + result.Parameters.AddWithValue("?salePrice", item.SalePrice); + result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); + result.Parameters.AddWithValue("?creationDate", item.CreationDate); + result.Parameters.AddWithValue("?groupID", item.GroupID); + result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); + result.Parameters.AddWithValue("?flags", item.Flags); + + lock (m_dbLock) + result.ExecuteNonQuery(); + + result.Dispose(); } - result.Dispose(); - - result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon); - result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); - lock (m_dbLock) + using (MySqlCommand result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon)) { - result.ExecuteNonQuery(); + result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); + + lock (m_dbLock) + result.ExecuteNonQuery(); } - result.Dispose(); } } catch (MySqlException e) @@ -533,12 +533,12 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); - cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); - - lock (m_dbLock) + using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon)) { - cmd.ExecuteNonQuery(); + cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); + + lock (m_dbLock) + cmd.ExecuteNonQuery(); } } } @@ -579,24 +579,26 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); - cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); - cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); - cmd.Parameters.AddWithValue("?folderName", folderName); - cmd.Parameters.AddWithValue("?type", folder.Type); - cmd.Parameters.AddWithValue("?version", folder.Version); - - try + using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) { - lock (m_dbLock) + cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); + cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); + cmd.Parameters.AddWithValue("?folderName", folderName); + cmd.Parameters.AddWithValue("?type", folder.Type); + cmd.Parameters.AddWithValue("?version", folder.Version); + + try { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + { + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); } - } - catch (Exception e) - { - m_log.Error(e.ToString()); } } } @@ -624,20 +626,22 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand(sql, dbcon); - cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); - cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); - - try + using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) { - lock (m_dbLock) + cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); + cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); + + try { - cmd.ExecuteNonQuery(); + lock (m_dbLock) + { + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); } - } - catch (Exception e) - { - m_log.Error(e.ToString()); } } } diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index fc625f0..7808060 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -63,13 +63,14 @@ namespace OpenSim.Data.MySQL public void LogoutRegionAgents(UUID regionID) { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); - - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - - ExecuteNonQuery(cmd); + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); + + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + ExecuteNonQuery(cmd); + } } public bool ReportAgent(UUID sessionID, UUID regionID) @@ -81,17 +82,18 @@ namespace OpenSim.Data.MySQL if (regionID == UUID.Zero) return false; - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); - - cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - - if (ExecuteNonQuery(cmd) == 0) - return false; + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); + + cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + if (ExecuteNonQuery(cmd) == 0) + return false; + } return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index d1f1932..0614879 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -329,11 +329,12 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - return RunCommand(cmd); + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); + } } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 381a514..b36ff5a 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -129,114 +129,114 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = dbcon.CreateCommand(); - foreach (SceneObjectPart prim in obj.Parts) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims (" + - "UUID, CreationDate, " + - "Name, Text, Description, " + - "SitName, TouchName, ObjectFlags, " + - "OwnerMask, NextOwnerMask, GroupMask, " + - "EveryoneMask, BaseMask, PositionX, " + - "PositionY, PositionZ, GroupPositionX, " + - "GroupPositionY, GroupPositionZ, VelocityX, " + - "VelocityY, VelocityZ, AngularVelocityX, " + - "AngularVelocityY, AngularVelocityZ, " + - "AccelerationX, AccelerationY, " + - "AccelerationZ, RotationX, " + - "RotationY, RotationZ, " + - "RotationW, SitTargetOffsetX, " + - "SitTargetOffsetY, SitTargetOffsetZ, " + - "SitTargetOrientW, SitTargetOrientX, " + - "SitTargetOrientY, SitTargetOrientZ, " + - "RegionUUID, CreatorID, " + - "OwnerID, GroupID, " + - "LastOwnerID, SceneGroupID, " + - "PayPrice, PayButton1, " + - "PayButton2, PayButton3, " + - "PayButton4, LoopedSound, " + - "LoopedSoundGain, TextureAnimation, " + - "OmegaX, OmegaY, OmegaZ, " + - "CameraEyeOffsetX, CameraEyeOffsetY, " + - "CameraEyeOffsetZ, CameraAtOffsetX, " + - "CameraAtOffsetY, CameraAtOffsetZ, " + - "ForceMouselook, ScriptAccessPin, " + - "AllowedDrop, DieAtEdge, " + - "SalePrice, SaleType, " + - "ColorR, ColorG, ColorB, ColorA, " + - "ParticleSystem, ClickAction, Material, " + - "CollisionSound, CollisionSoundVolume, " + - "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + - "?CreationDate, ?Name, ?Text, " + - "?Description, ?SitName, ?TouchName, " + - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + - "?GroupMask, ?EveryoneMask, ?BaseMask, " + - "?PositionX, ?PositionY, ?PositionZ, " + - "?GroupPositionX, ?GroupPositionY, " + - "?GroupPositionZ, ?VelocityX, " + - "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + - "?AngularVelocityY, ?AngularVelocityZ, " + - "?AccelerationX, ?AccelerationY, " + - "?AccelerationZ, ?RotationX, " + - "?RotationY, ?RotationZ, " + - "?RotationW, ?SitTargetOffsetX, " + - "?SitTargetOffsetY, ?SitTargetOffsetZ, " + - "?SitTargetOrientW, ?SitTargetOrientX, " + - "?SitTargetOrientY, ?SitTargetOrientZ, " + - "?RegionUUID, ?CreatorID, ?OwnerID, " + - "?GroupID, ?LastOwnerID, ?SceneGroupID, " + - "?PayPrice, ?PayButton1, ?PayButton2, " + - "?PayButton3, ?PayButton4, ?LoopedSound, " + - "?LoopedSoundGain, ?TextureAnimation, " + - "?OmegaX, ?OmegaY, ?OmegaZ, " + - "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + - "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + - "?CameraAtOffsetY, ?CameraAtOffsetZ, " + - "?ForceMouselook, ?ScriptAccessPin, " + - "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + - "?SaleType, ?ColorR, ?ColorG, " + - "?ColorB, ?ColorA, ?ParticleSystem, " + - "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes (" + - "UUID, Shape, ScaleX, ScaleY, " + - "ScaleZ, PCode, PathBegin, PathEnd, " + - "PathScaleX, PathScaleY, PathShearX, " + - "PathShearY, PathSkew, PathCurve, " + - "PathRadiusOffset, PathRevolutions, " + - "PathTaperX, PathTaperY, PathTwist, " + - "PathTwistBegin, ProfileBegin, ProfileEnd, " + - "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) values (?UUID, " + - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + - "?PCode, ?PathBegin, ?PathEnd, " + - "?PathScaleX, ?PathScaleY, " + - "?PathShearX, ?PathShearY, " + - "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + - "?PathRevolutions, ?PathTaperX, " + - "?PathTaperY, ?PathTwist, " + - "?PathTwistBegin, ?ProfileBegin, " + - "?ProfileEnd, ?ProfileCurve, " + - "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); + foreach (SceneObjectPart prim in obj.Parts) + { + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims (" + + "UUID, CreationDate, " + + "Name, Text, Description, " + + "SitName, TouchName, ObjectFlags, " + + "OwnerMask, NextOwnerMask, GroupMask, " + + "EveryoneMask, BaseMask, PositionX, " + + "PositionY, PositionZ, GroupPositionX, " + + "GroupPositionY, GroupPositionZ, VelocityX, " + + "VelocityY, VelocityZ, AngularVelocityX, " + + "AngularVelocityY, AngularVelocityZ, " + + "AccelerationX, AccelerationY, " + + "AccelerationZ, RotationX, " + + "RotationY, RotationZ, " + + "RotationW, SitTargetOffsetX, " + + "SitTargetOffsetY, SitTargetOffsetZ, " + + "SitTargetOrientW, SitTargetOrientX, " + + "SitTargetOrientY, SitTargetOrientZ, " + + "RegionUUID, CreatorID, " + + "OwnerID, GroupID, " + + "LastOwnerID, SceneGroupID, " + + "PayPrice, PayButton1, " + + "PayButton2, PayButton3, " + + "PayButton4, LoopedSound, " + + "LoopedSoundGain, TextureAnimation, " + + "OmegaX, OmegaY, OmegaZ, " + + "CameraEyeOffsetX, CameraEyeOffsetY, " + + "CameraEyeOffsetZ, CameraAtOffsetX, " + + "CameraAtOffsetY, CameraAtOffsetZ, " + + "ForceMouselook, ScriptAccessPin, " + + "AllowedDrop, DieAtEdge, " + + "SalePrice, SaleType, " + + "ColorR, ColorG, ColorB, ColorA, " + + "ParticleSystem, ClickAction, Material, " + + "CollisionSound, CollisionSoundVolume, " + + "PassTouches, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + + "?CreationDate, ?Name, ?Text, " + + "?Description, ?SitName, ?TouchName, " + + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + + "?GroupMask, ?EveryoneMask, ?BaseMask, " + + "?PositionX, ?PositionY, ?PositionZ, " + + "?GroupPositionX, ?GroupPositionY, " + + "?GroupPositionZ, ?VelocityX, " + + "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + + "?AngularVelocityY, ?AngularVelocityZ, " + + "?AccelerationX, ?AccelerationY, " + + "?AccelerationZ, ?RotationX, " + + "?RotationY, ?RotationZ, " + + "?RotationW, ?SitTargetOffsetX, " + + "?SitTargetOffsetY, ?SitTargetOffsetZ, " + + "?SitTargetOrientW, ?SitTargetOrientX, " + + "?SitTargetOrientY, ?SitTargetOrientZ, " + + "?RegionUUID, ?CreatorID, ?OwnerID, " + + "?GroupID, ?LastOwnerID, ?SceneGroupID, " + + "?PayPrice, ?PayButton1, ?PayButton2, " + + "?PayButton3, ?PayButton4, ?LoopedSound, " + + "?LoopedSoundGain, ?TextureAnimation, " + + "?OmegaX, ?OmegaY, ?OmegaZ, " + + "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + + "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + + "?CameraAtOffsetY, ?CameraAtOffsetZ, " + + "?ForceMouselook, ?ScriptAccessPin, " + + "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + + "?SaleType, ?ColorR, ?ColorG, " + + "?ColorB, ?ColorA, ?ParticleSystem, " + + "?ClickAction, ?Material, ?CollisionSound, " + + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes (" + + "UUID, Shape, ScaleX, ScaleY, " + + "ScaleZ, PCode, PathBegin, PathEnd, " + + "PathScaleX, PathScaleY, PathShearX, " + + "PathShearY, PathSkew, PathCurve, " + + "PathRadiusOffset, PathRevolutions, " + + "PathTaperX, PathTaperY, PathTwist, " + + "PathTwistBegin, ProfileBegin, ProfileEnd, " + + "ProfileCurve, ProfileHollow, Texture, " + + "ExtraParams, State, Media) values (?UUID, " + + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + + "?PCode, ?PathBegin, ?PathEnd, " + + "?PathScaleX, ?PathScaleY, " + + "?PathShearX, ?PathShearY, " + + "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + + "?PathRevolutions, ?PathTaperX, " + + "?PathTaperY, ?PathTwist, " + + "?PathTwistBegin, ?ProfileBegin, " + + "?ProfileEnd, ?ProfileCurve, " + + "?ProfileHollow, ?Texture, ?ExtraParams, " + + "?State, ?Media)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); + } } - - cmd.Dispose(); } } } @@ -1804,37 +1804,36 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - MySqlCommand cmd = dbcon.CreateCommand(); - - if (items.Count == 0) - return; - - cmd.CommandText = "insert into primitems (" + - "invType, assetType, name, " + - "description, creationDate, nextPermissions, " + - "currentPermissions, basePermissions, " + - "everyonePermissions, groupPermissions, " + - "flags, itemID, primID, assetID, " + - "parentFolderID, creatorID, ownerID, " + - "groupID, lastOwnerID) values (?invType, " + - "?assetType, ?name, ?description, " + - "?creationDate, ?nextPermissions, " + - "?currentPermissions, ?basePermissions, " + - "?everyonePermissions, ?groupPermissions, " + - "?flags, ?itemID, ?primID, ?assetID, " + - "?parentFolderID, ?creatorID, ?ownerID, " + - "?groupID, ?lastOwnerID)"; - - foreach (TaskInventoryItem item in items) + using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.Parameters.Clear(); - - FillItemCommand(cmd, item); - - ExecuteNonQuery(cmd); + if (items.Count == 0) + return; + + cmd.CommandText = "insert into primitems (" + + "invType, assetType, name, " + + "description, creationDate, nextPermissions, " + + "currentPermissions, basePermissions, " + + "everyonePermissions, groupPermissions, " + + "flags, itemID, primID, assetID, " + + "parentFolderID, creatorID, ownerID, " + + "groupID, lastOwnerID) values (?invType, " + + "?assetType, ?name, ?description, " + + "?creationDate, ?nextPermissions, " + + "?currentPermissions, ?basePermissions, " + + "?everyonePermissions, ?groupPermissions, " + + "?flags, ?itemID, ?primID, ?assetID, " + + "?parentFolderID, ?creatorID, ?ownerID, " + + "?groupID, ?lastOwnerID)"; + + foreach (TaskInventoryItem item in items) + { + cmd.Parameters.Clear(); + + FillItemCommand(cmd, item); + + ExecuteNonQuery(cmd); + } } - - cmd.Dispose(); } } } diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index aa69d68..e964295 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -62,23 +62,24 @@ namespace OpenSim.Data.MySQL if (words.Length > 2) return new UserAccountData[0]; - MySqlCommand cmd = new MySqlCommand(); - - if (words.Length == 1) - { - 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); - cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); - cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); - } - else + using (MySqlCommand cmd = new MySqlCommand()) { - 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); - cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); - cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); - cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); - } + if (words.Length == 1) + { + 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); + cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + else + { + 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); + cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } - return DoQuery(cmd); + return DoQuery(cmd); + } } } -} +} \ No newline at end of file -- cgit v1.1 From 4ad45934c67f221fa54e1c7407949b375956eed6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 30 Apr 2012 16:00:31 +0100 Subject: If there are no new prim items to store then don't bother opening the MySqlConnection only to do nothing with it. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b36ff5a..b2a1481 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1800,15 +1800,15 @@ namespace OpenSim.Data.MySQL { RemoveItems(primID); + if (items.Count == 0) + return; + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); using (MySqlCommand cmd = dbcon.CreateCommand()) { - if (items.Count == 0) - return; - cmd.CommandText = "insert into primitems (" + "invType, assetType, name, " + "description, creationDate, nextPermissions, " + -- cgit v1.1 From bc543c1797c629a8584dd2e74d3c5f7a67de96c9 Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Wed, 23 May 2012 21:06:25 +0200 Subject: Environment Module - allows Environment settings for Viewer3 warning: includes database region store migrations for mssql, mysql, sqlite enable/disable this module: Cap_EnvironmentSettings = "localhost" (for enable) Cap_EnvironmentSettings = "" (for disable) at ClientStack.LindenCaps section (OpenSimDefaults.ini file) or owerwrite in OpenSim.ini mantis: http://opensimulator.org/mantis/view.php?id=5860 Signed-off-by: BlueWall --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 62 ++++++++++++++++++++++ .../Data/MySQL/Resources/RegionStore.migrations | 11 ++++ 2 files changed, 73 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b2a1481..1a2e113 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -969,6 +969,68 @@ namespace OpenSim.Data.MySQL } } + #region RegionEnvironmentSettings + public string LoadRegionEnvironmentSettings(UUID regionUUID) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + string command = "select * from `regionenvironment` where region_id = ?region_id"; + + using (MySqlCommand cmd = new MySqlCommand(command)) + { + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) + { + return String.Empty; + } + else + { + return Convert.ToString(result["llsd_settings"]); + } + } + } + } + + public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; + + cmd.Parameters.AddWithValue("region_id", regionUUID); + cmd.Parameters.AddWithValue("llsd_settings", settings); + + ExecuteNonQuery(cmd); + } + } + } + + public void RemoveRegionEnvironmentSettings(UUID regionUUID) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; + cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); + ExecuteNonQuery(cmd); + } + } + } + #endregion + public void StoreRegionSettings(RegionSettings rs) { lock (m_dbLock) diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 099beaf..4a925fb 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -883,4 +883,15 @@ ALTER TABLE `regionsettings` MODIFY COLUMN `TelehubObject` VARCHAR(36) NOT NULL COMMIT; +:VERSION 44 #--------------------- Environment Settings + +BEGIN; + +CREATE TABLE `regionenvironment` ( + `region_id` varchar(36) NOT NULL, + `llsd_settings` TEXT NOT NULL, + PRIMARY KEY (`region_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; -- cgit v1.1 From dc82ad0f7abe5f09675dfc3768da2a0134503916 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 02:06:22 +0100 Subject: Add a skeleton for a name value storage associated with regions --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 13 +++++++++++++ OpenSim/Data/MySQL/Resources/RegionStore.migrations | 7 +++++++ 2 files changed, 20 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 1a2e113..be985ab 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1966,5 +1966,18 @@ namespace OpenSim.Data.MySQL } } } + + public void SaveExtra(UUID regionID, string name, string val) + { + } + + public void RemoveExtra(UUID regionID, string name) + { + } + + public Dictionary GetExtra(UUID regionID) + { + return null; + } } } diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 4a925fb..5b59779 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -895,3 +895,10 @@ CREATE TABLE `regionenvironment` ( COMMIT; +:VERSION 45 + +BEGIN; + +CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); + +COMMIT; -- cgit v1.1 From c7f2debd38e35b0f049df9cc33ff8fb4eede40db Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:21:28 +0200 Subject: Fix and finish the extra parameters storage system for MySQL --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 58 ++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index be985ab..3fc04ee 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1969,15 +1969,71 @@ namespace OpenSim.Data.MySQL public void SaveExtra(UUID regionID, string name, string val) { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + cmd.Parameters.AddWithValue("?value", val); + + cmd.ExecuteNonQuery(); + } + } + } } public void RemoveExtra(UUID regionID, string name) { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + + cmd.ExecuteNonQuery(); + } + } + } } public Dictionary GetExtra(UUID regionID) { - return null; + Dictionary ret = new Dictionary(); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + ret[r["Name"].ToString()] = r["value"].ToString(); + } + } + } + } + } + + return ret; } } } -- cgit v1.1 From 7c6e8fab155ff24d460e8de4597531849c291957 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 31 Aug 2012 00:29:57 +0100 Subject: Do Windlight storage and removal calls in MySQL under m_dbLock, as is done with all the other database calls. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 210 +++++++++++++++--------------- 1 file changed, 108 insertions(+), 102 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3fc04ee..a021590 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -853,118 +853,124 @@ namespace OpenSim.Data.MySQL public void StoreRegionWindlightSettings(RegionLightShareData wl) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + lock (m_dbLock) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; - cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; - cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; - cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; - cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; - cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; - cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; - cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; - cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; - cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; - cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; - cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; - cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; - cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; - cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; - cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; - cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; - cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; - cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; - cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; - cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; - cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; - cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; - cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; - cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; - - cmd.Parameters.AddWithValue("region_id", wl.regionID); - cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); - cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); - cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); - cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); - cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); - cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); - cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); - cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); - cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); - cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); - cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); - cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); - cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); - cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); - cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); - cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); - cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); - cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); - cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); - cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); - cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); - cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); - cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); - cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); - cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); - cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); - cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); - cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); - cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); - cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); - cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); - cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); - cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); - cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); - cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); - cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); - cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); - cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); - cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); - cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); - cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); - cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); - cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); - cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); - cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); - cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); - cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); - cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); - cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); - cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); - cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); - cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); - cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); - cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); - cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); - cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); - cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); - cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); - cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); - - ExecuteNonQuery(cmd); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; + cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; + cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; + cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; + cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; + cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; + cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; + cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; + cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; + cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; + cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; + cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; + cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; + cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; + cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; + cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; + cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; + cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; + cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; + cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; + cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; + cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; + cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; + cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; + cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; + + cmd.Parameters.AddWithValue("region_id", wl.regionID); + cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); + cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); + cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); + cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); + cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); + cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); + cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); + cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); + cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); + cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); + cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); + cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); + cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); + cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); + cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); + cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); + cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); + cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); + cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); + cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); + cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); + cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); + cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); + cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); + cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); + cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); + cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); + cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); + cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); + cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); + cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); + cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); + cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); + cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); + cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); + cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); + cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); + cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); + cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); + cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); + cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); + cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); + cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); + cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); + cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); + cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); + cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); + cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); + cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); + cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); + cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); + cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); + cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); + cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); + cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); + + ExecuteNonQuery(cmd); + } } } } public void RemoveRegionWindlightSettings(UUID regionID) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + lock (m_dbLock) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; - cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); - ExecuteNonQuery(cmd); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + ExecuteNonQuery(cmd); + } } } } -- cgit v1.1 From 3bd3f448a2d5b64b267427a0f8f820109338a7bb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 31 Aug 2012 00:33:06 +0100 Subject: Also do other MySQL region settings related calls under m_dbLock, in common with other calls. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 247 ++++++++++++++++-------------- 1 file changed, 130 insertions(+), 117 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index a021590..d562783 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -719,95 +719,99 @@ namespace OpenSim.Data.MySQL RegionLightShareData nWP = new RegionLightShareData(); nWP.OnSave += StoreRegionWindlightSettings; - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + lock (m_dbLock) { - dbcon.Open(); - - string command = "select * from `regionwindlight` where region_id = ?regionID"; - - using (MySqlCommand cmd = new MySqlCommand(command)) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.Connection = dbcon; - - cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); - - IDataReader result = ExecuteReader(cmd); - if (!result.Read()) - { - //No result, so store our default windlight profile and return it - nWP.regionID = regionUUID; - StoreRegionWindlightSettings(nWP); - return nWP; - } - else + dbcon.Open(); + + string command = "select * from `regionwindlight` where region_id = ?regionID"; + + using (MySqlCommand cmd = new MySqlCommand(command)) { - nWP.regionID = DBGuid.FromDB(result["region_id"]); - nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); - nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); - nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); - nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); - nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); - nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); - nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); - nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); - nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); - nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); - nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); - nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); - nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); - nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); - nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); - nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); - nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); - UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); - nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); - nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); - nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); - nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); - nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); - nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); - nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); - nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); - nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); - nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); - nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); - nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); - nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); - nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); - nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); - nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); - nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); - nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); - nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); - nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); - nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); - nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); - nWP.eastAngle = Convert.ToSingle(result["east_angle"]); - nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); - nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); - nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); - nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); - nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); - nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); - nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); - nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); - nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); - nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); - nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); - nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); - nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); - nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); - nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); - nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); - nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); - nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); - nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); - nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); - nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); - nWP.valid = true; + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) + { + //No result, so store our default windlight profile and return it + nWP.regionID = regionUUID; + StoreRegionWindlightSettings(nWP); + return nWP; + } + else + { + nWP.regionID = DBGuid.FromDB(result["region_id"]); + nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); + nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); + nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); + nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); + nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); + nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); + nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); + nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); + nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); + nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); + nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); + nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); + nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); + nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); + nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); + nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); + nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); + UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); + nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); + nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); + nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); + nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); + nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); + nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); + nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); + nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); + nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); + nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); + nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); + nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); + nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); + nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); + nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); + nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); + nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); + nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); + nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); + nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); + nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); + nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); + nWP.eastAngle = Convert.ToSingle(result["east_angle"]); + nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); + nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); + nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); + nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); + nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); + nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); + nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); + nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); + nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); + nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); + nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); + nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); + nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); + nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); + nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); + nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); + nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); + nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); + nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); + nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); + nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); + nWP.valid = true; + } } } } + return nWP; } @@ -978,26 +982,29 @@ namespace OpenSim.Data.MySQL #region RegionEnvironmentSettings public string LoadRegionEnvironmentSettings(UUID regionUUID) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + lock (m_dbLock) { - dbcon.Open(); - - string command = "select * from `regionenvironment` where region_id = ?region_id"; - - using (MySqlCommand cmd = new MySqlCommand(command)) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.Connection = dbcon; - - cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); - - IDataReader result = ExecuteReader(cmd); - if (!result.Read()) - { - return String.Empty; - } - else + dbcon.Open(); + + string command = "select * from `regionenvironment` where region_id = ?region_id"; + + using (MySqlCommand cmd = new MySqlCommand(command)) { - return Convert.ToString(result["llsd_settings"]); + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) + { + return String.Empty; + } + else + { + return Convert.ToString(result["llsd_settings"]); + } } } } @@ -1005,33 +1012,39 @@ namespace OpenSim.Data.MySQL public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + lock (m_dbLock) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; - - cmd.Parameters.AddWithValue("region_id", regionUUID); - cmd.Parameters.AddWithValue("llsd_settings", settings); - - ExecuteNonQuery(cmd); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; + + cmd.Parameters.AddWithValue("region_id", regionUUID); + cmd.Parameters.AddWithValue("llsd_settings", settings); + + ExecuteNonQuery(cmd); + } } } } public void RemoveRegionEnvironmentSettings(UUID regionUUID) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + lock (m_dbLock) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; - cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); - ExecuteNonQuery(cmd); + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; + cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); + ExecuteNonQuery(cmd); + } } } } -- cgit v1.1 From ae58cf42242433c786162b53a2724962f4a8380b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 25 Sep 2012 20:03:49 -0700 Subject: TOS module. WARNING: migration in GridUser table. --- OpenSim/Data/MySQL/Resources/GridUserStore.migrations | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations index 32b85ee..440d076 100644 --- a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations @@ -17,3 +17,11 @@ CREATE TABLE `GridUser` ( ) ENGINE=InnoDB; COMMIT; + +:VERSION 2 # -------------------------- + +BEGIN; + +ALTER TABLE `GridUser` ADD COLUMN TOS CHAR(36); + +COMMIT; -- cgit v1.1 From 7a5070518833a29252fc638f9dd216040bcfad7a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 27 Sep 2012 16:43:18 -0700 Subject: Removed the bits about the TOSModule. That module doesn't go into core. WARNING: migration on GridUser withdrawn too, but left the migration number there. --- OpenSim/Data/MySQL/Resources/GridUserStore.migrations | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations index 440d076..d08e096 100644 --- a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations @@ -19,9 +19,6 @@ CREATE TABLE `GridUser` ( COMMIT; :VERSION 2 # -------------------------- - BEGIN; -ALTER TABLE `GridUser` ADD COLUMN TOS CHAR(36); - COMMIT; -- cgit v1.1 From 73c9abf5f2e2017bf924d6183502e337d28a7232 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Oct 2012 01:35:27 +0100 Subject: Move OpenSim.Data.RegionFlags -> OpenSim.Framework.RegionFlags to make it easier for other code to use (e.g. LSL_Api) without having to reference OpenSim.Data just for this. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 0614879..a2d4ae4 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -30,11 +30,11 @@ using System.Collections; using System.Collections.Generic; using System.Data; using System.Reflection; - +using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; -using MySql.Data.MySqlClient; +using RegionFlags = OpenSim.Framework.RegionFlags; namespace OpenSim.Data.MySQL { -- cgit v1.1 From a8424490aea0c202cf95f0eac566a49d7670c691 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 Nov 2012 22:39:54 +0000 Subject: Increment version number of a folder when an object it contains is deleted. Not doing this was allowing the viewer inventory cache to become out of sync if an item was directly deleted. --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index caf18a4..189ee5e 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -123,11 +123,24 @@ namespace OpenSim.Data.MySQL { } + public override bool Delete(string field, string val) + { + XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(field, val)) + return false; + + IncrementFolderVersion(retrievedItems[0].parentFolderID); + + return true; + } + public bool MoveItem(string id, string newParent) { using (MySqlCommand cmd = new MySqlCommand()) { - cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.Parameters.AddWithValue("?ParentFolderID", newParent); cmd.Parameters.AddWithValue("?InventoryID", id); @@ -184,6 +197,13 @@ namespace OpenSim.Data.MySQL if (!base.Store(item)) return false; + IncrementFolderVersion(item.parentFolderID); + + return true; + } + + private bool IncrementFolderVersion(UUID folderID) + { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -193,7 +213,7 @@ namespace OpenSim.Data.MySQL cmd.Connection = dbcon; cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); + cmd.Parameters.AddWithValue("?folderID", folderID.ToString()); try { @@ -205,9 +225,11 @@ namespace OpenSim.Data.MySQL } cmd.Dispose(); } + dbcon.Close(); } + return true; } } -} +} \ No newline at end of file -- cgit v1.1 From bf469819a628dcb8df18d3e1fb6ff5ac77038f2d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 Nov 2012 23:44:52 +0000 Subject: Update folder version numbers when moving items and making the Delete(string[], string[]) call (not just string, string). This is to stop viewer inventory cache version numbers becoming out of sync with grid stored numbers when viewer performs these actions. If there are no problems with these changes, they will be propogated to SQLite (and MSSQL if that's simple enough). May also need to do the same on folder store/create/delete and maybe propogate version increments up the folder hierarchy, but that requires investigation. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 6 +++ OpenSim/Data/MySQL/MySQLXInventoryData.cs | 51 ++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index da8e958..995c6a5 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -219,6 +219,8 @@ namespace OpenSim.Data.MySQL public virtual bool Store(T row) { +// m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked"); + using (MySqlCommand cmd = new MySqlCommand()) { string query = ""; @@ -273,6 +275,10 @@ namespace OpenSim.Data.MySQL public virtual bool Delete(string[] fields, string[] keys) { +// m_log.DebugFormat( +// "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}", +// string.Join(",", fields), string.Join(",", keys)); + if (fields.Length != keys.Length) return false; diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 189ee5e..cccc500 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -26,9 +26,10 @@ */ using System; +using System.Collections.Generic; using System.Data; +using System.Linq; using System.Reflection; -using System.Collections.Generic; using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; @@ -118,6 +119,8 @@ namespace OpenSim.Data.MySQL public class MySqlItemHandler : MySQLGenericTableHandler { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public MySqlItemHandler(string c, string t, string m) : base(c, t, m) { @@ -132,21 +135,53 @@ namespace OpenSim.Data.MySQL if (!base.Delete(field, val)) return false; - IncrementFolderVersion(retrievedItems[0].parentFolderID); + // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) +// IncrementFolderVersion(retrievedItems[0].parentFolderID); + + return true; + } + + public override bool Delete(string[] fields, string[] vals) + { + XInventoryItem[] retrievedItems = Get(fields, vals); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(fields, vals)) + return false; + + HashSet deletedItemFolderUUIDs = new HashSet(); + + Array.ForEach(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); + + foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) + IncrementFolderVersion(deletedItemFolderUUID); return true; } public bool MoveItem(string id, string newParent) { + XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); + if (retrievedItems.Length == 0) + return false; + + UUID oldParent = retrievedItems[0].parentFolderID; + using (MySqlCommand cmd = new MySqlCommand()) { cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.Parameters.AddWithValue("?ParentFolderID", newParent); cmd.Parameters.AddWithValue("?InventoryID", id); - return ExecuteNonQuery(cmd) == 0 ? false : true; + if (ExecuteNonQuery(cmd) == 0) + return false; } + + IncrementFolderVersion(oldParent); + IncrementFolderVersion(newParent); + + return true; } public XInventoryItem[] GetActiveGestures(UUID principalID) @@ -204,6 +239,14 @@ namespace OpenSim.Data.MySQL private bool IncrementFolderVersion(UUID folderID) { + return IncrementFolderVersion(folderID.ToString()); + } + + private bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -213,7 +256,7 @@ namespace OpenSim.Data.MySQL cmd.Connection = dbcon; cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", folderID.ToString()); + cmd.Parameters.AddWithValue("?folderID", folderID); try { -- cgit v1.1 From 75c880a6f3631a527b532773a8a493309a96028e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Nov 2012 00:59:18 +0000 Subject: Update parent inventory folder version numbers when folders are moved/created/deleted to match version numbers cached by viewers. This is done in the way that one would expect (e.g. moving a folder increments version number on both source and destination parent folders). This should hopefully improve viewer reuse of its cached inventory information. Currently MySQL only but will be implement for SQLite/MSSQL if there are no issues. --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 94 ++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index cccc500..7a3b5b4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -42,12 +42,12 @@ namespace OpenSim.Data.MySQL /// public class MySQLXInventoryData : IXInventoryData { - private MySQLGenericTableHandler m_Folders; + private MySqlFolderHandler m_Folders; private MySqlItemHandler m_Items; public MySQLXInventoryData(string conn, string realm) { - m_Folders = new MySQLGenericTableHandler( + m_Folders = new MySqlFolderHandler( conn, "inventoryfolders", "InventoryStore"); m_Items = new MySqlItemHandler( conn, "inventoryitems", String.Empty); @@ -106,6 +106,11 @@ namespace OpenSim.Data.MySQL return m_Items.MoveItem(id, newParent); } + public bool MoveFolder(string id, string newParent) + { + return m_Folders.MoveFolder(id, newParent); + } + public XInventoryItem[] GetActiveGestures(UUID principalID) { return m_Items.GetActiveGestures(principalID); @@ -275,4 +280,89 @@ namespace OpenSim.Data.MySQL return true; } } + + public class MySqlFolderHandler : MySQLGenericTableHandler + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySqlFolderHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public bool MoveFolder(string id, string newParentFolderID) + { + XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); + + if (folders.Length == 0) + return false; + + UUID oldParentFolderUUID = folders[0].parentFolderID; + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText + = String.Format( + "update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm); + cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID); + cmd.Parameters.AddWithValue("?folderID", id); + + if (ExecuteNonQuery(cmd) == 0) + return false; + } + + IncrementFolderVersion(oldParentFolderUUID); + IncrementFolderVersion(newParentFolderID); + + return true; + } + + public override bool Store(XInventoryFolder folder) + { + if (!base.Store(folder)) + return false; + + IncrementFolderVersion(folder.parentFolderID); + + return true; + } + + private bool IncrementFolderVersion(UUID folderID) + { + return IncrementFolderVersion(folderID.ToString()); + } + + private bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.Connection = dbcon; + + cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); + cmd.Parameters.AddWithValue("?folderID", folderID); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + return false; + } + cmd.Dispose(); + } + + dbcon.Close(); + } + + return true; + } + } } \ No newline at end of file -- cgit v1.1 From e4cb7af98a122773e84baf9be38b8b34f02e89a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 13 Nov 2012 19:26:43 -0800 Subject: Updated all existing AssemblyVersions's to 0.7.5.*. Many DLLs still don't have an AssemblyInfo file. --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index c28829c..ab3fe36 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From 350cd58e5e52b88651035bcba19010807bff7870 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Nov 2012 04:01:30 +0000 Subject: refactor: move common inventory folder version update code to parent class in mysql, mssql and sqlite database plugins --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 51 ++++++------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 7a3b5b4..c74033e 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL } } - public class MySqlItemHandler : MySQLGenericTableHandler + public class MySqlItemHandler : MySqlInventoryHandler { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -241,47 +241,9 @@ namespace OpenSim.Data.MySQL return true; } - - private bool IncrementFolderVersion(UUID folderID) - { - return IncrementFolderVersion(folderID.ToString()); - } - - private bool IncrementFolderVersion(string folderID) - { -// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); -// Util.PrintCallStack(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = new MySqlCommand()) - { - cmd.Connection = dbcon; - - cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", folderID); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - return false; - } - cmd.Dispose(); - } - - dbcon.Close(); - } - - return true; - } } - public class MySqlFolderHandler : MySQLGenericTableHandler + public class MySqlFolderHandler : MySqlInventoryHandler { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -326,13 +288,18 @@ namespace OpenSim.Data.MySQL return true; } + } + + public class MySqlInventoryHandler : MySQLGenericTableHandler where T: class, new() + { + public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {} - private bool IncrementFolderVersion(UUID folderID) + protected bool IncrementFolderVersion(UUID folderID) { return IncrementFolderVersion(folderID.ToString()); } - private bool IncrementFolderVersion(string folderID) + protected bool IncrementFolderVersion(string folderID) { // m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); // Util.PrintCallStack(); -- cgit v1.1 From f85b23edea3af2880086d096c85838cf48dd01a4 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 8 Dec 2012 17:33:03 -0500 Subject: Add agent verification to Presence --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 7808060..577a71a 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -95,5 +95,16 @@ namespace OpenSim.Data.MySQL return true; } + + public PresenceData VerifyAgent(UUID secureSessionID) + { + PresenceData[] ret = Get("SecureSessionID", + secureSessionID.ToString()); + + if (ret.Length == 0) + return null; + + return ret[0]; + } } } \ No newline at end of file -- cgit v1.1 From 8efae93b51082e0af9048306ffa8ca82586969af Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 9 Dec 2012 15:08:32 -0500 Subject: Restrict IPresenceData.VerifyAgent Restrict IPresenceData.VerifyAgent to only return bool result --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 577a71a..3f90639 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -96,15 +96,18 @@ namespace OpenSim.Data.MySQL return true; } - public PresenceData VerifyAgent(UUID secureSessionID) + public bool VerifyAgent(UUID agentId, UUID secureSessionID) { PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString()); if (ret.Length == 0) - return null; + return false; - return ret[0]; + if(ret[0].UserID != agentId.ToString()) + return false; + + return true; } } } \ No newline at end of file -- cgit v1.1 From a3e1e6dd611a179eb2d894a45ae45ef278ae2e85 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Aug 2010 21:57:08 +0100 Subject: Implement dynamic attribute persistence on mysql and mssql mssql is untested --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 16 ++++++++++++++-- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index d562783..b7f39fb 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -202,7 +202,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL, ?DynAttrs)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -230,7 +230,7 @@ namespace OpenSim.Data.MySQL "?PathTwistBegin, ?ProfileBegin, " + "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; + "?State, ?Media, ?DynAttrs)"; FillShapeCommand(cmd, prim); @@ -1291,6 +1291,11 @@ namespace OpenSim.Data.MySQL if (!(row["MediaURL"] is System.DBNull)) prim.MediaUrl = (string)row["MediaURL"]; + + if (!(row["DynAttrs"] is System.DBNull)) + prim.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); + else + prim.DynAttrs = new DynAttrsOSDMap(); return prim; } @@ -1637,6 +1642,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); } /// @@ -1829,6 +1835,11 @@ namespace OpenSim.Data.MySQL if (!(row["Media"] is System.DBNull)) s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); + + if (!(row["DynAttrs"] is System.DBNull)) + s.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); + else + s.DynAttrs = new DynAttrsOSDMap(); return s; } @@ -1873,6 +1884,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); + cmd.Parameters.AddWithValue("DynAttrs", s.DynAttrs.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 5b59779..1a38836 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -902,3 +902,12 @@ BEGIN; CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); COMMIT; + +:VERSION 46 #---------------- Dynamic attributes + +BEGIN; + +ALTER TABLE prims ADD COLUMN DynAttrs TEXT; +ALTER TABLE primshapes ADD COLUMN DynAttrs TEXT; + +COMMIT; -- cgit v1.1 From a6d9c263650cc23d60f941718f87a64aa2f360b2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 16 Aug 2010 22:21:46 +0100 Subject: Encapsulate an OSDMap in DAMap (was DynAttrsOSDMap) rather than inheriting from it This is the easier way to give us control over locking, rather than asking that OSDMap IDictionary methods be virtual --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b7f39fb..e558702 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1293,9 +1293,9 @@ namespace OpenSim.Data.MySQL prim.MediaUrl = (string)row["MediaURL"]; if (!(row["DynAttrs"] is System.DBNull)) - prim.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); + prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); else - prim.DynAttrs = new DynAttrsOSDMap(); + prim.DynAttrs = new DAMap(); return prim; } @@ -1837,9 +1837,9 @@ namespace OpenSim.Data.MySQL s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); if (!(row["DynAttrs"] is System.DBNull)) - s.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); + s.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); else - s.DynAttrs = new DynAttrsOSDMap(); + s.DynAttrs = new DAMap(); return s; } -- cgit v1.1 From 918b06286607a06e73eae5f24762b45eee76fd6a Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 21 Jan 2013 18:45:01 +0200 Subject: Added missing DynAttrs references in MySQL --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index e558702..77fa1ec 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -171,7 +171,8 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + + "LinkNumber, MediaURL, DynAttrs) " + + "values (?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + @@ -202,7 +203,8 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL, ?DynAttrs)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, " + + "?MediaURL, ?DynAttrs)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -219,7 +221,8 @@ namespace OpenSim.Data.MySQL "PathTaperX, PathTaperY, PathTwist, " + "PathTwistBegin, ProfileBegin, ProfileEnd, " + "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) values (?UUID, " + + "ExtraParams, State, Media, DynAttrs) " + + "values (?UUID, " + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + "?PCode, ?PathBegin, ?PathEnd, " + "?PathScaleX, ?PathScaleY, " + -- cgit v1.1 From fdec05a15ef126f344c03427e9ef264b4248646b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Jan 2013 08:49:36 +0200 Subject: Stopped storing dynamic attributes in the PrimShape --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 10 ++-------- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 77fa1ec..1a6a0fb 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -221,7 +221,7 @@ namespace OpenSim.Data.MySQL "PathTaperX, PathTaperY, PathTwist, " + "PathTwistBegin, ProfileBegin, ProfileEnd, " + "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media, DynAttrs) " + + "ExtraParams, State, Media) " + "values (?UUID, " + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + "?PCode, ?PathBegin, ?PathEnd, " + @@ -233,7 +233,7 @@ namespace OpenSim.Data.MySQL "?PathTwistBegin, ?ProfileBegin, " + "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media, ?DynAttrs)"; + "?State, ?Media)"; FillShapeCommand(cmd, prim); @@ -1838,11 +1838,6 @@ namespace OpenSim.Data.MySQL if (!(row["Media"] is System.DBNull)) s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); - - if (!(row["DynAttrs"] is System.DBNull)) - s.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); - else - s.DynAttrs = new DAMap(); return s; } @@ -1887,7 +1882,6 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); - cmd.Parameters.AddWithValue("DynAttrs", s.DynAttrs.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 1a38836..c48aec2 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -908,6 +908,5 @@ COMMIT; BEGIN; ALTER TABLE prims ADD COLUMN DynAttrs TEXT; -ALTER TABLE primshapes ADD COLUMN DynAttrs TEXT; COMMIT; -- cgit v1.1 From 86802bcf937e19ea99c2f9b7bc757b4e9daf3d16 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Jan 2013 08:55:15 +0200 Subject: Store NULL in the 'DynAttrs' column if the prim doesn't have any dynamic attributes --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 1a6a0fb..c95311e 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1645,7 +1645,11 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); - cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); + + if (prim.DynAttrs.Count > 0) + cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); + else + cmd.Parameters.AddWithValue("DynAttrs", null); } /// -- cgit v1.1 From 1f1da230976451d30d920c237d53c699ba96b9d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Feb 2013 00:23:17 +0000 Subject: Bump version and assembly version numbers from 0.7.5 to 0.7.6 This is mostly Bluewall's work but I am also bumping the general version number OpenSimulator 0.7.5 remains in the release candidate stage. I'm doing this because master is significantly adding things that will not be in 0.7.5 This update should not cause issues with existing external binary DLLs because our DLLs do not have strong names and so the exact version match requirement is not in force. --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index ab3fe36..7bfa28d 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.7.5.*")] +[assembly : AssemblyVersion("0.7.6.*")] [assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From e5beb480eaf23fa7454728724de80b2a67ded1e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Feb 2013 08:03:04 +0000 Subject: Partial port of Avination's support for the new physics parameters. Implements the parameters as properties, the serialization and database storage (MySQL only). Implements llSetPrimitiveParams for prim physics shape and the other 4 extra params. Only the prim shape type "None" is currently functional. No support for the Viewer UI (yet), that will be ported in due course. Lots more to port, this is a large-ish changeset. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 56 +++++++++++++++------- .../Data/MySQL/Resources/RegionStore.migrations | 13 +++++ 2 files changed, 51 insertions(+), 18 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index c95311e..2f471a0 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -52,7 +52,7 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); - protected virtual Assembly Assembly + protected Assembly Assembly { get { return GetType().Assembly; } } @@ -119,8 +119,10 @@ namespace OpenSim.Data.MySQL // Eligibility check // - if ((flags & (uint)PrimFlags.Temporary) != 0) - return; + // PrimFlags.Temporary is not used in OpenSim code and cannot + // be guaranteed to always be clear. Don't check it. +// if ((flags & (uint)PrimFlags.Temporary) != 0) +// return; if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) return; @@ -135,7 +137,7 @@ namespace OpenSim.Data.MySQL foreach (SceneObjectPart prim in obj.Parts) { cmd.Parameters.Clear(); - + cmd.CommandText = "replace into prims (" + "UUID, CreationDate, " + "Name, Text, Description, " + @@ -171,8 +173,10 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL, DynAttrs) " + - "values (?UUID, " + + "LinkNumber, MediaURL, " + + "PhysicsShapeType, Density, GravityModifier, " + + "Friction, Restitution, DynAttrs " + + ") values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + @@ -203,15 +207,17 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, " + - "?MediaURL, ?DynAttrs)"; - + "?CollisionSoundVolume, ?PassTouches, " + + "?LinkNumber, ?MediaURL, " + + "?PhysicsShapeType, ?Density, ?GravityModifier, " + + "?Friction, ?Restitution, ?DynAttrs)"; + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - + ExecuteNonQuery(cmd); - + cmd.Parameters.Clear(); - + cmd.CommandText = "replace into primshapes (" + "UUID, Shape, ScaleX, ScaleY, " + "ScaleZ, PCode, PathBegin, PathEnd, " + @@ -234,9 +240,9 @@ namespace OpenSim.Data.MySQL "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + "?State, ?Media)"; - + FillShapeCommand(cmd, prim); - + ExecuteNonQuery(cmd); } } @@ -582,7 +588,7 @@ namespace OpenSim.Data.MySQL cmd.CommandText = "insert into terrain (RegionUUID, " + "Revision, Heightfield) values (?RegionUUID, " + "1, ?Heightfield)"; - + cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); ExecuteNonQuery(cmd); @@ -741,7 +747,7 @@ namespace OpenSim.Data.MySQL { //No result, so store our default windlight profile and return it nWP.regionID = regionUUID; - StoreRegionWindlightSettings(nWP); +// StoreRegionWindlightSettings(nWP); return nWP; } else @@ -1097,7 +1103,8 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; + "?TerrainImageID, " + + "?TelehubObject, ?ParcelImageID)"; FillRegionSettingsCommand(cmd, rs); @@ -1300,6 +1307,12 @@ namespace OpenSim.Data.MySQL else prim.DynAttrs = new DAMap(); + prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString()); + prim.Density = (float)(double)row["Density"]; + prim.GravityModifier = (float)(double)row["GravityModifier"]; + prim.Friction = (float)(double)row["Friction"]; + prim.Bounciness = (float)(double)row["Restitution"]; + return prim; } @@ -1499,7 +1512,7 @@ namespace OpenSim.Data.MySQL for (int x = 0; x < (int)Constants.RegionSize; x++) for (int y = 0; y < (int)Constants.RegionSize; y++) { - double height = val[x, y]; + double height = 20.0; if (height == 0.0) height = double.Epsilon; @@ -1646,6 +1659,12 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType); + cmd.Parameters.AddWithValue("Density", (double)prim.Density); + cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); + cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); + cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); + if (prim.DynAttrs.Count > 0) cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); else @@ -1728,6 +1747,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); + cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); } diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index c48aec2..48cd60b 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -910,3 +910,16 @@ BEGIN; ALTER TABLE prims ADD COLUMN DynAttrs TEXT; COMMIT; + +:VERSION 47 #---------------- Extra prim params + +BEGIN; + +ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; +ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000'; +ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1'; +ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; +ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; + +COMMIT; + -- cgit v1.1 From 054a9928a0a393e6e880c0a716714b9f009f6ede Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Feb 2013 18:13:02 +0000 Subject: Fix a bug I brought in by manually editing a diff file. Terrain is if cource not always at 20m. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 2f471a0..41174f4 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1512,7 +1512,7 @@ namespace OpenSim.Data.MySQL for (int x = 0; x < (int)Constants.RegionSize; x++) for (int y = 0; y < (int)Constants.RegionSize; y++) { - double height = 20.0; + double height = val[x, y]; if (height == 0.0) height = double.Epsilon; -- cgit v1.1 From 6504e3d4cee1573115e8a83c06227a297a32f093 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 03:30:02 +0000 Subject: Rename "Bounciness" to "Restitution" --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 41174f4..1b02b4f 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1311,7 +1311,7 @@ namespace OpenSim.Data.MySQL prim.Density = (float)(double)row["Density"]; prim.GravityModifier = (float)(double)row["GravityModifier"]; prim.Friction = (float)(double)row["Friction"]; - prim.Bounciness = (float)(double)row["Restitution"]; + prim.Restitution = (float)(double)row["Restitution"]; return prim; } @@ -1663,7 +1663,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Density", (double)prim.Density); cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); - cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); + cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution); if (prim.DynAttrs.Count > 0) cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); -- cgit v1.1 From 85b81ff7f20334ebe50a5a33e41060fdcbd69d65 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 7 Feb 2013 08:23:57 +0200 Subject: Added physics parameters support to MSSQL and SQLite (not tested) --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 19 ++++++++++--------- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 1b02b4f..9cc6f40 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -173,9 +173,9 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL, " + + "LinkNumber, MediaURL, DynAttrs, " + "PhysicsShapeType, Density, GravityModifier, " + - "Friction, Restitution, DynAttrs " + + "Friction, Restitution " + ") values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + @@ -208,9 +208,9 @@ namespace OpenSim.Data.MySQL "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + "?CollisionSoundVolume, ?PassTouches, " + - "?LinkNumber, ?MediaURL, " + + "?LinkNumber, ?MediaURL, ?DynAttrs, " + "?PhysicsShapeType, ?Density, ?GravityModifier, " + - "?Friction, ?Restitution, ?DynAttrs)"; + "?Friction, ?Restitution)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -1659,16 +1659,17 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); - cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType); - cmd.Parameters.AddWithValue("Density", (double)prim.Density); - cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); - cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); - cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution); if (prim.DynAttrs.Count > 0) cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); else cmd.Parameters.AddWithValue("DynAttrs", null); + + cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType); + cmd.Parameters.AddWithValue("Density", (double)prim.Density); + cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); + cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); + cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution); } /// diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 48cd60b..513c784 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -911,7 +911,7 @@ ALTER TABLE prims ADD COLUMN DynAttrs TEXT; COMMIT; -:VERSION 47 #---------------- Extra prim params +:VERSION 47 #---------------- Extra physics params BEGIN; -- cgit v1.1 From 8b1b8a3921595088e85f4e11bc2b1d335aed83aa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Feb 2013 12:08:05 -0800 Subject: I need these for OfflineIM and Groups. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 995c6a5..35fa89f 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -301,5 +301,65 @@ namespace OpenSim.Data.MySQL return ExecuteNonQuery(cmd) > 0; } } + + public long GetCount(string field, string key) + { + return GetCount(new string[] { field }, new string[] { key }); + } + + public long GetCount(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return 0; + + List terms = new List(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + for (int i = 0; i < fields.Length; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add("`" + fields[i] + "` = ?" + fields[i]); + } + + string where = String.Join(" and ", terms.ToArray()); + + string query = String.Format("select count(*) from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + Object result = DoQueryScalar(cmd); + + return Convert.ToInt64(result); + } + } + + public long GetCount(string where) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + string query = String.Format("select count(*) from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + object result = DoQueryScalar(cmd); + + return Convert.ToInt64(result); + } + } + + public object DoQueryScalar(MySqlCommand cmd) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + cmd.Connection = dbcon; + + return cmd.ExecuteScalar(); + } + } + } } \ No newline at end of file -- cgit v1.1 From 46e182dbf546dcb58d088c043a0baa2dcfed9125 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Feb 2013 06:37:20 -0800 Subject: Offline IM: moved the Data and MySQL bits to the corresponding places in core, so that it will be easier to plugin a SQLite backend, if anyone is interested in doing that. --- OpenSim/Data/MySQL/MySQLOfflineIMData.cs | 62 ++++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/IM_Store.migrations | 24 +++++++++ 2 files changed, 86 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLOfflineIMData.cs create mode 100644 OpenSim/Data/MySQL/Resources/IM_Store.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs new file mode 100644 index 0000000..252f358 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs @@ -0,0 +1,62 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Data.MySQL; + +using OpenMetaverse; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySQLOfflineIMData : MySQLGenericTableHandler, IOfflineIMData + { + public MySQLOfflineIMData(string connectionString, string realm) + : base(connectionString, realm, "IM_Store") + { + } + + public void DeleteOld() + { + uint now = (uint)Util.UnixTimeSinceEpoch(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); + cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old + + ExecuteNonQuery(cmd); + } + + } + } +} diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations new file mode 100644 index 0000000..7cfcd43 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations @@ -0,0 +1,24 @@ +:VERSION 1 # -------------------------- + +BEGIN; + +CREATE TABLE `im_offline` ( + `ID` MEDIUMINT NOT NULL AUTO_INCREMENT, + `PrincipalID` char(36) NOT NULL default '', + `Message` text NOT NULL, + `TMStamp` timestamp NOT NULL, + PRIMARY KEY (`ID`), + KEY `PrincipalID` (`PrincipalID`) +) ENGINE=MyISAM; + +COMMIT; + +:VERSION 2 # -------------------------- + +BEGIN; + +INSERT INTO `im_offline` SELECT * from `diva_im_offline`; +DROP TABLE `diva_im_offline`; +DELETE FROM `migrations` WHERE name='diva_im_Store'; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 9380d01976726885bd993573aa649f2cb0992909 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Feb 2013 07:26:40 -0800 Subject: First commit of Diva Groups. The Data bits went to OpenSim.Data core, the rest to Addons.Groups.dll. --- OpenSim/Data/MySQL/MySQLGroupsData.cs | 484 +++++++++++++++++++++ .../MySQL/Resources/os_groups_Store.migrations | 115 +++++ 2 files changed, 599 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLGroupsData.cs create mode 100644 OpenSim/Data/MySQL/Resources/os_groups_Store.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs new file mode 100644 index 0000000..2a1bd6c --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs @@ -0,0 +1,484 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Data.MySQL; + +using OpenMetaverse; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySQLGroupsData : IGroupsData + { + private MySqlGroupsGroupsHandler m_Groups; + private MySqlGroupsMembershipHandler m_Membership; + private MySqlGroupsRolesHandler m_Roles; + private MySqlGroupsRoleMembershipHandler m_RoleMembership; + private MySqlGroupsInvitesHandler m_Invites; + private MySqlGroupsNoticesHandler m_Notices; + private MySqlGroupsPrincipalsHandler m_Principals; + + public MySQLGroupsData(string connectionString, string realm) + { + m_Groups = new MySqlGroupsGroupsHandler(connectionString, realm + "_groups", realm + "_Store"); + m_Membership = new MySqlGroupsMembershipHandler(connectionString, realm + "_membership"); + m_Roles = new MySqlGroupsRolesHandler(connectionString, realm + "_roles"); + m_RoleMembership = new MySqlGroupsRoleMembershipHandler(connectionString, realm + "_rolemembership"); + m_Invites = new MySqlGroupsInvitesHandler(connectionString, realm + "_invites"); + m_Notices = new MySqlGroupsNoticesHandler(connectionString, realm + "_notices"); + m_Principals = new MySqlGroupsPrincipalsHandler(connectionString, realm + "_principals"); + } + + #region groups table + public bool StoreGroup(GroupData data) + { + return m_Groups.Store(data); + } + + public GroupData RetrieveGroup(UUID groupID) + { + GroupData[] groups = m_Groups.Get("GroupID", groupID.ToString()); + if (groups.Length > 0) + return groups[0]; + + return null; + } + + public GroupData RetrieveGroup(string name) + { + GroupData[] groups = m_Groups.Get("Name", name); + if (groups.Length > 0) + return groups[0]; + + return null; + } + + public GroupData[] RetrieveGroups(string pattern) + { + if (string.IsNullOrEmpty(pattern)) + pattern = "1 ORDER BY Name LIMIT 100"; + else + pattern = string.Format("Name LIKE %{0}% ORDER BY Name LIMIT 100", pattern); + + return m_Groups.Get(pattern); + } + + public bool DeleteGroup(UUID groupID) + { + return m_Groups.Delete("GroupID", groupID.ToString()); + } + + public int GroupsCount() + { + return (int)m_Groups.GetCount("Location=\"\""); + } + + #endregion + + #region membership table + public MembershipData[] RetrieveMembers(UUID groupID) + { + return m_Membership.Get("GroupID", groupID.ToString()); + } + + public MembershipData RetrieveMember(UUID groupID, string pricipalID) + { + MembershipData[] m = m_Membership.Get(new string[] { "GroupID", "PrincipalID" }, + new string[] { groupID.ToString(), pricipalID }); + if (m != null && m.Length > 0) + return m[0]; + + return null; + } + + public MembershipData[] RetrieveMemberships(string pricipalID) + { + return m_Membership.Get("PrincipalID", pricipalID.ToString()); + } + + public bool StoreMember(MembershipData data) + { + return m_Membership.Store(data); + } + + public bool DeleteMember(UUID groupID, string pricipalID) + { + return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" }, + new string[] { groupID.ToString(), pricipalID }); + } + + public int MemberCount(UUID groupID) + { + return (int)m_Membership.GetCount("GroupID", groupID.ToString()); + } + #endregion + + #region roles table + public bool StoreRole(RoleData data) + { + return m_Roles.Store(data); + } + + public RoleData RetrieveRole(UUID groupID, UUID roleID) + { + RoleData[] data = m_Roles.Get(new string[] { "GroupID", "RoleID" }, + new string[] { groupID.ToString(), roleID.ToString() }); + + if (data != null && data.Length > 0) + return data[0]; + + return null; + } + + public RoleData[] RetrieveRoles(UUID groupID) + { + //return m_Roles.RetrieveRoles(groupID); + return m_Roles.Get("GroupID", groupID.ToString()); + } + + public bool DeleteRole(UUID groupID, UUID roleID) + { + return m_Roles.Delete(new string[] { "GroupID", "RoleID" }, + new string[] { groupID.ToString(), roleID.ToString() }); + } + + public int RoleCount(UUID groupID) + { + return (int)m_Roles.GetCount("GroupID", groupID.ToString()); + } + + + #endregion + + #region rolememberhip table + public RoleMembershipData[] RetrieveRolesMembers(UUID groupID) + { + RoleMembershipData[] data = m_RoleMembership.Get("GroupID", groupID.ToString()); + + return data; + } + + public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID) + { + RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID" }, + new string[] { groupID.ToString(), roleID.ToString() }); + + return data; + } + + public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID) + { + RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "PrincipalID" }, + new string[] { groupID.ToString(), principalID.ToString() }); + + return data; + } + + public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID) + { + RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID", "PrincipalID" }, + new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() }); + + if (data != null && data.Length > 0) + return data[0]; + + return null; + } + + public int RoleMemberCount(UUID groupID, UUID roleID) + { + return (int)m_RoleMembership.GetCount(new string[] { "GroupID", "RoleID" }, + new string[] { groupID.ToString(), roleID.ToString() }); + } + + public bool StoreRoleMember(RoleMembershipData data) + { + return m_RoleMembership.Store(data); + } + + public bool DeleteRoleMember(RoleMembershipData data) + { + return m_RoleMembership.Delete(new string[] { "GroupID", "RoleID", "PrincipalID"}, + new string[] { data.GroupID.ToString(), data.RoleID.ToString(), data.PrincipalID }); + } + + public bool DeleteMemberAllRoles(UUID groupID, string principalID) + { + return m_RoleMembership.Delete(new string[] { "GroupID", "PrincipalID" }, + new string[] { groupID.ToString(), principalID }); + } + + #endregion + + #region principals table + public bool StorePrincipal(PrincipalData data) + { + return m_Principals.Store(data); + } + + public PrincipalData RetrievePrincipal(string principalID) + { + PrincipalData[] p = m_Principals.Get("PrincipalID", principalID); + if (p != null && p.Length > 0) + return p[0]; + + return null; + } + + public bool DeletePrincipal(string principalID) + { + return m_Principals.Delete("PrincipalID", principalID); + } + #endregion + + #region invites table + + public bool StoreInvitation(InvitationData data) + { + return m_Invites.Store(data); + } + + public InvitationData RetrieveInvitation(UUID inviteID) + { + InvitationData[] invites = m_Invites.Get("InviteID", inviteID.ToString()); + + if (invites != null && invites.Length > 0) + return invites[0]; + + return null; + } + + public InvitationData RetrieveInvitation(UUID groupID, string principalID) + { + InvitationData[] invites = m_Invites.Get(new string[] { "GroupID", "PrincipalID" }, + new string[] { groupID.ToString(), principalID }); + + if (invites != null && invites.Length > 0) + return invites[0]; + + return null; + } + + public bool DeleteInvite(UUID inviteID) + { + return m_Invites.Delete("InviteID", inviteID.ToString()); + } + + public void DeleteOldInvites() + { + m_Invites.DeleteOld(); + } + + #endregion + + #region notices table + + public bool StoreNotice(NoticeData data) + { + return m_Notices.Store(data); + } + + public NoticeData RetrieveNotice(UUID noticeID) + { + NoticeData[] notices = m_Notices.Get("NoticeID", noticeID.ToString()); + + if (notices != null && notices.Length > 0) + return notices[0]; + + return null; + } + + public NoticeData[] RetrieveNotices(UUID groupID) + { + NoticeData[] notices = m_Notices.Get("GroupID", groupID.ToString()); + + return notices; + } + + public bool DeleteNotice(UUID noticeID) + { + return m_Notices.Delete("NoticeID", noticeID.ToString()); + } + + public void DeleteOldNotices() + { + m_Notices.DeleteOld(); + } + + #endregion + + #region combinations + public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID) + { + // TODO + return null; + } + public MembershipData[] RetrievePrincipalGroupMemberships(string principalID) + { + // TODO + return null; + } + + #endregion + } + + public class MySqlGroupsGroupsHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsGroupsHandler(string connectionString, string realm, string store) + : base(connectionString, realm, store) + { + } + + } + + public class MySqlGroupsMembershipHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsMembershipHandler(string connectionString, string realm) + : base(connectionString, realm, string.Empty) + { + } + + } + + public class MySqlGroupsRolesHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsRolesHandler(string connectionString, string realm) + : base(connectionString, realm, string.Empty) + { + } + + } + + public class MySqlGroupsRoleMembershipHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsRoleMembershipHandler(string connectionString, string realm) + : base(connectionString, realm, string.Empty) + { + } + + } + + public class MySqlGroupsInvitesHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsInvitesHandler(string connectionString, string realm) + : base(connectionString, realm, string.Empty) + { + } + + public void DeleteOld() + { + uint now = (uint)Util.UnixTimeSinceEpoch(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); + cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old + + ExecuteNonQuery(cmd); + } + + } + } + + public class MySqlGroupsNoticesHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsNoticesHandler(string connectionString, string realm) + : base(connectionString, realm, string.Empty) + { + } + + public void DeleteOld() + { + uint now = (uint)Util.UnixTimeSinceEpoch(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); + cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old + + ExecuteNonQuery(cmd); + } + + } + } + + public class MySqlGroupsPrincipalsHandler : MySQLGenericTableHandler + { + protected override Assembly Assembly + { + // WARNING! Moving migrations to this assembly!!! + get { return GetType().Assembly; } + } + + public MySqlGroupsPrincipalsHandler(string connectionString, string realm) + : base(connectionString, realm, string.Empty) + { + } + } +} diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations new file mode 100644 index 0000000..9e6f1c1 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations @@ -0,0 +1,115 @@ +:VERSION 1 # -------------------------- + +BEGIN; + +CREATE TABLE `os_groups_groups` ( + `GroupID` char(36) NOT NULL default '', + `Location` varchar(255) NOT NULL default '', + `Name` varchar(255) NOT NULL default '', + `Charter` text NOT NULL, + `InsigniaID` char(36) NOT NULL default '', + `FounderID` char(36) NOT NULL default '', + `MembershipFee` int(11) NOT NULL default '0', + `OpenEnrollment` varchar(255) NOT NULL default '', + `ShowInList` int(4) NOT NULL default '0', + `AllowPublish` int(4) NOT NULL default '0', + `MaturePublish` int(4) NOT NULL default '0', + `OwnerRoleID` char(36) NOT NULL default '', + PRIMARY KEY (`GroupID`), + UNIQUE KEY `Name` (`Name`), + FULLTEXT KEY `Name_2` (`Name`) +) ENGINE=MyISAM; + + +CREATE TABLE `os_groups_membership` ( + `GroupID`char(36) NOT NULL default '', + `PrincipalID` VARCHAR(255) NOT NULL default '', + `SelectedRoleID` char(36) NOT NULL default '', + `Contribution` int(11) NOT NULL default '0', + `ListInProfile` int(4) NOT NULL default '1', + `AcceptNotices` int(4) NOT NULL default '1', + `AccessToken` char(36) NOT NULL default '', + PRIMARY KEY (`GroupID`,`PrincipalID`), + KEY `PrincipalID` (`PrincipalID`) +) ENGINE=MyISAM; + + +CREATE TABLE `os_groups_roles` ( + `GroupID` char(36) NOT NULL default '', + `RoleID` char(36) NOT NULL default '', + `Name` varchar(255) NOT NULL default '', + `Description` varchar(255) NOT NULL default '', + `Title` varchar(255) NOT NULL default '', + `Powers` bigint(20) unsigned NOT NULL default '0', + PRIMARY KEY (`GroupID`,`RoleID`), + KEY `GroupID` (`GroupID`) +) ENGINE=MyISAM; + + +CREATE TABLE `os_groups_rolemembership` ( + `GroupID` char(36) NOT NULL default '', + `RoleID` char(36) NOT NULL default '', + `PrincipalID` VARCHAR(255) NOT NULL default '', + PRIMARY KEY (`GroupID`,`RoleID`,`PrincipalID`), + KEY `PrincipalID` (`PrincipalID`) +) ENGINE=MyISAM; + + +CREATE TABLE `os_groups_invites` ( + `InviteID` char(36) NOT NULL default '', + `GroupID` char(36) NOT NULL default '', + `RoleID` char(36) NOT NULL default '', + `PrincipalID` VARCHAR(255) NOT NULL default '', + `TMStamp` timestamp NOT NULL, + PRIMARY KEY (`InviteID`), + UNIQUE KEY `PrincipalGroup` (`GroupID`,`PrincipalID`) +) ENGINE=MyISAM; + + +CREATE TABLE `os_groups_notices` ( + `GroupID` char(36) NOT NULL default '', + `NoticeID` char(36) NOT NULL default '', + `TMStamp` int(10) unsigned NOT NULL default '0', + `FromName` varchar(255) NOT NULL default '', + `Subject` varchar(255) NOT NULL default '', + `Message` text NOT NULL, + `HasAttachment` int(4) NOT NULL default '0', + `AttachmentType` int(4) NOT NULL default '0', + `AttachmentName` varchar(128) NOT NULL default '', + `AttachmentItemID` char(36) NOT NULL default '', + `AttachmentOwnerID` varchar(255) NOT NULL default '', + PRIMARY KEY (`NoticeID`), + KEY `GroupID` (`GroupID`), + KEY `TMStamp` (`TMStamp`) +) ENGINE=MyISAM; + +CREATE TABLE `os_groups_principals` ( + `PrincipalID` VARCHAR(255) NOT NULL default '', + `ActiveGroupID` char(36) NOT NULL default '', + PRIMARY KEY (`PrincipalID`) +) ENGINE=MyISAM; + +COMMIT; + +:VERSION 2 # -------------------------- + +BEGIN; + +INSERT INTO `os_groups_groups` SELECT * from `diva_groups_groups`; +DROP TABLE `diva_groups_groups`; +INSERT INTO `os_groups_membership` SELECT * from `diva_groups_membership`; +DROP TABLE `diva_groups_membership`; +INSERT INTO `os_groups_roles` SELECT * from `diva_groups_roles`; +DROP TABLE `diva_groups_roles`; +INSERT INTO `os_groups_rolemembership` SELECT * from `diva_groups_rolemembership`; +DROP TABLE `diva_groups_rolemembership`; +INSERT INTO `os_groups_invites` SELECT * from `diva_groups_invites`; +DROP TABLE `diva_groups_invites`; +INSERT INTO `os_groups_notices` SELECT * from `diva_groups_notices`; +DROP TABLE `diva_groups_notices`; +INSERT INTO `os_groups_principals` SELECT * from `diva_groups_principals`; +DROP TABLE `diva_groups_principals`; + +DELETE FROM `migrations` WHERE name='diva_im_Store'; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 4779f7d7d5ce0e284d9ed15104389f8479b11545 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Feb 2013 17:14:55 -0800 Subject: Deleted all AssemblyFileVersion directives --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 7bfa28d..1146d92 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("0.7.6.*")] -[assembly : AssemblyFileVersion("0.6.5.0")] + -- cgit v1.1 From 74916ed777d811088344077b08a190ff17129c70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Feb 2013 21:35:54 +0000 Subject: Add more information to warnings logged when asset names and descriptions have to be truncated for database storage On balance, I still think this is useful because asset names and descriptions can sometimes be helpful in determining what things are. Even though they are never subsequently (inventory names/descriptions are always used instead). --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 ++++++-- OpenSim/Data/MySQL/MySQLXAssetData.cs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 73de64b..cf80b3d 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -173,14 +173,18 @@ namespace OpenSim.Data.MySQL if (asset.Name.Length > 64) { assetName = asset.Name.Substring(0, 64); - m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + m_log.WarnFormat( + "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; if (asset.Description.Length > 64) { assetDescription = asset.Description.Substring(0, 64); - m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + m_log.WarnFormat( + "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); } try diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index e6ac22e..c2282c8 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -204,14 +204,18 @@ namespace OpenSim.Data.MySQL if (asset.Name.Length > 64) { assetName = asset.Name.Substring(0, 64); - m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); + m_log.WarnFormat( + "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; if (asset.Description.Length > 64) { assetDescription = asset.Description.Substring(0, 64); - m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); + m_log.WarnFormat( + "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); } if (m_enableCompression) -- cgit v1.1 From e9f3cd1a60bfc5e936d1029495ada2c2bff99430 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Mar 2013 23:17:54 +0000 Subject: Implement access time updates on assets for XAssetService. This only happens if access time is older than 30 days currently, in order to reduce database updates. The idea is to give some idea of assets which haven't been accessed for a very, very long time. These might conceivably be deleteable, though this will be a risk due to caching at other points in the chain. This is actually currently much less useable on the xasset service since access time is on metadata rather than the data itself. And many metadata entries may point to the same data. Probably need to address this. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 95 +++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 38 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index c2282c8..273fbca 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -50,6 +50,11 @@ namespace OpenSim.Data.MySQL get { return GetType().Assembly; } } + /// + /// Number of days that must pass before we update the access time on an asset when it has been fetched. + /// + private const int DaysBetweenAccessTimeUpdates = 30; + private bool m_enableCompression = false; private string m_connectionString; private object m_dbLock = new object(); @@ -133,7 +138,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", + "SELECT name, description, access_time, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", dbcon)) { cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -171,12 +176,14 @@ namespace OpenSim.Data.MySQL // asset.ID, asset.Name, asset.Data.Length, compressedLength); } } + + UpdateAccessTime(asset.Metadata, (int)dbReader["access_time"]); } } } catch (Exception e) { - m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); + m_log.Error("[MYSQL XASSET DATA]: Failure fetching asset " + assetID + ": " + e.Message); } } } @@ -303,41 +310,49 @@ namespace OpenSim.Data.MySQL } } -// private void UpdateAccessTime(AssetBase asset) -// { -// lock (m_dbLock) -// { -// using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) -// { -// dbcon.Open(); -// MySqlCommand cmd = -// new MySqlCommand("update assets set access_time=?access_time where id=?id", -// dbcon); -// -// // need to ensure we dispose -// try -// { -// using (cmd) -// { -// // create unix epoch time -// int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); -// cmd.Parameters.AddWithValue("?id", asset.ID); -// cmd.Parameters.AddWithValue("?access_time", now); -// cmd.ExecuteNonQuery(); -// cmd.Dispose(); -// } -// } -// catch (Exception e) -// { -// m_log.ErrorFormat( -// "[ASSETS DB]: " + -// "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() -// + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); -// } -// } -// } -// -// } + /// + /// Updates the access time of the asset if it was accessed above a given threshhold amount of time. + /// + /// + /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done + /// over the threshold time to avoid excessive database writes as assets are fetched. + /// + /// + /// + private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime) + { + DateTime now = DateTime.UtcNow; + + if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) + return; + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = + new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon); + + try + { + using (cmd) + { + // create unix epoch time + cmd.Parameters.AddWithValue("?id", assetMetadata.ID); + cmd.Parameters.AddWithValue("?access_time", (int)Utils.DateTimeToUnixTime(now)); + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", + assetMetadata.ID, assetMetadata.Name); + } + } + } + } /// /// We assume we already have the m_dbLock. @@ -422,6 +437,8 @@ namespace OpenSim.Data.MySQL return assetExists; } + + /// /// Returns a list of AssetMetadata objects. The list is a subset of /// the entire data set offset by containing @@ -439,7 +456,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,access_time,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?count", count); @@ -461,6 +478,8 @@ namespace OpenSim.Data.MySQL // We'll ignore this for now - it appears unused! // metadata.SHA1 = dbReader["hash"]); + UpdateAccessTime(metadata, (int)dbReader["access_time"]); + retList.Add(metadata); } } -- cgit v1.1 From 35843e8ec8c58803664ab33ad52fd8e64a8765c6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Mar 2013 23:42:16 +0000 Subject: Change the table and field names of XAssetService mysql db tables to be capitalized like Avatars, Friends, etc. Also fixes access time being set on assets rather than XAssetsMeta This is to try and be somewhat consistent with other service tables that are mainly in this style. No migration is supplied, since nobody should be using this service yet except on a test basis. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 92 +++++++++++----------- .../Data/MySQL/Resources/XAssetStore.migrations | 30 +++---- 2 files changed, 60 insertions(+), 62 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 273fbca..8c93825 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -138,10 +138,10 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, access_time, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", + "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID", dbcon)) { - cmd.Parameters.AddWithValue("?id", assetID.ToString()); + cmd.Parameters.AddWithValue("?ID", assetID.ToString()); try { @@ -149,18 +149,18 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); - asset.Data = (byte[])dbReader["data"]; - asset.Description = (string)dbReader["description"]; + asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); + asset.Data = (byte[])dbReader["Data"]; + asset.Description = (string)dbReader["Description"]; - string local = dbReader["local"].ToString(); + string local = dbReader["Local"].ToString(); if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) asset.Local = true; else asset.Local = false; - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); - asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); + asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); if (m_enableCompression) { @@ -177,13 +177,13 @@ namespace OpenSim.Data.MySQL } } - UpdateAccessTime(asset.Metadata, (int)dbReader["access_time"]); + UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); } } } catch (Exception e) { - m_log.Error("[MYSQL XASSET DATA]: Failure fetching asset " + assetID + ": " + e.Message); + m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); } } } @@ -249,23 +249,23 @@ namespace OpenSim.Data.MySQL { using (MySqlCommand cmd = new MySqlCommand( - "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + - "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", + "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" + + "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)", dbcon)) { // create unix epoch time int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?name", assetName); - cmd.Parameters.AddWithValue("?description", assetDescription); - cmd.Parameters.AddWithValue("?asset_type", asset.Type); - cmd.Parameters.AddWithValue("?local", asset.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Temporary); - cmd.Parameters.AddWithValue("?create_time", now); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); - cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); + cmd.Parameters.AddWithValue("?ID", asset.ID); + cmd.Parameters.AddWithValue("?Hash", hash); + cmd.Parameters.AddWithValue("?Name", assetName); + cmd.Parameters.AddWithValue("?Description", assetDescription); + cmd.Parameters.AddWithValue("?AssetType", asset.Type); + cmd.Parameters.AddWithValue("?Local", asset.Local); + cmd.Parameters.AddWithValue("?Temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?CreateTime", now); + cmd.Parameters.AddWithValue("?AccessTime", now); + cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); + cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags); cmd.ExecuteNonQuery(); } } @@ -285,11 +285,11 @@ namespace OpenSim.Data.MySQL { using (MySqlCommand cmd = new MySqlCommand( - "INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)", + "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", dbcon)) { - cmd.Parameters.AddWithValue("?hash", hash); - cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.Parameters.AddWithValue("?Hash", hash); + cmd.Parameters.AddWithValue("?Data", asset.Data); cmd.ExecuteNonQuery(); } } @@ -332,15 +332,15 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); MySqlCommand cmd = - new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon); + new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); try { using (cmd) { // create unix epoch time - cmd.Parameters.AddWithValue("?id", assetMetadata.ID); - cmd.Parameters.AddWithValue("?access_time", (int)Utils.DateTimeToUnixTime(now)); + cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); + cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); cmd.ExecuteNonQuery(); } } @@ -368,9 +368,9 @@ namespace OpenSim.Data.MySQL bool exists = false; - using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) + using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon)) { - cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?Hash", hash); try { @@ -410,9 +410,9 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon)) + using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon)) { - cmd.Parameters.AddWithValue("?id", uuid.ToString()); + cmd.Parameters.AddWithValue("?ID", uuid.ToString()); try { @@ -427,8 +427,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.ErrorFormat( - "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); + m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e); } } } @@ -438,7 +437,6 @@ namespace OpenSim.Data.MySQL } - /// /// Returns a list of AssetMetadata objects. The list is a subset of /// the entire data set offset by containing @@ -456,7 +454,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,access_time,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); + MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?count", count); @@ -467,18 +465,18 @@ namespace OpenSim.Data.MySQL while (dbReader.Read()) { AssetMetadata metadata = new AssetMetadata(); - metadata.Name = (string)dbReader["name"]; - metadata.Description = (string)dbReader["description"]; - metadata.Type = (sbyte)dbReader["asset_type"]; - metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. - metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); - metadata.FullID = DBGuid.FromDB(dbReader["id"]); - metadata.CreatorID = dbReader["creator_id"].ToString(); + metadata.Name = (string)dbReader["Name"]; + metadata.Description = (string)dbReader["Description"]; + metadata.Type = (sbyte)dbReader["AssetType"]; + metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); + metadata.FullID = DBGuid.FromDB(dbReader["ID"]); + metadata.CreatorID = dbReader["CreatorID"].ToString(); // We'll ignore this for now - it appears unused! // metadata.SHA1 = dbReader["hash"]); - UpdateAccessTime(metadata, (int)dbReader["access_time"]); + UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); retList.Add(metadata); } @@ -504,9 +502,9 @@ namespace OpenSim.Data.MySQL { dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon)) + using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) { - cmd.Parameters.AddWithValue("?id", id); + cmd.Parameters.AddWithValue("?ID", id); cmd.ExecuteNonQuery(); } diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index d3cca5e..0c49d0d 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -3,24 +3,24 @@ BEGIN; -CREATE TABLE `xassetsmeta` ( - `id` char(36) NOT NULL, - `hash` binary(32) NOT NULL, - `name` varchar(64) NOT NULL, - `description` varchar(64) NOT NULL, - `asset_type` tinyint(4) NOT NULL, - `local` tinyint(1) NOT NULL, - `temporary` tinyint(1) NOT NULL, - `create_time` int(11) NOT NULL, - `access_time` int(11) NOT NULL, - `asset_flags` int(11) NOT NULL, - `creator_id` varchar(128) NOT NULL, +CREATE TABLE `XAssetsMeta` ( + `ID` char(36) NOT NULL, + `Hash` binary(32) NOT NULL, + `Name` varchar(64) NOT NULL, + `Description` varchar(64) NOT NULL, + `AssetType` tinyint(4) NOT NULL, + `Local` tinyint(1) NOT NULL, + `Temporary` tinyint(1) NOT NULL, + `CreateTime` int(11) NOT NULL, + `AccessTime` int(11) NOT NULL, + `AssetFlags` int(11) NOT NULL, + `CreatorID` varchar(128) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; -CREATE TABLE `xassetsdata` ( - `hash` binary(32) NOT NULL, - `data` longblob NOT NULL, +CREATE TABLE `XAssetsData` ( + `Hash` binary(32) NOT NULL, + `Data` longblob NOT NULL, PRIMARY KEY (`hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; -- cgit v1.1 From e20b0d5695dc583d161b39fa26bfd56e63c7b30e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Apr 2013 00:03:37 +0100 Subject: minor: Make exceptions thrown by MySQLAssetData more consistent. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index cf80b3d..21362b9 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -142,7 +142,8 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message); + m_log.Error( + string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); } } } @@ -209,8 +210,11 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", - asset.FullID, asset.Name, e.Message); + m_log.Error( + string.Format( + "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", + asset.FullID, asset.Name) + , e); } } } @@ -241,10 +245,11 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.ErrorFormat( - "[ASSETS DB]: " + - "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); + m_log.Error( + string.Format( + "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", + asset.FullID, asset.Name), + e); } } } @@ -284,8 +289,8 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); + m_log.Error( + string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e); } } } @@ -344,7 +349,11 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + m_log.Error( + string.Format( + "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", + start, count), + e); } } } -- cgit v1.1 From 3bc801746466cbd401f481295876b357fa27125b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 25 Apr 2013 09:23:15 -0700 Subject: Recover a lost "virtual". Downstream projects need this. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 9cc6f40..2d20eaf 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -52,7 +52,7 @@ namespace OpenSim.Data.MySQL private string m_connectionString; private object m_dbLock = new object(); - protected Assembly Assembly + protected virtual Assembly Assembly { get { return GetType().Assembly; } } -- cgit v1.1 From a517e597f5960e5ce5eeea89e9087ac32a42bf06 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 28 Apr 2013 09:03:09 -0700 Subject: Fix wrong sql statement in offline im. --- OpenSim/Data/MySQL/MySQLOfflineIMData.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs index 252f358..bafd204 100644 --- a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs +++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs @@ -47,13 +47,10 @@ namespace OpenSim.Data.MySQL public void DeleteOld() { - uint now = (uint)Util.UnixTimeSinceEpoch(); - using (MySqlCommand cmd = new MySqlCommand()) { - cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); - cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old - + cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm); + ExecuteNonQuery(cmd); } -- cgit v1.1 From 81d8deb1a830765ec64948db5ec3902894761f24 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 11 May 2013 01:27:37 +0100 Subject: Send up the part missing from the Avination Estate commit. Warning - contains a small migration. --- OpenSim/Data/MySQL/Resources/EstateStore.migrations | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index df82a2e..2d1c2b5 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -77,5 +77,11 @@ BEGIN; ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; +:VERSION 33 #--------------------- +BEGIN; +ALTER TABLE estate_settings ADD COLUMN `AllowLandmark` tinyint(4) NOT NULL default '1'; +ALTER TABLE estate_settings ADD COLUMN `AllowParcelChanges` tinyint(4) NOT NULL default '1'; +ALTER TABLE estate_settings ADD COLUMN `AllowSetHome` tinyint(4) NOT NULL default '1'; +COMMIT; -- cgit v1.1 From 328883700a15e4216bf7b251ac099d38f413375e Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 13 May 2013 22:11:28 -0400 Subject: UserProfiles UserProfiles for Robust and Standalone. Includes service and connectors for Robust and standalone opensim plus matching region module. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 1023 ++++++++++++++++++++ .../Data/MySQL/Resources/UserProfiles.migrations | 83 ++ 2 files changed, 1106 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLUserProfilesData.cs create mode 100644 OpenSim/Data/MySQL/Resources/UserProfiles.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs new file mode 100644 index 0000000..09bd448 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -0,0 +1,1023 @@ +using System; +using System.Data; +using System.Reflection; +using OpenSim.Data; +using OpenSim.Framework; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using log4net; + +namespace OpenSim.Data.MySQL +{ + public class UserProfilesData: IProfilesData + { + static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region Properites + string ConnectionString + { + get; set; + } + + protected object Lock + { + get; set; + } + + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + + #endregion Properties + + #region class Member Functions + public UserProfilesData(string connectionString) + { + ConnectionString = connectionString; + Init(); + } + + void Init() + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + + Migration m = new Migration(dbcon, Assembly, "UserProfiles"); + m.Update(); + } + } + #endregion Member Functions + + #region Classifieds Queries + /// + /// Gets the classified records. + /// + /// + /// Array of classified records + /// + /// + /// Creator identifier. + /// + public OSDArray GetClassifiedRecords(UUID creatorId) + { + OSDArray data = new OSDArray(); + + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?Id", creatorId); + using( MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) + { + if(reader.HasRows) + { + while (reader.Read()) + { + OSDMap n = new OSDMap(); + UUID Id = UUID.Zero; + + string Name = null; + try + { + UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id); + Name = Convert.ToString(reader["name"]); + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": UserAccount exception {0}", e.Message); + } + n.Add("classifieduuid", OSD.FromUUID(Id)); + n.Add("name", OSD.FromString(Name)); + data.Add(n); + } + } + } + } + } + return data; + } + + public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) + { + string query = string.Empty; + + + query += "INSERT INTO classifieds ("; + query += "`classifieduuid`,"; + query += "`creatoruuid`,"; + query += "`creationdate`,"; + query += "`expirationdate`,"; + query += "`category`,"; + query += "`name`,"; + query += "`description`,"; + query += "`parceluuid`,"; + query += "`parentestate`,"; + query += "`snapshotuuid`,"; + query += "`simname`,"; + query += "`posglobal`,"; + query += "`parcelname`,"; + query += "`classifiedflags`,"; + query += "`priceforlisting`) "; + query += "VALUES ("; + query += "?ClassifiedId,"; + query += "?CreatorId,"; + query += "?CreatedDate,"; + query += "?ExpirationDate,"; + query += "?Category,"; + query += "?Name,"; + query += "?Description,"; + query += "?ParcelId,"; + query += "?ParentEstate,"; + query += "?SnapshotId,"; + query += "?SimName,"; + query += "?GlobalPos,"; + query += "?ParcelName,"; + query += "?Flags,"; + query += "?ListingPrice ) "; + query += "ON DUPLICATE KEY UPDATE "; + query += "category=?Category, "; + query += "expirationdate=?ExpirationDate, "; + query += "name=?Name, "; + query += "description=?Description, "; + query += "parentestate=?ParentEstate, "; + query += "posglobal=?GlobalPos, "; + query += "parcelname=?ParcelName, "; + query += "classifiedflags=?Flags, "; + query += "priceforlisting=?ListingPrice, "; + query += "snapshotuuid=?SnapshotId"; + + if(string.IsNullOrEmpty(ad.ParcelName)) + ad.ParcelName = "Unknown"; + if(ad.ParcelId == null) + ad.ParcelId = UUID.Zero; + if(string.IsNullOrEmpty(ad.Description)) + ad.Description = "No Description"; + + DateTime epoch = new DateTime(1970, 1, 1); + DateTime now = DateTime.Now; + TimeSpan epochnow = now - epoch; + TimeSpan duration; + DateTime expiration; + TimeSpan epochexp; + + if(ad.Flags == 2) + { + duration = new TimeSpan(7,0,0,0); + expiration = now.Add(duration); + epochexp = expiration - epoch; + } + else + { + duration = new TimeSpan(365,0,0,0); + expiration = now.Add(duration); + epochexp = expiration - epoch; + } + ad.CreationDate = (int)epochnow.TotalSeconds; + ad.ExpirationDate = (int)epochexp.TotalSeconds; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?ClassifiedId", ad.ClassifiedId.ToString()); + cmd.Parameters.AddWithValue("?CreatorId", ad.CreatorId.ToString()); + cmd.Parameters.AddWithValue("?CreatedDate", ad.CreationDate.ToString()); + cmd.Parameters.AddWithValue("?ExpirationDate", ad.ExpirationDate.ToString()); + cmd.Parameters.AddWithValue("?Category", ad.Category.ToString()); + cmd.Parameters.AddWithValue("?Name", ad.Name.ToString()); + cmd.Parameters.AddWithValue("?Description", ad.Description.ToString()); + cmd.Parameters.AddWithValue("?ParcelId", ad.ParcelId.ToString()); + cmd.Parameters.AddWithValue("?ParentEstate", ad.ParentEstate.ToString()); + cmd.Parameters.AddWithValue("?SnapshotId", ad.SnapshotId.ToString ()); + cmd.Parameters.AddWithValue("?SimName", ad.SimName.ToString()); + cmd.Parameters.AddWithValue("?GlobalPos", ad.GlobalPos.ToString()); + cmd.Parameters.AddWithValue("?ParcelName", ad.ParcelName.ToString()); + cmd.Parameters.AddWithValue("?Flags", ad.Flags.ToString()); + cmd.Parameters.AddWithValue("?ListingPrice", ad.Price.ToString ()); + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": ClassifiedesUpdate exception {0}", e.Message); + result = e.Message; + return false; + } + return true; + } + + public bool DeleteClassifiedRecord(UUID recordId) + { + string query = string.Empty; + + query += "DELETE FROM classifieds WHERE "; + query += "classifieduuid = ?ClasifiedId"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?ClassifiedId", recordId.ToString()); + + lock(Lock) + { + cmd.ExecuteNonQuery(); + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": DeleteClassifiedRecord exception {0}", e.Message); + return false; + } + return true; + } + + public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) + { + string query = string.Empty; + + query += "SELECT * FROM classifieds WHERE "; + query += "classifieduuid = ?AdId"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?AdId", ad.ClassifiedId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if(reader.Read ()) + { + ad.CreatorId = new UUID(reader.GetGuid("creatoruuid")); + ad.ParcelId = new UUID(reader.GetGuid("parceluuid")); + ad.SnapshotId = new UUID(reader.GetGuid("snapshotuuid")); + ad.CreationDate = Convert.ToInt32(reader["creationdate"]); + ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); + ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); + ad.Flags = (byte)reader.GetUInt32("classifiedflags"); + ad.Category = reader.GetInt32("category"); + ad.Price = reader.GetInt16("priceforlisting"); + ad.Name = reader.GetString("name"); + ad.Description = reader.GetString("description"); + ad.SimName = reader.GetString("simname"); + ad.GlobalPos = reader.GetString("posglobal"); + ad.ParcelName = reader.GetString("parcelname"); + + } + } + } + dbcon.Close(); + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": GetPickInfo exception {0}", e.Message); + } + return true; + } + #endregion Classifieds Queries + + #region Picks Queries + public OSDArray GetAvatarPicks(UUID avatarId) + { + string query = string.Empty; + + query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; + query += "creatoruuid = ?Id"; + OSDArray data = new OSDArray(); + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if(reader.HasRows) + { + while (reader.Read()) + { + OSDMap record = new OSDMap(); + + record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); + record.Add("name",OSD.FromString((string)reader["name"])); + data.Add(record); + } + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": GetAvatarPicks exception {0}", e.Message); + } + return data; + } + + public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) + { + string query = string.Empty; + UserProfilePick pick = new UserProfilePick(); + + query += "SELECT * FROM userpicks WHERE "; + query += "creatoruuid = ?CreatorId AND "; + query += "pickuuid = ?PickId"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?CreatorId", avatarId.ToString()); + cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if(reader.HasRows) + { + reader.Read(); + + string description = (string)reader["description"]; + + if (string.IsNullOrEmpty(description)) + description = "No description given."; + + UUID.TryParse((string)reader["pickuuid"], out pick.PickId); + UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); + UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); + UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); + pick.GlobalPos = (string)reader["posglobal"]; + bool.TryParse((string)reader["toppick"], out pick.TopPick); + bool.TryParse((string)reader["enabled"], out pick.Enabled); + pick.Name = (string)reader["name"]; + pick.Desc = description; + pick.User = (string)reader["user"]; + pick.OriginalName = (string)reader["originalname"]; + pick.SimName = (string)reader["simname"]; + pick.SortOrder = (int)reader["sortorder"]; + } + } + } + dbcon.Close(); + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": GetPickInfo exception {0}", e.Message); + } + return pick; + } + + public bool UpdatePicksRecord(UserProfilePick pick) + { + string query = string.Empty; + + query += "INSERT INTO userpicks VALUES ("; + query += "?PickId,"; + query += "?CreatorId,"; + query += "?TopPick,"; + query += "?ParcelId,"; + query += "?Name,"; + query += "?Desc,"; + query += "?SnapshotId,"; + query += "?User,"; + query += "?Original,"; + query += "?SimName,"; + query += "?GlobalPos,"; + query += "?SortOrder,"; + query += "?Enabled) "; + query += "ON DUPLICATE KEY UPDATE "; + query += "parceluuid=?ParcelId,"; + query += "name=?Name,"; + query += "description=?Desc,"; + query += "snapshotuuid=?SnapshotId,"; + query += "pickuuid=?PickId,"; + query += "posglobal=?GlobalPos"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?PickId", pick.PickId.ToString()); + cmd.Parameters.AddWithValue("?CreatorId", pick.CreatorId.ToString()); + cmd.Parameters.AddWithValue("?TopPick", pick.TopPick.ToString()); + cmd.Parameters.AddWithValue("?ParcelId", pick.ParcelId.ToString()); + cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); + cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); + cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); + cmd.Parameters.AddWithValue("?User", pick.User.ToString()); + cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); + cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); + cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); + cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); + cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": UpdateAvatarNotes exception {0}", e.Message); + return false; + } + return true; + } + + public bool DeletePicksRecord(UUID pickId) + { + string query = string.Empty; + + query += "DELETE FROM userpicks WHERE "; + query += "pickuuid = ?PickId"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": DeleteUserPickRecord exception {0}", e.Message); + return false; + } + return true; + } + #endregion Picks Queries + + #region Avatar Notes Queries + public bool GetAvatarNotes(ref UserProfileNotes notes) + { // WIP + string query = string.Empty; + + query += "SELECT `notes` FROM usernotes WHERE "; + query += "useruuid = ?Id AND "; + query += "targetuuid = ?TargetId"; + OSDArray data = new OSDArray(); + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?Id", notes.UserId.ToString()); + cmd.Parameters.AddWithValue("?TargetId", notes.TargetId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.HasRows) + { + reader.Read(); + notes.Notes = OSD.FromString((string)reader["notes"]); + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": GetAvatarNotes exception {0}", e.Message); + } + return true; + } + + public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) + { + string query = string.Empty; + bool remove; + + if(string.IsNullOrEmpty(note.Notes)) + { + remove = true; + query += "DELETE FROM usernotes WHERE "; + query += "useruuid=?UserId AND "; + query += "targetuuid=?TargetId"; + } + else + { + remove = false; + query += "INSERT INTO usernotes VALUES ( "; + query += "?UserId,"; + query += "?TargetId,"; + query += "?Notes )"; + query += "ON DUPLICATE KEY "; + query += "UPDATE "; + query += "notes=?Notes"; + } + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + if(!remove) + cmd.Parameters.AddWithValue("?Notes", note.Notes); + cmd.Parameters.AddWithValue("?TargetId", note.TargetId.ToString ()); + cmd.Parameters.AddWithValue("?UserId", note.UserId.ToString()); + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": UpdateAvatarNotes exception {0}", e.Message); + return false; + } + return true; + + } + #endregion Avatar Notes Queries + + #region Avatar Properties + public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) + { + string query = string.Empty; + + query += "SELECT * FROM userprofile WHERE "; + query += "useruuid = ?Id"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.HasRows) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": Getting data for {0}.", props.UserId); + reader.Read(); + props.WebUrl = (string)reader["profileURL"]; + UUID.TryParse((string)reader["profileImage"], out props.ImageId); + props.AboutText = (string)reader["profileAboutText"]; + UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); + props.FirstLifeText = (string)reader["profileFirstText"]; + UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); + props.WantToMask = (int)reader["profileWantToMask"]; + props.WantToText = (string)reader["profileWantToText"]; + props.SkillsMask = (int)reader["profileSkillsMask"]; + props.SkillsText = (string)reader["profileSkillsText"]; + props.Language = (string)reader["profileLanguages"]; + } + else + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": No data for {0}", props.UserId); + + props.WebUrl = string.Empty; + props.ImageId = UUID.Zero; + props.AboutText = string.Empty; + props.FirstLifeImageId = UUID.Zero; + props.FirstLifeText = string.Empty; + props.PartnerId = UUID.Zero; + props.WantToMask = 0; + props.WantToText = string.Empty; + props.SkillsMask = 0; + props.SkillsText = string.Empty; + props.Language = string.Empty; + + query = "INSERT INTO userprofile (`useruuid`) VALUES (?userId)"; + + dbcon.Close(); + dbcon.Open(); + + using (MySqlCommand put = new MySqlCommand(query, dbcon)) + { + put.Parameters.AddWithValue("?userId", props.UserId.ToString()); + put.ExecuteNonQuery(); + } + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": Requst properties exception {0}", e.Message); + result = e.Message; + return false; + } + return true; + } + + public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) + { + string query = string.Empty; + + query += "UPDATE userprofile SET "; + query += "profileURL=?profileURL, "; + query += "profileImage=?image, "; + query += "profileAboutText=?abouttext,"; + query += "profileFirstImage=?firstlifeimage,"; + query += "profileFirstText=?firstlifetext "; + query += "WHERE useruuid=?uuid"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); + cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); + cmd.Parameters.AddWithValue("?abouttext", props.AboutText); + cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); + cmd.Parameters.AddWithValue("?firstlifetext", props.FirstLifeText); + cmd.Parameters.AddWithValue("?uuid", props.UserId.ToString()); + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": AgentPropertiesUpdate exception {0}", e.Message); + + return false; + } + return true; + } + #endregion Avatar Properties + + #region Avatar Interests + public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) + { + string query = string.Empty; + + query += "UPDATE userprofile SET "; + query += "profileWantToMask=?WantMask, "; + query += "profileWantToText=?WantText,"; + query += "profileSkillsMask=?SkillsMask,"; + query += "profileSkillsText=?SkillsText, "; + query += "profileLanguages=?Languages "; + query += "WHERE useruuid=?uuid"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?WantMask", up.WantToMask); + cmd.Parameters.AddWithValue("?WantText", up.WantToText); + cmd.Parameters.AddWithValue("?SkillsMask", up.SkillsMask); + cmd.Parameters.AddWithValue("?SkillsText", up.SkillsText); + cmd.Parameters.AddWithValue("?Languages", up.Language); + cmd.Parameters.AddWithValue("?uuid", up.UserId.ToString()); + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": AgentInterestsUpdate exception {0}", e.Message); + result = e.Message; + return false; + } + return true; + } + #endregion Avatar Interests + + public OSDArray GetUserImageAssets(UUID avatarId) + { + OSDArray data = new OSDArray(); + string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; + + // Get classified image assets + + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) + { + cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.HasRows) + { + while (reader.Read()) + { + data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); + } + } + } + } + + dbcon.Close(); + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) + { + cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.HasRows) + { + while (reader.Read()) + { + data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); + } + } + } + } + + dbcon.Close(); + dbcon.Open(); + + query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; + + using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) + { + cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.HasRows) + { + while (reader.Read()) + { + data.Add(new OSDString((string)reader["profileImage"].ToString ())); + data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); + } + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": GetAvatarNotes exception {0}", e.Message); + } + return data; + } + + #region User Preferences + public OSDArray GetUserPreferences(UUID avatarId) + { + string query = string.Empty; + + query += "SELECT imviaemail,visible,email FROM "; + query += "usersettings WHERE "; + query += "useruuid = ?Id"; + + OSDArray data = new OSDArray(); + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if(reader.HasRows) + { + reader.Read(); + OSDMap record = new OSDMap(); + + record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); + record.Add("visible",OSD.FromString((string)reader["visible"])); + record.Add("email",OSD.FromString((string)reader["email"])); + data.Add(record); + } + else + { + using (MySqlCommand put = new MySqlCommand(query, dbcon)) + { + query = "INSERT INTO usersettings VALUES "; + query += "(?Id,'false','false', '')"; + + lock(Lock) + { + put.ExecuteNonQuery(); + } + } + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": Get preferences exception {0}", e.Message); + } + return data; + } + + public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) + { + string query = string.Empty; + + query += "UPDATE userpsettings SET "; + query += "imviaemail=?ImViaEmail, "; + query += "visible=?Visible,"; + query += "WHERE useruuid=?uuid"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); + cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); + cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); + + lock(Lock) + { + cmd.ExecuteNonQuery(); + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": AgentInterestsUpdate exception {0}", e.Message); + return false; + } + return true; + } + #endregion User Preferences + + #region Integration + public bool GetUserAppData(ref UserAppData props, ref string result) + { + string query = string.Empty; + + query += "SELECT * FROM `userdata` WHERE "; + query += "UserId = ?Id AND "; + query += "TagId = ?TagId"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); + cmd.Parameters.AddWithValue ("?TagId", props.TagId.ToString()); + + using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.HasRows) + { + reader.Read(); + props.DataKey = (string)reader["DataKey"]; + props.DataVal = (string)reader["DataVal"]; + } + else + { + query += "INSERT INTO userdata VALUES ( "; + query += "?UserId,"; + query += "?TagId,"; + query += "?DataKey,"; + query += "?DataVal) "; + + using (MySqlCommand put = new MySqlCommand(query, dbcon)) + { + put.Parameters.AddWithValue("?Id", props.UserId.ToString()); + put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); + put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); + put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); + + lock(Lock) + { + put.ExecuteNonQuery(); + } + } + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": Requst application data exception {0}", e.Message); + result = e.Message; + return false; + } + return true; + } + + public bool SetUserAppData(UserAppData props, ref string result) + { + string query = string.Empty; + + query += "UPDATE userdata SET "; + query += "TagId = ?TagId, "; + query += "DataKey = ?DataKey, "; + query += "DataVal = ?DataVal WHERE "; + query += "UserId = ?UserId AND "; + query += "TagId = ?TagId"; + + try + { + using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) + { + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) + { + cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); + cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString ()); + cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString ()); + cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString ()); + + lock(Lock) + { + cmd.ExecuteNonQuery(); + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": SetUserData exception {0}", e.Message); + return false; + } + return true; + } + #endregion Integration + } +} + diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations new file mode 100644 index 0000000..c29f1ab --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations @@ -0,0 +1,83 @@ +:VERSION 1 # ------------------------------- + +begin; + +CREATE TABLE IF NOT EXISTS `classifieds` ( + `classifieduuid` char(36) NOT NULL, + `creatoruuid` char(36) NOT NULL, + `creationdate` int(20) NOT NULL, + `expirationdate` int(20) NOT NULL, + `category` varchar(20) NOT NULL, + `name` varchar(255) NOT NULL, + `description` text NOT NULL, + `parceluuid` char(36) NOT NULL, + `parentestate` int(11) NOT NULL, + `snapshotuuid` char(36) NOT NULL, + `simname` varchar(255) NOT NULL, + `posglobal` varchar(255) NOT NULL, + `parcelname` varchar(255) NOT NULL, + `classifiedflags` int(8) NOT NULL, + `priceforlisting` int(5) NOT NULL, + PRIMARY KEY (`classifieduuid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +CREATE TABLE IF NOT EXISTS `usernotes` ( + `useruuid` varchar(36) NOT NULL, + `targetuuid` varchar(36) NOT NULL, + `notes` text NOT NULL, + UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +CREATE TABLE IF NOT EXISTS `userpicks` ( + `pickuuid` varchar(36) NOT NULL, + `creatoruuid` varchar(36) NOT NULL, + `toppick` enum('true','false') NOT NULL, + `parceluuid` varchar(36) NOT NULL, + `name` varchar(255) NOT NULL, + `description` text NOT NULL, + `snapshotuuid` varchar(36) NOT NULL, + `user` varchar(255) NOT NULL, + `originalname` varchar(255) NOT NULL, + `simname` varchar(255) NOT NULL, + `posglobal` varchar(255) NOT NULL, + `sortorder` int(2) NOT NULL, + `enabled` enum('true','false') NOT NULL, + PRIMARY KEY (`pickuuid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +CREATE TABLE IF NOT EXISTS `userprofile` ( + `useruuid` varchar(36) NOT NULL, + `profilePartner` varchar(36) NOT NULL, + `profileAllowPublish` binary(1) NOT NULL, + `profileMaturePublish` binary(1) NOT NULL, + `profileURL` varchar(255) NOT NULL, + `profileWantToMask` int(3) NOT NULL, + `profileWantToText` text NOT NULL, + `profileSkillsMask` int(3) NOT NULL, + `profileSkillsText` text NOT NULL, + `profileLanguages` text NOT NULL, + `profileImage` varchar(36) NOT NULL, + `profileAboutText` text NOT NULL, + `profileFirstImage` varchar(36) NOT NULL, + `profileFirstText` text NOT NULL, + PRIMARY KEY (`useruuid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +commit; + +:VERSION 2 # ------------------------------- + +begin; +CREATE TABLE IF NOT EXISTS `userdata` ( + `UserId` char(36) NOT NULL, + `TagId` varchar(64) NOT NULL, + `DataKey` varchar(255), + `DataVal` varchar(255), + PRIMARY KEY (`UserId`,`TagId`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +commit; + -- cgit v1.1 From bf035233232885b798a56a1687319ba167e4bf60 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 31 May 2013 10:40:47 -0400 Subject: Fill in fields with default values on profile creation --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 50 +++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 09bd448..5d7149b 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -622,7 +622,7 @@ namespace OpenSim.Data.MySQL { m_log.DebugFormat("[PROFILES_DATA]" + ": No data for {0}", props.UserId); - + props.WebUrl = string.Empty; props.ImageId = UUID.Zero; props.AboutText = string.Empty; @@ -634,8 +634,38 @@ namespace OpenSim.Data.MySQL props.SkillsMask = 0; props.SkillsText = string.Empty; props.Language = string.Empty; + props.PublishProfile = false; + props.PublishMature = false; - query = "INSERT INTO userprofile (`useruuid`) VALUES (?userId)"; + query = "INSERT INTO userprofile ("; + query += "useruuid, "; + query += "profilePartner, "; + query += "profileAllowPublish, "; + query += "profileMaturePublish, "; + query += "profileURL, "; + query += "profileWantToMask, "; + query += "profileWantToText, "; + query += "profileSkillsMask, "; + query += "profileSkillsText, "; + query += "profileLanguages, "; + query += "profileImage, "; + query += "profileAboutText, "; + query += "profileFirstImage, "; + query += "profileFirstText) VALUES ("; + query += "?userId, "; + query += "?profilePartner, "; + query += "?profileAllowPublish, "; + query += "?profileMaturePublish, "; + query += "?profileURL, "; + query += "?profileWantToMask, "; + query += "?profileWantToText, "; + query += "?profileSkillsMask, "; + query += "?profileSkillsText, "; + query += "?profileLanguages, "; + query += "?profileImage, "; + query += "?profileAboutText, "; + query += "?profileFirstImage, "; + query += "?profileFirstText)"; dbcon.Close(); dbcon.Open(); @@ -643,6 +673,20 @@ namespace OpenSim.Data.MySQL using (MySqlCommand put = new MySqlCommand(query, dbcon)) { put.Parameters.AddWithValue("?userId", props.UserId.ToString()); + put.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); + put.Parameters.AddWithValue("?profileAllowPublish", props.PublishProfile); + put.Parameters.AddWithValue("?profileMaturePublish", props.PublishMature); + put.Parameters.AddWithValue("?profileURL", props.WebUrl); + put.Parameters.AddWithValue("?profileWantToMask", props.WantToMask); + put.Parameters.AddWithValue("?profileWantToText", props.WantToText); + put.Parameters.AddWithValue("?profileSkillsMask", props.SkillsMask); + put.Parameters.AddWithValue("?profileSkillsText", props.SkillsText); + put.Parameters.AddWithValue("?profileLanguages", props.Language); + put.Parameters.AddWithValue("?profileImage", props.ImageId.ToString()); + put.Parameters.AddWithValue("?profileAboutText", props.AboutText); + put.Parameters.AddWithValue("?profileFirstImage", props.FirstLifeImageId.ToString()); + put.Parameters.AddWithValue("?profileFirstText", props.FirstLifeText); + put.ExecuteNonQuery(); } } @@ -665,6 +709,7 @@ namespace OpenSim.Data.MySQL string query = string.Empty; query += "UPDATE userprofile SET "; + query += "profilePartner=?profilePartner, "; query += "profileURL=?profileURL, "; query += "profileImage=?image, "; query += "profileAboutText=?abouttext,"; @@ -680,6 +725,7 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); + cmd.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); cmd.Parameters.AddWithValue("?abouttext", props.AboutText); cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); -- cgit v1.1 From d7fa9f671eefebd49c0e8f56e56088b0c0b3d93c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 31 May 2013 22:03:27 -0400 Subject: Adding standard OpenSim header to source files --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 5d7149b..4c6c8e3 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Data; using System.Reflection; -- cgit v1.1 From a3210d1cf812554b53afb407fd76dbb67ce2ac28 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 6 Jun 2013 03:17:38 +0100 Subject: Database persistence for keyframes. Contains a Migration. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 29 +++++++++++++++++++--- .../Data/MySQL/Resources/RegionStore.migrations | 7 ++++++ 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 2d20eaf..448962a 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -173,9 +173,9 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL, DynAttrs, " + + "LinkNumber, MediaURL, KeyframeMotion, " + "PhysicsShapeType, Density, GravityModifier, " + - "Friction, Restitution " + + "Friction, Restitution, DynAttrs " + ") values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + @@ -208,9 +208,9 @@ namespace OpenSim.Data.MySQL "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + "?CollisionSoundVolume, ?PassTouches, " + - "?LinkNumber, ?MediaURL, ?DynAttrs, " + + "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + "?PhysicsShapeType, ?Density, ?GravityModifier, " + - "?Friction, ?Restitution)"; + "?Friction, ?Restitution, ?DynAttrs)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -455,7 +455,11 @@ namespace OpenSim.Data.MySQL foreach (SceneObjectPart prim in prims.Values) { if (prim.ParentUUID == UUID.Zero) + { objects[prim.UUID] = new SceneObjectGroup(prim); + if (prim.KeyframeMotion != null) + prim.KeyframeMotion.UpdateSceneObject(objects[prim.UUID]); + } } // Add all of the children objects to the SOGs @@ -1307,6 +1311,19 @@ namespace OpenSim.Data.MySQL else prim.DynAttrs = new DAMap(); + if (!(row["KeyframeMotion"] is DBNull)) + { + Byte[] data = (byte[])row["KeyframeMotion"]; + if (data.Length > 0) + prim.KeyframeMotion = KeyframeMotion.FromData(null, data); + else + prim.KeyframeMotion = null; + } + else + { + prim.KeyframeMotion = null; + } + prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString()); prim.Density = (float)(double)row["Density"]; prim.GravityModifier = (float)(double)row["GravityModifier"]; @@ -1659,6 +1676,10 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + if (prim.KeyframeMotion != null) + cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize()); + else + cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); if (prim.DynAttrs.Count > 0) cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 513c784..70b9558 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -923,3 +923,10 @@ ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; COMMIT; +:VERSION 48 #---------------- Keyframes + +BEGIN; + +ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; + +COMMIT; -- cgit v1.1 From 33573003620674f4a4f6c8fadd969c7aa6576a5d Mon Sep 17 00:00:00 2001 From: teravus Date: Wed, 12 Jun 2013 18:13:00 -0500 Subject: * This fixes having to select and deselect prim to get keyframemotion to start running when pulled from data storage. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 448962a..de52623 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -457,8 +457,6 @@ namespace OpenSim.Data.MySQL if (prim.ParentUUID == UUID.Zero) { objects[prim.UUID] = new SceneObjectGroup(prim); - if (prim.KeyframeMotion != null) - prim.KeyframeMotion.UpdateSceneObject(objects[prim.UUID]); } } -- cgit v1.1 From f7d09b898ad6df32b3f07cb64657623980178c2f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 27 Jun 2013 23:14:28 +0100 Subject: Make the concept of namespaces explicit in dynamic attributes This is in order to reduce the likelihood of naming clashes, make it easier to filter in/out attributes, ensure uniformity, etc. All dynattrs in the opensim distro itself or likely future ones should be in the "OpenSim" namespace. This does alter the underlying dynattrs data structure. All data in previous structures may not be available, though old structures should not cause errors. This is done without notice since this feature has been explicitly labelled as experimental, subject to change and has not been in a release. However, existing materials data is being preserved by moving it to the "Materials" store in the "OpenSim" namespace. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index de52623..cf367ef 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1679,7 +1679,7 @@ namespace OpenSim.Data.MySQL else cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); - if (prim.DynAttrs.Count > 0) + if (prim.DynAttrs.CountNamespaces > 0) cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); else cmd.Parameters.AddWithValue("DynAttrs", null); -- cgit v1.1 From dc0455e217b8da3fc8bd49e959b57d6021312b77 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Jun 2013 19:11:44 +0100 Subject: In XAssetService, on a delete asset request also delete the asset in any chained service. This eliminates the async migration since it causes a race condition with the "delete asset" console command --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 8c93825..91389ce 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -199,6 +199,8 @@ namespace OpenSim.Data.MySQL /// On failure : Throw an exception and attempt to reconnect to database public void StoreAsset(AssetBase asset) { +// m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); + lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) -- cgit v1.1 From e984bfb4c63718d5176b17f6beea46f4512cf304 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 2 Jul 2013 14:31:39 -0700 Subject: This should have a strong effect on the Unknown User issue mantis #6625 --- OpenSim/Data/MySQL/MySQLGridUserData.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index a9ce94d..df1ecc6 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -46,7 +46,7 @@ namespace OpenSim.Data.MySQL public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} - public GridUserData Get(string userID) + public new GridUserData Get(string userID) { GridUserData[] ret = Get("UserID", userID); @@ -56,6 +56,9 @@ namespace OpenSim.Data.MySQL return ret[0]; } - + public GridUserData[] GetAll(string userID) + { + return base.Get("UserID LIKE {0}%", userID); + } } } \ No newline at end of file -- cgit v1.1 From 2c05caec7fcf14c7e61c2f66854fc24f06d5b480 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 2 Jul 2013 15:47:02 -0700 Subject: Really make it call the method with the query interface --- OpenSim/Data/MySQL/MySQLGridUserData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index df1ecc6..f476fd2 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -58,7 +58,7 @@ namespace OpenSim.Data.MySQL public GridUserData[] GetAll(string userID) { - return base.Get("UserID LIKE {0}%", userID); + return base.Get(String.Format("UserID LIKE {0}%", userID)); } } } \ No newline at end of file -- cgit v1.1 From 316e8f92391f561d459bc6240ccd78b0a98c20c6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 2 Jul 2013 16:10:09 -0700 Subject: Fix SQL statement --- OpenSim/Data/MySQL/MySQLGridUserData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index f476fd2..00560c1 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -58,7 +58,7 @@ namespace OpenSim.Data.MySQL public GridUserData[] GetAll(string userID) { - return base.Get(String.Format("UserID LIKE {0}%", userID)); + return base.Get(String.Format("UserID LIKE '{0}%'", userID)); } } } \ No newline at end of file -- cgit v1.1 From 068a3afad9b585399e5422108f8c5074c9e6b33f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jul 2013 09:51:31 -0700 Subject: HG Friends: migration #3 is failing on some installations of MySql. Setting the table to InnoDB seems to fix the problem. --- OpenSim/Data/MySQL/Resources/FriendsStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 55d82ec..5faf956 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations @@ -9,7 +9,7 @@ CREATE TABLE `Friends` ( `Offered` VARCHAR(32) NOT NULL DEFAULT 0, PRIMARY KEY(`PrincipalID`, `Friend`), KEY(`PrincipalID`) -); +) ENGINE=InnoDB; COMMIT; -- cgit v1.1 From e33ac50388b5b9d6d06c58c45e2ea6f17e9b987f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jul 2013 14:31:20 -0700 Subject: HG UAS: Moved hg-session data from memory to DB storage. This makes it so that traveling info survives Robust resets. It should also eliminate the cause of empty IP addresses in agent circuit data that we saw in CC grid. MySQL only. --- OpenSim/Data/MySQL/MySQLHGTravelData.cs | 70 ++++++++++++++++++++++ .../Data/MySQL/Resources/HGTravelStore.migrations | 17 ++++++ 2 files changed, 87 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLHGTravelData.cs create mode 100644 OpenSim/Data/MySQL/Resources/HGTravelStore.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLHGTravelData.cs b/OpenSim/Data/MySQL/MySQLHGTravelData.cs new file mode 100644 index 0000000..1efbfc3 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLHGTravelData.cs @@ -0,0 +1,70 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + /// + /// A MySQL Interface for user grid data + /// + public class MySQLHGTravelData : MySQLGenericTableHandler, IHGTravelingData + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { } + + public HGTravelingData Get(UUID sessionID) + { + HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public HGTravelingData[] GetSessions(UUID userID) + { + return base.Get("UserID", userID.ToString()); + } + + public bool Delete(UUID sessionID) + { + return Delete("SessionID", sessionID.ToString()); + } + + } +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..a0c9ebe --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations @@ -0,0 +1,17 @@ +:VERSION 1 # -------------------------- + +BEGIN; + +CREATE TABLE `hg_traveling_data` ( + `SessionID` VARCHAR(36) NOT NULL, + `UserID` VARCHAR(36) NOT NULL, + `GridExternalName` VARCHAR(255) NOT NULL DEFAULT '', + `ServiceToken` VARCHAR(255) NOT NULL DEFAULT '', + `ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '', + `MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '', + PRIMARY KEY (`SessionID`), + KEY (`UserID`) +) ENGINE=InnoDB; + +COMMIT; + -- cgit v1.1 From b0140383da21de03cb655160a2912d04c5b470e6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jul 2013 15:47:54 -0700 Subject: Cleanup old hg sessions (older than 2 days) --- OpenSim/Data/MySQL/MySQLHGTravelData.cs | 10 ++++++++++ OpenSim/Data/MySQL/Resources/HGTravelStore.migrations | 1 + 2 files changed, 11 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLHGTravelData.cs b/OpenSim/Data/MySQL/MySQLHGTravelData.cs index 1efbfc3..e81b880 100644 --- a/OpenSim/Data/MySQL/MySQLHGTravelData.cs +++ b/OpenSim/Data/MySQL/MySQLHGTravelData.cs @@ -66,5 +66,15 @@ namespace OpenSim.Data.MySQL return Delete("SessionID", sessionID.ToString()); } + public void DeleteOld() + { + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm); + + ExecuteNonQuery(cmd); + } + + } } } \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations index a0c9ebe..b4e4422 100644 --- a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations +++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations @@ -9,6 +9,7 @@ CREATE TABLE `hg_traveling_data` ( `ServiceToken` VARCHAR(255) NOT NULL DEFAULT '', `ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '', `MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '', + `TMStamp` timestamp NOT NULL, PRIMARY KEY (`SessionID`), KEY (`UserID`) ) ENGINE=InnoDB; -- cgit v1.1 From 170a6f0563c9b9e228dad0b1db5654f2114a05f4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 28 Jul 2013 09:00:28 -0700 Subject: This makes group search work (Groups V2). --- OpenSim/Data/MySQL/MySQLGroupsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 2a1bd6c..0318284 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs @@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL if (string.IsNullOrEmpty(pattern)) pattern = "1 ORDER BY Name LIMIT 100"; else - pattern = string.Format("Name LIKE %{0}% ORDER BY Name LIMIT 100", pattern); + pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern); return m_Groups.Get(pattern); } -- cgit v1.1 From 4cbadc3c4984b8bebc7098a720846309f645ad7b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 2 Sep 2013 17:27:45 +0100 Subject: Allow one to specify a DefaultHGRegion flag in [GridService] in order to allow different default regions for HG and direct grid logins. This requires a new GridService.GetDefaultHypergridRegions() so ROBUST services require updating but not simulators. This method still returns regions flagged with just DefaultRegion after any DefaultHGRegions, so if no DefaultHGRegions are specified then existing configured defaults will still work. Immediate use is for conference where we need to be able to specify different defaults However, this is also generally useful to send experienced HG users to one default location and local users whose specified region fails (e.g. no "home" or "last") to another. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a2d4ae4..2ad7590 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL return Get((int)RegionFlags.DefaultRegion, scopeID); } + public List GetDefaultHypergridRegions(UUID scopeID) + { + return Get((int)RegionFlags.DefaultHGRegion, scopeID); + } + public List GetFallbackRegions(UUID scopeID, int x, int y) { List regions = Get((int)RegionFlags.FallbackRegion, scopeID); -- cgit v1.1 From 2dc92e7de11086c7649d3ee0f8adc974efce6805 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 4 Aug 2013 19:19:11 +0200 Subject: Preserve attachment point & position when attachment is rezzed in world Patch taken from http://opensimulator.org/mantis/view.php?id=4905 originally by Greg C. Fixed to apply to r/23314 commit ba9daf849e7c8db48e7c03e7cdedb77776b2052f (cherry picked from commit 4ff9fbca441110cc2b93edc7286e0e9339e61cbe) --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 29 ++++++++++++++++++---- .../Data/MySQL/Resources/RegionStore.migrations | 10 ++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index cf367ef..b03a904 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -173,7 +173,8 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber, MediaURL, KeyframeMotion, " + + "LinkNumber, MediaURL, AttachedPosX, " + + "AttachedPosY, AttachedPosZ, KeyframeMotion, " + "PhysicsShapeType, Density, GravityModifier, " + "Friction, Restitution, DynAttrs " + ") values (" + "?UUID, " + @@ -208,7 +209,8 @@ namespace OpenSim.Data.MySQL "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + "?CollisionSoundVolume, ?PassTouches, " + - "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + + "?LinkNumber, ?MediaURL, ?AttachedPosX, " + + "?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " + "?PhysicsShapeType, ?Density, ?GravityModifier, " + "?Friction, ?Restitution, ?DynAttrs)"; @@ -227,7 +229,7 @@ namespace OpenSim.Data.MySQL "PathTaperX, PathTaperY, PathTwist, " + "PathTwistBegin, ProfileBegin, ProfileEnd, " + "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) " + + "ExtraParams, State, LastAttachPoint, Media) " + "values (?UUID, " + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + "?PCode, ?PathBegin, ?PathEnd, " + @@ -239,7 +241,7 @@ namespace OpenSim.Data.MySQL "?PathTwistBegin, ?ProfileBegin, " + "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; + "?State, ?LastAttachPoint, ?Media)"; FillShapeCommand(cmd, prim); @@ -1303,7 +1305,16 @@ namespace OpenSim.Data.MySQL if (!(row["MediaURL"] is System.DBNull)) prim.MediaUrl = (string)row["MediaURL"]; - + + if (!(row["AttachedPosX"] is System.DBNull)) + { + prim.AttachedPos = new Vector3( + (float)(double)row["AttachedPosX"], + (float)(double)row["AttachedPosY"], + (float)(double)row["AttachedPosZ"] + ); + } + if (!(row["DynAttrs"] is System.DBNull)) prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); else @@ -1673,6 +1684,12 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + if (prim.AttachedPos != null) + { + cmd.Parameters.AddWithValue("AttachedPosX", (double)prim.AttachedPos.X); + cmd.Parameters.AddWithValue("AttachedPosY", (double)prim.AttachedPos.Y); + cmd.Parameters.AddWithValue("AttachedPosZ", (double)prim.AttachedPos.Z); + } if (prim.KeyframeMotion != null) cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize()); @@ -1879,6 +1896,7 @@ namespace OpenSim.Data.MySQL s.ExtraParams = (byte[])row["ExtraParams"]; s.State = (byte)(int)row["State"]; + s.LastAttachPoint = (byte)(int)row["LastAttachPoint"]; if (!(row["Media"] is System.DBNull)) s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); @@ -1925,6 +1943,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); + cmd.Parameters.AddWithValue("LastAttachPoint", s.LastAttachPoint); cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); } diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 70b9558..a77e44d 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -930,3 +930,13 @@ BEGIN; ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; COMMIT; + +:VERSION 49 #--------------------- Save attachment info + +BEGIN; +ALTER TABLE prims ADD COLUMN AttachedPosX double default 0; +ALTER TABLE prims ADD COLUMN AttachedPosY double default 0; +ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0; +ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; +COMMIT; + -- cgit v1.1 From aea5d3a84212a236fe1a766131b8e3513f3705a8 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 24 Sep 2013 13:41:44 -0700 Subject: Remove time based terrain storage in SQLite so revision number can be used to denote terrain format revision. Add terrain DB format revision codes to ISimulationDataStore.cs. Setup so legacy compatible terrain storage and fetch is possible while allowing future format extensions. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index b03a904..5751dc8 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -575,6 +575,7 @@ namespace OpenSim.Data.MySQL public void StoreTerrain(double[,] ter, UUID regionID) { m_log.Info("[REGION DB]: Storing terrain"); + int revision = (int)DBTerrainRevision.Legacy256; lock (m_dbLock) { @@ -589,10 +590,10 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); - cmd.CommandText = "insert into terrain (RegionUUID, " + - "Revision, Heightfield) values (?RegionUUID, " + - "1, ?Heightfield)"; + cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" + + "values (?RegionUUID, ?Revision, ?Heightfield)"; + cmd.Parameters.AddWithValue("Revision", revision); cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); ExecuteNonQuery(cmd); -- cgit v1.1 From 42bdf446585007029faf4cd21abd289487f0f797 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Oct 2013 23:33:47 +0100 Subject: Bump OPenSimulator version and assembly versions up to 0.8.0 Dev --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 1146d92..f562300 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.7.6.*")] +[assembly : AssemblyVersion("0.8.0.*")] -- cgit v1.1 From 7416809077227f35ab70ed44060e51f2bcf66937 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 2 Oct 2013 16:59:37 -0700 Subject: varregion: plug in TerrainData class and modify TerrainModule and LLClientView to use same. This passes a terrain info class around rather than passing a one dimensional array thus allowing variable regions. Update the database storage for variable region sizes. This should be downward compatible (same format for 256x256 regions). --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 47 +++++++++++-------------------- 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 5751dc8..4bd8617 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -48,6 +48,7 @@ namespace OpenSim.Data.MySQL public class MySQLSimulationData : ISimulationDataStore { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static string LogHeader = "[REGION DB MYSQL]"; private string m_connectionString; private object m_dbLock = new object(); @@ -91,7 +92,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); + m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e); throw; } @@ -572,11 +573,14 @@ namespace OpenSim.Data.MySQL } } + // Legacy entry point for when terrain was always a 256x256 hieghtmap public void StoreTerrain(double[,] ter, UUID regionID) { - m_log.Info("[REGION DB]: Storing terrain"); - int revision = (int)DBTerrainRevision.Legacy256; + StoreTerrain(new HeightmapTerrainData(ter), regionID); + } + public void StoreTerrain(TerrainData terrData, UUID regionID) + { lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) @@ -590,11 +594,18 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); + int terrainDBRevision; + Array terrainDBblob; + terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); + + m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}", + LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision); + cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" + "values (?RegionUUID, ?Revision, ?Heightfield)"; - - cmd.Parameters.AddWithValue("Revision", revision); - cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); + + cmd.Parameters.AddWithValue("Revision", terrainDBRevision); + cmd.Parameters.AddWithValue("Heightfield", terrainDBblob); ExecuteNonQuery(cmd); } @@ -1526,30 +1537,6 @@ namespace OpenSim.Data.MySQL } /// - /// - /// - /// - /// - private static Array SerializeTerrain(double[,] val) - { - MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); - BinaryWriter bw = new BinaryWriter(str); - - // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < (int)Constants.RegionSize; x++) - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - double height = val[x, y]; - if (height == 0.0) - height = double.Epsilon; - - bw.Write(height); - } - - return str.ToArray(); - } - - /// /// Fill the prim command with prim values /// /// -- cgit v1.1 From ff5885ab234bc9a7efda49eea0e2200711c4933c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 1 Nov 2013 11:35:31 -0700 Subject: varregion: push TerrainData implementation up and down the database storage stack. Implement both LoadTerrain and StoreTerrain for all DBs. Move all database blob serialization/deserialization into TerrainData. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 32 +++++++++++-------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 4bd8617..42f2ebb 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -613,9 +613,16 @@ namespace OpenSim.Data.MySQL } } + // Legacy region loading public double[,] LoadTerrain(UUID regionID) { - double[,] terrain = null; + TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); + return terrData.GetDoubles(); + } + + public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) + { + TerrainData terrData = null; lock (m_dbLock) { @@ -635,32 +642,15 @@ namespace OpenSim.Data.MySQL while (reader.Read()) { int rev = Convert.ToInt32(reader["Revision"]); - - terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; - terrain.Initialize(); - - using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) - { - using (BinaryReader br = new BinaryReader(mstr)) - { - for (int x = 0; x < (int)Constants.RegionSize; x++) - { - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - terrain[x, y] = br.ReadDouble(); - } - } - } - - m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); - } + byte[] blob = (byte[])reader["Heightfield"]; + terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); } } } } } - return terrain; + return terrData; } public void RemoveLandObject(UUID globalID) -- cgit v1.1 From 823a175f07297e7a8a973ddf0223e60d3ea7c933 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 5 Dec 2013 20:06:04 -0500 Subject: Stop writing partner id to record when updating profile data. This should be changed only by admin in backend. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 4c6c8e3..dc88f94 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -736,7 +736,6 @@ namespace OpenSim.Data.MySQL string query = string.Empty; query += "UPDATE userprofile SET "; - query += "profilePartner=?profilePartner, "; query += "profileURL=?profileURL, "; query += "profileImage=?image, "; query += "profileAboutText=?abouttext,"; @@ -752,7 +751,6 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); - cmd.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); cmd.Parameters.AddWithValue("?abouttext", props.AboutText); cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); -- cgit v1.1 From 1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 6 Dec 2013 02:52:13 -0500 Subject: Add support for user preferences (im via email) --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 39 ++++++++++------------ .../Data/MySQL/Resources/UserProfiles.migrations | 10 ++++++ 2 files changed, 28 insertions(+), 21 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index dc88f94..63492c2 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -895,7 +895,7 @@ namespace OpenSim.Data.MySQL } #region User Preferences - public OSDArray GetUserPreferences(UUID avatarId) + public bool GetUserPreferences(ref UserPreferences pref, ref string result) { string query = string.Empty; @@ -912,19 +912,16 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); using (MySqlDataReader reader = cmd.ExecuteReader()) { if(reader.HasRows) { reader.Read(); - OSDMap record = new OSDMap(); - - record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); - record.Add("visible",OSD.FromString((string)reader["visible"])); - record.Add("email",OSD.FromString((string)reader["email"])); - data.Add(record); + bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); + bool.TryParse((string)reader["visible"], out pref.Visible); + pref.EMail = (string)reader["email"]; } else { @@ -947,17 +944,19 @@ namespace OpenSim.Data.MySQL { m_log.DebugFormat("[PROFILES_DATA]" + ": Get preferences exception {0}", e.Message); + result = e.Message; + return false; } - return data; + return true; } - public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) + public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) { string query = string.Empty; - - query += "UPDATE userpsettings SET "; + + query += "UPDATE usersettings SET "; query += "imviaemail=?ImViaEmail, "; - query += "visible=?Visible,"; + query += "visible=?Visible "; query += "WHERE useruuid=?uuid"; try @@ -967,14 +966,11 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); - cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); - cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); - - lock(Lock) - { - cmd.ExecuteNonQuery(); - } + cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail); + cmd.Parameters.AddWithValue("?Visible", pref.Visible); + cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); + + cmd.ExecuteNonQuery(); } } } @@ -982,6 +978,7 @@ namespace OpenSim.Data.MySQL { m_log.DebugFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); + result = e.Message; return false; } return true; diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations index c29f1ab..bd325da 100644 --- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations @@ -81,3 +81,13 @@ CREATE TABLE IF NOT EXISTS `userdata` ( commit; +:VERSION 3 # ------------------------------- +begin; +CREATE TABLE IF NOT EXISTS `usersettings` ( + `useruuid` varchar(36) NOT NULL, + `imviaemail` enum('true','false') NOT NULL, + `visible` enum('true','false') NOT NULL, + `email` varchar(254) NOT NULL, + PRIMARY KEY (`useruuid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +commit; \ No newline at end of file -- cgit v1.1 From b03ec6137f462486a3469f6ba4bbd363dc85295f Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 16 Dec 2013 15:10:09 -0500 Subject: Populate user preferences with UserAccount email if it is present, else return an error indicating no email is on record for the user. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 63492c2..0bf9595 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -925,15 +925,19 @@ namespace OpenSim.Data.MySQL } else { + dbcon.Close(); + dbcon.Open(); + + query = "INSERT INTO usersettings VALUES "; + query += "(?uuid,'false','false', ?Email)"; + using (MySqlCommand put = new MySqlCommand(query, dbcon)) { - query = "INSERT INTO usersettings VALUES "; - query += "(?Id,'false','false', '')"; - lock(Lock) - { - put.ExecuteNonQuery(); - } + put.Parameters.AddWithValue("?Email", pref.EMail); + put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); + + put.ExecuteNonQuery(); } } } -- cgit v1.1 From 141d771a931140402cfa0575cf31e7116540f7d0 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 16 Dec 2013 15:43:34 -0500 Subject: Fix issue with editing notes for other avatars --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 0bf9595..6ed3b06 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -546,6 +546,10 @@ namespace OpenSim.Data.MySQL reader.Read(); notes.Notes = OSD.FromString((string)reader["notes"]); } + else + { + notes.Notes = OSD.FromString(""); + } } } } -- cgit v1.1 From 46c2791fe2f9ea92535d3933602e24dcba8f96f9 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 29 Oct 2013 16:03:58 +0200 Subject: In the offline message table, store the sender. This data is useful for preventing abuse (e.g., someone who sends too many messages), or for deleting message if their sender has been deleted. --- OpenSim/Data/MySQL/Resources/IM_Store.migrations | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations index 7cfcd43..f73475e 100644 --- a/OpenSim/Data/MySQL/Resources/IM_Store.migrations +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations @@ -21,4 +21,14 @@ INSERT INTO `im_offline` SELECT * from `diva_im_offline`; DROP TABLE `diva_im_offline`; DELETE FROM `migrations` WHERE name='diva_im_Store'; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 3 # -------------------------- + +BEGIN; + +ALTER TABLE `im_offline` + ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`, + ADD KEY `FromID` (`FromID`); + +COMMIT; -- cgit v1.1 From e5d59dc696e647624047465e0e718f2c65106b3c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 28 Jan 2014 15:29:06 -0800 Subject: Repair database routines so they properly return null when asked for the heighmap of a region that does not exist. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 42f2ebb..2921c1c 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -616,10 +616,14 @@ namespace OpenSim.Data.MySQL // Legacy region loading public double[,] LoadTerrain(UUID regionID) { + double[,] ret = null; TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); - return terrData.GetDoubles(); + if (terrData != null) + ret = terrData.GetDoubles(); + return ret; } + // Returns 'null' if region not found public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) { TerrainData terrData = null; -- cgit v1.1 From 01520bbb3e3a1700e10ccb080ba4875e40e202ff Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 18 Mar 2014 00:02:55 +0000 Subject: Save and load dwell parcel stat in MySQL DB adaptor. Field in table already exists! The SQLite database adaptor was loading and saving dwell whilst MySQL was not, even though the field already exists in the db table. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 2921c1c..c5645a7 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -695,7 +695,7 @@ namespace OpenSim.Data.MySQL "MusicURL, PassHours, PassPrice, SnapshotUUID, " + "UserLocationX, UserLocationY, UserLocationZ, " + "UserLookAtX, UserLookAtY, UserLookAtZ, " + - "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + + "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + "?UUID, ?RegionUUID, " + "?LocalLandID, ?Bitmap, ?Name, ?Description, " + @@ -706,7 +706,7 @@ namespace OpenSim.Data.MySQL "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + - "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ + "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); @@ -1484,6 +1484,7 @@ namespace OpenSim.Data.MySQL UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); + newData.Dwell = Convert.ToSingle(row["Dwell"]); newData.AuthBuyerID = authedbuyer; newData.SnapshotID = snapshotID; @@ -1815,6 +1816,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); + cmd.Parameters.AddWithValue("Dwell", land.OtherCleanTime); cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); cmd.Parameters.AddWithValue("MediaType", land.MediaType); cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); @@ -1822,7 +1824,6 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); - } /// -- cgit v1.1 From ae56b946cf9bcde386b75db565c87057fb261fcc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 18 Mar 2014 00:34:40 +0000 Subject: Fix a bug in previous commit 01520bb where I accidentally saved OtherCleanTime instead of Dwell --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index c5645a7..8937b64 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1816,7 +1816,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); - cmd.Parameters.AddWithValue("Dwell", land.OtherCleanTime); + cmd.Parameters.AddWithValue("Dwell", land.Dwell); cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); cmd.Parameters.AddWithValue("MediaType", land.MediaType); cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); -- cgit v1.1 From b9e0d0fdb217f4e5cd90883dca1b2f622dc61c1d Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 30 Oct 2013 16:15:06 +0200 Subject: Don't show hidden groups in search results Resolves http://opensimulator.org/mantis/view.php?id=6937 --- OpenSim/Data/MySQL/MySQLGroupsData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 0318284..8e39229 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs @@ -86,11 +86,11 @@ namespace OpenSim.Data.MySQL public GroupData[] RetrieveGroups(string pattern) { if (string.IsNullOrEmpty(pattern)) - pattern = "1 ORDER BY Name LIMIT 100"; + pattern = "1"; else - pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern); + pattern = string.Format("Name LIKE '%{0}%'", pattern); - return m_Groups.Get(pattern); + return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); } public bool DeleteGroup(UUID groupID) -- cgit v1.1 From 1b30ae81b5501fbd21b0f589df6286421b0c083a Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 5 Jan 2014 11:28:33 +0200 Subject: Fixed updating usersettings in the database Resolves http://opensimulator.org/mantis/view.php?id=6938 --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 6ed3b06..cc4c5b0 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -974,8 +974,8 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail); - cmd.Parameters.AddWithValue("?Visible", pref.Visible); + cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower()); + cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower()); cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); cmd.ExecuteNonQuery(); -- cgit v1.1 From d1c3f8eef58b29eb8760eeb1ac03852a2387f927 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 31 Mar 2014 11:53:12 +0300 Subject: Added assets service method AssetsExist(), which returns whether the given list of assets exist. This method is used to optimize sending assets with embedded assets: e.g., when a Hypergrid visitor takes an item into the inventory. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 42 +++++++++++++++++------------------ OpenSim/Data/MySQL/MySQLXAssetData.cs | 40 ++++++++++++++++----------------- 2 files changed, 39 insertions(+), 43 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 21362b9..c96139d 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -257,46 +257,44 @@ namespace OpenSim.Data.MySQL } /// - /// Check if the asset exists in the database + /// Check if the assets exist in the database. /// - /// The asset UUID - /// true if it exists, false otherwise. - override public bool ExistsAsset(UUID uuid) + /// The assets' IDs + /// For each asset: true if it exists, false otherwise + public override bool[] AssetsExist(UUID[] uuids) { -// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); + if (uuids.Length == 0) + return new bool[0]; - bool assetExists = false; + HashSet exist = new HashSet(); + + string ids = "'" + string.Join("','", uuids) + "'"; + string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) + using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) { - cmd.Parameters.AddWithValue("?id", uuid.ToString()); - - try + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + while (dbReader.Read()) { - if (dbReader.Read()) - { -// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); - assetExists = true; - } + UUID id = DBGuid.FromDB(dbReader["id"]); + exist.Add(id); } } - catch (Exception e) - { - m_log.Error( - string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e); - } } } } - return assetExists; + bool[] results = new bool[uuids.Length]; + for (int i = 0; i < uuids.Length; i++) + results[i] = exist.Contains(uuids[i]); + + return results; } /// diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 91389ce..1bf6a9a 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -397,45 +397,43 @@ namespace OpenSim.Data.MySQL } /// - /// Check if the asset exists in the database + /// Check if the assets exist in the database. /// - /// The asset UUID - /// true if it exists, false otherwise. - public bool ExistsAsset(UUID uuid) + /// The asset UUID's + /// For each asset: true if it exists, false otherwise + public bool[] AssetsExist(UUID[] uuids) { -// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); + if (uuids.Length == 0) + return new bool[0]; + + HashSet exists = new HashSet(); - bool assetExists = false; + string ids = "'" + string.Join("','", uuids) + "'"; + string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); lock (m_dbLock) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon)) + using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) { - cmd.Parameters.AddWithValue("?ID", uuid.ToString()); - - try + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + while (dbReader.Read()) { - if (dbReader.Read()) - { -// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); - assetExists = true; - } + UUID id = DBGuid.FromDB(dbReader["ID"]); + exists.Add(id); } } - catch (Exception e) - { - m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e); - } } } } - return assetExists; + bool[] results = new bool[uuids.Length]; + for (int i = 0; i < uuids.Length; i++) + results[i] = exists.Contains(uuids[i]); + return results; } -- cgit v1.1 From acc2c42a795b42df702ded3cc302daa8b3e4c04c Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 20 Apr 2014 12:47:30 +0300 Subject: Better logging in PresenceService, to help diagnose presence problems. --- OpenSim/Data/MySQL/Resources/Presence.migrations | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index be4030e..c4e40fa 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations @@ -1,4 +1,4 @@ -:VERSION 1 # -------------------------- +:VERSION 1 # -------------------------- BEGIN; @@ -21,3 +21,11 @@ BEGIN; ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; COMMIT; + +:VERSION 3 # -------------------------- + +BEGIN; + +CREATE INDEX RegionID ON Presence(RegionID); + +COMMIT; -- cgit v1.1 From 93a9ed2a6d5f6005ae213e2e91f1c79e2fd7f775 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Apr 2014 12:04:06 +0300 Subject: Changed the maximum asset name and description lengths to constants. Also, pre-truncate the description of dynamic textures. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLXAssetData.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index c96139d..f03e322 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -171,18 +171,18 @@ namespace OpenSim.Data.MySQL dbcon)) { string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 1bf6a9a..430bb9f 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -210,18 +210,18 @@ namespace OpenSim.Data.MySQL using (MySqlTransaction transaction = dbcon.BeginTransaction()) { string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); -- cgit v1.1 From 2c9859314f72cfa32358c43bc47a668ec62af008 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 23 Apr 2014 16:18:28 +0300 Subject: Changed table 'im_offline' to use UTF8 characters. This fixes a problem with Offline IM V2 (only relevant to MySQL). This fixes http://opensimulator.org/mantis/view.php?id=7123 Users that use MySQL should change their MySQL configuration to support UTF8. In the config file /etc/my.cnf (Linux) or my.ini (Windows), add these settings: [mysqld] character-set-server=utf8 [client] default-character-set=utf8 And then restart MySQL (on Linux: "sudo service mysqld restart"). --- OpenSim/Data/MySQL/Resources/IM_Store.migrations | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations index f73475e..79ead98 100644 --- a/OpenSim/Data/MySQL/Resources/IM_Store.migrations +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations @@ -1,4 +1,4 @@ -:VERSION 1 # -------------------------- +:VERSION 1 # -------------------------- BEGIN; @@ -32,3 +32,11 @@ ALTER TABLE `im_offline` ADD KEY `FromID` (`FromID`); COMMIT; + +:VERSION 4 # -------------------------- + +BEGIN; + +ALTER TABLE im_offline CONVERT TO CHARACTER SET utf8; + +COMMIT; -- cgit v1.1 From 998d7009a65def0a4debc9369d35b63611db5b55 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Apr 2014 20:04:12 +0300 Subject: Eliminated many warnings --- OpenSim/Data/MySQL/MySQLFriendsData.cs | 2 +- OpenSim/Data/MySQL/MySQLXAssetData.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 3cd6b8f..6ba9fbd 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -47,7 +47,7 @@ namespace OpenSim.Data.MySQL return Delete(principalID.ToString(), friend); } - public bool Delete(string principalID, string friend) + public override bool Delete(string principalID, string friend) { using (MySqlCommand cmd = new MySqlCommand()) { diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 430bb9f..8361da2 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -346,7 +346,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } } - catch (Exception e) + catch (Exception) { m_log.ErrorFormat( "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", -- cgit v1.1 From d15a3b10a3031b9552d67d2e2d435a689b448e2f Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 24 Apr 2014 14:19:03 +0300 Subject: When sending JSON-RPC calls (for UserProfile), use WebUtil instead of constructing the HTTP requests manually. This allows the calls to be logged when using "debug http all 6". --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index cc4c5b0..e301bbe 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -634,8 +634,6 @@ namespace OpenSim.Data.MySQL { if(reader.HasRows) { - m_log.DebugFormat("[PROFILES_DATA]" + - ": Getting data for {0}.", props.UserId); reader.Read(); props.WebUrl = (string)reader["profileURL"]; UUID.TryParse((string)reader["profileImage"], out props.ImageId); @@ -651,9 +649,6 @@ namespace OpenSim.Data.MySQL } else { - m_log.DebugFormat("[PROFILES_DATA]" + - ": No data for {0}", props.UserId); - props.WebUrl = string.Empty; props.ImageId = UUID.Zero; props.AboutText = string.Empty; -- cgit v1.1 From d32d25634d0a8d257ed3d05abb9e6c70d086b3f5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 May 2014 22:09:37 +0100 Subject: Escape find string in MySQL core groups plugin --- OpenSim/Data/MySQL/MySQLGroupsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 8e39229..afa499e 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs @@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL if (string.IsNullOrEmpty(pattern)) pattern = "1"; else - pattern = string.Format("Name LIKE '%{0}%'", pattern); + pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern)); return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); } -- cgit v1.1 From eaf595c008998047eaa754696f8b1bec70faa65c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 31 May 2014 11:40:54 -0700 Subject: Fix a bug where estate not found would result in a dummy estate record with erroneous information. Also, added conversion of EstateSettings from/to key-value pairs in preparation for robust net work connectors. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3dd46cb..69c89d4 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -145,7 +145,11 @@ namespace OpenSim.Data.MySQL cmd.CommandText = sql; cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - return DoLoad(cmd, regionID, create); + EstateSettings e = DoLoad(cmd, regionID, create); + if (!create && e.EstateID == 0) // Not found + return null; + + return e; } } @@ -427,7 +431,10 @@ namespace OpenSim.Data.MySQL cmd.CommandText = sql; cmd.Parameters.AddWithValue("?EstateID", estateID); - return DoLoad(cmd, UUID.Zero, false); + EstateSettings e = DoLoad(cmd, UUID.Zero, false); + if (e.EstateID != estateID) + return null; + return e; } } -- cgit v1.1 From 5450b1b0247bb3907f60f2b3f9b0582903de4f83 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jun 2014 18:37:15 +0100 Subject: Change assembly versions to 0.8.1 --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index f562300..249842c 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.8.0.*")] +[assembly : AssemblyVersion("0.8.1.*")] -- cgit v1.1 From 4a9282e681f9b1a5410028b473af47d0896f81e6 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 21 Jul 2014 12:42:16 -0400 Subject: Add missing parts to profiles - classified delete --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index e301bbe..adb75d6 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -250,7 +250,7 @@ namespace OpenSim.Data.MySQL string query = string.Empty; query += "DELETE FROM classifieds WHERE "; - query += "classifieduuid = ?ClasifiedId"; + query += "classifieduuid = ?recordId"; try { @@ -260,12 +260,8 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("?ClassifiedId", recordId.ToString()); - - lock(Lock) - { - cmd.ExecuteNonQuery(); - } + cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); + cmd.ExecuteNonQuery(); } } } -- cgit v1.1 From f129b824c38f2ea74e4777c1399cdb9e755db96e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Aug 2014 19:46:46 +0100 Subject: Removing locking on requests in MySQLAssetData. These locks are not necessary since the connection is taken from the underlying mysql pool and not shared. Such locking is already not done by some other parts of OpenSim.Data.MySQL. Pointed out by arribasim-dev --- OpenSim/Data/MySQL/MySQLAssetData.cs | 305 +++++++++++++++++------------------ 1 file changed, 144 insertions(+), 161 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index f03e322..5d8da17 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -45,7 +45,6 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_connectionString; - private object m_dbLock = new object(); protected virtual Assembly Assembly { @@ -107,47 +106,46 @@ namespace OpenSim.Data.MySQL override public AssetBase GetAsset(UUID assetID) { AssetBase asset = null; - lock (m_dbLock) + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand( + "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", + dbcon)) { - dbcon.Open(); + cmd.Parameters.AddWithValue("?id", assetID.ToString()); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", - dbcon)) + try { - cmd.Parameters.AddWithValue("?id", assetID.ToString()); - - try + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); - asset.Data = (byte[])dbReader["data"]; - asset.Description = (string)dbReader["description"]; - - string local = dbReader["local"].ToString(); - if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) - asset.Local = true; - else - asset.Local = false; - - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); - asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); - } + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); + asset.Data = (byte[])dbReader["data"]; + asset.Description = (string)dbReader["description"]; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); } } - catch (Exception e) - { - m_log.Error( - string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); - } + } + catch (Exception e) + { + m_log.Error( + string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); } } } + return asset; } @@ -158,100 +156,94 @@ namespace OpenSim.Data.MySQL /// On failure : Throw an exception and attempt to reconnect to database override public void StoreAsset(AssetBase asset) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = + new MySqlCommand( + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", + dbcon)) { - dbcon.Open(); + string assetName = asset.Name; + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) + { + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); + m_log.WarnFormat( + "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Name, asset.ID, asset.Name.Length, assetName.Length); + } - using (MySqlCommand cmd = - new MySqlCommand( - "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", - dbcon)) + string assetDescription = asset.Description; + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - string assetName = asset.Name; - if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) - { - assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); - m_log.WarnFormat( - "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", - asset.Name, asset.ID, asset.Name.Length, assetName.Length); - } - - string assetDescription = asset.Description; - if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) - { - assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); - m_log.WarnFormat( - "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", - asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); - } - - try - { - using (cmd) - { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?name", assetName); - cmd.Parameters.AddWithValue("?description", assetDescription); - cmd.Parameters.AddWithValue("?assetType", asset.Type); - cmd.Parameters.AddWithValue("?local", asset.Local); - cmd.Parameters.AddWithValue("?temporary", asset.Temporary); - cmd.Parameters.AddWithValue("?create_time", now); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); - cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); - cmd.Parameters.AddWithValue("?data", asset.Data); - cmd.ExecuteNonQuery(); - } - } - catch (Exception e) + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); + m_log.WarnFormat( + "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); + } + + try + { + using (cmd) { - m_log.Error( - string.Format( - "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", - asset.FullID, asset.Name) - , e); + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?name", assetName); + cmd.Parameters.AddWithValue("?description", assetDescription); + cmd.Parameters.AddWithValue("?assetType", asset.Type); + cmd.Parameters.AddWithValue("?local", asset.Local); + cmd.Parameters.AddWithValue("?temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?create_time", now); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); + cmd.Parameters.AddWithValue("?data", asset.Data); + cmd.ExecuteNonQuery(); } } + catch (Exception e) + { + m_log.Error( + string.Format( + "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", + asset.FullID, asset.Name) + , e); + } } } } private void UpdateAccessTime(AssetBase asset) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); + dbcon.Open(); - using (MySqlCommand cmd - = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) + using (MySqlCommand cmd + = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) + { + try { - try - { - using (cmd) - { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?id", asset.ID); - cmd.Parameters.AddWithValue("?access_time", now); - cmd.ExecuteNonQuery(); - } - } - catch (Exception e) + using (cmd) { - m_log.Error( - string.Format( - "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", - asset.FullID, asset.Name), - e); + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?id", asset.ID); + cmd.Parameters.AddWithValue("?access_time", now); + cmd.ExecuteNonQuery(); } } + catch (Exception e) + { + m_log.Error( + string.Format( + "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", + asset.FullID, asset.Name), + e); + } } } } @@ -271,20 +263,17 @@ namespace OpenSim.Data.MySQL string ids = "'" + string.Join("','", uuids) + "'"; string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) { - dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + while (dbReader.Read()) { - while (dbReader.Read()) - { - UUID id = DBGuid.FromDB(dbReader["id"]); - exist.Add(id); - } + UUID id = DBGuid.FromDB(dbReader["id"]); + exist.Add(id); } } } @@ -309,50 +298,47 @@ namespace OpenSim.Data.MySQL { List retList = new List(count); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd + = new MySqlCommand( + "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", + dbcon)) { - dbcon.Open(); + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); - using (MySqlCommand cmd - = new MySqlCommand( - "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", - dbcon)) + try { - cmd.Parameters.AddWithValue("?start", start); - cmd.Parameters.AddWithValue("?count", count); - - try + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + while (dbReader.Read()) { - while (dbReader.Read()) - { - AssetMetadata metadata = new AssetMetadata(); - metadata.Name = (string)dbReader["name"]; - metadata.Description = (string)dbReader["description"]; - metadata.Type = (sbyte)dbReader["assetType"]; - metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. - metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); - metadata.FullID = DBGuid.FromDB(dbReader["id"]); - metadata.CreatorID = dbReader["CreatorID"].ToString(); - - // Current SHA1s are not stored/computed. - metadata.SHA1 = new byte[] { }; - - retList.Add(metadata); - } + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string)dbReader["name"]; + metadata.Description = (string)dbReader["description"]; + metadata.Type = (sbyte)dbReader["assetType"]; + metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); + metadata.FullID = DBGuid.FromDB(dbReader["id"]); + metadata.CreatorID = dbReader["CreatorID"].ToString(); + + // Current SHA1s are not stored/computed. + metadata.SHA1 = new byte[] { }; + + retList.Add(metadata); } } - catch (Exception e) - { - m_log.Error( - string.Format( - "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", - start, count), - e); - } + } + catch (Exception e) + { + m_log.Error( + string.Format( + "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", + start, count), + e); } } } @@ -362,17 +348,14 @@ namespace OpenSim.Data.MySQL public override bool Delete(string id) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); + dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) - { - cmd.Parameters.AddWithValue("?id", id); - cmd.ExecuteNonQuery(); - } + using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) + { + cmd.Parameters.AddWithValue("?id", id); + cmd.ExecuteNonQuery(); } } -- cgit v1.1 From d899bdcb9bbf1b52f91daabacfb630059757fcea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Aug 2014 19:52:03 +0100 Subject: Remove lock in MySQLFramework. This is not necessary as the connection is not shared. --- OpenSim/Data/MySQL/MySQLFramework.cs | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 3fdcf1e..5820a90 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -45,38 +45,29 @@ namespace OpenSim.Data.MySQL System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected string m_connectionString; - protected object m_dbLock = new object(); protected MySqlFramework(string connectionString) { m_connectionString = connectionString; } - ////////////////////////////////////////////////////////////// - // - // All non queries are funneled through one connection - // to increase performance a little - // protected int ExecuteNonQuery(MySqlCommand cmd) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - cmd.Connection = dbcon; + dbcon.Open(); + cmd.Connection = dbcon; - try - { - return cmd.ExecuteNonQuery(); - } - catch (Exception e) - { - m_log.Error(e.Message, e); - return 0; - } + try + { + return cmd.ExecuteNonQuery(); + } + catch (Exception e) + { + m_log.Error(e.Message, e); + return 0; } } } } -} +} \ No newline at end of file -- cgit v1.1 From 709038aa2adfe5a668c2452ec7acde517125c4e8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Aug 2014 20:23:48 +0100 Subject: Remove some use of database connection locking from MySQLSimulationData - this has not been necessary for some time as database connections are not shared. However, many locks remain since they may effectively be providing transactionality in some operations (e.g. prim updates across multiple tables). These are candidates for being replaced with proper database transactions, since this would not block unrelated operations (e.g. land save and object save) or unrelated operations on the same tables (e.g. storage of one linkset whilst another is being removed). In practice, any performance deg due to contention is probably rare and short lived as the major prim operations are performed in memory and only persisted some time afterwards. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 616 +++++++++++++++--------------- 1 file changed, 298 insertions(+), 318 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 8937b64..bb0ab75 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -51,6 +51,15 @@ namespace OpenSim.Data.MySQL private static string LogHeader = "[REGION DB MYSQL]"; private string m_connectionString; + + /// + /// This lock was being used to serialize database operations when the connection was shared, but this has + /// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead. + /// FIXME: However, the locks remain in many places since they are effectively providing a level of + /// transactionality. This should be replaced by more efficient database transactions which would not require + /// unrelated operations to block each other or unrelated operations on the same tables from blocking each + /// other. + /// private object m_dbLock = new object(); protected virtual Assembly Assembly @@ -738,95 +747,92 @@ namespace OpenSim.Data.MySQL RegionLightShareData nWP = new RegionLightShareData(); nWP.OnSave += StoreRegionWindlightSettings; - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + string command = "select * from `regionwindlight` where region_id = ?regionID"; + + using (MySqlCommand cmd = new MySqlCommand(command)) { - dbcon.Open(); - - string command = "select * from `regionwindlight` where region_id = ?regionID"; - - using (MySqlCommand cmd = new MySqlCommand(command)) + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) { - cmd.Connection = dbcon; - - cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); - - IDataReader result = ExecuteReader(cmd); - if (!result.Read()) - { - //No result, so store our default windlight profile and return it - nWP.regionID = regionUUID; + //No result, so store our default windlight profile and return it + nWP.regionID = regionUUID; // StoreRegionWindlightSettings(nWP); - return nWP; - } - else - { - nWP.regionID = DBGuid.FromDB(result["region_id"]); - nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); - nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); - nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); - nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); - nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); - nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); - nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); - nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); - nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); - nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); - nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); - nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); - nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); - nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); - nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); - nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); - nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); - UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); - nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); - nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); - nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); - nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); - nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); - nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); - nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); - nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); - nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); - nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); - nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); - nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); - nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); - nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); - nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); - nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); - nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); - nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); - nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); - nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); - nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); - nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); - nWP.eastAngle = Convert.ToSingle(result["east_angle"]); - nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); - nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); - nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); - nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); - nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); - nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); - nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); - nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); - nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); - nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); - nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); - nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); - nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); - nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); - nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); - nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); - nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); - nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); - nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); - nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); - nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); - nWP.valid = true; - } + return nWP; + } + else + { + nWP.regionID = DBGuid.FromDB(result["region_id"]); + nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); + nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); + nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); + nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); + nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); + nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); + nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); + nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); + nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); + nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); + nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); + nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); + nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); + nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); + nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); + nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); + nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); + UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); + nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); + nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); + nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); + nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); + nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); + nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); + nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); + nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); + nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); + nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); + nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); + nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); + nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); + nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); + nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); + nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); + nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); + nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); + nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); + nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); + nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); + nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); + nWP.eastAngle = Convert.ToSingle(result["east_angle"]); + nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); + nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); + nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); + nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); + nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); + nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); + nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); + nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); + nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); + nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); + nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); + nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); + nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); + nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); + nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); + nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); + nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); + nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); + nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); + nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); + nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); + nWP.valid = true; } } } @@ -876,124 +882,118 @@ namespace OpenSim.Data.MySQL public void StoreRegionWindlightSettings(RegionLightShareData wl) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; - cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; - cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; - cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; - cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; - cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; - cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; - cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; - cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; - cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; - cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; - cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; - cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; - cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; - cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; - cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; - cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; - cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; - cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; - cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; - cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; - cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; - cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; - cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; - cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; - - cmd.Parameters.AddWithValue("region_id", wl.regionID); - cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); - cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); - cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); - cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); - cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); - cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); - cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); - cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); - cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); - cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); - cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); - cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); - cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); - cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); - cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); - cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); - cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); - cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); - cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); - cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); - cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); - cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); - cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); - cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); - cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); - cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); - cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); - cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); - cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); - cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); - cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); - cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); - cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); - cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); - cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); - cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); - cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); - cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); - cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); - cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); - cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); - cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); - cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); - cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); - cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); - cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); - cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); - cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); - cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); - cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); - cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); - cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); - cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); - cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); - cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); - cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); - cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); - cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); - cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); - cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); - - ExecuteNonQuery(cmd); - } + cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; + cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; + cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; + cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; + cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; + cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; + cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; + cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; + cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; + cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; + cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; + cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; + cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; + cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; + cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; + cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; + cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; + cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; + cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; + cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; + cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; + cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; + cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; + cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; + cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; + + cmd.Parameters.AddWithValue("region_id", wl.regionID); + cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); + cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); + cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); + cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); + cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); + cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); + cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); + cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); + cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); + cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); + cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); + cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); + cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); + cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); + cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); + cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); + cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); + cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); + cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); + cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); + cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); + cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); + cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); + cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); + cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); + cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); + cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); + cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); + cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); + cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); + cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); + cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); + cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); + cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); + cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); + cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); + cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); + cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); + cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); + cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); + cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); + cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); + cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); + cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); + cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); + cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); + cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); + cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); + cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); + cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); + cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); + cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); + cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); + cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); + cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); + cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); + cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); + cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); + + ExecuteNonQuery(cmd); } } } public void RemoveRegionWindlightSettings(UUID regionID) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; - cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); - ExecuteNonQuery(cmd); - } + cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + ExecuteNonQuery(cmd); } } } @@ -1001,29 +1001,26 @@ namespace OpenSim.Data.MySQL #region RegionEnvironmentSettings public string LoadRegionEnvironmentSettings(UUID regionUUID) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + string command = "select * from `regionenvironment` where region_id = ?region_id"; + + using (MySqlCommand cmd = new MySqlCommand(command)) { - dbcon.Open(); - - string command = "select * from `regionenvironment` where region_id = ?region_id"; - - using (MySqlCommand cmd = new MySqlCommand(command)) + cmd.Connection = dbcon; + + cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); + + IDataReader result = ExecuteReader(cmd); + if (!result.Read()) { - cmd.Connection = dbcon; - - cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); - - IDataReader result = ExecuteReader(cmd); - if (!result.Read()) - { - return String.Empty; - } - else - { - return Convert.ToString(result["llsd_settings"]); - } + return String.Empty; + } + else + { + return Convert.ToString(result["llsd_settings"]); } } } @@ -1031,39 +1028,33 @@ namespace OpenSim.Data.MySQL public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; - - cmd.Parameters.AddWithValue("region_id", regionUUID); - cmd.Parameters.AddWithValue("llsd_settings", settings); - - ExecuteNonQuery(cmd); - } + cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; + + cmd.Parameters.AddWithValue("region_id", regionUUID); + cmd.Parameters.AddWithValue("llsd_settings", settings); + + ExecuteNonQuery(cmd); } } } public void RemoveRegionEnvironmentSettings(UUID regionUUID) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; - cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); - ExecuteNonQuery(cmd); - } + cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; + cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); + ExecuteNonQuery(cmd); } } } @@ -1071,57 +1062,55 @@ namespace OpenSim.Data.MySQL public void StoreRegionSettings(RegionSettings rs) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "replace into regionsettings (regionUUID, " + - "block_terraform, block_fly, allow_damage, " + - "restrict_pushing, allow_land_resell, " + - "allow_land_join_divide, block_show_in_search, " + - "agent_limit, object_bonus, maturity, " + - "disable_scripts, disable_collisions, " + - "disable_physics, terrain_texture_1, " + - "terrain_texture_2, terrain_texture_3, " + - "terrain_texture_4, elevation_1_nw, " + - "elevation_2_nw, elevation_1_ne, " + - "elevation_2_ne, elevation_1_se, " + - "elevation_2_se, elevation_1_sw, " + - "elevation_2_sw, water_height, " + - "terrain_raise_limit, terrain_lower_limit, " + - "use_estate_sun, fixed_sun, sun_position, " + - "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id, map_tile_ID, " + - "TelehubObject, parcel_tile_ID) " + - "values (?RegionUUID, ?BlockTerraform, " + - "?BlockFly, ?AllowDamage, ?RestrictPushing, " + - "?AllowLandResell, ?AllowLandJoinDivide, " + - "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + - "?Maturity, ?DisableScripts, ?DisableCollisions, " + - "?DisablePhysics, ?TerrainTexture1, " + - "?TerrainTexture2, ?TerrainTexture3, " + - "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + - "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + - "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + - "?WaterHeight, ?TerrainRaiseLimit, " + - "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + - "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + - "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?TerrainImageID, " + - "?TelehubObject, ?ParcelImageID)"; - - FillRegionSettingsCommand(cmd, rs); + dbcon.Open(); - ExecuteNonQuery(cmd); - } + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into regionsettings (regionUUID, " + + "block_terraform, block_fly, allow_damage, " + + "restrict_pushing, allow_land_resell, " + + "allow_land_join_divide, block_show_in_search, " + + "agent_limit, object_bonus, maturity, " + + "disable_scripts, disable_collisions, " + + "disable_physics, terrain_texture_1, " + + "terrain_texture_2, terrain_texture_3, " + + "terrain_texture_4, elevation_1_nw, " + + "elevation_2_nw, elevation_1_ne, " + + "elevation_2_ne, elevation_1_se, " + + "elevation_2_se, elevation_1_sw, " + + "elevation_2_sw, water_height, " + + "terrain_raise_limit, terrain_lower_limit, " + + "use_estate_sun, fixed_sun, sun_position, " + + "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + + "sunvectorz, loaded_creation_datetime, " + + "loaded_creation_id, map_tile_ID, " + + "TelehubObject, parcel_tile_ID) " + + "values (?RegionUUID, ?BlockTerraform, " + + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + + "?AllowLandResell, ?AllowLandJoinDivide, " + + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + + "?Maturity, ?DisableScripts, ?DisableCollisions, " + + "?DisablePhysics, ?TerrainTexture1, " + + "?TerrainTexture2, ?TerrainTexture3, " + + "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + + "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + + "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + + "?WaterHeight, ?TerrainRaiseLimit, " + + "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + + "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + + "?LoadedCreationDateTime, ?LoadedCreationID, " + + "?TerrainImageID, " + + "?TelehubObject, ?ParcelImageID)"; + + FillRegionSettingsCommand(cmd, rs); + + ExecuteNonQuery(cmd); } } + SaveSpawnPoints(rs); } @@ -2043,41 +2032,35 @@ namespace OpenSim.Data.MySQL public void SaveExtra(UUID regionID, string name, string val) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); + dbcon.Open(); - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?Name", name); - cmd.Parameters.AddWithValue("?value", val); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + cmd.Parameters.AddWithValue("?value", val); - cmd.ExecuteNonQuery(); - } + cmd.ExecuteNonQuery(); } } } public void RemoveExtra(UUID regionID, string name) { - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); + dbcon.Open(); - using (MySqlCommand cmd = dbcon.CreateCommand()) - { - cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?Name", name); + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); - cmd.ExecuteNonQuery(); - } + cmd.ExecuteNonQuery(); } } } @@ -2086,22 +2069,19 @@ namespace OpenSim.Data.MySQL { Dictionary ret = new Dictionary(); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); + dbcon.Open(); - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + using (IDataReader r = cmd.ExecuteReader()) { - cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - using (IDataReader r = cmd.ExecuteReader()) + while (r.Read()) { - while (r.Read()) - { - ret[r["Name"].ToString()] = r["value"].ToString(); - } + ret[r["Name"].ToString()] = r["value"].ToString(); } } } -- cgit v1.1 From 0cb805a64cff87b5696528afa01c76732dae98aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Aug 2014 20:28:56 +0100 Subject: Remove query locking in MySQLUserProfileData. This is not necessary as the connection is not shared. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index adb75d6..7e846e3 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -46,11 +46,6 @@ namespace OpenSim.Data.MySQL { get; set; } - - protected object Lock - { - get; set; - } protected virtual Assembly Assembly { @@ -1025,11 +1020,8 @@ namespace OpenSim.Data.MySQL put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); - - lock(Lock) - { - put.ExecuteNonQuery(); - } + + put.ExecuteNonQuery(); } } } @@ -1065,14 +1057,11 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); - cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString ()); - cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString ()); - cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString ()); - - lock(Lock) - { - cmd.ExecuteNonQuery(); - } + cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString()); + cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); + cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString()); + + cmd.ExecuteNonQuery(); } } } @@ -1086,5 +1075,4 @@ namespace OpenSim.Data.MySQL } #endregion Integration } -} - +} \ No newline at end of file -- cgit v1.1 From fabab7414f346c91f5aa9a3ae3f29c262d131c6d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Aug 2014 20:34:33 +0100 Subject: Remove database connection locking in MySQLXAssetData. This is unnecessary as connections aren't shared and transactions are already in place where necessary. --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 354 ++++++++++++++++------------------ 1 file changed, 168 insertions(+), 186 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 8361da2..af7e876 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -57,7 +57,6 @@ namespace OpenSim.Data.MySQL private bool m_enableCompression = false; private string m_connectionString; - private object m_dbLock = new object(); /// /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock @@ -131,60 +130,58 @@ namespace OpenSim.Data.MySQL // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); AssetBase asset = null; - lock (m_dbLock) + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand( + "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID", + dbcon)) { - dbcon.Open(); + cmd.Parameters.AddWithValue("?ID", assetID.ToString()); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID", - dbcon)) + try { - cmd.Parameters.AddWithValue("?ID", assetID.ToString()); - - try + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); - asset.Data = (byte[])dbReader["Data"]; - asset.Description = (string)dbReader["Description"]; + asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); + asset.Data = (byte[])dbReader["Data"]; + asset.Description = (string)dbReader["Description"]; - string local = dbReader["Local"].ToString(); - if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) - asset.Local = true; - else - asset.Local = false; + string local = dbReader["Local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; - asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); - asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); + asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); - if (m_enableCompression) + if (m_enableCompression) + { + using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) { - using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) - { - MemoryStream outputStream = new MemoryStream(); - WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); - // int compressedLength = asset.Data.Length; - asset.Data = outputStream.ToArray(); - - // m_log.DebugFormat( - // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", - // asset.ID, asset.Name, asset.Data.Length, compressedLength); - } + MemoryStream outputStream = new MemoryStream(); + WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); +// int compressedLength = asset.Data.Length; + asset.Data = outputStream.ToArray(); + +// m_log.DebugFormat( +// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", +// asset.ID, asset.Name, asset.Data.Length, compressedLength); } - - UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); } + + UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); } } - catch (Exception e) - { - m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); - } + } + catch (Exception e) + { + m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); } } } @@ -201,113 +198,110 @@ namespace OpenSim.Data.MySQL { // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + + using (MySqlTransaction transaction = dbcon.BeginTransaction()) { - dbcon.Open(); + string assetName = asset.Name; + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) + { + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); + m_log.WarnFormat( + "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Name, asset.ID, asset.Name.Length, assetName.Length); + } - using (MySqlTransaction transaction = dbcon.BeginTransaction()) + string assetDescription = asset.Description; + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - string assetName = asset.Name; - if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) - { - assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); - m_log.WarnFormat( - "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", - asset.Name, asset.ID, asset.Name.Length, assetName.Length); - } - - string assetDescription = asset.Description; - if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) - { - assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); - m_log.WarnFormat( - "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", - asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); - } + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); + m_log.WarnFormat( + "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", + asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); + } - if (m_enableCompression) - { - MemoryStream outputStream = new MemoryStream(); + if (m_enableCompression) + { + MemoryStream outputStream = new MemoryStream(); - using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) - { - // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); - // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. - compressionStream.Close(); - byte[] compressedData = outputStream.ToArray(); - asset.Data = compressedData; - } + using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) + { +// Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); + // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. + compressionStream.Close(); + byte[] compressedData = outputStream.ToArray(); + asset.Data = compressedData; } + } - byte[] hash = hasher.ComputeHash(asset.Data); + byte[] hash = hasher.ComputeHash(asset.Data); // m_log.DebugFormat( // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", // asset.ID, asset.Name, hash, compressedData.Length); + try + { + using (MySqlCommand cmd = + new MySqlCommand( + "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" + + "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)", + dbcon)) + { + // create unix epoch time + int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); + cmd.Parameters.AddWithValue("?ID", asset.ID); + cmd.Parameters.AddWithValue("?Hash", hash); + cmd.Parameters.AddWithValue("?Name", assetName); + cmd.Parameters.AddWithValue("?Description", assetDescription); + cmd.Parameters.AddWithValue("?AssetType", asset.Type); + cmd.Parameters.AddWithValue("?Local", asset.Local); + cmd.Parameters.AddWithValue("?Temporary", asset.Temporary); + cmd.Parameters.AddWithValue("?CreateTime", now); + cmd.Parameters.AddWithValue("?AccessTime", now); + cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); + cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags); + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", + asset.FullID, asset.Name, e.Message); + + transaction.Rollback(); + + return; + } + + if (!ExistsData(dbcon, transaction, hash)) + { try { using (MySqlCommand cmd = new MySqlCommand( - "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" + - "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)", + "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", dbcon)) { - // create unix epoch time - int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); - cmd.Parameters.AddWithValue("?ID", asset.ID); cmd.Parameters.AddWithValue("?Hash", hash); - cmd.Parameters.AddWithValue("?Name", assetName); - cmd.Parameters.AddWithValue("?Description", assetDescription); - cmd.Parameters.AddWithValue("?AssetType", asset.Type); - cmd.Parameters.AddWithValue("?Local", asset.Local); - cmd.Parameters.AddWithValue("?Temporary", asset.Temporary); - cmd.Parameters.AddWithValue("?CreateTime", now); - cmd.Parameters.AddWithValue("?AccessTime", now); - cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); - cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags); + cmd.Parameters.AddWithValue("?Data", asset.Data); cmd.ExecuteNonQuery(); } } catch (Exception e) { - m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", + m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", asset.FullID, asset.Name, e.Message); transaction.Rollback(); return; } - - if (!ExistsData(dbcon, transaction, hash)) - { - try - { - using (MySqlCommand cmd = - new MySqlCommand( - "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", - dbcon)) - { - cmd.Parameters.AddWithValue("?Hash", hash); - cmd.Parameters.AddWithValue("?Data", asset.Data); - cmd.ExecuteNonQuery(); - } - } - catch (Exception e) - { - m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", - asset.FullID, asset.Name, e.Message); - - transaction.Rollback(); - - return; - } - } - - transaction.Commit(); } + + transaction.Commit(); } } } @@ -328,31 +322,28 @@ namespace OpenSim.Data.MySQL if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) return; - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - MySqlCommand cmd = - new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); + dbcon.Open(); + MySqlCommand cmd = + new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); - try - { - using (cmd) - { - // create unix epoch time - cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); - cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); - cmd.ExecuteNonQuery(); - } - } - catch (Exception) + try + { + using (cmd) { - m_log.ErrorFormat( - "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", - assetMetadata.ID, assetMetadata.Name); + // create unix epoch time + cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); + cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); + cmd.ExecuteNonQuery(); } } + catch (Exception) + { + m_log.ErrorFormat( + "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", + assetMetadata.ID, assetMetadata.Name); + } } } @@ -411,20 +402,17 @@ namespace OpenSim.Data.MySQL string ids = "'" + string.Join("','", uuids) + "'"; string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + dbcon.Open(); + using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) { - dbcon.Open(); - using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + while (dbReader.Read()) { - while (dbReader.Read()) - { - UUID id = DBGuid.FromDB(dbReader["ID"]); - exists.Add(id); - } + UUID id = DBGuid.FromDB(dbReader["ID"]); + exists.Add(id); } } } @@ -449,43 +437,40 @@ namespace OpenSim.Data.MySQL { List retList = new List(count); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); - cmd.Parameters.AddWithValue("?start", start); - cmd.Parameters.AddWithValue("?count", count); + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + while (dbReader.Read()) { - while (dbReader.Read()) - { - AssetMetadata metadata = new AssetMetadata(); - metadata.Name = (string)dbReader["Name"]; - metadata.Description = (string)dbReader["Description"]; - metadata.Type = (sbyte)dbReader["AssetType"]; - metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. - metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); - metadata.FullID = DBGuid.FromDB(dbReader["ID"]); - metadata.CreatorID = dbReader["CreatorID"].ToString(); - - // We'll ignore this for now - it appears unused! + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string)dbReader["Name"]; + metadata.Description = (string)dbReader["Description"]; + metadata.Type = (sbyte)dbReader["AssetType"]; + metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); + metadata.FullID = DBGuid.FromDB(dbReader["ID"]); + metadata.CreatorID = dbReader["CreatorID"].ToString(); + + // We'll ignore this for now - it appears unused! // metadata.SHA1 = dbReader["hash"]); - UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); + UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); - retList.Add(metadata); - } + retList.Add(metadata); } } - catch (Exception e) - { - m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); - } + } + catch (Exception e) + { + m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); } } @@ -496,21 +481,18 @@ namespace OpenSim.Data.MySQL { // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); - lock (m_dbLock) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) - { - cmd.Parameters.AddWithValue("?ID", id); - cmd.ExecuteNonQuery(); - } + dbcon.Open(); - // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we - // keep a reference count (?) + using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) + { + cmd.Parameters.AddWithValue("?ID", id); + cmd.ExecuteNonQuery(); } + + // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we + // keep a reference count (?) } return true; -- cgit v1.1 From 5c9ef4d083a6162b097797aacfc83d3cdeb50c73 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 15 Oct 2014 09:42:29 -0400 Subject: Fix logging level to Error in exception handlers --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 7e846e3..c8479f0 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -111,7 +111,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": UserAccount exception {0}", e.Message); } n.Add("classifieduuid", OSD.FromUUID(Id)); @@ -232,7 +232,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": ClassifiedesUpdate exception {0}", e.Message); result = e.Message; return false; @@ -262,7 +262,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": DeleteClassifiedRecord exception {0}", e.Message); return false; } @@ -312,7 +312,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": GetPickInfo exception {0}", e.Message); } return true; @@ -356,7 +356,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": GetAvatarPicks exception {0}", e.Message); } return data; @@ -413,7 +413,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": GetPickInfo exception {0}", e.Message); } return pick; @@ -472,7 +472,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": UpdateAvatarNotes exception {0}", e.Message); return false; } @@ -502,7 +502,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": DeleteUserPickRecord exception {0}", e.Message); return false; } @@ -547,7 +547,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": GetAvatarNotes exception {0}", e.Message); } return true; @@ -595,7 +595,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": UpdateAvatarNotes exception {0}", e.Message); return false; } @@ -713,7 +713,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": Requst properties exception {0}", e.Message); result = e.Message; return false; @@ -753,7 +753,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": AgentPropertiesUpdate exception {0}", e.Message); return false; @@ -795,7 +795,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); result = e.Message; return false; @@ -878,7 +878,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": GetAvatarNotes exception {0}", e.Message); } return data; @@ -936,7 +936,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": Get preferences exception {0}", e.Message); result = e.Message; return false; @@ -970,7 +970,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); result = e.Message; return false; @@ -1030,7 +1030,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": Requst application data exception {0}", e.Message); result = e.Message; return false; @@ -1067,7 +1067,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.DebugFormat("[PROFILES_DATA]" + + m_log.ErrorFormat("[PROFILES_DATA]" + ": SetUserData exception {0}", e.Message); return false; } -- cgit v1.1 From b46387091470f3d1465c05625a656228ca54fd61 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 27 Oct 2014 17:27:42 -0400 Subject: Add hypergrid teleporting support to user profiles picks --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 8 ++++++-- OpenSim/Data/MySQL/Resources/UserProfiles.migrations | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index c8479f0..cab0ca8 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -397,6 +397,7 @@ namespace OpenSim.Data.MySQL UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); pick.GlobalPos = (string)reader["posglobal"]; + pick.Gatekeeper = (string)reader["gatekeeper"]; bool.TryParse((string)reader["toppick"], out pick.TopPick); bool.TryParse((string)reader["enabled"], out pick.Enabled); pick.Name = (string)reader["name"]; @@ -436,14 +437,16 @@ namespace OpenSim.Data.MySQL query += "?SimName,"; query += "?GlobalPos,"; query += "?SortOrder,"; - query += "?Enabled) "; + query += "?Enabled,"; + query += "?Gatekeeper)"; query += "ON DUPLICATE KEY UPDATE "; query += "parceluuid=?ParcelId,"; query += "name=?Name,"; query += "description=?Desc,"; query += "snapshotuuid=?SnapshotId,"; query += "pickuuid=?PickId,"; - query += "posglobal=?GlobalPos"; + query += "posglobal=?GlobalPos,"; + query += "gatekeeper=?Gatekeeper"; try { @@ -463,6 +466,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); + cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper); cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations index bd325da..87e99fa 100644 --- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations @@ -90,4 +90,9 @@ CREATE TABLE IF NOT EXISTS `usersettings` ( `email` varchar(254) NOT NULL, PRIMARY KEY (`useruuid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -commit; \ No newline at end of file +commit; + +:VERSION 4 # ------------------------------- +begin; +ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255); +commit; -- cgit v1.1 From 12108bf6e9dc16b6b4b1fe344c1b12ed31a1e4b4 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 23 Nov 2014 14:25:48 -0500 Subject: Fix handling of user preference updates where no email address is supplied --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index cab0ca8..da05ff0 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -915,7 +915,10 @@ namespace OpenSim.Data.MySQL reader.Read(); bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); bool.TryParse((string)reader["visible"], out pref.Visible); - pref.EMail = (string)reader["email"]; + pref.EMail = (string)reader["email"]; + + if(string.IsNullOrEmpty(pref.EMail)) + pref.EMail = "No EMail Address Provided"; } else { @@ -954,7 +957,8 @@ namespace OpenSim.Data.MySQL query += "UPDATE usersettings SET "; query += "imviaemail=?ImViaEmail, "; - query += "visible=?Visible "; + query += "visible=?Visible, "; + query += "email=?EMail "; query += "WHERE useruuid=?uuid"; try @@ -966,7 +970,8 @@ namespace OpenSim.Data.MySQL { cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower()); cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower()); - cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); + cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); + cmd.Parameters.AddWithValue("?EMail", pref.EMail.ToString().ToLower()); cmd.ExecuteNonQuery(); } @@ -975,7 +980,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { m_log.ErrorFormat("[PROFILES_DATA]" + - ": AgentInterestsUpdate exception {0}", e.Message); + ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); result = e.Message; return false; } -- cgit v1.1 From 41cc73233c1d2e17222fdc510606032701690a60 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 24 Nov 2014 10:59:39 -0500 Subject: Re-work handling of email notifications settings. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index da05ff0..0dd9e2f 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -916,9 +916,6 @@ namespace OpenSim.Data.MySQL bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); bool.TryParse((string)reader["visible"], out pref.Visible); pref.EMail = (string)reader["email"]; - - if(string.IsNullOrEmpty(pref.EMail)) - pref.EMail = "No EMail Address Provided"; } else { -- cgit v1.1 From a76aec8467439a4c4c2249656fe84a9ee5b9426c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 25 Nov 2014 19:27:15 -0500 Subject: Fix whitespace hoping to avoid a flogging --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 0dd9e2f..1f616fe 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -915,7 +915,7 @@ namespace OpenSim.Data.MySQL reader.Read(); bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); bool.TryParse((string)reader["visible"], out pref.Visible); - pref.EMail = (string)reader["email"]; + pref.EMail = (string)reader["email"]; } else { @@ -955,7 +955,7 @@ namespace OpenSim.Data.MySQL query += "UPDATE usersettings SET "; query += "imviaemail=?ImViaEmail, "; query += "visible=?Visible, "; - query += "email=?EMail "; + query += "email=?EMail "; query += "WHERE useruuid=?uuid"; try @@ -967,8 +967,8 @@ namespace OpenSim.Data.MySQL { cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower()); cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower()); - cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); - cmd.Parameters.AddWithValue("?EMail", pref.EMail.ToString().ToLower()); + cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); + cmd.Parameters.AddWithValue("?EMail", pref.EMail.ToString().ToLower()); cmd.ExecuteNonQuery(); } @@ -977,7 +977,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { m_log.ErrorFormat("[PROFILES_DATA]" + - ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); + ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); result = e.Message; return false; } -- cgit v1.1 From 492d49eb08bc8b7ecec1c75d7d7f9fdad3b1186f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 13 Jan 2015 20:33:36 +0000 Subject: Fix MySQL and PGSQL *UserProfilesData.GetUserAppData() calls to correctly set the UserId parameter instead of the non-existing Id parameter when writing a record because none yet exists. SQLite version is already correct for this. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 1f616fe..86f2efe 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -1022,7 +1022,7 @@ namespace OpenSim.Data.MySQL using (MySqlCommand put = new MySqlCommand(query, dbcon)) { - put.Parameters.AddWithValue("?Id", props.UserId.ToString()); + put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); -- cgit v1.1 From e5c0b68849d21e9f2d91b23586143e46becbce3b Mon Sep 17 00:00:00 2001 From: Cinder Date: Tue, 3 Mar 2015 20:42:22 -0700 Subject: Follow up to last commit, fix field length Signed-off-by: BlueWall --- OpenSim/Data/MySQL/Resources/AssetStore.migrations | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index e0526fe..2c5e7c3 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations @@ -75,3 +75,6 @@ ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; +:VERSION 9 + +ALTER TABLE assets MODIFY description varchar(128); -- cgit v1.1 From e520364f65e1915e13d28b829e9dd62f6904957d Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 4 Mar 2015 10:02:23 -0700 Subject: Chase latest change to asset description length with an update to XAssetStore db tables Signed-off-by: BlueWall --- OpenSim/Data/MySQL/Resources/XAssetStore.migrations | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index 0c49d0d..d56c917 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -24,4 +24,12 @@ CREATE TABLE `XAssetsData` ( PRIMARY KEY (`hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 2 + +BEGIN; + +ALTER TABLE xassetsmeta MODIFY Description varchar(128); + +COMMIT; -- cgit v1.1 From 11a24d04b678ed517c50dfd50575c210137cca3b Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 4 Mar 2015 13:47:02 -0500 Subject: Revert "Chase latest change to asset description length with an update to XAssetStore db tables" This reverts commit e520364f65e1915e13d28b829e9dd62f6904957d. --- OpenSim/Data/MySQL/Resources/XAssetStore.migrations | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index d56c917..0c49d0d 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -24,12 +24,4 @@ CREATE TABLE `XAssetsData` ( PRIMARY KEY (`hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; -COMMIT; - -:VERSION 2 - -BEGIN; - -ALTER TABLE xassetsmeta MODIFY Description varchar(128); - -COMMIT; +COMMIT; \ No newline at end of file -- cgit v1.1 From 56ae3da291e753ac5a3c2457aa97a7a290fe5342 Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 4 Mar 2015 10:02:23 -0700 Subject: Chase latest change to asset description length with an update to XAssetStore db tables Signed-off-by: BlueWall --- OpenSim/Data/MySQL/Resources/XAssetStore.migrations | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index 0c49d0d..d56c917 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -24,4 +24,12 @@ CREATE TABLE `XAssetsData` ( PRIMARY KEY (`hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 2 + +BEGIN; + +ALTER TABLE xassetsmeta MODIFY Description varchar(128); + +COMMIT; -- cgit v1.1 From d7b45a3ed20e6d4230faa812616a6031001c8977 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 4 Mar 2015 19:27:34 -0500 Subject: Alter the migrations so that it is a no-op as the columns are unused and the operation is very expensive --- OpenSim/Data/MySQL/Resources/AssetStore.migrations | 3 ++- OpenSim/Data/MySQL/Resources/XAssetStore.migrations | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index 2c5e7c3..661d825 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations @@ -77,4 +77,5 @@ ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; :VERSION 9 -ALTER TABLE assets MODIFY description varchar(128); +BEGIN; +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index d56c917..9459e3e 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations @@ -29,7 +29,4 @@ COMMIT; :VERSION 2 BEGIN; - -ALTER TABLE xassetsmeta MODIFY Description varchar(128); - COMMIT; -- cgit v1.1 From 1e444b1449ffad4969709c039f7c606c9f8f484d Mon Sep 17 00:00:00 2001 From: AliciaRaven Date: Tue, 31 Mar 2015 12:35:55 +0100 Subject: Change UserProfiles so that the parcel name is used for a ProfilePick and not the parcel owners name. This change also fixes a bug where if the avatar enters and does not move, creating or editing a ProfilePick would set the parcelId as an empty UUID. This is because ScenePresence.currentParcelUUID is not set until the avatar moves. Signed-off-by: Michael Cerquoni --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 86f2efe..b35595d 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -402,7 +402,7 @@ namespace OpenSim.Data.MySQL bool.TryParse((string)reader["enabled"], out pick.Enabled); pick.Name = (string)reader["name"]; pick.Desc = description; - pick.User = (string)reader["user"]; + pick.ParcelName = (string)reader["user"]; pick.OriginalName = (string)reader["originalname"]; pick.SimName = (string)reader["simname"]; pick.SortOrder = (int)reader["sortorder"]; @@ -443,6 +443,8 @@ namespace OpenSim.Data.MySQL query += "parceluuid=?ParcelId,"; query += "name=?Name,"; query += "description=?Desc,"; + query += "user=?User,"; + query += "simname=?SimName,"; query += "snapshotuuid=?SnapshotId,"; query += "pickuuid=?PickId,"; query += "posglobal=?GlobalPos,"; @@ -462,7 +464,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); - cmd.Parameters.AddWithValue("?User", pick.User.ToString()); + cmd.Parameters.AddWithValue("?User", pick.ParcelName.ToString()); cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); -- cgit v1.1 From da32512ea449c2de2d4a6069f899fbd4a8bb03fa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 29 Apr 2015 18:47:17 -0700 Subject: Updated all occurrences of AssemblyVersion("0.8.1.*") to AssemblyVersion("0.8.2.*") --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index 249842c..b46d175 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.8.1.*")] +[assembly : AssemblyVersion("0.8.2.*")] -- cgit v1.1 From 6f71d5c2c65802bd6b0196e825cabbfe8d34fe9e Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 5 Jun 2015 08:52:25 -0600 Subject: Support for Linden AgentPreferences capability and friends (UpdateAgentLanguage and UpdateAgentInformation) and Mantis #7157 Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 73 ++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/AgentPrefs.migrations | 18 ++++++ 2 files changed, 91 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs create mode 100644 OpenSim/Data/MySQL/Resources/AgentPrefs.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs new file mode 100644 index 0000000..0ea2f64 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015, Cinder Roxley + * + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (the "Software") to use, reproduce, display, distribute, + * execute, and transmit the Software, and to prepare derivative works of the + * Software, and to permit third-parties to whom the Software is furnished to + * do so, all subject to the following: + * + * The copyright notices in the Software and this entire statement, including + * the above license grant, this restriction and the following disclaimer, + * must be included in all copies of the Software, in whole or in part, and + * all derivative works of the Software, unless such copies or derivative + * works are solely in the form of machine-executable object code generated by + * a source language processor. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySQLAgentPreferencesData : MySQLGenericTableHandler, IAgentPreferencesData + { + public MySQLAgentPreferencesData(string connectionString, string realm) + : base(connectionString, realm, "AgentPrefs") + { + } + + public AgentPreferencesData GetPrefs(UUID agentID) + { + AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString()); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public void StorePrefs(AgentPreferencesData data) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("replace into `{0}` (`PrincipalID`, `AccessPrefs`, `HoverHeight`, `Language`, `LanguageIsPublic`, `PermEveryone`, `PermGroup`, `PermNextOwner`) VALUES (?Principal, ?AP, ?HH, ?Lang, ?LIP, ?PE, ?PG, ?PNO)", m_Realm); + cmd.Parameters.AddWithValue("?Principal", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?AP", data.AccessPrefs); + cmd.Parameters.AddWithValue("?HH", data.HoverHeight); + cmd.Parameters.AddWithValue("?Lang", data.Language); + cmd.Parameters.AddWithValue("?LIP", data.LanguageIsPublic); + cmd.Parameters.AddWithValue("?PE", data.PermEveryone); + cmd.Parameters.AddWithValue("?PG", data.PermGroup); + cmd.Parameters.AddWithValue("?PNO", data.PermNextOwner); + + ExecuteNonQuery(cmd); + } + } + } +} + diff --git a/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations new file mode 100644 index 0000000..e496f72 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations @@ -0,0 +1,18 @@ +:VERSION 1 # ------------------------- + +BEGIN; + +CREATE TABLE `AgentPrefs` ( + `PrincipalID` CHAR(36) NOT NULL, + `AccessPrefs` CHAR(2) NOT NULL DEFAULT 'M', + `HoverHeight` DOUBLE(30, 27) NOT NULL DEFAULT 0, + `Language` CHAR(5) NOT NULL DEFAULT 'en-us', + `LanguageIsPublic` BOOLEAN NOT NULL DEFAULT 1, + `PermEveryone` INT(6) NOT NULL DEFAULT 0, + `PermGroup` INT(6) NOT NULL DEFAULT 0, + `PermNextOwner` INT(6) NOT NULL DEFAULT 532480, + UNIQUE KEY `PrincipalID` (`PrincipalID`), + PRIMARY KEY(`PrincipalID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; -- cgit v1.1 From c1ddb7f05e337a65c9505ea714879038b9a215d4 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 5 Jun 2015 18:13:42 -0600 Subject: Relicense AgentPreferences files to BSD and OpenSimulator Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index 0ea2f64..cd9004a 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -1,27 +1,28 @@ /* - * Copyright (C) 2015, Cinder Roxley - * - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (the "Software") to use, reproduce, display, distribute, - * execute, and transmit the Software, and to prepare derivative works of the - * Software, and to permit third-parties to whom the Software is furnished to - * do so, all subject to the following: - * - * The copyright notices in the Software and this entire statement, including - * the above license grant, this restriction and the following disclaimer, - * must be included in all copies of the Software, in whole or in part, and - * all derivative works of the Software, unless such copies or derivative - * works are solely in the form of machine-executable object code generated by - * a source language processor. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; -- cgit v1.1 From 0fa94f222df8ed7f308730c3692bf2a774138718 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 12 Jun 2015 18:48:07 -0600 Subject: Refactor AgentPreferences so that database operations happen centrally. the opensim way. Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index cd9004a..bf188ee 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -52,22 +52,9 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public void StorePrefs(AgentPreferencesData data) + public void Store(AgentPreferencesData data) { - using (MySqlCommand cmd = new MySqlCommand()) - { - cmd.CommandText = String.Format("replace into `{0}` (`PrincipalID`, `AccessPrefs`, `HoverHeight`, `Language`, `LanguageIsPublic`, `PermEveryone`, `PermGroup`, `PermNextOwner`) VALUES (?Principal, ?AP, ?HH, ?Lang, ?LIP, ?PE, ?PG, ?PNO)", m_Realm); - cmd.Parameters.AddWithValue("?Principal", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?AP", data.AccessPrefs); - cmd.Parameters.AddWithValue("?HH", data.HoverHeight); - cmd.Parameters.AddWithValue("?Lang", data.Language); - cmd.Parameters.AddWithValue("?LIP", data.LanguageIsPublic); - cmd.Parameters.AddWithValue("?PE", data.PermEveryone); - cmd.Parameters.AddWithValue("?PG", data.PermGroup); - cmd.Parameters.AddWithValue("?PNO", data.PermNextOwner); - - ExecuteNonQuery(cmd); - } + base.Store(data); } } } -- cgit v1.1 From 3853904b80c659ae94db780f4de713d639200e50 Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 14 Jun 2015 08:45:22 -0600 Subject: Quell three new warnings I introduced with AgentPrefsData, return an empty llsd map instead of an empty llsd block when no AgentPrefs service is available to try and appease Firestorm Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index bf188ee..6be205e 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -52,9 +52,9 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public void Store(AgentPreferencesData data) + public override bool Store(AgentPreferencesData data) { - base.Store(data); + return base.Store(data); } } } -- cgit v1.1 From 496f35b4e85b2145138de0924add1c0be7be5320 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jun 2015 08:04:25 -0700 Subject: Removing the Store methods in the DB layer of AgentPreferences, as they were simply calling the base ones. --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index 6be205e..ed0ab98 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -51,11 +51,6 @@ namespace OpenSim.Data.MySQL return ret[0]; } - - public override bool Store(AgentPreferencesData data) - { - return base.Store(data); - } } } -- cgit v1.1 From 26726372025e31105acb72bcd38314d5709bfb1b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 11 Jul 2015 19:10:39 +0200 Subject: Rename for uniformity, add data module --- OpenSim/Data/MySQL/MySQLFSAssetData.cs | 361 +++++++++++++++++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLFSAssetData.cs (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs new file mode 100644 index 0000000..a57bfe0 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs @@ -0,0 +1,361 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using System.Collections.Generic; +using System.Data; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Server.Base; +using OpenSim.Services.Base; +using OpenSim.Services.Interfaces; +using Nini.Config; +using log4net; +using MySql.Data.MySqlClient; +using System.Data; +using OpenMetaverse; + +namespace OpenSim.Data.MySQL +{ + public delegate string StoreDelegate(AssetBase asset, bool force); + + public class FSAssetConnectorData + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + protected MySqlConnection m_Connection = null; + protected string m_ConnectionString; + protected string m_Table; + protected Object m_connLock = new Object(); + + public FSAssetConnectorData(string connectionString, string table) + { + m_ConnectionString = connectionString; + m_Table = table; + + OpenDatabase(); + } + + private bool OpenDatabase() + { + try + { + m_Connection = new MySqlConnection(m_ConnectionString); + + m_Connection.Open(); + } + catch (MySqlException e) + { + m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", + e.Message.ToString()); + + return false; + } + + return true; + } + + private IDataReader ExecuteReader(MySqlCommand c) + { + IDataReader r = null; + MySqlConnection connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + connection.Open(); + c.Connection = connection; + + r = c.ExecuteReader(); + + return r; + } + + private void ExecuteNonQuery(MySqlCommand c) + { + lock (m_connLock) + { + bool errorSeen = false; + + while (true) + { + try + { + c.ExecuteNonQuery(); + } + catch (MySqlException) + { + System.Threading.Thread.Sleep(500); + + m_Connection.Close(); + m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); + m_Connection.Open(); + c.Connection = m_Connection; + + if (!errorSeen) + { + errorSeen = true; + continue; + } + m_log.ErrorFormat("[FSASSETS] MySQL command: {0}", c.CommandText); + throw; + } + + break; + } + } + } + + public AssetMetadata Get(string id, out string hash) + { + hash = String.Empty; + + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, asset_flags from {0} where id = ?id", m_Table); + cmd.Parameters.AddWithValue("?id", id); + + IDataReader reader = ExecuteReader(cmd); + + if (!reader.Read()) + { + reader.Close(); + FreeCommand(cmd); + return null; + } + + AssetMetadata meta = new AssetMetadata(); + + hash = reader["hash"].ToString(); + + meta.ID = id; + meta.FullID = new UUID(id); + + meta.Name = reader["name"].ToString(); + meta.Description = reader["description"].ToString(); + meta.Type = (sbyte)Convert.ToInt32(reader["type"]); + meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); + meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); + meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); + + reader.Close(); + + cmd.CommandText = String.Format("update {0} set access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); + + cmd.ExecuteNonQuery(); + + FreeCommand(cmd); + + return meta; + } + + protected void FreeCommand(MySqlCommand cmd) + { + MySqlConnection c = cmd.Connection; + cmd.Dispose(); + c.Close(); + c.Dispose(); + } + + public bool Store(AssetMetadata meta, string hash) + { + try + { + string oldhash; + AssetMetadata existingAsset = Get(meta.ID, out oldhash); + + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.Parameters.AddWithValue("?id", meta.ID); + cmd.Parameters.AddWithValue("?name", meta.Name); + cmd.Parameters.AddWithValue("?description", meta.Description); + cmd.Parameters.AddWithValue("?type", meta.Type.ToString()); + cmd.Parameters.AddWithValue("?hash", hash); + cmd.Parameters.AddWithValue("?asset_flags", meta.Flags); + + if (existingAsset == null) + { + cmd.CommandText = String.Format("insert into {0} (id, name, description, type, hash, asset_flags, create_time, access_time) values ( ?id, ?name, ?description, ?type, ?hash, ?asset_flags, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", m_Table); + + ExecuteNonQuery(cmd); + + cmd.Dispose(); + + return true; + } + + //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); + + //ExecuteNonQuery(cmd); + + cmd.Dispose(); + return false; + } + catch(Exception e) + { + m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); + m_log.Error(e.ToString()); + return false; + } + } + + /// + /// Check if the assets exist in the database. + /// + /// The asset UUID's + /// For each asset: true if it exists, false otherwise + public bool[] AssetsExist(UUID[] uuids) + { + if (uuids.Length == 0) + return new bool[0]; + + HashSet exists = new HashSet(); + + string ids = "'" + string.Join("','", uuids) + "'"; + string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table); + + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = sql; + + using (MySqlDataReader dbReader = cmd.ExecuteReader()) + { + while (dbReader.Read()) + { + UUID id = DBGuid.FromDB(dbReader["ID"]); + exists.Add(id); + } + } + } + + bool[] results = new bool[uuids.Length]; + for (int i = 0; i < uuids.Length; i++) + results[i] = exists.Contains(uuids[i]); + return results; + } + + public int Count() + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table); + + IDataReader reader = ExecuteReader(cmd); + + reader.Read(); + + int count = Convert.ToInt32(reader["count"]); + + reader.Close(); + FreeCommand(cmd); + + return count; + } + + public void Delete(string id) + { + MySqlCommand cmd = m_Connection.CreateCommand(); + + cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); + + cmd.Parameters.AddWithValue("?id", id); + + ExecuteNonQuery(cmd); + + cmd.Dispose(); + } + + public void Import(string conn, string table, int start, int count, bool force, StoreDelegate store) + { + MySqlConnection importConn; + + try + { + importConn = new MySqlConnection(conn); + + importConn.Open(); + } + catch (MySqlException e) + { + m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", + e.Message.ToString()); + + return; + } + + int imported = 0; + + MySqlCommand cmd = importConn.CreateCommand(); + + string limit = String.Empty; + if (count != -1) + { + limit = String.Format(" limit {0},{1}", start, count); + } + + cmd.CommandText = String.Format("select * from {0}{1}", table, limit); + + MainConsole.Instance.Output("Querying database"); + IDataReader reader = cmd.ExecuteReader(); + + MainConsole.Instance.Output("Reading data"); + + while (reader.Read()) + { + if ((imported % 100) == 0) + { + MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported)); + } + + AssetBase asset = new AssetBase(); + AssetMetadata meta = new AssetMetadata(); + + meta.ID = reader["id"].ToString(); + meta.FullID = new UUID(meta.ID); + + meta.Name = reader["name"].ToString(); + meta.Description = reader["description"].ToString(); + meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]); + meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); + meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); + + asset.Metadata = meta; + asset.Data = (byte[])reader["data"]; + + store(asset, force); + + imported++; + } + + reader.Close(); + cmd.Dispose(); + importConn.Close(); + + MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); + } + } +} -- cgit v1.1 From a343c07d12900e5c46e289711803e068b8e653b7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 11 Jul 2015 19:21:32 +0200 Subject: Some cleanup, add prebuild project, correct path --- OpenSim/Data/MySQL/MySQLFSAssetData.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs index a57bfe0..4d7a395 100644 --- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs @@ -32,10 +32,6 @@ using System.Data; using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Server.Base; -using OpenSim.Services.Base; -using OpenSim.Services.Interfaces; -using Nini.Config; using log4net; using MySql.Data.MySqlClient; using System.Data; -- cgit v1.1 From f3f748ed111223bdf9cbc25fcabb18b4ab427d37 Mon Sep 17 00:00:00 2001 From: AliciaRaven Date: Sun, 12 Jul 2015 01:35:57 +0100 Subject: Bringing FSAssets more inline with current OpenSim standards. * If no connection string found in assets config, fallback to using default database config * Create database storage interface to allow other db connectors to be written at some point * Add MySQL migrations file to create the initial db table * Added new config option named DaysBetweenAccessTimeUpdates to reduce db load by only updating access times when fetching assets if the last access time was over the threshold. This idea was taken from XAssets service. * Change log message headers to indicate FS assets is the source not just assets Signed-off-by: Melanie Thielker --- OpenSim/Data/MySQL/MySQLFSAssetData.cs | 107 ++++++++++++++++----- .../Data/MySQL/Resources/FSAssetStore.migrations | 18 ++++ 2 files changed, 100 insertions(+), 25 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/FSAssetStore.migrations (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs index 4d7a395..19e23b5 100644 --- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs @@ -29,37 +29,77 @@ using System; using System.Reflection; using System.Collections.Generic; using System.Data; -using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Console; using log4net; using MySql.Data.MySqlClient; -using System.Data; using OpenMetaverse; namespace OpenSim.Data.MySQL { - public delegate string StoreDelegate(AssetBase asset, bool force); - - public class FSAssetConnectorData + public class MySQLFSAssetData : IFSAssetDataPlugin { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected MySqlConnection m_Connection = null; protected string m_ConnectionString; protected string m_Table; protected Object m_connLock = new Object(); - public FSAssetConnectorData(string connectionString, string table) + /// + /// Number of days that must pass before we update the access time on an asset when it has been fetched + /// Config option to change this is "DaysBetweenAccessTimeUpdates" + /// + private int DaysBetweenAccessTimeUpdates = 0; + + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + + public MySQLFSAssetData() + { + } + + #region IPlugin Members + + public string Version { get { return "1.0.0.0"; } } + + // Loads and initialises the MySQL storage plugin and checks for migrations + public void Initialise(string connect, string realm, int UpdateAccessTime) + { + m_ConnectionString = connect; + m_Table = realm; + + DaysBetweenAccessTimeUpdates = UpdateAccessTime; + + try + { + OpenDatabase(); + + Migration m = new Migration(m_Connection, Assembly, "FSAssetStore"); + m.Update(); + } + catch (MySqlException e) + { + m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", e.Message.ToString()); + } + } + + public void Initialise() { - m_ConnectionString = connectionString; - m_Table = table; + throw new NotImplementedException(); + } + + public void Dispose() { } - OpenDatabase(); + public string Name + { + get { return "MySQL FSAsset storage engine"; } } + #endregion + private bool OpenDatabase() { try @@ -126,13 +166,15 @@ namespace OpenSim.Data.MySQL } } + #region IFSAssetDataPlugin Members + public AssetMetadata Get(string id, out string hash) { hash = String.Empty; MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, asset_flags from {0} where id = ?id", m_Table); + cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, access_time, asset_flags from {0} where id = ?id", m_Table); cmd.Parameters.AddWithValue("?id", id); IDataReader reader = ExecuteReader(cmd); @@ -158,17 +200,29 @@ namespace OpenSim.Data.MySQL meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); - reader.Close(); + int AccessTime = Convert.ToInt32(reader["access_time"]); - cmd.CommandText = String.Format("update {0} set access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); + reader.Close(); - cmd.ExecuteNonQuery(); + UpdateAccessTime(AccessTime, cmd); FreeCommand(cmd); return meta; } + private void UpdateAccessTime(int AccessTime, MySqlCommand cmd) + { + // Reduce DB work by only updating access time if asset hasn't recently been accessed + // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" + if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) + return; + + cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); + + cmd.ExecuteNonQuery(); + } + protected void FreeCommand(MySqlCommand cmd) { MySqlConnection c = cmd.Connection; @@ -214,7 +268,7 @@ namespace OpenSim.Data.MySQL catch(Exception e) { m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); - m_log.Error(e.ToString()); + m_log.Error(e.ToString()); return false; } } @@ -272,20 +326,21 @@ namespace OpenSim.Data.MySQL return count; } - public void Delete(string id) + public bool Delete(string id) { - MySqlCommand cmd = m_Connection.CreateCommand(); - - cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); + using (MySqlCommand cmd = m_Connection.CreateCommand()) + { + cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); - cmd.Parameters.AddWithValue("?id", id); + cmd.Parameters.AddWithValue("?id", id); - ExecuteNonQuery(cmd); + ExecuteNonQuery(cmd); + } - cmd.Dispose(); + return true; } - public void Import(string conn, string table, int start, int count, bool force, StoreDelegate store) + public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) { MySqlConnection importConn; @@ -353,5 +408,7 @@ namespace OpenSim.Data.MySQL MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); } + + #endregion } } diff --git a/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations new file mode 100644 index 0000000..87d08c6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations @@ -0,0 +1,18 @@ +# ----------------- +:VERSION 1 + +BEGIN; + +CREATE TABLE `fsassets` ( + `id` char(36) NOT NULL, + `name` varchar(64) NOT NULL DEFAULT '', + `description` varchar(64) NOT NULL DEFAULT '', + `type` int(11) NOT NULL, + `hash` char(80) NOT NULL, + `create_time` int(11) NOT NULL DEFAULT '0', + `access_time` int(11) NOT NULL DEFAULT '0', + `asset_flags` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; \ No newline at end of file -- cgit v1.1 From 7b571a928c2e32ee41a59e5c7784932e1ab823bb Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 14 Jul 2015 21:16:25 +0200 Subject: Mantis #7629: Change LandFlags column to unsigned. Thanks, Jim! --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index a77e44d..7aefadb 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -940,3 +940,11 @@ ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0; ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; COMMIT; +:VERSION 50 #---- Change LandFlags to unsigned + +BEGIN; + +ALTER TABLE land CHANGE COLUMN LandFlags LandFlags unsigned default null; + +COMMIT; + -- cgit v1.1 From c7f6e248e8544200871a1bf814f34e2ee0f9d977 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 14 Jul 2015 21:22:53 +0200 Subject: Correcting errors in previous change: MySQL needs int unsigned, not unsigned int. PGSQL has no unsigned types, changing to bigint. --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 7aefadb..ac31380 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -944,7 +944,7 @@ COMMIT; BEGIN; -ALTER TABLE land CHANGE COLUMN LandFlags LandFlags unsigned default null; +ALTER TABLE land CHANGE COLUMN LandFlags LandFlags int unsigned default null; COMMIT; -- cgit v1.1 From aadd5627fedba6a50e9680e174bad3f0045c4943 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 24 Jul 2015 13:00:05 +0300 Subject: Removed unused code that checked wait_timeout in MySQLEstateData --- OpenSim/Data/MySQL/MySQLEstateData.cs | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 69c89d4..fe1487b 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -43,12 +43,7 @@ namespace OpenSim.Data.MySQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private const string m_waitTimeoutSelect = "select @@wait_timeout"; - private string m_connectionString; - private long m_waitTimeout; - private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; -// private long m_lastConnectionUse; private FieldInfo[] m_Fields; private Dictionary m_FieldMap = @@ -81,8 +76,6 @@ namespace OpenSim.Data.MySQL m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); } - GetWaitTimeout(); - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -108,33 +101,6 @@ namespace OpenSim.Data.MySQL get { return new List(m_FieldMap.Keys).ToArray(); } } - protected void GetWaitTimeout() - { - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) - { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * - TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } - } - } - -// m_lastConnectionUse = DateTime.Now.Ticks; - - m_log.DebugFormat( - "[REGION DB]: Connection wait timeout {0} seconds", - m_waitTimeout / TimeSpan.TicksPerSecond); - } - } - public EstateSettings LoadEstateSettings(UUID regionID, bool create) { string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + -- cgit v1.1