| 1 |
|
| 2 |
# Copyright (c) 2021-2025, PostgreSQL Global Development Group |
| 3 |
|
| 4 |
use strict; |
| 5 |
use warnings FATAL => 'all'; |
| 6 |
|
| 7 |
use PostgreSQL::Test::Cluster; |
| 8 |
use PostgreSQL::Test::Utils; |
| 9 |
use Test::More; |
| 10 |
|
| 11 |
# Tests to check connection string handling in utilities |
| 12 |
|
| 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. |
| 15 |
$ENV{LC_ALL} = 'C'; |
| 16 |
$ENV{PGCLIENTENCODING} = 'LATIN1'; |
| 17 |
|
| 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 '=' |
| 21 |
my $dbname2 = |
| 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); |
| 25 |
|
| 26 |
my $node = PostgreSQL::Test::Cluster->new('main'); |
| 27 |
$node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]); |
| 28 |
$node->start; |
| 29 |
|
| 30 |
foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase') |
| 31 |
{ |
| 32 |
$node->run_log([ 'createdb', $dbname ]); |
| 33 |
} |
| 34 |
|
| 35 |
$node->command_ok( |
| 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'); |
| 40 |
$node->command_ok( |
| 41 |
[qw(clusterdb --all --echo --verbose)], |
| 42 |
'clusterdb --all with unusual database names'); |
| 43 |
|
| 44 |
done_testing(); |