Re: pgsql: libpq: Grease the protocol by default - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pgsql: libpq: Grease the protocol by default
Date
Msg-id 3864574.1771898936@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: libpq: Grease the protocol by default  (Jacob Champion <jacob.champion@enterprisedb.com>)
Responses Re: pgsql: libpq: Grease the protocol by default
Re: pgsql: libpq: Grease the protocol by default
List pgsql-hackers
Jacob Champion <jacob.champion@enterprisedb.com> writes:
> On Mon, Feb 23, 2026 at 4:45 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Also: I was initially baffled why you thought this needs
>> back-patching, but I guess you have one eye on packagers like
>> Debian who think they can make older versions use newer libpq.so.

> Right.

Actually, that is going to be harder than you thought, because libpq
before v18 will spit up on connection option "max_protocol_version".
This patch will not work as-is for back-patching unless we care to
also back-patch the addition of that option, which I'd be inclined
to resist.

Fortunately, we long ago had the foresight to invent PQlibVersion,
so you could make addition of the extra option conditional on
PQlibVersion(conn) >= 180000 in branches before 18.

> Hmmm, looks like the -dump1.log output is actually from *before*
> pg_upgrade actually runs:

Yeah, I came to the same conclusion.  I got a clean BF run using
your patch together with the attached patch for the BF client.
(In this patch, I did not worry about scenarios involving old
minor releases.  If Andrew is excited about that case he can
extend the version-comparison logic.)

            regards, tom lane

--- PGBuild/Modules/TestUpgradeXversion.pm~    2025-11-25 07:47:25.000000000 -0500
+++ PGBuild/Modules/TestUpgradeXversion.pm    2026-02-23 20:57:31.640149574 -0500
@@ -483,9 +483,17 @@ sub test_upgrade    ## no critic (Subrou
         $dump_opts .= ' --extra-float-digits=0';
     }

+    # with very old servers we must restrict the protocol version.
+    my $maxpversion = "";
+    if (   ($this_branch eq 'HEAD' || $this_branch gt 'REL_18_STABLE')
+        && ($oversion ne 'HEAD' && $oversion le 'REL_9_2_STABLE'))
+    {
+        $maxpversion = '-d max_protocol_version=3.0';
+    }
+
     # use the NEW pg_dumpall so we're comparing apples with apples.
     setinstenv($self, "$installdir", $save_env);
-    system( qq{"$installdir/bin/pg_dumpall" $dump_opts -p $sport -f }
+    system( qq{"$installdir/bin/pg_dumpall" $dump_opts $maxpversion -p $sport -f }
           . qq{"$upgrade_loc/origin-$oversion.sql" }
           . qq{> "$upgrade_loc/$oversion-dump1.log" 2>&1});
     return if $?;

pgsql-hackers by date:

Previous
From: Nitin Motiani
Date:
Subject: Re: [PATCH] Support reading large objects with pg_read_all_data
Next
From: David Rowley
Date:
Subject: Re: More speedups for tuple deformation