From 3e1ca2bd2136a51f23dff0d31f4725b4e05c3f7c Mon Sep 17 00:00:00 2001 From: fernando Date: Tue, 15 Oct 2013 11:55:08 -0500 Subject: [PATCH] * Fixes mantis #6802 Simulator crashes whist loading (lighshare enabled) * Please test --- OpenSim/Data/PGSQL/PGSQLEstateData.cs | 14 +++++++++----- OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 8 ++++---- .../PGSQL/Resources/InventoryStore.migrations | 9 +++++++++ .../PGSQL/Resources/RegionStore.migrations | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/OpenSim/Data/PGSQL/PGSQLEstateData.cs b/OpenSim/Data/PGSQL/PGSQLEstateData.cs index 347baf3cd1..141b8edaa1 100644 --- a/OpenSim/Data/PGSQL/PGSQLEstateData.cs +++ b/OpenSim/Data/PGSQL/PGSQLEstateData.cs @@ -201,11 +201,10 @@ namespace OpenSim.Data.PGSQL string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray())); - m_log.Debug("[DB ESTATE]: SQL: " + sql); using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) using (NpgsqlCommand insertCommand = new NpgsqlCommand(sql, conn)) { - insertCommand.CommandText = sql + "; Select cast(lastval() as int) as ID ;"; + insertCommand.CommandText = sql; foreach (string name in names) { @@ -218,11 +217,16 @@ namespace OpenSim.Data.PGSQL es.EstateID = 100; - using (NpgsqlDataReader result = insertCommand.ExecuteReader()) + if (insertCommand.ExecuteNonQuery() > 0) { - if (result.Read()) + insertCommand.CommandText = "Select cast(lastval() as int) as ID ;"; + + using (NpgsqlDataReader result = insertCommand.ExecuteReader()) { - es.EstateID = (uint)result.GetInt32(0); + if (result.Read()) + { + es.EstateID = (uint)result.GetInt32(0); + } } } diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index 5753ae31bb..69b0bebf1d 100644 --- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs @@ -727,7 +727,7 @@ namespace OpenSim.Data.PGSQL using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) { - cmd.Parameters.Add(_Database.CreateParameter("regionID", regionUUID)); + cmd.Parameters.Add(_Database.CreateParameter("regionID", regionUUID.ToString() )); conn.Open(); using (NpgsqlDataReader result = cmd.ExecuteReader()) { @@ -817,7 +817,7 @@ namespace OpenSim.Data.PGSQL using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) { conn.Open(); - cmd.Parameters.Add(_Database.CreateParameter("region_id", regionID)); + cmd.Parameters.Add(_Database.CreateParameter("region_id", regionID.ToString())); cmd.ExecuteNonQuery(); } } @@ -831,8 +831,8 @@ namespace OpenSim.Data.PGSQL conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) { - cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID)); - exists = (int)cmd.ExecuteScalar() > 0; + cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString() )); + exists = cmd.ExecuteNonQuery() > 0; } } if (exists) diff --git a/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations b/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations index b61e1f8753..8f7982ad35 100644 --- a/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations @@ -209,3 +209,12 @@ alter table inventoryitems alter column "creatorID" type varchar(255); Commit; + +:VERSION 10 + +BEGIN TRANSACTION; + +Alter table inventoryitems Rename Column "SaleType" to "saleType"; + +Commit; + diff --git a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations index 65eb011989..1e33027e48 100644 --- a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations @@ -1134,3 +1134,21 @@ ALTER TABLE prims ADD "Friction" double precision NOT NULL default '0.6'; ALTER TABLE prims ADD "Restitution" double precision NOT NULL default '0.5'; COMMIT; + +:VERSION 40 #-- regionwindlight changed type from smallint to bool + +BEGIN TRANSACTION; + +ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_x_lock DROP DEFAULT; +ALTER TABLE regionwindlight ALTER cloud_scroll_x_lock TYPE bool USING CASE WHEN cloud_scroll_x_lock=0 THEN FALSE ELSE TRUE END; +ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_x_lock SET DEFAULT FALSE; + +ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_y_lock DROP DEFAULT; +ALTER TABLE regionwindlight ALTER cloud_scroll_y_lock TYPE bool USING CASE WHEN cloud_scroll_y_lock=0 THEN FALSE ELSE TRUE END; +ALTER TABLE regionwindlight ALTER COLUMN cloud_scroll_y_lock SET DEFAULT FALSE; + +ALTER TABLE regionwindlight ALTER COLUMN draw_classic_clouds DROP DEFAULT; +ALTER TABLE regionwindlight ALTER draw_classic_clouds TYPE bool USING CASE WHEN draw_classic_clouds=0 THEN FALSE ELSE TRUE END; +ALTER TABLE regionwindlight ALTER COLUMN draw_classic_clouds SET DEFAULT FALSE; + +COMMIT;