On Fri, Apr 4, 2025 at 5:23 PM Álvaro Herrera <alvhe...@alvh.no-ip.org> wrote: > > On 2025-Apr-04, Ashutosh Bapat wrote: > > > connection error: 'psql: error: connection to server on socket > > "/tmp/LiPa_UJpSb/.s.PGSQL.13779" failed: FATAL: database "regression" > > does not exist' > > while running '/home/ashutosh/work/units/pghead/build/dev/bin/psql > > --no-psqlrc --no-align --tuples-only --quiet --dbname port=13779 > > host=/tmp/LiPa_UJpSb dbname='regression' --file - --variable > > ON_ERROR_STOP=1' at > > /home/ashutosh/work/units/pghead/coderoot/pg/src/test/perl/PostgreSQL/Test/Cluster.pm > > line 2256. > > # Postmaster PID for node "old_node" is 779230 > > ### Stopping node "old_node" using mode immediate > > This is saying that Cluster->psql() (line 2256) tried to connect to > database regression and failed unexpectedly. Is your "olddump" file > created with pg_dumpall from a cluster that contains such a database? > If not, then the test isn't broken, you're just not operating it > correctly :-)
My bad, didn't pay attention to that error (even while pasting it) :(. You are right. I used pg_dump (without --create) to create olddump. The comment about olddump just mentions dump output. I think we should mention pg_dumpall there. > > Maybe the failure could be clearer: rather than blindly trying to > connect to regression, first see if it exists, and die with a hard > failure ("your old dump must contain database regression") if not. > Alternatively, if the regression database doesn't exist, just skip that > part. Right. Something like attached? -- Best Wishes, Ashutosh Bapat
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl index 311391d7acd..18073a0fefe 100644 --- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl +++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl @@ -105,8 +105,8 @@ sub get_dump_for_comparison # Testing upgrades with an older version of PostgreSQL requires setting up # two environment variables, as of: -# - "olddump", to point to a dump file that will be used to set up the old -# instance to upgrade from. +# - "olddump", to point to a dump file, usually output of pg_dumpall, that will +# be used to set up the old instance to upgrade from. # - "oldinstall", to point to the installation path of the old cluster. if ( (defined($ENV{olddump}) && !defined($ENV{oldinstall})) || (!defined($ENV{olddump}) && defined($ENV{oldinstall}))) @@ -247,6 +247,10 @@ if (defined($ENV{olddump})) $oldnode->command_ok( [ 'psql', '--no-psqlrc', '--file' => $olddumpfile, 'postgres' ], 'loaded old dump file'); + + $result = $oldnode->safe_psql('postgres', + "SELECT count(*) FROM pg_database WHERE datname='regression'"); + die "old dump must contain database regression" unless $result == 1; } else {