Hi,

pgadmin3 is old and dead upstream, but it's still better than the
monster pgadmin4 became. So lets give it support for psql 10 & 11,
tested by connecting to 10.5 on debian stable. Patch taken from debian.

Landry
Index: Makefile
===================================================================
RCS file: /cvs/ports/databases/pgadmin3/Makefile,v
retrieving revision 1.38
diff -u -r1.38 Makefile
--- Makefile    16 Apr 2018 15:07:09 -0000      1.38
+++ Makefile    24 Oct 2018 09:15:31 -0000
@@ -5,7 +5,7 @@
 V=             1.22.1
 DISTNAME=      pgadmin3-$V
 CATEGORIES=    databases devel
-REVISION=      0
+REVISION=      1
 
 HOMEPAGE=      http://www.pgadmin.org/
 
Index: patches/patch-pgadmin_frm_events_cpp.orig
===================================================================
RCS file: patches/patch-pgadmin_frm_events_cpp.orig
diff -N patches/patch-pgadmin_frm_events_cpp.orig
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pgadmin_frm_events_cpp.orig   24 Oct 2018 09:15:31 -0000
@@ -0,0 +1,52 @@
+$OpenBSD: patch-pgadmin_frm_events_cpp,v 1.1 2014/10/24 15:01:18 dcoppa Exp $
+--- pgadmin/frm/events.cpp.orig        Fri Sep 27 16:51:46 2013
++++ pgadmin/frm/events.cpp     Thu Oct 23 12:46:41 2014
+@@ -41,7 +41,7 @@
+ 
+ // Mutex to protect the "currentObject" from race conditions.
+ //
+-static wxMutex s_currentObjectMutex;
++static wxMutex *currentObjectMutex = new wxMutex( wxMUTEX_RECURSIVE );
+ 
+ // Event table
+ BEGIN_EVENT_TABLE(frmMain, pgFrame)
+@@ -418,9 +418,9 @@ void frmMain::execSelChange(wxTreeItemId item, bool cu
+       //
+       // Lock the assignment to prevent the race conditions between 
onSelRightClick and execSelChange.
+       //
+-              s_currentObjectMutex.Lock();
+-              currentObject = browser->GetObject(item);
+-              s_currentObjectMutex.Unlock();
++      currentObjectMutex->Lock();
++      currentObject = browser->GetObject(item);
++      currentObjectMutex->Unlock();
+ 
+       // If we didn't get an object, then we may have a right click, or
+       // invalid click, so ignore.
+@@ -735,6 +735,7 @@ void frmMain::OnContextMenu(wxCommandEvent &event)
+ void frmMain::OnSelRightClick(wxTreeEvent &event)
+ {
+       wxTreeItemId item = event.GetItem();
++
+       if (item != browser->GetSelection())
+       {
+               browser->SelectItem(item);
+@@ -742,13 +743,16 @@ void frmMain::OnSelRightClick(wxTreeEvent &event)
+               // Prevent changes to "currentObject" by "execSelchange" 
function by another thread.
+               // Will hold the lock until we do popup on the respective 
object.
+               //
+-              s_currentObjectMutex.Lock();
++              currentObjectMutex->Lock();
+               currentObject = browser->GetObject(item);
+       }
++      else
++              currentObjectMutex->Lock();
+ 
+       if (currentObject)
+               doPopup(browser, event.GetPoint(), currentObject);
+-      s_currentObjectMutex.Unlock();
++
++      currentObjectMutex->Unlock();
+ }
+ 
+ 
Index: patches/patch-pgadmin_include_pgAdmin3_h
===================================================================
RCS file: patches/patch-pgadmin_include_pgAdmin3_h
diff -N patches/patch-pgadmin_include_pgAdmin3_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pgadmin_include_pgAdmin3_h    24 Oct 2018 09:15:31 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+adapted from 
https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=878295;filename=postgresql_10.x_support.patch;msg=3
+
+Index: pgadmin/include/pgAdmin3.h
+--- pgadmin/include/pgAdmin3.h.orig
++++ pgadmin/include/pgAdmin3.h
+@@ -58,8 +58,8 @@
+ // Supported server minimum and maximum values.
+ const short SERVER_MIN_VERSION_N = 0x0804;
+ const wxString SERVER_MIN_VERSION_T = wxT("8.4");
+-const short SERVER_MAX_VERSION_N = 0x0905;
+-const wxString SERVER_MAX_VERSION_T = wxT("9.5");
++const short SERVER_MAX_VERSION_N = 0x0B00;
++const wxString SERVER_MAX_VERSION_T = wxT("11.0");
+ 
+ // Supported Greenplum Database and Greenplum HAWQ minimum and maximum values.
+ const short GP_MIN_VERSION_N = 0x0802;
Index: patches/patch-pgadmin_schema_pgServer_cpp
===================================================================
RCS file: patches/patch-pgadmin_schema_pgServer_cpp
diff -N patches/patch-pgadmin_schema_pgServer_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pgadmin_schema_pgServer_cpp   24 Oct 2018 09:15:31 -0000
@@ -0,0 +1,61 @@
+$OpenBSD$
+
+adapted from 
https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=878295;filename=postgresql_10.x_support.patch;msg=3
+
+Index: pgadmin/schema/pgServer.cpp
+--- pgadmin/schema/pgServer.cpp.orig
++++ pgadmin/schema/pgServer.cpp
+@@ -905,13 +905,24 @@ int pgServer::Connect(frmMain *form, bool askPassword,
+               if (conn->BackendMinimumVersion(8, 5))
+               {
+                       sql += wxT(", CASE WHEN usesuper THEN 
pg_is_in_recovery() ELSE NULL END as inrecovery");
+-                      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(10, 0))
++                      {
++                              sql += wxT(", CASE WHEN usesuper THEN 
pg_last_wal_receive_lsn() ELSE NULL END as receiveloc");
++                              sql += wxT(", CASE WHEN usesuper THEN 
pg_last_wal_replay_lsn() ELSE NULL END as replayloc");
++                      }
++                      else
++                      {
++                              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");
+-                      sql += wxT(", CASE WHEN usesuper AND 
pg_is_in_recovery() THEN pg_is_xlog_replay_paused() ELSE NULL END as 
isreplaypaused");
++                      if (conn->BackendMinimumVersion(10, 0))
++                              sql += wxT(", CASE WHEN usesuper AND 
pg_is_in_recovery() THEN pg_is_wal_replay_paused() ELSE NULL END as 
isreplaypaused");
++                      else
++                              sql += wxT(", CASE WHEN usesuper AND 
pg_is_in_recovery() THEN pg_is_xlog_replay_paused() ELSE NULL END as 
isreplaypaused");
+               }
+ 
+               pgSet *set = ExecuteSet(sql + wxT("\n  FROM pg_user WHERE 
usename=current_user"));
+@@ -1434,7 +1445,11 @@ bool pgServer::ReloadConfiguration()
+ bool pgServer::PauseReplay()
+ {
+       SetReplayPaused(true);
+-      wxString sql = wxT("SELECT pg_xlog_replay_pause()");
++      wxString sql;
++      if (conn->BackendMinimumVersion(10, 0))
++              sql = wxT("SELECT pg_wal_replay_pause()");
++      else
++              sql = wxT("SELECT pg_xlog_replay_pause()");
+       return conn->ExecuteVoid(sql);
+ }
+ 
+@@ -1442,7 +1457,11 @@ bool pgServer::PauseReplay()
+ bool pgServer::ResumeReplay()
+ {
+       SetReplayPaused(false);
+-      wxString sql = wxT("SELECT pg_xlog_replay_resume()");
++      wxString sql;
++      if (conn->BackendMinimumVersion(10, 0))
++              sql = wxT("SELECT pg_wal_replay_resume()");
++      else
++              sql = wxT("SELECT pg_xlog_replay_resume()");
+       return conn->ExecuteVoid(sql);
+ }
+ 

Reply via email to