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 <ajlduarte@sapo.pt>
LSLKeyTest
Geir Nøklebye 2016-07-15 16:34:32 +02:00 committed by UbitUmarov
parent 5f5c4aca40
commit 653b896794
2 changed files with 24 additions and 6 deletions

View File

@ -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;

View File

@ -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
{
@ -1546,6 +1551,10 @@ namespace OpenSim.Data.PGSQL
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();
}