# Copyright (c) 2021-2025, PostgreSQL Global Development Group
use strict;
use warnings FATAL => 'all';
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
if ($PostgreSQL::Test::Utils::is_msys2)
{
plan skip_all => 'High bit name tests fail on Msys2';
}
# We're going to use byte sequences that aren't valid UTF-8 strings. Use # LATIN1, which accepts any byte and has a conversion from each byte to UTF-8.
$ENV{LC_ALL} = 'C';
$ENV{PGCLIENTENCODING} = 'LATIN1';
# Create database and user names covering the range of LATIN1 # characters, for use in a connection string by pg_dumpall. Skip ',' # because of pg_regress --create-role, skip [\n\r] because pg_dumpall # does not allow them. We also skip many ASCII letters, to keep the # total number of tested characters to what will fit in four names. # The odds of finding something interesting by testing all ASCII letters # seem too small to justify the cycles of testing a fifth name.
my $dbname1 = 'regression'
. generate_ascii_string(1, 9)
. generate_ascii_string(11, 12)
. generate_ascii_string(14, 33)
. (
$PostgreSQL::Test::Utils::windows_os
? ''
: '"x"') # IPC::Run mishandles '"' on Windows
. generate_ascii_string(35, 43) # skip ','
. generate_ascii_string(45, 54);
my $dbname2 = 'regression' . generate_ascii_string(55, 65) # skip 'B'-'W'
. generate_ascii_string(88, 99) # skip 'd'-'w'
. generate_ascii_string(120, 149);
my $dbname3 = 'regression' . generate_ascii_string(150, 202);
my $dbname4 = 'regression' . generate_ascii_string(203, 255);
# not sufficient to use --roles-only here
$node->command_fails(
[ 'pg_dumpall', '--no-sync', '--username' => $src_bootstrap_super, '--file' => $discard,
], 'pg_dumpall with \n\r in database name');
$node->run_log(
[ 'dropdb', '--username' => $src_bootstrap_super, "foo\n\rbar" ]);
# make a table, so the parallel worker has something to dump
$node->safe_psql(
$dbname1, 'CREATE TABLE t0()',
extra_params => [ '--username' => $src_bootstrap_super ]);
# XXX no printed message when this fails, just SIGPIPE termination
$node->command_ok(
[ 'pg_dump', '--format' => 'directory', '--no-sync', '--jobs' => 2, '--file' => $dirfmt, '--username' => $username1,
$node->connstr($dbname1),
], 'parallel dump');
# make superuser for restore
$envar_node->run_log(
[ 'createuser', '--username' => $dst_bootstrap_super, '--superuser', $restore_super,
]);
{
local $ENV{PGPORT} = $envar_node->port;
local $ENV{PGUSER} = $restore_super;
$result = run_log([ 'psql', '--no-psqlrc', '--file' => $plain ], '2>' => \$stderr);
}
ok($result, 'restore full dump using environment variables for connection parameters'
);
is($stderr, '', 'no dump errors');
# Restore full dump through psql using command-line options for # dbname/user connection parameters. "\connect dbname=" forgets # user/port from command line.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.