SVN Commit by dpage: r4377 - in trunk/pgadmin3: . src/base src/frm src/include/base - Mailing list pgadmin-hackers

From svn@pgadmin.org
Subject SVN Commit by dpage: r4377 - in trunk/pgadmin3: . src/base src/frm src/include/base
Date
Msg-id 200507042041.j64KfQf5005879@developer.pgadmin.org
Whole thread Raw
List pgadmin-hackers
Author: dpage
Date: 2005-07-04 21:41:25 +0100 (Mon, 04 Jul 2005)
New Revision: 4377

Modified:
   trunk/pgadmin3/CHANGELOG.txt
   trunk/pgadmin3/src/base/pgConnBase.cpp
   trunk/pgadmin3/src/frm/frmQuery.cpp
   trunk/pgadmin3/src/include/base/pgConnBase.h
Log:
Check for and display asynchronous notifications in the query tool.

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt    2005-06-28 19:55:52 UTC (rev 4376)
+++ trunk/pgadmin3/CHANGELOG.txt    2005-07-04 20:41:25 UTC (rev 4377)
@@ -17,6 +17,7 @@
 </ul>
 <br>
 <ul>
+    <li>2005-07-04 DP        Check for and display asynchronous notifications in the query tool.
     <li>2005-06-21 AP        typo fixes, rename "initial db" to "maintenance db"
     <li>2005-06-19 AP        pgAgent moved under server, some more fixes
     <li>2005-06-19 AP        further translation issues

Modified: trunk/pgadmin3/src/base/pgConnBase.cpp
===================================================================
--- trunk/pgadmin3/src/base/pgConnBase.cpp    2005-06-28 19:55:52 UTC (rev 4376)
+++ trunk/pgadmin3/src/base/pgConnBase.cpp    2005-07-04 20:41:25 UTC (rev 4377)
@@ -288,6 +288,22 @@
 }


+pgNotification *pgConnBase::GetNotification()
+{
+    pgNotify *notify;
+
+    notify = PQnotifies(conn);
+    if (!notify)
+        return NULL;
+
+    pgNotification *ret = new pgNotification;
+    ret->name = wxString(notify->relname, *conv);
+    ret->pid = notify->be_pid;
+    ret->data = wxString(notify->extra, *conv);
+
+    return ret;
+}
+
 //////////////////////////////////////////////////////////////////////////
 // Execute SQL
 //////////////////////////////////////////////////////////////////////////

Modified: trunk/pgadmin3/src/frm/frmQuery.cpp
===================================================================
--- trunk/pgadmin3/src/frm/frmQuery.cpp    2005-06-28 19:55:52 UTC (rev 4376)
+++ trunk/pgadmin3/src/frm/frmQuery.cpp    2005-07-04 20:41:25 UTC (rev 4377)
@@ -1125,8 +1125,6 @@
                         nr.Printf(_("%ld  rows not retrieved."), rowsTotal - rowsReadTotal);
                         showMessage(wxString::Format(_("Total %ld rows.\n"), rowsTotal) + nr, nr);
                     }
-                    msgHistory->AppendText(wxT("\n"));
-
                 }
                 if (rowsTotal == rowsReadTotal)
                     SetStatusText(wxString::Format(_("%d rows."), rowsTotal), STATUSPOS_ROWS);
@@ -1135,6 +1133,40 @@
             }
         }
     }
+
+    // Display async notifications
+    pgNotification *notify;
+    int notifies = 0;
+    notify = conn->GetNotification();
+    while (notify)
+    {
+        wxString notifyStr;
+        notifies++;
+
+        if (notify->data.IsEmpty())
+            notifyStr.Printf(_("\nAsynchronous notification of '%s' received from backend pid %d"), notify->name,
notify->pid);
+        else
+            notifyStr.Printf(_("\nAsynchronous notification of '%s' received from backend pid %d\n   Data: %s"),
notify->name,notify->pid, notify->data); 
+
+        msgResult->AppendText(notifyStr);
+        msgHistory->AppendText(notifyStr);
+
+        notify = conn->GetNotification();
+    }
+
+    if (notifies)
+    {
+        wxString statusMsg = statusBar->GetStatusText(STATUSPOS_MSGS);
+        if (statusMsg.Last() == '.')
+            statusMsg = statusMsg.Left(statusMsg.Length() - 1);
+
+        SetStatusText(wxString::Format(_("%s (%d asynchronous notifications received)."), statusMsg, notifies),
STATUSPOS_MSGS);
+    }
+
+    msgResult->AppendText(wxT("\n"));
+    msgHistory->AppendText(wxT("\n"));
+
+
     setTools(false);
     if (rowsReadTotal)
     {

Modified: trunk/pgadmin3/src/include/base/pgConnBase.h
===================================================================
--- trunk/pgadmin3/src/include/base/pgConnBase.h    2005-06-28 19:55:52 UTC (rev 4376)
+++ trunk/pgadmin3/src/include/base/pgConnBase.h    2005-07-04 20:41:25 UTC (rev 4377)
@@ -44,6 +44,14 @@
     PGCONN_FATAL_ERROR = PGRES_FATAL_ERROR
 };

+
+// Our version of a pgNotify
+typedef struct pgNotification {
+    wxString name;
+    int pid;
+    wxString data;
+} pgNotification;
+
 // Class declarations
 class pgConnBase
 {
@@ -79,6 +87,7 @@
     bool IsSSLconnected();
     PGconn *connection() { return conn; }
     void Notice(const char *msg);
+    pgNotification *GetNotification();

 protected:
     PGconn *conn;


pgadmin-hackers by date:

Previous
From: blacknoz@club-internet.fr
Date:
Subject: Re: [pgadmin-support] PGAdmin3 export query to file bug
Next
From: svn@pgadmin.org
Date:
Subject: SVN Commit by dpage: r4378 - in trunk/pgadmin3/pkg/win32: . resources