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