Hi,

This patch uses the function pg_last_xact_replay_timestamp() available
since PostgreSQL 9.1. It displays the timestamp in the server properties
tab.

Comments?


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com
>From cf699a52562b9f963fab20111052247184fd00e9 Mon Sep 17 00:00:00 2001
From: Guillaume Lelarge <[email protected]>
Date: Mon, 29 Nov 2010 22:18:01 +0100
Subject: [PATCH] Add timestamp of last xact replay in server props

Shows this new information on 9.1 slave servers only. The only issue is that
there's no refresh of the information. The user needs to disconnect/reconnect
to have the new value (but just like any other server properties).

Implements #280.
---
 pgadmin/include/schema/pgServer.h |    4 +++-
 pgadmin/schema/pgServer.cpp       |   12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/pgadmin/include/schema/pgServer.h b/pgadmin/include/schema/pgServer.h
index 1ac5793..3a646a8 100644
--- a/pgadmin/include/schema/pgServer.h
+++ b/pgadmin/include/schema/pgServer.h
@@ -92,6 +92,8 @@ public:
     void iSetReceiveLoc(const wxString& s) { receiveLoc=s; }
     wxString GetReplayLoc() const { return replayLoc; }
     void iSetReplayLoc(const wxString& s) { replayLoc=s; }
+    wxString GetReplayTimestamp() const { return replayTimestamp; }
+    void iSetReplayTimestamp(const wxString& s) { replayTimestamp=s; }
 
     pgConn *CreateConn(wxString dbName=wxEmptyString, OID oid=0, wxString applicationname=wxEmptyString);
 
@@ -172,7 +174,7 @@ private:
 	wxString group;
 
     bool inRecovery;
-    wxString receiveLoc, replayLoc;
+    wxString receiveLoc, replayLoc, replayTimestamp;
     wxDateTime confLoadedSince;
 
 #ifdef WIN32
diff --git a/pgadmin/schema/pgServer.cpp b/pgadmin/schema/pgServer.cpp
index 279ce84..cc3e3ad 100644
--- a/pgadmin/schema/pgServer.cpp
+++ b/pgadmin/schema/pgServer.cpp
@@ -724,6 +724,10 @@ int pgServer::Connect(frmMain *form, bool askPassword, const wxString &pwd, bool
             sql += wxT(", CASE WHEN usesuper THEN pg_last_xlog_receive_location() ELSE NULL END as receiveloc");
             sql += wxT(", CASE WHEN usesuper THEN pg_last_xlog_replay_location() ELSE NULL END as replayloc");
         }
+        if (conn->BackendMinimumVersion(9, 1))
+        {
+            sql += wxT(", CASE WHEN usesuper THEN pg_last_xact_replay_timestamp() ELSE NULL END as replay_timestamp");
+        }
 
         pgSet *set=ExecuteSet(sql + wxT("\n  FROM pg_user WHERE usename=current_user"));
         if (set)
@@ -740,6 +744,10 @@ int pgServer::Connect(frmMain *form, bool askPassword, const wxString &pwd, bool
                 iSetReplayLoc(set->GetVal(wxT("replayloc")));
                 iSetReceiveLoc(set->GetVal(wxT("receiveloc")));
             }
+            if (conn->BackendMinimumVersion(9, 1))
+            {
+                iSetReplayTimestamp(set->GetVal(wxT("replay_timestamp")));
+            }
             delete set;
         }
 
@@ -1029,6 +1037,10 @@ void pgServer::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *prop
                 properties->AppendItem(_("Last XLOG receive location"), GetReceiveLoc());
                 properties->AppendItem(_("Last XLOG replay location"), GetReplayLoc());
             }
+            if (conn->BackendMinimumVersion(9,1))
+            {
+                properties->AppendItem(_("Last XACT replay timestamp"), GetReplayTimestamp());
+            }
         }
         if (GetServerControllable())
             properties->AppendItem(_("Running?"), GetServerRunning());
-- 
1.7.1

-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to