Package: postgresql-client-common
Version: 246

Hi,
I am currently using the following postgresql-client package set:
$ dpkg -l|grep postgresql
ii  postgresql-client                     15+246                            all 
         front-end programs for PostgreSQL (supported version)
ii  postgresql-client-11                  11.16-0+deb10u1                   
amd64        front-end programs for PostgreSQL 11
ii  postgresql-client-12                  12.4-1                            
amd64        front-end programs for PostgreSQL 12
ii  postgresql-client-13                  13.9-0+deb11u1                    
amd64        front-end programs for PostgreSQL 13
ii  postgresql-client-14                  14.2-1+b3                         
amd64        front-end programs for PostgreSQL 14
ri  postgresql-client-15                  15.1-1+b1                         
amd64        front-end programs for PostgreSQL 15
ii  postgresql-client-common              246                               all 
         manager for multiple PostgreSQL client versions

When I connect with pg_dump to a <9.2 server version it cannot fallback
to a proper (older) pg_dump version and it is trying to run the newest
from the system, which is 15.

This is resulting with the following mismatch:

pg_dump: error: aborting because of server version mismatch
pg_dump: detail: server version: 9.1.24; pg_dump version: 15.1 (Debian 
15.1-1+b1)

My quick and dirty fix was adding the pg_dump to the list of $cmdname.
But this was not sufficient because the $version was set to 15, so I had
to additionaly comment out the `if` statement (forcing the max_version).

--- /usr/share/postgresql-common/pg_wrapper.old 2023-01-25 11:54:36.119793367 
+0100
+++ /usr/share/postgresql-common/pg_wrapper     2023-01-25 11:52:37.810434143 
+0100
@@ -127,11 +127,11 @@
 
 # if we have no version yet, use the latest version. If we were called as psql,
 # pg_archivecleanup, or pg_isready, always use latest version
-if (not $version or $cmdname =~ /^(psql|pg_archivecleanup|pg_isready)$/) {
+if (not $version or $cmdname =~ 
/^(psql|pg_dump|pg_archivecleanup|pg_isready)$/) {
     my $max_version;
-    if ($version and $version < 9.2) { # psql 15 only supports PG 9.2+
+    #if ($version and $version < 9.2) { # psql 15 only supports PG 9.2+
         $max_version = 14;
-    }
+    #}

     $version = get_newest_version($cmdname, $max_version);
 }

Then it works properly, selecting:
$ pg_dump -V
pg_dump (PostgreSQL) 14.2 (Debian 14.2-1+b3)

and no more server mismatch

Is it possible to fix this problem, so we have automatic fallback in this
scenario?

-- 
regards,
Mariusz Białończyk
https://skyboo.net | https://github.com/manio

Reply via email to