mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 20:55:43 +08:00
Allow estate config files to specify a specific EstateID. Defaults to 0 if not specified which uses auto increment id as current behaviour.
This commit is contained in:
@@ -55,12 +55,12 @@ namespace OpenSim.Data
|
||||
EstateSettings LoadEstateSettings(int estateID);
|
||||
|
||||
/// <summary>
|
||||
/// Create a new estate.
|
||||
/// Create a new estate. Zero estateID for auto increment id
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="EstateSettings"/>
|
||||
/// </returns>
|
||||
EstateSettings CreateNewEstate();
|
||||
EstateSettings CreateNewEstate(int estateID);
|
||||
|
||||
/// <summary>
|
||||
/// Load/Get all estate settings.
|
||||
|
||||
@@ -120,10 +120,12 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
public EstateSettings CreateNewEstate(int estateID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
|
||||
es.OnSave += StoreEstateSettings;
|
||||
es.EstateID = Convert.ToUInt32(estateID);
|
||||
|
||||
DoCreate(es);
|
||||
|
||||
@@ -193,7 +195,9 @@ namespace OpenSim.Data.MySQL
|
||||
// Migration case
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
// Remove EstateID and use AutoIncrement
|
||||
if (es.EstateID < 100)
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
|
||||
|
||||
@@ -222,16 +226,20 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
cmd2.ExecuteNonQuery();
|
||||
|
||||
cmd2.CommandText = "select LAST_INSERT_ID() as id";
|
||||
cmd2.Parameters.Clear();
|
||||
|
||||
using (IDataReader r = cmd2.ExecuteReader())
|
||||
// Only get Auto ID if we actually used it else we just get 0
|
||||
if (es.EstateID < 100)
|
||||
{
|
||||
r.Read();
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
}
|
||||
cmd2.CommandText = "select LAST_INSERT_ID() as id";
|
||||
cmd2.Parameters.Clear();
|
||||
|
||||
es.Save();
|
||||
using (IDataReader r = cmd2.ExecuteReader())
|
||||
{
|
||||
r.Read();
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
}
|
||||
|
||||
es.Save();
|
||||
}
|
||||
}
|
||||
dbcon.Close();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace OpenSim.Data.Null
|
||||
return GetEstate();
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
public EstateSettings CreateNewEstate(int estateID)
|
||||
{
|
||||
return new EstateSettings();
|
||||
}
|
||||
|
||||
@@ -177,10 +177,12 @@ namespace OpenSim.Data.PGSQL
|
||||
return es;
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
public EstateSettings CreateNewEstate(int estateID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
|
||||
es.OnSave += StoreEstateSettings;
|
||||
es.EstateID = Convert.ToUInt32(estateID);
|
||||
|
||||
DoCreate(es);
|
||||
|
||||
@@ -197,7 +199,9 @@ namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
// Remove EstateID and use AutoIncrement
|
||||
if (es.EstateID < 100)
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray()));
|
||||
|
||||
@@ -215,10 +219,9 @@ namespace OpenSim.Data.PGSQL
|
||||
//insertCommand.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
|
||||
es.EstateID = 100;
|
||||
|
||||
if (insertCommand.ExecuteNonQuery() > 0)
|
||||
if (insertCommand.ExecuteNonQuery() > 0 && es.EstateID < 100)
|
||||
{
|
||||
// Only get Auto ID if we actually used it
|
||||
insertCommand.CommandText = "Select cast(lastval() as int) as ID ;";
|
||||
|
||||
using (NpgsqlDataReader result = insertCommand.ExecuteReader())
|
||||
|
||||
@@ -167,10 +167,12 @@ namespace OpenSim.Data.SQLite
|
||||
return es;
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
public EstateSettings CreateNewEstate(int estateID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
|
||||
es.OnSave += StoreEstateSettings;
|
||||
es.EstateID = Convert.ToUInt32(estateID);
|
||||
|
||||
DoCreate(es);
|
||||
|
||||
@@ -186,9 +188,12 @@ namespace OpenSim.Data.SQLite
|
||||
private void DoCreate(EstateSettings es)
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
names.Remove("EstateID");
|
||||
|
||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||
// Remove EstateID and use AutoIncrement
|
||||
if (es.EstateID < 100)
|
||||
names.Remove("EstateID");
|
||||
|
||||
using (SqliteCommand cmd = m_connection.CreateCommand())
|
||||
{
|
||||
string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
|
||||
|
||||
@@ -212,12 +217,16 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "select LAST_INSERT_ROWID() as id";
|
||||
cmd.Parameters.Clear();
|
||||
using(IDataReader r = cmd.ExecuteReader())
|
||||
// Only get Auto ID if we actually used it else we just get 0
|
||||
if (es.EstateID < 100)
|
||||
{
|
||||
r.Read();
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
cmd.CommandText = "select LAST_INSERT_ROWID() as id";
|
||||
cmd.Parameters.Clear();
|
||||
using (IDataReader r = cmd.ExecuteReader())
|
||||
{
|
||||
r.Read();
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user