2 # Copyright (c) 2021-2025, PostgreSQL Global Development Group
5 use warnings FATAL
=> 'all';
7 use PostgreSQL
::Test
::Cluster
;
8 use PostgreSQL
::Test
::Utils
;
11 # Tests to check connection string handling in utilities
13 # We're going to use byte sequences that aren't valid UTF-8 strings. Use
14 # LATIN1, which accepts any byte and has a conversion from each byte to UTF-8.
16 $ENV{PGCLIENTENCODING
} = 'LATIN1';
18 # Create database names covering the range of LATIN1 characters and
19 # run the utilities' --all options over them.
20 my $dbname1 = generate_ascii_string
(1, 63); # contains '='
22 generate_ascii_string
(67, 129); # skip 64-66 to keep length to 62
23 my $dbname3 = generate_ascii_string
(130, 192);
24 my $dbname4 = generate_ascii_string
(193, 255);
26 my $node = PostgreSQL
::Test
::Cluster
->new('main');
27 $node->init(extra
=> [ '--locale=C', '--encoding=LATIN1' ]);
30 foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase')
32 $node->run_log([ 'createdb', $dbname ]);
36 [qw(vacuumdb --all --echo --analyze-only)],
37 'vacuumdb --all with unusual database names');
38 $node->command_ok([qw(reindexdb --all --echo)],
39 'reindexdb --all with unusual database names');
41 [qw(clusterdb --all --echo --verbose)],
42 'clusterdb --all with unusual database names');