Re: pgsql: Trial fix for old cross-version upgrades. - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Trial fix for old cross-version upgrades.
Date
Msg-id 2811968.1740770968@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Trial fix for old cross-version upgrades.  (Sami Imseih <samimseih@gmail.com>)
Responses Re: pgsql: Trial fix for old cross-version upgrades.
List pgsql-committers
Sami Imseih <samimseih@gmail.com> writes:
> repro'd. I don't want to attach the file here, but I added a cp
> to get the dump file somewhere local

Thanks for the tips about an efficient repro.  I installed 5.16.3
locally using perlbrew and was able to duplicate the problem.
After a bit of fooling around I found that using an explicit \n
instead of ^ fixes it.  Not the world's most idiomatic regex,
but it'll do.  Will push the attached shortly.

            regards, tom lane

diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
index ec874852d12..81a8f44aa9f 100644
--- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
+++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
@@ -296,7 +296,7 @@ sub adjust_old_dumpfile

     # Same with version argument to pg_restore_relation_stats() or
     # pg_restore_attribute_stats().
-    $dump =~ s {(^\s+'version',) '\d+'::integer,$}
+    $dump =~ s {\n(\s+'version',) '\d+'::integer,$}
         {$1 '000000'::integer,}mg;

     if ($old_version < 16)
@@ -645,7 +645,7 @@ sub adjust_new_dumpfile

     # Same with version argument to pg_restore_relation_stats() or
     # pg_restore_attribute_stats().
-    $dump =~ s {(^\s+'version',) '\d+'::integer,$}
+    $dump =~ s {\n(\s+'version',) '\d+'::integer,$}
         {$1 '000000'::integer,}mg;

     # pre-v16 dumps do not know about XMLSERIALIZE(NO INDENT).

pgsql-committers by date:

Previous
From: Sami Imseih
Date:
Subject: Re: pgsql: Trial fix for old cross-version upgrades.
Next
From: Sami Imseih
Date:
Subject: Re: pgsql: Trial fix for old cross-version upgrades.