diff options
author | Geir Nøklebye | 2015-07-25 20:35:25 +0200 |
---|---|---|
committer | Oren Hurvitz | 2015-07-26 11:59:15 +0100 |
commit | a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e (patch) | |
tree | e1db8a02d0c706535af733ccd75d9f4fd1c56230 /OpenSim/Data | |
parent | Add LogFile option in OpenSimDefaults.ini. It was omitted accidentally (diff) | |
download | opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.zip opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.tar.gz opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.tar.bz2 opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.tar.xz |
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>
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--] | OpenSim/Data/PGSQL/PGSQLGroupsData.cs | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | OpenSim/Data/PGSQL/PGSQLPresenceData.cs | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | OpenSim/Data/PGSQL/Resources/Presence.migrations | 8 |
3 files changed, 26 insertions, 17 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs index 669e3c8..e257e7c 100644..100755 --- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs | |||
@@ -31,12 +31,13 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using log4net; | ||
34 | using Npgsql; | 35 | using Npgsql; |
35 | 36 | ||
36 | namespace OpenSim.Data.PGSQL | 37 | namespace OpenSim.Data.PGSQL |
37 | { | 38 | { |
38 | public class PGSQLGroupsData : IGroupsData | 39 | public class PGSQLGroupsData : IGroupsData |
39 | { | 40 | { |
40 | private PGSqlGroupsGroupsHandler m_Groups; | 41 | private PGSqlGroupsGroupsHandler m_Groups; |
41 | private PGSqlGroupsMembershipHandler m_Membership; | 42 | private PGSqlGroupsMembershipHandler m_Membership; |
42 | private PGSqlGroupsRolesHandler m_Roles; | 43 | private PGSqlGroupsRolesHandler m_Roles; |
@@ -82,14 +83,17 @@ namespace OpenSim.Data.PGSQL | |||
82 | 83 | ||
83 | public GroupData[] RetrieveGroups(string pattern) | 84 | public GroupData[] RetrieveGroups(string pattern) |
84 | { | 85 | { |
86 | |||
85 | if (string.IsNullOrEmpty(pattern)) // True for where clause | 87 | if (string.IsNullOrEmpty(pattern)) // True for where clause |
86 | { | 88 | { |
87 | pattern = " true ORDER BY lower(\"Name\") LIMIT 100"; | 89 | pattern = " 1 ORDER BY lower(\"Name\") LIMIT 100"; |
90 | |||
88 | return m_Groups.Get(pattern); | 91 | return m_Groups.Get(pattern); |
89 | } | 92 | } |
90 | else | 93 | else |
91 | { | 94 | { |
92 | pattern = " lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100"; | 95 | pattern = " \"ShowInList\" = 1 AND lower(\"Name\") LIKE lower('%" + pattern + "%') ORDER BY lower(\"Name\") LIMIT 100"; |
96 | |||
93 | return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); | 97 | return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); |
94 | } | 98 | } |
95 | } | 99 | } |
@@ -428,13 +432,11 @@ namespace OpenSim.Data.PGSQL | |||
428 | 432 | ||
429 | public void DeleteOld() | 433 | public void DeleteOld() |
430 | { | 434 | { |
431 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
432 | 435 | ||
433 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | 436 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
434 | { | 437 | { |
435 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm); | 438 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); |
436 | cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | 439 | |
437 | |||
438 | ExecuteNonQuery(cmd); | 440 | ExecuteNonQuery(cmd); |
439 | } | 441 | } |
440 | 442 | ||
@@ -456,13 +458,11 @@ namespace OpenSim.Data.PGSQL | |||
456 | 458 | ||
457 | public void DeleteOld() | 459 | public void DeleteOld() |
458 | { | 460 | { |
459 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
460 | 461 | ||
461 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | 462 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
462 | { | 463 | { |
463 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm); | 464 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); |
464 | cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | 465 | |
465 | |||
466 | ExecuteNonQuery(cmd); | 466 | ExecuteNonQuery(cmd); |
467 | } | 467 | } |
468 | 468 | ||
diff --git a/OpenSim/Data/PGSQL/PGSQLPresenceData.cs b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs index 666de07..0376585 100644..100755 --- a/OpenSim/Data/PGSQL/PGSQLPresenceData.cs +++ b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Data.PGSQL | |||
66 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | 66 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
67 | { | 67 | { |
68 | 68 | ||
69 | cmd.CommandText = String.Format(@"DELETE FROM {0} WHERE ""RegionID""=:RegionID", m_Realm); | 69 | cmd.CommandText = String.Format("DELETE FROM {0} WHERE \"RegionID\" = :regionID", m_Realm); |
70 | 70 | ||
71 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); | 71 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); |
72 | cmd.Connection = conn; | 72 | cmd.Connection = conn; |
@@ -80,14 +80,15 @@ namespace OpenSim.Data.PGSQL | |||
80 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); | 80 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); |
81 | if (pd.Length == 0) | 81 | if (pd.Length == 0) |
82 | return false; | 82 | return false; |
83 | |||
84 | if (regionID == UUID.Zero) | ||
85 | return false; | ||
83 | 86 | ||
84 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) | 87 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
85 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | 88 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
86 | { | 89 | { |
87 | 90 | ||
88 | cmd.CommandText = String.Format(@"UPDATE {0} SET | 91 | cmd.CommandText = String.Format("UPDATE {0} SET \"RegionID\" = :regionID, \"LastSeen\" = now() WHERE \"SessionID\" = :sessionID", m_Realm); |
89 | ""RegionID"" = :RegionID | ||
90 | WHERE ""SessionID"" = :SessionID", m_Realm); | ||
91 | 92 | ||
92 | cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID)); | 93 | cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID)); |
93 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); | 94 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); |
diff --git a/OpenSim/Data/PGSQL/Resources/Presence.migrations b/OpenSim/Data/PGSQL/Resources/Presence.migrations index 684faa2..482beef 100644..100755 --- a/OpenSim/Data/PGSQL/Resources/Presence.migrations +++ b/OpenSim/Data/PGSQL/Resources/Presence.migrations | |||
@@ -28,3 +28,11 @@ BEGIN TRANSACTION; | |||
28 | ALTER TABLE Presence ADD "LastSeen" Timestamp; | 28 | ALTER TABLE Presence ADD "LastSeen" Timestamp; |
29 | 29 | ||
30 | COMMIT; | 30 | COMMIT; |
31 | |||
32 | :VERSION 3 # -------------------------- | ||
33 | |||
34 | BEGIN; | ||
35 | |||
36 | CREATE INDEX RegionID ON Presence("RegionID"); | ||
37 | |||
38 | COMMIT; | ||