Skip to content

Commit abe5622

Browse files
committed
002_pg_upgrade.pl: rename some variables for clarity
This renames %node_params to %old_node_params, @initdb_params to @old_initdb_params, and adds separate @new_initdb_params and %new_node_params rather than reusing the former in confusing ways. Extracted from a larger patch from the same author. Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://postgr.es/m/CAExHW5sDm+aGb7A4EXK=X9rkrmSPDgc03EdADt=wWkdMO=XPSA@mail.gmail.com
1 parent ea5d3f5 commit abe5622

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/bin/pg_upgrade/t/002_pg_upgrade.pl

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ sub get_dump_for_comparison
128128
PostgreSQL::Test::Cluster->new('old_node',
129129
install_path => $ENV{oldinstall});
130130

131-
my %node_params = ();
131+
my %old_node_params = ();
132132

133133
# To increase coverage of non-standard segment size and group access without
134134
# increasing test runtime, run these tests with a custom setting.
@@ -194,34 +194,34 @@ sub get_dump_for_comparison
194194
my %encodings = ('UTF-8' => 6, 'SQL_ASCII' => 0);
195195
my $original_encoding = $encodings{$original_enc_name};
196196

197-
my @initdb_params = @custom_opts;
197+
my @old_initdb_params = @custom_opts;
198198

199-
push @initdb_params, ('--encoding', $original_enc_name);
200-
push @initdb_params, ('--lc-collate', $original_datcollate);
201-
push @initdb_params, ('--lc-ctype', $original_datctype);
199+
push @old_initdb_params, ('--encoding', $original_enc_name);
200+
push @old_initdb_params, ('--lc-collate', $original_datcollate);
201+
push @old_initdb_params, ('--lc-ctype', $original_datctype);
202202

203203
# add --locale-provider, if supported
204204
my %provider_name = ('b' => 'builtin', 'i' => 'icu', 'c' => 'libc');
205205
if ($oldnode->pg_version >= 15)
206206
{
207-
push @initdb_params,
207+
push @old_initdb_params,
208208
('--locale-provider', $provider_name{$original_provider});
209209
if ($original_provider eq 'b')
210210
{
211-
push @initdb_params, ('--builtin-locale', $original_datlocale);
211+
push @old_initdb_params, ('--builtin-locale', $original_datlocale);
212212
}
213213
elsif ($original_provider eq 'i')
214214
{
215-
push @initdb_params, ('--icu-locale', $original_datlocale);
215+
push @old_initdb_params, ('--icu-locale', $original_datlocale);
216216
}
217217
}
218218

219219
# Since checksums are now enabled by default, and weren't before 18,
220220
# pass '-k' to initdb on old versions so that upgrades work.
221-
push @initdb_params, '-k' if $oldnode->pg_version < 18;
221+
push @old_initdb_params, '-k' if $oldnode->pg_version < 18;
222222

223-
$node_params{extra} = \@initdb_params;
224-
$oldnode->init(%node_params);
223+
$old_node_params{extra} = \@old_initdb_params;
224+
$oldnode->init(%old_node_params);
225225
$oldnode->start;
226226

227227
my $result;
@@ -322,7 +322,7 @@ sub get_dump_for_comparison
322322
get_dump_for_comparison($oldnode, 'regression', 'src_dump', 1);
323323

324324
# Setup destination database cluster
325-
$dstnode->init(%node_params);
325+
$dstnode->init(%old_node_params);
326326
# Stabilize stats for comparison.
327327
$dstnode->append_conf('postgresql.conf', 'autovacuum = off');
328328
$dstnode->start;
@@ -358,17 +358,16 @@ sub get_dump_for_comparison
358358
# Initialize a new node for the upgrade.
359359
my $newnode = PostgreSQL::Test::Cluster->new('new_node');
360360

361-
# Reset to original parameters.
362-
@initdb_params = @custom_opts;
363361

364362
# The new cluster will be initialized with different locale settings,
365363
# but these settings will be overwritten with those of the original
366364
# cluster.
367-
push @initdb_params, ('--encoding', 'SQL_ASCII');
368-
push @initdb_params, ('--locale-provider', 'libc');
369-
370-
$node_params{extra} = \@initdb_params;
371-
$newnode->init(%node_params);
365+
my %new_node_params = %old_node_params;
366+
my @new_initdb_params = @custom_opts;
367+
push @new_initdb_params, ('--encoding', 'SQL_ASCII');
368+
push @new_initdb_params, ('--locale-provider', 'libc');
369+
$new_node_params{extra} = \@new_initdb_params;
370+
$newnode->init(%new_node_params);
372371

373372
# Stabilize stats for comparison.
374373
$newnode->append_conf('postgresql.conf', 'autovacuum = off');

0 commit comments

Comments
 (0)