rename SQLiteNG to SQLite and SQLite to SQLiteLegacy this seems the least evil way forward since mono 2.6 and later will see increasing usage, and this only works with what was
SQLiteNG MAC USERS WILL NEED TO CHANGE REFERENCES TO "OpenSim.Data.SQLite.dll" to "OpenSim.Data.SQLiteLegacy.dll" in OpenSim.ini and config-include/StandaloneCommon.ini (if using standalone) See the OpenSim.ini.example and StandaloneCommon.ini.example files for more details This commit also temporarily changes unsigned ParentEstateID values in the OpenSim.Data.Tests to signed temporarily, since the new plugin enforces creation of signed fields in the database (which is what the SQL actually specifies). And change data columns in sqlite is a pita.0.6.9
parent
955db6e4be
commit
56fe4c24b8
|
@ -30,7 +30,7 @@ using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData
|
public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData
|
||||||
{
|
{
|
|
@ -30,7 +30,7 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
@ -62,8 +62,8 @@ namespace OpenSim.Data.SQLite
|
||||||
Migration m = new Migration(m_connection, assem, "EstateStore");
|
Migration m = new Migration(m_connection, assem, "EstateStore");
|
||||||
m.Update();
|
m.Update();
|
||||||
|
|
||||||
m_connection.Close();
|
//m_connection.Close();
|
||||||
m_connection.Open();
|
// m_connection.Open();
|
||||||
|
|
||||||
Type t = typeof(EstateSettings);
|
Type t = typeof(EstateSettings);
|
||||||
m_Fields = t.GetFields(BindingFlags.NonPublic |
|
m_Fields = t.GetFields(BindingFlags.NonPublic |
|
||||||
|
@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.Add(":RegionID", regionID.ToString());
|
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -140,13 +140,13 @@ namespace OpenSim.Data.SQLite
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
{
|
{
|
||||||
if ((bool)m_FieldMap[name].GetValue(es))
|
if ((bool)m_FieldMap[name].GetValue(es))
|
||||||
cmd.Parameters.Add(":"+name, "1");
|
cmd.Parameters.AddWithValue(":"+name, "1");
|
||||||
else
|
else
|
||||||
cmd.Parameters.Add(":"+name, "0");
|
cmd.Parameters.AddWithValue(":"+name, "0");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ namespace OpenSim.Data.SQLite
|
||||||
r.Close();
|
r.Close();
|
||||||
|
|
||||||
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
||||||
cmd.Parameters.Add(":RegionID", regionID.ToString());
|
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||||
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
|
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
||||||
|
|
||||||
// This will throw on dupe key
|
// This will throw on dupe key
|
||||||
try
|
try
|
||||||
|
@ -222,13 +222,13 @@ namespace OpenSim.Data.SQLite
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
{
|
{
|
||||||
if ((bool)m_FieldMap[name].GetValue(es))
|
if ((bool)m_FieldMap[name].GetValue(es))
|
||||||
cmd.Parameters.Add(":"+name, "1");
|
cmd.Parameters.AddWithValue(":"+name, "1");
|
||||||
else
|
else
|
||||||
cmd.Parameters.Add(":"+name, "0");
|
cmd.Parameters.AddWithValue(":"+name, "0");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ namespace OpenSim.Data.SQLite
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
|
cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
|
||||||
cmd.Parameters.Add(":EstateID", es.EstateID);
|
cmd.Parameters.AddWithValue(":EstateID", es.EstateID);
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ namespace OpenSim.Data.SQLite
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "delete from estateban where EstateID = :EstateID";
|
cmd.CommandText = "delete from estateban where EstateID = :EstateID";
|
||||||
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
|
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
@ -281,8 +281,8 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
foreach (EstateBan b in es.EstateBans)
|
foreach (EstateBan b in es.EstateBans)
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
|
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
||||||
cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString());
|
cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
@ -294,7 +294,7 @@ namespace OpenSim.Data.SQLite
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
|
cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
|
||||||
cmd.Parameters.Add(":EstateID", EstateID.ToString());
|
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
@ -304,8 +304,8 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
foreach (UUID uuid in data)
|
foreach (UUID uuid in data)
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(":EstateID", EstateID.ToString());
|
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
||||||
cmd.Parameters.Add(":uuid", uuid.ToString());
|
cmd.Parameters.AddWithValue(":uuid", uuid.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
@ -319,7 +319,7 @@ namespace OpenSim.Data.SQLite
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
|
cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
|
||||||
cmd.Parameters.Add(":EstateID", EstateID);
|
cmd.Parameters.AddWithValue(":EstateID", EstateID);
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -336,5 +336,66 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
return uuids.ToArray();
|
return uuids.ToArray();
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteEstateData.cs
|
||||||
|
=======
|
||||||
|
|
||||||
|
public EstateSettings LoadEstateSettings(int estateID)
|
||||||
|
{
|
||||||
|
string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID";
|
||||||
|
|
||||||
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
||||||
|
|
||||||
|
return DoLoad(cmd, UUID.Zero, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> GetEstates(string search)
|
||||||
|
{
|
||||||
|
List<int> result = new List<int>();
|
||||||
|
|
||||||
|
string sql = "select EstateID from estate_settings where estate_settings.EstateName :EstateName";
|
||||||
|
|
||||||
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
cmd.Parameters.AddWithValue(":EstateName", search);
|
||||||
|
|
||||||
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
result.Add(Convert.ToInt32(r["EstateID"]));
|
||||||
|
}
|
||||||
|
r.Close();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LinkRegion(UUID regionID, int estateID)
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
|
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
||||||
|
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
||||||
|
|
||||||
|
if (cmd.ExecuteNonQuery() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> GetRegions(int estateID)
|
||||||
|
{
|
||||||
|
return new List<UUID>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteEstate(int estateID)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteEstateData.cs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLite
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,19 @@ namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteFramework.cs
|
||||||
cmd.Connection = m_Connection;
|
cmd.Connection = m_Connection;
|
||||||
|
=======
|
||||||
|
/*
|
||||||
|
SqliteConnection newConnection =
|
||||||
|
(SqliteConnection)((ICloneable)connection).Clone();
|
||||||
|
newConnection.Open();
|
||||||
|
|
||||||
|
cmd.Connection = newConnection;
|
||||||
|
*/
|
||||||
|
cmd.Connection = connection;
|
||||||
|
//Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteFramework.cs
|
||||||
|
|
||||||
return cmd.ExecuteNonQuery();
|
return cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -65,12 +77,27 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
protected IDataReader ExecuteReader(SqliteCommand cmd)
|
protected IDataReader ExecuteReader(SqliteCommand cmd)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteFramework.cs
|
||||||
SqliteConnection newConnection =
|
SqliteConnection newConnection =
|
||||||
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||||
newConnection.Open();
|
newConnection.Open();
|
||||||
|
|
||||||
cmd.Connection = newConnection;
|
cmd.Connection = newConnection;
|
||||||
return cmd.ExecuteReader();
|
return cmd.ExecuteReader();
|
||||||
|
=======
|
||||||
|
lock (connection)
|
||||||
|
{
|
||||||
|
//SqliteConnection newConnection =
|
||||||
|
// (SqliteConnection)((ICloneable)connection).Clone();
|
||||||
|
//newConnection.Open();
|
||||||
|
|
||||||
|
//cmd.Connection = newConnection;
|
||||||
|
cmd.Connection = connection;
|
||||||
|
//Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
|
return cmd.ExecuteReader();
|
||||||
|
}
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteFramework.cs
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void CloseReaderCommand(SqliteCommand cmd)
|
protected void CloseReaderCommand(SqliteCommand cmd)
|
||||||
|
|
|
@ -33,7 +33,7 @@ using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
public class SQLiteFriendsData : SQLiteGenericTableHandler<FriendsData>, IFriendsData
|
public class SQLiteFriendsData : SQLiteGenericTableHandler<FriendsData>, IFriendsData
|
||||||
{
|
{
|
|
@ -30,7 +30,7 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
@ -54,7 +54,27 @@ namespace OpenSim.Data.SQLite
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
if (storeName != String.Empty)
|
if (storeName != String.Empty)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
|
=======
|
||||||
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
|
Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString));
|
||||||
|
m_Connection.Open();
|
||||||
|
|
||||||
|
if (storeName != String.Empty)
|
||||||
|
{
|
||||||
|
Assembly assem = GetType().Assembly;
|
||||||
|
//SqliteConnection newConnection =
|
||||||
|
// (SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||||
|
//newConnection.Open();
|
||||||
|
|
||||||
|
//Migration m = new Migration(newConnection, assem, storeName);
|
||||||
|
Migration m = new Migration(m_Connection, assem, storeName);
|
||||||
|
m.Update();
|
||||||
|
//newConnection.Close();
|
||||||
|
//newConnection.Dispose();
|
||||||
|
}
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||||
|
|
||||||
Migration m = new Migration(m_Connection, assem, storeName);
|
Migration m = new Migration(m_Connection, assem, storeName);
|
||||||
m.Update();
|
m.Update();
|
||||||
|
@ -180,7 +200,11 @@ namespace OpenSim.Data.SQLite
|
||||||
result.Add(row);
|
result.Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||||
CloseReaderCommand(cmd);
|
CloseReaderCommand(cmd);
|
||||||
|
=======
|
||||||
|
//CloseCommand(cmd);
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
ds = new DataSet();
|
ds = new DataSet();
|
||||||
|
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteInventoryStore.cs
|
||||||
ds.Tables.Add(createInventoryFoldersTable());
|
ds.Tables.Add(createInventoryFoldersTable());
|
||||||
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
||||||
setupFoldersCommands(invFoldersDa, conn);
|
setupFoldersCommands(invFoldersDa, conn);
|
||||||
|
@ -98,6 +99,19 @@ namespace OpenSim.Data.SQLite
|
||||||
invItemsDa.Fill(ds.Tables["inventoryitems"]);
|
invItemsDa.Fill(ds.Tables["inventoryitems"]);
|
||||||
setupItemsCommands(invItemsDa, conn);
|
setupItemsCommands(invItemsDa, conn);
|
||||||
m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
|
m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
|
||||||
|
=======
|
||||||
|
ds.Tables.Add(createInventoryFoldersTable());
|
||||||
|
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
||||||
|
setupFoldersCommands(invFoldersDa, conn);
|
||||||
|
CreateDataSetMapping(invFoldersDa, "inventoryfolders");
|
||||||
|
m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
|
||||||
|
|
||||||
|
ds.Tables.Add(createInventoryItemsTable());
|
||||||
|
invItemsDa.Fill(ds.Tables["inventoryitems"]);
|
||||||
|
setupItemsCommands(invItemsDa, conn);
|
||||||
|
CreateDataSetMapping(invItemsDa, "inventoryitems");
|
||||||
|
m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteInventoryStore.cs
|
||||||
|
|
||||||
ds.AcceptChanges();
|
ds.AcceptChanges();
|
||||||
}
|
}
|
||||||
|
@ -721,6 +735,15 @@ namespace OpenSim.Data.SQLite
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
protected void CreateDataSetMapping(IDataAdapter da, string tableName)
|
||||||
|
{
|
||||||
|
ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName);
|
||||||
|
foreach (DataColumn col in ds.Tables[tableName].Columns)
|
||||||
|
{
|
||||||
|
dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the "inventoryitems" table
|
/// Create the "inventoryitems" table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -32,7 +32,7 @@ using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
@ -86,20 +86,19 @@ namespace OpenSim.Data.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connectionString">the connection string</param>
|
/// <param name="connectionString">the connection string</param>
|
||||||
public void Initialise(string connectionString)
|
public void Initialise(string connectionString)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
m_connectionString = connectionString;
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
ds = new DataSet();
|
ds = new DataSet("Region");
|
||||||
|
|
||||||
m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString);
|
m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString);
|
||||||
m_conn = new SqliteConnection(m_connectionString);
|
m_conn = new SqliteConnection(m_connectionString);
|
||||||
m_conn.Open();
|
m_conn.Open();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn);
|
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn);
|
||||||
primDa = new SqliteDataAdapter(primSelectCmd);
|
primDa = new SqliteDataAdapter(primSelectCmd);
|
||||||
// SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
|
|
||||||
|
|
||||||
SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn);
|
SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn);
|
||||||
shapeDa = new SqliteDataAdapter(shapeSelectCmd);
|
shapeDa = new SqliteDataAdapter(shapeSelectCmd);
|
||||||
|
@ -128,14 +127,12 @@ namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
ds.Tables.Add(createPrimTable());
|
ds.Tables.Add(createPrimTable());
|
||||||
setupPrimCommands(primDa, m_conn);
|
setupPrimCommands(primDa, m_conn);
|
||||||
primDa.Fill(ds.Tables["prims"]);
|
|
||||||
|
|
||||||
ds.Tables.Add(createShapeTable());
|
ds.Tables.Add(createShapeTable());
|
||||||
setupShapeCommands(shapeDa, m_conn);
|
setupShapeCommands(shapeDa, m_conn);
|
||||||
|
|
||||||
ds.Tables.Add(createItemsTable());
|
ds.Tables.Add(createItemsTable());
|
||||||
setupItemsCommands(itemsDa, m_conn);
|
setupItemsCommands(itemsDa, m_conn);
|
||||||
itemsDa.Fill(ds.Tables["primitems"]);
|
|
||||||
|
|
||||||
ds.Tables.Add(createTerrainTable());
|
ds.Tables.Add(createTerrainTable());
|
||||||
setupTerrainCommands(terrainDa, m_conn);
|
setupTerrainCommands(terrainDa, m_conn);
|
||||||
|
@ -147,13 +144,21 @@ namespace OpenSim.Data.SQLite
|
||||||
setupLandAccessCommands(landAccessListDa, m_conn);
|
setupLandAccessCommands(landAccessListDa, m_conn);
|
||||||
|
|
||||||
ds.Tables.Add(createRegionSettingsTable());
|
ds.Tables.Add(createRegionSettingsTable());
|
||||||
|
|
||||||
setupRegionSettingsCommands(regionSettingsDa, m_conn);
|
setupRegionSettingsCommands(regionSettingsDa, m_conn);
|
||||||
|
|
||||||
// WORKAROUND: This is a work around for sqlite on
|
// WORKAROUND: This is a work around for sqlite on
|
||||||
// windows, which gets really unhappy with blob columns
|
// windows, which gets really unhappy with blob columns
|
||||||
// that have no sample data in them. At some point we
|
// that have no sample data in them. At some point we
|
||||||
// need to actually find a proper way to handle this.
|
// need to actually find a proper way to handle this.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
primDa.Fill(ds.Tables["prims"]);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Info("[REGION DB]: Caught fill error on prims table");
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shapeDa.Fill(ds.Tables["primshapes"]);
|
shapeDa.Fill(ds.Tables["primshapes"]);
|
||||||
|
@ -198,9 +203,27 @@ namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
m_log.Info("[REGION DB]: Caught fill error on regionsettings table");
|
m_log.Info("[REGION DB]: Caught fill error on regionsettings table");
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
// We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values!
|
||||||
|
// Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409
|
||||||
|
// Possibly because we manually set up our own DataTables before connecting to the database
|
||||||
|
CreateDataSetMapping(primDa, "prims");
|
||||||
|
CreateDataSetMapping(shapeDa, "primshapes");
|
||||||
|
CreateDataSetMapping(itemsDa, "primitems");
|
||||||
|
CreateDataSetMapping(terrainDa, "terrain");
|
||||||
|
CreateDataSetMapping(landDa, "land");
|
||||||
|
CreateDataSetMapping(landAccessListDa, "landaccesslist");
|
||||||
|
CreateDataSetMapping(regionSettingsDa, "regionsettings");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error(e);
|
||||||
|
Environment.Exit(23);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -594,7 +617,7 @@ namespace OpenSim.Data.SQLite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rev = (int) row["Revision"];
|
rev = Convert.ToInt32(row["Revision"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -746,6 +769,7 @@ namespace OpenSim.Data.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Commit()
|
public void Commit()
|
||||||
{
|
{
|
||||||
|
m_log.Debug("[SQLITE]: Starting commit");
|
||||||
lock (ds)
|
lock (ds)
|
||||||
{
|
{
|
||||||
primDa.Update(ds, "prims");
|
primDa.Update(ds, "prims");
|
||||||
|
@ -760,19 +784,12 @@ namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
regionSettingsDa.Update(ds, "regionsettings");
|
regionSettingsDa.Update(ds, "regionsettings");
|
||||||
}
|
}
|
||||||
catch (SqliteExecutionException SqlEx)
|
catch (SqliteException SqlEx)
|
||||||
{
|
|
||||||
if (SqlEx.Message.Contains("logic error"))
|
|
||||||
{
|
{
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!",
|
"There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!",
|
||||||
SqlEx);
|
SqlEx);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw SqlEx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ds.AcceptChanges();
|
ds.AcceptChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,6 +810,15 @@ namespace OpenSim.Data.SQLite
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
protected void CreateDataSetMapping(IDataAdapter da, string tableName)
|
||||||
|
{
|
||||||
|
ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName);
|
||||||
|
foreach (DataColumn col in ds.Tables[tableName].Columns)
|
||||||
|
{
|
||||||
|
dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1955,6 +1981,7 @@ namespace OpenSim.Data.SQLite
|
||||||
sql += ") values (:";
|
sql += ") values (:";
|
||||||
sql += String.Join(", :", cols);
|
sql += String.Join(", :", cols);
|
||||||
sql += ")";
|
sql += ")";
|
||||||
|
m_log.DebugFormat("[SQLITE]: Created insert command {0}", sql);
|
||||||
SqliteCommand cmd = new SqliteCommand(sql);
|
SqliteCommand cmd = new SqliteCommand(sql);
|
||||||
|
|
||||||
// this provides the binding for all our parameters, so
|
// this provides the binding for all our parameters, so
|
||||||
|
@ -2251,5 +2278,35 @@ namespace OpenSim.Data.SQLite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PrintDataSet(DataSet ds)
|
||||||
|
{
|
||||||
|
// Print out any name and extended properties.
|
||||||
|
Console.WriteLine("DataSet is named: {0}", ds.DataSetName);
|
||||||
|
foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
foreach (DataTable dt in ds.Tables)
|
||||||
|
{
|
||||||
|
Console.WriteLine("=> {0} Table:", dt.TableName);
|
||||||
|
// Print out the column names.
|
||||||
|
for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
|
||||||
|
{
|
||||||
|
Console.Write(dt.Columns[curCol].ColumnName + "\t");
|
||||||
|
}
|
||||||
|
Console.WriteLine("\n----------------------------------");
|
||||||
|
// Print the DataTable.
|
||||||
|
for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
|
||||||
|
{
|
||||||
|
for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
|
||||||
|
{
|
||||||
|
Console.Write(dt.Rows[curRow][curCol].ToString() + "\t");
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
|
public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
|
||||||
{
|
{
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLite
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.Sqlite;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -147,7 +147,11 @@ namespace OpenSim.Data.SQLite
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
|
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteXInventoryData.cs
|
||||||
CloseReaderCommand(cmd);
|
CloseReaderCommand(cmd);
|
||||||
|
=======
|
||||||
|
//CloseCommand(cmd);
|
||||||
|
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteXInventoryData.cs
|
||||||
|
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,11 @@ using System.Runtime.InteropServices;
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
|
|
||||||
[assembly : AssemblyTitle("OpenSim.Data.SQLiteNG")]
|
[assembly : AssemblyTitle("OpenSim.Data.SQLiteLegacy")]
|
||||||
[assembly : AssemblyDescription("")]
|
[assembly : AssemblyDescription("")]
|
||||||
[assembly : AssemblyConfiguration("")]
|
[assembly : AssemblyConfiguration("")]
|
||||||
[assembly : AssemblyCompany("http://opensimulator.org")]
|
[assembly : AssemblyCompany("http://opensimulator.org")]
|
||||||
[assembly : AssemblyProduct("OpenSim.Data.SQLiteNG")]
|
[assembly : AssemblyProduct("OpenSim.Data.SQLiteLegacy")]
|
||||||
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
||||||
[assembly : AssemblyTrademark("")]
|
[assembly : AssemblyTrademark("")]
|
||||||
[assembly : AssemblyCulture("")]
|
[assembly : AssemblyCulture("")]
|
|
@ -30,11 +30,11 @@ using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An asset storage interface for the SQLite database system
|
/// An asset storage interface for the SQLite database system
|
|
@ -0,0 +1,262 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
|
{
|
||||||
|
public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData
|
||||||
|
{
|
||||||
|
private string m_Realm;
|
||||||
|
private List<string> m_ColumnNames;
|
||||||
|
private int m_LastExpire;
|
||||||
|
private string m_connectionString;
|
||||||
|
|
||||||
|
protected static SqliteConnection m_Connection;
|
||||||
|
private static bool m_initialized = false;
|
||||||
|
|
||||||
|
public SQLiteAuthenticationData(string connectionString, string realm)
|
||||||
|
: base(connectionString)
|
||||||
|
{
|
||||||
|
m_Realm = realm;
|
||||||
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
|
if (!m_initialized)
|
||||||
|
{
|
||||||
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
|
m_Connection.Open();
|
||||||
|
|
||||||
|
using (SqliteConnection dbcon = (SqliteConnection)((ICloneable)m_Connection).Clone())
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore");
|
||||||
|
m.Update();
|
||||||
|
dbcon.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthenticationData Get(UUID principalID)
|
||||||
|
{
|
||||||
|
AuthenticationData ret = new AuthenticationData();
|
||||||
|
ret.Data = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID");
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||||
|
|
||||||
|
IDataReader result = ExecuteReader(cmd, m_Connection);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (result.Read())
|
||||||
|
{
|
||||||
|
ret.PrincipalID = principalID;
|
||||||
|
|
||||||
|
if (m_ColumnNames == null)
|
||||||
|
{
|
||||||
|
m_ColumnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string s in m_ColumnNames)
|
||||||
|
{
|
||||||
|
if (s == "UUID")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret.Data[s] = result[s].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Store(AuthenticationData data)
|
||||||
|
{
|
||||||
|
if (data.Data.ContainsKey("UUID"))
|
||||||
|
data.Data.Remove("UUID");
|
||||||
|
|
||||||
|
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||||
|
string[] values = new string[data.Data.Count];
|
||||||
|
int i = 0;
|
||||||
|
foreach (object o in data.Data.Values)
|
||||||
|
values[i++] = o.ToString();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
|
if (Get(data.PrincipalID) != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
string update = "update `" + m_Realm + "` set ";
|
||||||
|
bool first = true;
|
||||||
|
foreach (string field in fields)
|
||||||
|
{
|
||||||
|
if (!first)
|
||||||
|
update += ", ";
|
||||||
|
update += "`" + field + "` = :" + field;
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||||
|
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
update += " where UUID = :UUID";
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||||
|
|
||||||
|
cmd.CommandText = update;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
||||||
|
String.Join("`, `", fields) +
|
||||||
|
"`) values (:UUID, :" + String.Join(", :", fields) + ")";
|
||||||
|
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||||
|
foreach (string field in fields)
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||||
|
|
||||||
|
cmd.CommandText = insert;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseCommand(cmd);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetDataItem(UUID principalID, string item, string value)
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = new SqliteCommand("update `" + m_Realm +
|
||||||
|
"` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'");
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetToken(UUID principalID, string token, int lifetime)
|
||||||
|
{
|
||||||
|
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||||
|
DoExpire();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
|
||||||
|
"', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))");
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Dispose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckToken(UUID principalID, string token, int lifetime)
|
||||||
|
{
|
||||||
|
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||||
|
DoExpire();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() +
|
||||||
|
" minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')");
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Dispose();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoExpire()
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')");
|
||||||
|
ExecuteNonQuery(cmd, m_Connection);
|
||||||
|
|
||||||
|
cmd.Dispose();
|
||||||
|
|
||||||
|
m_LastExpire = System.Environment.TickCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,9 +33,9 @@ using System.Threading;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A SQLite Interface for Avatar Data
|
/// A SQLite Interface for Avatar Data
|
||||||
|
@ -55,8 +55,8 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = new SqliteCommand();
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
|
cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
|
||||||
cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
|
cmd.Parameters.Add(":PrincipalID", principalID.ToString());
|
||||||
cmd.Parameters.AddWithValue(":Name", name);
|
cmd.Parameters.Add(":Name", name);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
//CloseCommand(cmd);
|
CloseCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,12 +30,12 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
public class SQLiteEstateStore : IEstateDataStore
|
public class SQLiteEstateStore : IEstateDataStore
|
||||||
{
|
{
|
||||||
|
@ -62,8 +62,8 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
Migration m = new Migration(m_connection, assem, "EstateStore");
|
Migration m = new Migration(m_connection, assem, "EstateStore");
|
||||||
m.Update();
|
m.Update();
|
||||||
|
|
||||||
//m_connection.Close();
|
m_connection.Close();
|
||||||
// m_connection.Open();
|
m_connection.Open();
|
||||||
|
|
||||||
Type t = typeof(EstateSettings);
|
Type t = typeof(EstateSettings);
|
||||||
m_Fields = t.GetFields(BindingFlags.NonPublic |
|
m_Fields = t.GetFields(BindingFlags.NonPublic |
|
||||||
|
@ -87,7 +87,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
cmd.Parameters.Add(":RegionID", regionID.ToString());
|
||||||
|
|
||||||
return DoLoad(cmd, regionID, create);
|
return DoLoad(cmd, regionID, create);
|
||||||
}
|
}
|
||||||
|
@ -143,13 +143,13 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
{
|
{
|
||||||
if ((bool)m_FieldMap[name].GetValue(es))
|
if ((bool)m_FieldMap[name].GetValue(es))
|
||||||
cmd.Parameters.AddWithValue(":"+name, "1");
|
cmd.Parameters.Add(":"+name, "1");
|
||||||
else
|
else
|
||||||
cmd.Parameters.AddWithValue(":"+name, "0");
|
cmd.Parameters.Add(":"+name, "0");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
r.Close();
|
r.Close();
|
||||||
|
|
||||||
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
||||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
cmd.Parameters.Add(":RegionID", regionID.ToString());
|
||||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
|
||||||
|
|
||||||
// This will throw on dupe key
|
// This will throw on dupe key
|
||||||
try
|
try
|
||||||
|
@ -211,13 +211,13 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
{
|
{
|
||||||
if ((bool)m_FieldMap[name].GetValue(es))
|
if ((bool)m_FieldMap[name].GetValue(es))
|
||||||
cmd.Parameters.AddWithValue(":"+name, "1");
|
cmd.Parameters.Add(":"+name, "1");
|
||||||
else
|
else
|
||||||
cmd.Parameters.AddWithValue(":"+name, "0");
|
cmd.Parameters.Add(":"+name, "0");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
|
cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
|
||||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID);
|
cmd.Parameters.Add(":EstateID", es.EstateID);
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "delete from estateban where EstateID = :EstateID";
|
cmd.CommandText = "delete from estateban where EstateID = :EstateID";
|
||||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
@ -270,8 +270,8 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
|
|
||||||
foreach (EstateBan b in es.EstateBans)
|
foreach (EstateBan b in es.EstateBans)
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
|
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
|
||||||
cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString());
|
cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
@ -283,7 +283,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
|
cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
|
||||||
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
cmd.Parameters.Add(":EstateID", EstateID.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
@ -293,8 +293,8 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
|
|
||||||
foreach (UUID uuid in data)
|
foreach (UUID uuid in data)
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
|
cmd.Parameters.Add(":EstateID", EstateID.ToString());
|
||||||
cmd.Parameters.AddWithValue(":uuid", uuid.ToString());
|
cmd.Parameters.Add(":uuid", uuid.ToString());
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
@ -308,7 +308,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
|
cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
|
||||||
cmd.Parameters.AddWithValue(":EstateID", EstateID);
|
cmd.Parameters.Add(":EstateID", EstateID);
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
cmd.Parameters.Add(":EstateID", estateID.ToString());
|
||||||
|
|
||||||
return DoLoad(cmd, UUID.Zero, false);
|
return DoLoad(cmd, UUID.Zero, false);
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.AddWithValue(":EstateName", search);
|
cmd.Parameters.Add(":EstateName", search);
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
IDataReader r = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -365,8 +365,8 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
||||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
cmd.Parameters.Add(":RegionID", regionID.ToString());
|
||||||
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
cmd.Parameters.Add(":EstateID", estateID.ToString());
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() == 0)
|
if (cmd.ExecuteNonQuery() == 0)
|
||||||
return false;
|
return false;
|
|
@ -31,9 +31,9 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A database interface class to a user profile storage system
|
/// A database interface class to a user profile storage system
|
||||||
|
@ -55,14 +55,11 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
{
|
{
|
||||||
lock (connection)
|
lock (connection)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
SqliteConnection newConnection =
|
SqliteConnection newConnection =
|
||||||
(SqliteConnection)((ICloneable)connection).Clone();
|
(SqliteConnection)((ICloneable)connection).Clone();
|
||||||
newConnection.Open();
|
newConnection.Open();
|
||||||
|
|
||||||
cmd.Connection = newConnection;
|
cmd.Connection = newConnection;
|
||||||
*/
|
|
||||||
cmd.Connection = connection;
|
|
||||||
//Console.WriteLine("XXX " + cmd.CommandText);
|
//Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
return cmd.ExecuteNonQuery();
|
return cmd.ExecuteNonQuery();
|
||||||
|
@ -73,12 +70,11 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
{
|
{
|
||||||
lock (connection)
|
lock (connection)
|
||||||
{
|
{
|
||||||
//SqliteConnection newConnection =
|
SqliteConnection newConnection =
|
||||||
// (SqliteConnection)((ICloneable)connection).Clone();
|
(SqliteConnection)((ICloneable)connection).Clone();
|
||||||
//newConnection.Open();
|
newConnection.Open();
|
||||||
|
|
||||||
//cmd.Connection = newConnection;
|
cmd.Connection = newConnection;
|
||||||
cmd.Connection = connection;
|
|
||||||
//Console.WriteLine("XXX " + cmd.CommandText);
|
//Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
return cmd.ExecuteReader();
|
return cmd.ExecuteReader();
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
|
{
|
||||||
|
public class SQLiteFriendsData : SQLiteGenericTableHandler<FriendsData>, IFriendsData
|
||||||
|
{
|
||||||
|
public SQLiteFriendsData(string connectionString, string realm)
|
||||||
|
: base(connectionString, realm, "FriendsStore")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public FriendsData[] GetFriends(UUID userID)
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
|
cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
|
||||||
|
cmd.Parameters.Add(":PrincipalID", userID.ToString());
|
||||||
|
|
||||||
|
return DoQuery(cmd);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(UUID principalID, string friend)
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
|
cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
|
||||||
|
cmd.Parameters.Add(":PrincipalID", principalID.ToString());
|
||||||
|
cmd.Parameters.Add(":Friend", friend);
|
||||||
|
|
||||||
|
ExecuteNonQuery(cmd, cmd.Connection);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,12 +30,12 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
public class SQLiteGenericTableHandler<T> : SQLiteFramework where T: class, new()
|
public class SQLiteGenericTableHandler<T> : SQLiteFramework where T: class, new()
|
||||||
{
|
{
|
||||||
|
@ -59,21 +59,19 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
{
|
{
|
||||||
m_Connection = new SqliteConnection(connectionString);
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString));
|
|
||||||
m_Connection.Open();
|
m_Connection.Open();
|
||||||
|
|
||||||
if (storeName != String.Empty)
|
if (storeName != String.Empty)
|
||||||
{
|
{
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
//SqliteConnection newConnection =
|
SqliteConnection newConnection =
|
||||||
// (SqliteConnection)((ICloneable)m_Connection).Clone();
|
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||||
//newConnection.Open();
|
newConnection.Open();
|
||||||
|
|
||||||
//Migration m = new Migration(newConnection, assem, storeName);
|
Migration m = new Migration(newConnection, assem, storeName);
|
||||||
Migration m = new Migration(m_Connection, assem, storeName);
|
|
||||||
m.Update();
|
m.Update();
|
||||||
//newConnection.Close();
|
newConnection.Close();
|
||||||
//newConnection.Dispose();
|
newConnection.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
|
@ -199,7 +197,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
result.Add(row);
|
result.Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
//CloseCommand(cmd);
|
CloseCommand(cmd);
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
|
@ -30,11 +30,11 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An Inventory Interface to the SQLite database
|
/// An Inventory Interface to the SQLite database
|
||||||
|
@ -98,13 +98,11 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
ds.Tables.Add(createInventoryFoldersTable());
|
ds.Tables.Add(createInventoryFoldersTable());
|
||||||
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
||||||
setupFoldersCommands(invFoldersDa, conn);
|
setupFoldersCommands(invFoldersDa, conn);
|
||||||
CreateDataSetMapping(invFoldersDa, "inventoryfolders");
|
|
||||||
m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
|
m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
|
||||||
|
|
||||||
ds.Tables.Add(createInventoryItemsTable());
|
ds.Tables.Add(createInventoryItemsTable());
|
||||||
invItemsDa.Fill(ds.Tables["inventoryitems"]);
|
invItemsDa.Fill(ds.Tables["inventoryitems"]);
|
||||||
setupItemsCommands(invItemsDa, conn);
|
setupItemsCommands(invItemsDa, conn);
|
||||||
CreateDataSetMapping(invItemsDa, "inventoryitems");
|
|
||||||
m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
|
m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
|
||||||
|
|
||||||
ds.AcceptChanges();
|
ds.AcceptChanges();
|
||||||
|
@ -730,15 +728,6 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
protected void CreateDataSetMapping(IDataAdapter da, string tableName)
|
|
||||||
{
|
|
||||||
ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName);
|
|
||||||
foreach (DataColumn col in ds.Tables[tableName].Columns)
|
|
||||||
{
|
|
||||||
dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the "inventoryitems" table
|
/// Create the "inventoryitems" table
|
||||||
/// </summary>
|
/// </summary>
|
|
@ -32,13 +32,13 @@ using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A RegionData Interface to the SQLite database
|
/// A RegionData Interface to the SQLite database
|
||||||
|
@ -86,19 +86,20 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connectionString">the connection string</param>
|
/// <param name="connectionString">the connection string</param>
|
||||||
public void Initialise(string connectionString)
|
public void Initialise(string connectionString)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
m_connectionString = connectionString;
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
ds = new DataSet("Region");
|
ds = new DataSet();
|
||||||
|
|
||||||
m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString);
|
m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString);
|
||||||
m_conn = new SqliteConnection(m_connectionString);
|
m_conn = new SqliteConnection(m_connectionString);
|
||||||
m_conn.Open();
|
m_conn.Open();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn);
|
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn);
|
||||||
primDa = new SqliteDataAdapter(primSelectCmd);
|
primDa = new SqliteDataAdapter(primSelectCmd);
|
||||||
|
// SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
|
||||||
|
|
||||||
SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn);
|
SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn);
|
||||||
shapeDa = new SqliteDataAdapter(shapeSelectCmd);
|
shapeDa = new SqliteDataAdapter(shapeSelectCmd);
|
||||||
|
@ -127,12 +128,14 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
{
|
{
|
||||||
ds.Tables.Add(createPrimTable());
|
ds.Tables.Add(createPrimTable());
|
||||||
setupPrimCommands(primDa, m_conn);
|
setupPrimCommands(primDa, m_conn);
|
||||||
|
primDa.Fill(ds.Tables["prims"]);
|
||||||
|
|
||||||
ds.Tables.Add(createShapeTable());
|
ds.Tables.Add(createShapeTable());
|
||||||
setupShapeCommands(shapeDa, m_conn);
|
setupShapeCommands(shapeDa, m_conn);
|
||||||
|
|
||||||
ds.Tables.Add(createItemsTable());
|
ds.Tables.Add(createItemsTable());
|
||||||
setupItemsCommands(itemsDa, m_conn);
|
setupItemsCommands(itemsDa, m_conn);
|
||||||
|
itemsDa.Fill(ds.Tables["primitems"]);
|
||||||
|
|
||||||
ds.Tables.Add(createTerrainTable());
|
ds.Tables.Add(createTerrainTable());
|
||||||
setupTerrainCommands(terrainDa, m_conn);
|
setupTerrainCommands(terrainDa, m_conn);
|
||||||
|
@ -144,21 +147,13 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
setupLandAccessCommands(landAccessListDa, m_conn);
|
setupLandAccessCommands(landAccessListDa, m_conn);
|
||||||
|
|
||||||
ds.Tables.Add(createRegionSettingsTable());
|
ds.Tables.Add(createRegionSettingsTable());
|
||||||
|
|
||||||
setupRegionSettingsCommands(regionSettingsDa, m_conn);
|
setupRegionSettingsCommands(regionSettingsDa, m_conn);
|
||||||
|
|
||||||
// WORKAROUND: This is a work around for sqlite on
|
// WORKAROUND: This is a work around for sqlite on
|
||||||
// windows, which gets really unhappy with blob columns
|
// windows, which gets really unhappy with blob columns
|
||||||
// that have no sample data in them. At some point we
|
// that have no sample data in them. At some point we
|
||||||
// need to actually find a proper way to handle this.
|
// need to actually find a proper way to handle this.
|
||||||
try
|
|
||||||
{
|
|
||||||
primDa.Fill(ds.Tables["prims"]);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
m_log.Info("[REGION DB]: Caught fill error on prims table");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shapeDa.Fill(ds.Tables["primshapes"]);
|
shapeDa.Fill(ds.Tables["primshapes"]);
|
||||||
|
@ -203,27 +198,9 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
{
|
{
|
||||||
m_log.Info("[REGION DB]: Caught fill error on regionsettings table");
|
m_log.Info("[REGION DB]: Caught fill error on regionsettings table");
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values!
|
|
||||||
// Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409
|
|
||||||
// Possibly because we manually set up our own DataTables before connecting to the database
|
|
||||||
CreateDataSetMapping(primDa, "prims");
|
|
||||||
CreateDataSetMapping(shapeDa, "primshapes");
|
|
||||||
CreateDataSetMapping(itemsDa, "primitems");
|
|
||||||
CreateDataSetMapping(terrainDa, "terrain");
|
|
||||||
CreateDataSetMapping(landDa, "land");
|
|
||||||
CreateDataSetMapping(landAccessListDa, "landaccesslist");
|
|
||||||
CreateDataSetMapping(regionSettingsDa, "regionsettings");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e);
|
|
||||||
Environment.Exit(23);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -626,7 +603,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rev = Convert.ToInt32(row["Revision"]);
|
rev = (int) row["Revision"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -778,7 +755,6 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Commit()
|
public void Commit()
|
||||||
{
|
{
|
||||||
m_log.Debug("[SQLITE]: Starting commit");
|
|
||||||
lock (ds)
|
lock (ds)
|
||||||
{
|
{
|
||||||
primDa.Update(ds, "prims");
|
primDa.Update(ds, "prims");
|
||||||
|
@ -793,12 +769,19 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
{
|
{
|
||||||
regionSettingsDa.Update(ds, "regionsettings");
|
regionSettingsDa.Update(ds, "regionsettings");
|
||||||
}
|
}
|
||||||
catch (SqliteException SqlEx)
|
catch (SqliteExecutionException SqlEx)
|
||||||
|
{
|
||||||
|
if (SqlEx.Message.Contains("logic error"))
|
||||||
{
|
{
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!",
|
"There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!",
|
||||||
SqlEx);
|
SqlEx);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw SqlEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
ds.AcceptChanges();
|
ds.AcceptChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -819,15 +802,6 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
protected void CreateDataSetMapping(IDataAdapter da, string tableName)
|
|
||||||
{
|
|
||||||
ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName);
|
|
||||||
foreach (DataColumn col in ds.Tables[tableName].Columns)
|
|
||||||
{
|
|
||||||
dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1990,7 +1964,6 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
sql += ") values (:";
|
sql += ") values (:";
|
||||||
sql += String.Join(", :", cols);
|
sql += String.Join(", :", cols);
|
||||||
sql += ")";
|
sql += ")";
|
||||||
m_log.DebugFormat("[SQLITE]: Created insert command {0}", sql);
|
|
||||||
SqliteCommand cmd = new SqliteCommand(sql);
|
SqliteCommand cmd = new SqliteCommand(sql);
|
||||||
|
|
||||||
// this provides the binding for all our parameters, so
|
// this provides the binding for all our parameters, so
|
||||||
|
@ -2287,35 +2260,5 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintDataSet(DataSet ds)
|
|
||||||
{
|
|
||||||
// Print out any name and extended properties.
|
|
||||||
Console.WriteLine("DataSet is named: {0}", ds.DataSetName);
|
|
||||||
foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
|
|
||||||
}
|
|
||||||
Console.WriteLine();
|
|
||||||
foreach (DataTable dt in ds.Tables)
|
|
||||||
{
|
|
||||||
Console.WriteLine("=> {0} Table:", dt.TableName);
|
|
||||||
// Print out the column names.
|
|
||||||
for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
|
|
||||||
{
|
|
||||||
Console.Write(dt.Columns[curCol].ColumnName + "\t");
|
|
||||||
}
|
|
||||||
Console.WriteLine("\n----------------------------------");
|
|
||||||
// Print the DataTable.
|
|
||||||
for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
|
|
||||||
{
|
|
||||||
for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
|
|
||||||
{
|
|
||||||
Console.Write(dt.Rows[curRow][curCol].ToString() + "\t");
|
|
||||||
}
|
|
||||||
Console.WriteLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
|
{
|
||||||
|
public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
|
||||||
|
{
|
||||||
|
public SQLiteUserAccountData(string connectionString, string realm)
|
||||||
|
: base(connectionString, realm, "UserAccount")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||||
|
{
|
||||||
|
string[] words = query.Split(new char[] {' '});
|
||||||
|
|
||||||
|
for (int i = 0 ; i < words.Length ; i++)
|
||||||
|
{
|
||||||
|
if (words[i].Length < 3)
|
||||||
|
{
|
||||||
|
if (i != words.Length - 1)
|
||||||
|
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
|
||||||
|
Array.Resize(ref words, words.Length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (words.Length == 0)
|
||||||
|
return new UserAccountData[0];
|
||||||
|
|
||||||
|
if (words.Length > 2)
|
||||||
|
return new UserAccountData[0];
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
|
if (words.Length == 1)
|
||||||
|
{
|
||||||
|
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
|
||||||
|
m_Realm, scopeID.ToString(), words[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
|
||||||
|
m_Realm, scopeID.ToString(), words[0], words[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DoQuery(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,9 +27,9 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A base class for methods needed by all SQLite database classes
|
/// A base class for methods needed by all SQLite database classes
|
|
@ -29,12 +29,12 @@ using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.SqliteClient;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLiteNG
|
namespace OpenSim.Data.SQLiteLegacy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A MySQL Interface for the Asset Server
|
/// A MySQL Interface for the Asset Server
|
||||||
|
@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLiteNG
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
//CloseCommand(cmd);
|
CloseCommand(cmd);
|
||||||
|
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
|
@ -39,7 +39,8 @@ namespace OpenSim.Data.Tests
|
||||||
public class DataTestUtil
|
public class DataTestUtil
|
||||||
{
|
{
|
||||||
public const uint UNSIGNED_INTEGER_MIN = uint.MinValue;
|
public const uint UNSIGNED_INTEGER_MIN = uint.MinValue;
|
||||||
public const uint UNSIGNED_INTEGER_MAX = uint.MaxValue;
|
//public const uint UNSIGNED_INTEGER_MAX = uint.MaxValue;
|
||||||
|
public const uint UNSIGNED_INTEGER_MAX = INTEGER_MAX;
|
||||||
|
|
||||||
public const int INTEGER_MIN = int.MinValue + 1; // Postgresql requires +1 to .NET int.MinValue
|
public const int INTEGER_MIN = int.MinValue + 1; // Postgresql requires +1 to .NET int.MinValue
|
||||||
public const int INTEGER_MAX = int.MaxValue;
|
public const int INTEGER_MAX = int.MaxValue;
|
||||||
|
|
|
@ -126,9 +126,15 @@
|
||||||
;storage_plugin = "OpenSim.Data.Null.dll"
|
;storage_plugin = "OpenSim.Data.Null.dll"
|
||||||
|
|
||||||
; --- To use sqlite as region storage:
|
; --- To use sqlite as region storage:
|
||||||
; NOTE: SQLite and OpenSim are not functioning properly with Mono 2.4.3 or greater.
|
;
|
||||||
; If you are using Mono you probably should be using MySQL
|
; PLEASE NOTE: Unfortunately, the current SQLite database plugin (necessary to use SQLite with Mono on Linux) is
|
||||||
|
; not compatible with the sqlite3 library installed on Mac OSX. If you're using Mono 2.4 you can still use the old sqlite
|
||||||
|
; library by uncommenting the SQLiteLegacy.dll storage plugin (and commenting out SQLite.dll). Unfortunately, the older library
|
||||||
|
; will not work with Mono 2.6 on Mac OSX so you will either need to replace the OSX sqlite3 system library or use MySQL instead
|
||||||
|
;
|
||||||
|
; You will also need to do the same thing in config-include/StandaloneCommon.ini if you are running in standalone mode
|
||||||
storage_plugin = "OpenSim.Data.SQLite.dll"
|
storage_plugin = "OpenSim.Data.SQLite.dll"
|
||||||
|
;storage_plugin = "OpenSim.Data.SQLiteLegacy.dll"
|
||||||
storage_connection_string="URI=file:OpenSim.db,version=3";
|
storage_connection_string="URI=file:OpenSim.db,version=3";
|
||||||
|
|
||||||
; --- To use MySQL storage, supply your own connection string (this is only an example):
|
; --- To use MySQL storage, supply your own connection string (this is only an example):
|
||||||
|
|
|
@ -4,7 +4,15 @@
|
||||||
;
|
;
|
||||||
;--- For SQLite
|
;--- For SQLite
|
||||||
StorageProvider = "OpenSim.Data.SQLite.dll"
|
StorageProvider = "OpenSim.Data.SQLite.dll"
|
||||||
;--- For MySql
|
|
||||||
|
; Unfortunately the current SQLite database plugin is not compatible with Mac OSX. You can still use the older
|
||||||
|
; legacy sqlite library if you are using Mono 2.4. Please see the notes in OpenSim.ini (search for sqlite)
|
||||||
|
; for more details
|
||||||
|
;StorageProvider = "OpenSim.Data.SQLiteLegacy.dll";
|
||||||
|
|
||||||
|
; MySql
|
||||||
|
; Uncomment these lines if you want to use mysql storage
|
||||||
|
; Change the connection string to your db details
|
||||||
;StorageProvider = "OpenSim.Data.MySQL.dll"
|
;StorageProvider = "OpenSim.Data.MySQL.dll"
|
||||||
;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;"
|
;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;"
|
||||||
|
|
||||||
|
|
|
@ -2473,7 +2473,7 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Data.SQLite" path="OpenSim/Data/SQLite" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Data.SQLiteLegacy" path="OpenSim/Data/SQLiteLegacy" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
<OutputPath>../../../bin/</OutputPath>
|
||||||
|
@ -2510,7 +2510,7 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Data.SQLiteNG" path="OpenSim/Data/SQLiteNG" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Data.SQLite" path="OpenSim/Data/SQLite" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
<OutputPath>../../../bin/</OutputPath>
|
||||||
|
|
Loading…
Reference in New Issue