Update PGSQL groups handler to accept search queries from the viewer
Update PGSQL groups handler to accept search queries from the viewer. Fixed malformed query strings. Signed-off-by: Oren Hurvitz <orenh@kitely.com>0.8.2-post-fixes
parent
965f94e30f
commit
a7fccbcf6f
|
@ -31,6 +31,7 @@ using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using log4net;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
|
|
||||||
namespace OpenSim.Data.PGSQL
|
namespace OpenSim.Data.PGSQL
|
||||||
|
@ -82,14 +83,17 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
public GroupData[] RetrieveGroups(string pattern)
|
public GroupData[] RetrieveGroups(string pattern)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(pattern)) // True for where clause
|
if (string.IsNullOrEmpty(pattern)) // True for where clause
|
||||||
{
|
{
|
||||||
pattern = " true ORDER BY lower(\"Name\") LIMIT 100";
|
pattern = " 1 ORDER BY lower(\"Name\") LIMIT 100";
|
||||||
|
|
||||||
return m_Groups.Get(pattern);
|
return m_Groups.Get(pattern);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pattern = " lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100";
|
pattern = " \"ShowInList\" = 1 AND lower(\"Name\") LIKE lower('%" + pattern + "%') ORDER BY lower(\"Name\") LIMIT 100";
|
||||||
|
|
||||||
return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern));
|
return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,12 +432,10 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
public void DeleteOld()
|
public void DeleteOld()
|
||||||
{
|
{
|
||||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm);
|
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm);
|
||||||
cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
}
|
}
|
||||||
|
@ -456,12 +458,10 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
public void DeleteOld()
|
public void DeleteOld()
|
||||||
{
|
{
|
||||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm);
|
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm);
|
||||||
cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||||
{
|
{
|
||||||
|
|
||||||
cmd.CommandText = String.Format(@"DELETE FROM {0} WHERE ""RegionID""=:RegionID", m_Realm);
|
cmd.CommandText = String.Format("DELETE FROM {0} WHERE \"RegionID\" = :regionID", m_Realm);
|
||||||
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
||||||
cmd.Connection = conn;
|
cmd.Connection = conn;
|
||||||
|
@ -81,13 +81,14 @@ namespace OpenSim.Data.PGSQL
|
||||||
if (pd.Length == 0)
|
if (pd.Length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (regionID == UUID.Zero)
|
||||||
|
return false;
|
||||||
|
|
||||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||||
{
|
{
|
||||||
|
|
||||||
cmd.CommandText = String.Format(@"UPDATE {0} SET
|
cmd.CommandText = String.Format("UPDATE {0} SET \"RegionID\" = :regionID, \"LastSeen\" = now() WHERE \"SessionID\" = :sessionID", m_Realm);
|
||||||
""RegionID"" = :RegionID
|
|
||||||
WHERE ""SessionID"" = :SessionID", m_Realm);
|
|
||||||
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID));
|
cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID));
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
||||||
|
|
|
@ -28,3 +28,11 @@ BEGIN TRANSACTION;
|
||||||
ALTER TABLE Presence ADD "LastSeen" Timestamp;
|
ALTER TABLE Presence ADD "LastSeen" Timestamp;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
:VERSION 3 # --------------------------
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE INDEX RegionID ON Presence("RegionID");
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
Loading…
Reference in New Issue