233054
The (pretty old) RHEL7 jdbc connector might well be run against newer
233054
PostgreSQL servers; newer than the system-default PostgreSQL 9.2,
233054
especially if we consider that we are asynchronously adding new servers
233054
into RHSCL channel.
233054
233054
During the lifetime of postgresql-jdbc package, PostgreSQL upstream bumped
233054
major version from 9.6 to 10 (together with changing of the versioning
233054
scheme), which caused troubles with the implemented server-version
233054
comparator in pgjdbc; that code did not count with two-digit numbers in
233054
version string.  This patch fixes the problem downstream-only way, since
233054
backporting related upstream fixes would lead to much larger patch and
233054
risks that something goes wrong.  We still fallback to the old comparison
233054
method when we are not sure about the comparison (that is when isNewerOrEqual
233054
throws some exception).
233054
233054
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Connection.java b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
233054
index 2fb37f4..d889247 100644
233054
--- a/org/postgresql/jdbc2/AbstractJdbc2Connection.java
233054
+++ b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
233054
@@ -1061,14 +1061,39 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
233054
         }
233054
     }
233054
 
233054
+    private static boolean
233054
+        isNewerOrEqual(String v1, String v2)
233054
+    {
233054
+        Iterator<String> i1 = Arrays.asList(v1.split("\\.")).iterator();
233054
+        Iterator<String> i2 = Arrays.asList(v2.split("\\.")).iterator();
233054
+
233054
+        while (true) {
233054
+            if (!i1.hasNext())
233054
+                return true;
233054
+            if (!i2.hasNext())
233054
+                return false;
233054
+
233054
+            int left = Integer.parseInt(i1.next());
233054
+            int right = Integer.parseInt(i2.next());
233054
+
233054
+            if (right == left)
233054
+                continue;
233054
+
233054
+            return right >= left;
233054
+        }
233054
+    }
233054
+
233054
     /**
233054
      * Is the server we are connected to running at least this version?
233054
-     * This comparison method will fail whenever a major or minor version
233054
-     * goes to two digits (10.3.0) or (7.10.1).
233054
      */
233054
     public boolean haveMinimumServerVersion(String ver)
233054
     {
233054
-        return (dbVersionNumber.compareTo(ver) >= 0);
233054
+        try {
233054
+            return isNewerOrEqual(ver, dbVersionNumber);
233054
+        }
233054
+        catch (Exception e) {
233054
+            return (dbVersionNumber.compareTo(ver) >= 0);
233054
+        }
233054
     }
233054
 
233054
     /*