From 653b896794d884dbdb44dace81d3cf99a93c7705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20N=C3=B8klebye?= Date: Fri, 15 Jul 2016 16:34:32 +0200 Subject: [PATCH] PGSQL: Update simulation data with a number of missing fields for parcels. Some of the fields should probably be migrated to type Boolean to avoid the hairy casting in the query. In addition the overall server code relies in the Replace in SQL statement that is proprietary to MySQL, so the PGSQL code is rather unsafe as it is. Should probably set a transaction on the whole operation so that if something goes wrong the database record is not zapped as it is now. PostgreSQL 9.5 has the upsert functionality which would bring the code closer to the MySQL version. This commit also has an update to PGSQLRegionData Signed-off-by: UbitUmarov --- OpenSim/Data/PGSQL/PGSQLRegionData.cs | 6 ++---- OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 24 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/OpenSim/Data/PGSQL/PGSQLRegionData.cs b/OpenSim/Data/PGSQL/PGSQLRegionData.cs index a7da013838..3924b7bba1 100644 --- a/OpenSim/Data/PGSQL/PGSQLRegionData.cs +++ b/OpenSim/Data/PGSQL/PGSQLRegionData.cs @@ -26,16 +26,14 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Data; -using System.Drawing; -using System.IO; using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; +using OpenSim.Data; using RegionFlags = OpenSim.Framework.RegionFlags; using Npgsql; diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index 960e7f651c..25e1a7f84b 100755 --- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs @@ -688,11 +688,14 @@ namespace OpenSim.Data.PGSQL string sql = @"INSERT 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"") + ""SnapshotUUID"",""UserLocationX"",""UserLocationY"",""UserLocationZ"",""UserLookAtX"",""UserLookAtY"",""UserLookAtZ"",""AuthbuyerID"",""OtherCleanTime"",""Dwell"", + ""MediaType"",""MediaDescription"",""MediaSize"",""MediaLoop"",""ObscureMusic"",""ObscureMedia"",""SeeAVs"",""AnyAVSounds"",""GroupAVSounds"") 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)"; + :SnapshotUUID,:UserLocationX,:UserLocationY,:UserLocationZ,:UserLookAtX,:UserLookAtY,:UserLookAtZ,:AuthbuyerID,:OtherCleanTime,:Dwell, + :MediaType,:MediaDescription,:MediaWidth::text || ',' || :MediaHeight::text,:MediaLoop,:ObscureMusic,:ObscureMedia,:SeeAVs::int::smallint, + :AnyAVSounds::int::smallint,:GroupAVSounds::int::smallint)"; using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) @@ -1520,6 +1523,8 @@ namespace OpenSim.Data.PGSQL newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]); newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); + newData.Dwell = Convert.ToSingle(row["Dwell"]); + try { @@ -1545,6 +1550,10 @@ namespace OpenSim.Data.PGSQL newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); + + newData.SeeAVs = Convert.ToBoolean(row["SeeAVs"]); + newData.AnyAVSounds = Convert.ToBoolean(row["AnyAVSounds"]); + newData.GroupAVSounds = Convert.ToBoolean(row["GroupAVSounds"]); return newData; } @@ -1947,6 +1956,17 @@ namespace OpenSim.Data.PGSQL parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z)); parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID)); parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime)); + parameters.Add(_Database.CreateParameter("Dwell", land.Dwell)); + parameters.Add(_Database.CreateParameter("MediaDescription", land.MediaDescription)); + parameters.Add(_Database.CreateParameter("MediaType", land.MediaType)); + parameters.Add(_Database.CreateParameter("MediaWidth", land.MediaWidth)); + parameters.Add(_Database.CreateParameter("MediaHeight", land.MediaHeight)); + parameters.Add(_Database.CreateParameter("MediaLoop", land.MediaLoop)); + parameters.Add(_Database.CreateParameter("ObscureMusic", land.ObscureMusic)); + parameters.Add(_Database.CreateParameter("ObscureMedia", land.ObscureMedia)); + parameters.Add(_Database.CreateParameter("SeeAVs", land.SeeAVs)); + parameters.Add(_Database.CreateParameter("AnyAVSounds", land.AnyAVSounds)); + parameters.Add(_Database.CreateParameter("GroupAVSounds", land.GroupAVSounds)); return parameters.ToArray(); }