Update copyright for 2022
[pgsql.git] / src / bin / scripts / t / 200_connstr.pl
blob6d75af1d6cb07578d981ef4e1253a7d7f4661cde
2 # Copyright (c) 2021-2022, PostgreSQL Global Development Group
4 use strict;
5 use warnings;
7 use PostgreSQL::Test::Cluster;
8 use PostgreSQL::Test::Utils;
9 use Test::More tests => 3;
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.
15 $ENV{LC_ALL} = 'C';
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 '='
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);
26 my $node = PostgreSQL::Test::Cluster->new('main');
27 $node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]);
28 $node->start;
30 foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase')
32 $node->run_log([ 'createdb', $dbname ]);
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');