Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
commit
81c08ec74a
|
@ -43,6 +43,7 @@ namespace OpenSim.Data.MSSQL
|
||||||
private List<string> m_ColumnNames = null;
|
private List<string> m_ColumnNames = null;
|
||||||
private int m_LastExpire = 0;
|
private int m_LastExpire = 0;
|
||||||
private string m_ConnectionString;
|
private string m_ConnectionString;
|
||||||
|
private MSSQLManager m_database;
|
||||||
|
|
||||||
public MSSQLAuthenticationData(string connectionString, string realm)
|
public MSSQLAuthenticationData(string connectionString, string realm)
|
||||||
{
|
{
|
||||||
|
@ -61,12 +62,12 @@ namespace OpenSim.Data.MSSQL
|
||||||
AuthenticationData ret = new AuthenticationData();
|
AuthenticationData ret = new AuthenticationData();
|
||||||
ret.Data = new Dictionary<string, object>();
|
ret.Data = new Dictionary<string, object>();
|
||||||
|
|
||||||
string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm);
|
string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@principalID", principalID.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||||
conn.Open();
|
conn.Open();
|
||||||
using (SqlDataReader result = cmd.ExecuteReader())
|
using (SqlDataReader result = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
@ -108,34 +109,33 @@ namespace OpenSim.Data.MSSQL
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
using (SqlCommand cmd = new SqlCommand())
|
||||||
{
|
{
|
||||||
updateBuilder.AppendFormat("update '{0}' set ", m_Realm);
|
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach (string field in fields)
|
foreach (string field in fields)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
updateBuilder.Append(", ");
|
updateBuilder.Append(", ");
|
||||||
updateBuilder.AppendFormat("'{0}' = @{0}",field);
|
updateBuilder.AppendFormat("{0} = @{0}",field);
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
||||||
cmd.Parameters.AddWithValue("@" + field, data.Data[field]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBuilder.Append(" where UUID = @principalID");
|
updateBuilder.Append(" where UUID = @principalID");
|
||||||
|
|
||||||
cmd.CommandText = updateBuilder.ToString();
|
cmd.CommandText = updateBuilder.ToString();
|
||||||
cmd.Connection = conn;
|
cmd.Connection = conn;
|
||||||
|
cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID));
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("@principalID", data.PrincipalID.ToString());
|
|
||||||
conn.Open();
|
conn.Open();
|
||||||
if (cmd.ExecuteNonQuery() < 1)
|
if (cmd.ExecuteNonQuery() < 1)
|
||||||
{
|
{
|
||||||
StringBuilder insertBuilder = new StringBuilder();
|
StringBuilder insertBuilder = new StringBuilder();
|
||||||
|
|
||||||
insertBuilder.AppendFormat("insert into '{0}' ('UUID', '", m_Realm);
|
insertBuilder.AppendFormat("insert into {0} (UUID, ", m_Realm);
|
||||||
insertBuilder.Append(String.Join("', '", fields));
|
insertBuilder.Append(String.Join(", ", fields));
|
||||||
insertBuilder.Append("') values (@principalID, @");
|
insertBuilder.Append(") values ( @principalID, @");
|
||||||
insertBuilder.Append(String.Join(", @", fields));
|
insertBuilder.Append(String.Join(", @", fields));
|
||||||
insertBuilder.Append(")");
|
insertBuilder.Append(")");
|
||||||
|
|
||||||
|
@ -152,12 +152,11 @@ namespace OpenSim.Data.MSSQL
|
||||||
|
|
||||||
public bool SetDataItem(UUID principalID, string item, string value)
|
public bool SetDataItem(UUID principalID, string item, string value)
|
||||||
{
|
{
|
||||||
string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item);
|
string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item);
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@" + item, value);
|
cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
||||||
cmd.Parameters.AddWithValue("@UUID", principalID.ToString());
|
|
||||||
conn.Open();
|
conn.Open();
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
if (cmd.ExecuteNonQuery() > 0)
|
||||||
return true;
|
return true;
|
||||||
|
@ -173,9 +172,9 @@ namespace OpenSim.Data.MSSQL
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@principalID", principalID.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||||
cmd.Parameters.AddWithValue("@token", token);
|
cmd.Parameters.Add(m_database.CreateParameter("@token", token));
|
||||||
cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime));
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
if (cmd.ExecuteNonQuery() > 0)
|
||||||
|
@ -194,9 +193,9 @@ namespace OpenSim.Data.MSSQL
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@principalID", principalID.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||||
cmd.Parameters.AddWithValue("@token", token);
|
cmd.Parameters.Add(m_database.CreateParameter("@token", token));
|
||||||
cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime));
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
if (cmd.ExecuteNonQuery() > 0)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -40,13 +40,15 @@ namespace OpenSim.Data.MSSQL
|
||||||
{
|
{
|
||||||
private string m_Realm;
|
private string m_Realm;
|
||||||
private List<string> m_ColumnNames = null;
|
private List<string> m_ColumnNames = null;
|
||||||
private int m_LastExpire = 0;
|
|
||||||
private string m_ConnectionString;
|
private string m_ConnectionString;
|
||||||
|
private MSSQLManager m_database;
|
||||||
|
|
||||||
public MSSQLUserAccountData(string connectionString, string realm)
|
public MSSQLUserAccountData(string connectionString, string realm)
|
||||||
{
|
{
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
m_ConnectionString = connectionString;
|
m_ConnectionString = connectionString;
|
||||||
|
m_database = new MSSQLManager(connectionString);
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
@ -65,16 +67,16 @@ namespace OpenSim.Data.MSSQL
|
||||||
UserAccountData ret = new UserAccountData();
|
UserAccountData ret = new UserAccountData();
|
||||||
ret.Data = new Dictionary<string, object>();
|
ret.Data = new Dictionary<string, object>();
|
||||||
|
|
||||||
string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm);
|
string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
||||||
if (scopeID != UUID.Zero)
|
if (scopeID != UUID.Zero)
|
||||||
sql += " and ScopeID = @scopeID";
|
sql += " and ScopeID = @scopeID";
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
|
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||||
|
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("@principalID", principalID);
|
|
||||||
cmd.Parameters.AddWithValue("@scopeID", scopeID);
|
|
||||||
conn.Open();
|
conn.Open();
|
||||||
using (SqlDataReader result = cmd.ExecuteReader())
|
using (SqlDataReader result = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
@ -123,17 +125,16 @@ namespace OpenSim.Data.MSSQL
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
using (SqlCommand cmd = new SqlCommand())
|
||||||
{
|
{
|
||||||
StringBuilder updateBuilder = new StringBuilder();
|
StringBuilder updateBuilder = new StringBuilder();
|
||||||
updateBuilder.AppendFormat("update '{0}' set ", m_Realm);
|
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach (string field in fields)
|
foreach (string field in fields)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
updateBuilder.Append(", ");
|
updateBuilder.Append(", ");
|
||||||
updateBuilder.AppendFormat("'{0}' = @{0}", field);
|
updateBuilder.AppendFormat("{0} = @{0}", field);
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
||||||
cmd.Parameters.AddWithValue("@" + field, data.Data[field]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBuilder.Append(" where UUID = @principalID");
|
updateBuilder.Append(" where UUID = @principalID");
|
||||||
|
@ -143,16 +144,16 @@ namespace OpenSim.Data.MSSQL
|
||||||
|
|
||||||
cmd.CommandText = updateBuilder.ToString();
|
cmd.CommandText = updateBuilder.ToString();
|
||||||
cmd.Connection = conn;
|
cmd.Connection = conn;
|
||||||
cmd.Parameters.AddWithValue("@principalID", data.PrincipalID);
|
cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID));
|
||||||
cmd.Parameters.AddWithValue("@scopeID", data.ScopeID);
|
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID));
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() < 1)
|
if (cmd.ExecuteNonQuery() < 1)
|
||||||
{
|
{
|
||||||
StringBuilder insertBuilder = new StringBuilder();
|
StringBuilder insertBuilder = new StringBuilder();
|
||||||
insertBuilder.AppendFormat("insert into '{0}' ('UUID', 'ScopeID', '", m_Realm);
|
insertBuilder.AppendFormat("insert into {0} (UUID, ScopeID, ", m_Realm);
|
||||||
insertBuilder.Append(String.Join("', '", fields));
|
insertBuilder.Append(String.Join(", ", fields));
|
||||||
insertBuilder.Append("') values (@principalID, @scopeID, @");
|
insertBuilder.Append(") values ( @principalID, @scopeID, @");
|
||||||
insertBuilder.Append(String.Join(", @", fields));
|
insertBuilder.Append(String.Join(", @", fields));
|
||||||
insertBuilder.Append(")");
|
insertBuilder.Append(")");
|
||||||
|
|
||||||
|
@ -169,12 +170,13 @@ namespace OpenSim.Data.MSSQL
|
||||||
|
|
||||||
public bool SetDataItem(UUID principalID, string item, string value)
|
public bool SetDataItem(UUID principalID, string item, string value)
|
||||||
{
|
{
|
||||||
string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item);
|
string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item);
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@" + item, value);
|
cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
||||||
cmd.Parameters.AddWithValue("@UUID", principalID);
|
cmd.Parameters.Add(m_database.CreateParameter("@UUID", principalID));
|
||||||
|
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
if (cmd.ExecuteNonQuery() > 0)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
BEGIN TRANSACTION
|
||||||
|
|
||||||
|
ALTER TABLE regions ADD scopeid uniqueidentifier default '00000000-0000-0000-0000-000000000000';
|
||||||
|
ALTER TABLE regions ADD DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [owner_uuid];
|
||||||
|
ALTER TABLE regions ADD sizeX integer not null default 0;
|
||||||
|
ALTER TABLE regions ADD sizeY integer not null default 0;
|
||||||
|
|
||||||
|
COMMIT
|
Loading…
Reference in New Issue