Fix a bunch of issues that crop up after the naive porting of the new sqlite db from master to 0.6.9
parent
d8b604b550
commit
0b8b302aa0
|
@ -1,257 +0,0 @@
|
|||
/*
|
||||
* 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.Sqlite;
|
||||
|
||||
namespace OpenSim.Data.SQLite
|
||||
{
|
||||
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();
|
||||
|
||||
Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore");
|
||||
m.Update();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -180,7 +180,7 @@ namespace OpenSim.Data.SQLite
|
|||
//
|
||||
cmd.Parameters.Clear();
|
||||
cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID";
|
||||
cmd.Parameters.Add(":UUID", regionID.ToString());
|
||||
cmd.Parameters.AddWithValue(":UUID", regionID.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -336,66 +336,5 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
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
|
||||
}
|
||||
}
|
|
@ -57,19 +57,7 @@ namespace OpenSim.Data.SQLite
|
|||
{
|
||||
lock (m_Connection)
|
||||
{
|
||||
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteFramework.cs
|
||||
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();
|
||||
}
|
||||
|
@ -77,27 +65,18 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
protected IDataReader ExecuteReader(SqliteCommand cmd)
|
||||
{
|
||||
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteFramework.cs
|
||||
SqliteConnection newConnection =
|
||||
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||
newConnection.Open();
|
||||
|
||||
cmd.Connection = newConnection;
|
||||
return cmd.ExecuteReader();
|
||||
=======
|
||||
lock (connection)
|
||||
lock (m_Connection)
|
||||
{
|
||||
//SqliteConnection newConnection =
|
||||
// (SqliteConnection)((ICloneable)connection).Clone();
|
||||
//newConnection.Open();
|
||||
|
||||
//cmd.Connection = newConnection;
|
||||
cmd.Connection = connection;
|
||||
cmd.Connection = m_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)
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* 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.Sqlite;
|
||||
|
||||
namespace OpenSim.Data.SQLite
|
||||
{
|
||||
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.AddWithValue(":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.AddWithValue(":PrincipalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue(":Friend", friend);
|
||||
|
||||
ExecuteNonQuery(cmd, cmd.Connection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -54,11 +54,8 @@ namespace OpenSim.Data.SQLite
|
|||
m_Realm = realm;
|
||||
if (storeName != String.Empty)
|
||||
{
|
||||
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||
Assembly assem = GetType().Assembly;
|
||||
=======
|
||||
m_Connection = new SqliteConnection(connectionString);
|
||||
Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString));
|
||||
//Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString));
|
||||
m_Connection.Open();
|
||||
|
||||
if (storeName != String.Empty)
|
||||
|
@ -74,10 +71,6 @@ namespace OpenSim.Data.SQLite
|
|||
//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);
|
||||
m.Update();
|
||||
}
|
||||
|
||||
Type t = typeof(T);
|
||||
|
@ -200,11 +193,7 @@ namespace OpenSim.Data.SQLite
|
|||
result.Add(row);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||
CloseReaderCommand(cmd);
|
||||
=======
|
||||
//CloseCommand(cmd);
|
||||
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
|
|
@ -89,17 +89,6 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
ds = new DataSet();
|
||||
|
||||
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteInventoryStore.cs
|
||||
ds.Tables.Add(createInventoryFoldersTable());
|
||||
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
||||
setupFoldersCommands(invFoldersDa, conn);
|
||||
m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
|
||||
|
||||
ds.Tables.Add(createInventoryItemsTable());
|
||||
invItemsDa.Fill(ds.Tables["inventoryitems"]);
|
||||
setupItemsCommands(invItemsDa, conn);
|
||||
m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
|
||||
=======
|
||||
ds.Tables.Add(createInventoryFoldersTable());
|
||||
invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
|
||||
setupFoldersCommands(invFoldersDa, conn);
|
||||
|
@ -111,7 +100,6 @@ namespace OpenSim.Data.SQLite
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Mono.Data.Sqlite;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Data.SQLite
|
||||
|
@ -66,7 +66,7 @@ namespace OpenSim.Data.SQLite
|
|||
connectionString = "URI=file:GridServerSqlite.db;";
|
||||
}
|
||||
|
||||
dbcon = new SQLiteConnection(connectionString);
|
||||
dbcon = new SqliteConnection(connectionString);
|
||||
|
||||
dbcon.Open();
|
||||
}
|
||||
|
@ -93,11 +93,11 @@ namespace OpenSim.Data.SQLite
|
|||
/// <returns>A SQLite DB Command</returns>
|
||||
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
|
||||
{
|
||||
SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
|
||||
SqliteCommand dbcommand = (SqliteCommand) dbcon.CreateCommand();
|
||||
dbcommand.CommandText = sql;
|
||||
foreach (KeyValuePair<string, string> param in parameters)
|
||||
{
|
||||
SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
|
||||
SqliteParameter paramx = new SqliteParameter(param.Key, param.Value);
|
||||
dbcommand.Parameters.Add(paramx);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* 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.Sqlite;
|
||||
|
||||
namespace OpenSim.Data.SQLite
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ using System.Collections.Generic;
|
|||
using System.Data;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Mono.Data.SqliteClient;
|
||||
using Mono.Data.Sqlite;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
|
|
|
@ -147,12 +147,8 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
|
||||
reader.Close();
|
||||
<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteXInventoryData.cs
|
||||
CloseReaderCommand(cmd);
|
||||
=======
|
||||
//CloseCommand(cmd);
|
||||
>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteXInventoryData.cs
|
||||
|
||||
//CloseCommand(cmd);
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,8 +234,7 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
AssetBase asset = new AssetBase(
|
||||
new UUID((String)row["UUID"]),
|
||||
(String)row["Name"],
|
||||
Convert.ToSByte(row["Type"]),
|
||||
UUID.Zero.ToString()
|
||||
Convert.ToSByte(row["Type"])
|
||||
);
|
||||
|
||||
asset.Description = (String) row["Description"];
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* 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.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Mono.Data.SqliteClient;
|
||||
|
||||
namespace OpenSim.Data.SQLiteLegacy
|
||||
{
|
||||
/// <summary>
|
||||
/// A SQLite Interface for Avatar Data
|
||||
/// </summary>
|
||||
public class SQLiteAvatarData : SQLiteGenericTableHandler<AvatarBaseData>,
|
||||
IAvatarData
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public SQLiteAvatarData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "Avatar")
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string name)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand();
|
||||
|
||||
cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
|
||||
cmd.Parameters.Add(":PrincipalID", principalID.ToString());
|
||||
cmd.Parameters.Add(":Name", name);
|
||||
|
||||
try
|
||||
{
|
||||
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseCommand(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
get { return new List<string>(m_FieldMap.Keys).ToArray(); }
|
||||
}
|
||||
|
||||
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
|
||||
public EstateSettings LoadEstateSettings(UUID regionID)
|
||||
{
|
||||
string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID";
|
||||
|
||||
|
@ -89,10 +89,10 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Add(":RegionID", regionID.ToString());
|
||||
|
||||
return DoLoad(cmd, regionID, create);
|
||||
return DoLoad(cmd, regionID);
|
||||
}
|
||||
|
||||
private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create)
|
||||
private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
es.OnSave += StoreEstateSettings;
|
||||
|
@ -125,8 +125,10 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
}
|
||||
r.Close();
|
||||
}
|
||||
else if (create)
|
||||
else
|
||||
{
|
||||
// Migration case
|
||||
//
|
||||
r.Close();
|
||||
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
@ -335,7 +337,7 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Add(":EstateID", estateID.ToString());
|
||||
|
||||
return DoLoad(cmd, UUID.Zero, false);
|
||||
return DoLoad(cmd, UUID.Zero);
|
||||
}
|
||||
|
||||
public List<int> GetEstates(string search)
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -272,16 +272,7 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
Commit();
|
||||
}
|
||||
}
|
||||
public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
|
||||
{
|
||||
//This connector doesn't support the windlight module yet
|
||||
//Return default LL windlight settings
|
||||
return new RegionLightShareData();
|
||||
}
|
||||
public void StoreRegionWindlightSettings(RegionLightShareData wl)
|
||||
{
|
||||
//This connector doesn't support the windlight module yet
|
||||
}
|
||||
|
||||
public RegionSettings LoadRegionSettings(UUID regionUUID)
|
||||
{
|
||||
lock (ds)
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue