Index: CHANGELOG.txt
===================================================================
RCS file: /projects/pgadmin3/CHANGELOG.txt,v
retrieving revision 1.115
retrieving revision 1.116
diff -LCHANGELOG.txt -LCHANGELOG.txt -u -w -r1.115 -r1.116
--- CHANGELOG.txt
+++ CHANGELOG.txt
@@ -16,6 +16,8 @@
+ - 2004-01-21 AP Update ServerStatus to pg_logdir_ls
+
- 2004-01-21 AP catch SIGPIPE
- 2004-01-20 AP owner, name, comment refactoring in dlgProperty
- 2004-01-20 AP support of function parameters
- 2004-01-20 AP tablespace changes
Index: frmStatus.h
===================================================================
RCS file: /projects/pgadmin3/src/include/frmStatus.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -Lsrc/include/frmStatus.h -Lsrc/include/frmStatus.h -u -w -r1.14 -r1.15
--- src/include/frmStatus.h
+++ src/include/frmStatus.h
@@ -56,8 +56,10 @@
void addLogFile(const wxString &filename, const wxDateTime timestamp, int pid, long len, long &read, bool skipFirst);
void addLogLine(const wxString &str, bool formatted=true);
+ void checkConnection();
frmMain *mainForm;
+ wxStatusBar *statusBar;
wxString logFormat;
bool logHasTimestamp, logFormatKnown;
int logFmtPos;
Index: frmStatus.cpp
===================================================================
RCS file: /projects/pgadmin3/src/ui/frmStatus.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -Lsrc/ui/frmStatus.cpp -Lsrc/ui/frmStatus.cpp -u -w -r1.31 -r1.32
--- src/ui/frmStatus.cpp
+++ src/ui/frmStatus.cpp
@@ -81,6 +81,8 @@
RestorePosition(-1, -1, 400, 240, 200, 150);
SetTitle(_title);
SetIcon(wxIcon(pgAdmin3_xpm));
+ statusBar = new wxStatusBar(this, -1);
+ wxXmlResource::Get()->AttachUnknownControl(wxT("unkStatusBar"), statusBar);
mainForm=form;
timer=0;
@@ -229,6 +231,11 @@
// To avoid hammering the lock manager (and the network for that matter),
// only query for the required tab.
+ wxLogNull nolog;
+
+ if (!connection)
+ return;
+
if (nbStatus->GetSelection() == 0)
{
// Status
@@ -237,6 +244,7 @@
if (dataSet1)
{
statusList->Freeze();
+ statusBar->SetStatusText(_("Refreshing."));
while (!dataSet1->Eof())
{
pid=dataSet1->GetLong(wxT("procpid"));
@@ -285,9 +293,10 @@
statusList->DeleteItem(row);
statusList->Thaw();
+ statusBar->SetStatusText(_("Done."));
}
else
- connection->IsAlive();
+ checkConnection();
row=0;
while (row < statusList->GetItemCount())
@@ -326,6 +335,7 @@
pgSet *dataSet2=connection->ExecuteSet(sql);
if (dataSet2)
{
+ statusBar->SetStatusText(_("Refreshing."));
lockList->Freeze();
while (!dataSet2->Eof())
@@ -385,9 +395,10 @@
lockList->DeleteItem(row);
lockList->Thaw();
+ statusBar->SetStatusText(_("Done."));
}
else
- connection->IsAlive();
+ checkConnection();
row=0;
while (row < lockList->GetItemCount())
@@ -401,7 +412,7 @@
}
else
{
- long newlen;
+ long newlen=0;
if (logDirectory.IsEmpty())
{
@@ -430,11 +441,22 @@
if (isCurrent)
{
// check if the current logfile changed
- newlen = StrToLong(connection->ExecuteScalar(wxT("SELECT pg_file_length(") + qtString(logfileName) + wxT(")")));
-
+ pgSet *set = connection->ExecuteSet(wxT("SELECT pg_file_length(") + qtString(logfileName) + wxT(") AS len"));
+ if (set)
+ {
+ newlen = set->GetLong(wxT("len"));
+ delete set;
+ }
+ else
+ {
+ checkConnection();
+ return;
+ }
if (newlen > logfileLength)
{
+ statusBar->SetStatusText(_("Refreshing."));
addLogFile(logfileName, logfileTimestamp, logfilePid, newlen, logfileLength, false);
+ statusBar->SetStatusText(_("Done."));
// as long as there was new data, the logfile is probably the current
// one so we don't need to check for rotation
@@ -479,17 +501,27 @@
}
+void frmStatus::checkConnection()
+{
+ if (!connection->IsAlive())
+ {
+ delete connection;
+ connection=0;
+ statusBar->SetStatusText(_("Connection broken."));
+ }
+}
+
void frmStatus::addLogFile(wxDateTime *dt, bool skipFirst)
{
pgSet *set=connection->ExecuteSet(
- wxT("SELECT ts, pid, fn, pg_file_length(fn) AS len\n")
- wxT(" FROM pg_logfiles_ls() AS (ts timestamp, pid int4, fn text)\n")
- wxT(" WHERE ts = '") + DateToAnsiStr(*dt) + wxT("'::timestamp"));
+ wxT("SELECT filetime, pid, filename, pg_file_length(filename) AS len\n")
+ wxT(" FROM pg_logdir_ls\n")
+ wxT(" WHERE filetime = '") + DateToAnsiStr(*dt) + wxT("'::timestamp"));
if (set)
{
- logfileName = set->GetVal(wxT("fn"));
- logfileTimestamp = set->GetDateTime(wxT("ts"));
+ logfileName = set->GetVal(wxT("filename"));
+ logfileTimestamp = set->GetDateTime(wxT("filetime"));
logfilePid = set->GetLong(wxT("pid"));
long len=set->GetLong(wxT("len"));
@@ -622,7 +654,6 @@
}
-
void frmStatus::emptyLogfileCombo()
{
while (cbLogfiles->GetCount())
@@ -736,6 +767,7 @@
OnRefresh(*(wxCommandEvent*)&event);
}
+
void frmStatus::OnTerminateBtn(wxCommandEvent &event)
{
ctlListView *lv;
@@ -772,6 +804,7 @@
OnRefresh(*(wxCommandEvent*)&event);
}
+
void frmStatus::OnSelStatusItem(wxListEvent &event)
{
if (connection->BackendMinimumVersion(7, 5))