1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Don't fall off the end of perl functions

This complies with the perlcritic policy
Subroutines::RequireFinalReturn, which is a severity 4 policy. Since we
only currently check at severity level 5, the policy is raised to that
level until we move to level 4 or lower, so that any new infringements
will be caught.

A small cosmetic piece of tidying of the pgperlcritic script is
included.

Mike Blackwell

Discussion: https://postgr.es/m/CAESHdJpfFm_9wQnQ3koY3c91FoRQsO-fh02za9R3OEMndOn84A@mail.gmail.com
This commit is contained in:
Andrew Dunstan
2018-05-27 09:08:42 -04:00
parent 8a56ff4848
commit 3a7cc727c7
47 changed files with 208 additions and 4 deletions

View File

@ -31,6 +31,7 @@ sub reset_pg_hba
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', "local all all $hba_method");
$node->reload;
return;
}
# Test access for a single role, useful to wrap all tests into one.
@ -47,6 +48,7 @@ sub test_role
my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role ]);
is($res, $expected_res,
"authentication $status_string for method $method, role $role");
return;
}
# Initialize master node

View File

@ -27,6 +27,7 @@ sub reset_pg_hba
unlink($node->data_dir . '/pg_hba.conf');
$node->append_conf('pg_hba.conf', "local all all $hba_method");
$node->reload;
return;
}
# Test access for a single role, useful to wrap all tests into one.
@ -45,6 +46,7 @@ sub test_login
is($res, $expected_res,
"authentication $status_string for role $role with password $password"
);
return;
}
# Initialize master node. Force UTF-8 encoding, so that we can use non-ASCII

View File

@ -164,6 +164,7 @@ sub test_access
'-U', $role
]);
is($res, $expected_res, $test_name);
return;
}
unlink($node->data_dir . '/pg_hba.conf');

View File

@ -144,6 +144,7 @@ sub test_access
my $res =
$node->psql('postgres', 'SELECT 1', extra_params => [ '-U', $role ]);
is($res, $expected_res, $test_name);
return;
}
note "simple bind";

View File

@ -372,6 +372,7 @@ sub dump_info
{
my ($self) = @_;
print $self->info;
return;
}
@ -393,6 +394,7 @@ sub set_replication_conf
"host replication all $test_localhost/32 sspi include_realm=1 map=regress\n";
}
close $hba;
return;
}
=pod
@ -487,6 +489,7 @@ sub init
$self->set_replication_conf if $params{allows_streaming};
$self->enable_archiving if $params{has_archiving};
return;
}
=pod
@ -512,6 +515,8 @@ sub append_conf
chmod($self->group_access() ? 0640 : 0600, $conffile)
or die("unable to set permissions for $conffile");
return;
}
=pod
@ -538,6 +543,7 @@ sub backup
TestLib::system_or_bail('pg_basebackup', '-D', $backup_path, '-p', $port,
'--no-sync');
print "# Backup finished\n";
return;
}
=item $node->backup_fs_hot(backup_name)
@ -556,6 +562,7 @@ sub backup_fs_hot
{
my ($self, $backup_name) = @_;
$self->_backup_fs($backup_name, 1);
return;
}
=item $node->backup_fs_cold(backup_name)
@ -572,6 +579,7 @@ sub backup_fs_cold
{
my ($self, $backup_name) = @_;
$self->_backup_fs($backup_name, 0);
return;
}
@ -612,6 +620,7 @@ sub _backup_fs
}
print "# Backup finished\n";
return;
}
@ -672,6 +681,7 @@ port = $port
));
$self->enable_streaming($root_node) if $params{has_streaming};
$self->enable_restoring($root_node) if $params{has_restoring};
return;
}
=pod
@ -703,6 +713,7 @@ sub start
}
$self->_update_pid(1);
return;
}
=pod
@ -728,6 +739,7 @@ sub stop
print "### Stopping node \"$name\" using mode $mode\n";
TestLib::system_or_bail('pg_ctl', '-D', $pgdata, '-m', $mode, 'stop');
$self->_update_pid(0);
return;
}
=pod
@ -746,6 +758,7 @@ sub reload
my $name = $self->name;
print "### Reloading node \"$name\"\n";
TestLib::system_or_bail('pg_ctl', '-D', $pgdata, 'reload');
return;
}
=pod
@ -767,6 +780,7 @@ sub restart
TestLib::system_or_bail('pg_ctl', '-D', $pgdata, '-l', $logfile,
'restart');
$self->_update_pid(1);
return;
}
=pod
@ -787,6 +801,7 @@ sub promote
print "### Promoting node \"$name\"\n";
TestLib::system_or_bail('pg_ctl', '-D', $pgdata, '-l', $logfile,
'promote');
return;
}
# Internal routine to enable streaming replication on a standby node.
@ -802,6 +817,7 @@ sub enable_streaming
primary_conninfo='$root_connstr application_name=$name'
standby_mode=on
));
return;
}
# Internal routine to enable archive recovery command on a standby node
@ -830,6 +846,7 @@ sub enable_restoring
restore_command = '$copy_command'
standby_mode = on
));
return;
}
# Internal routine to enable archiving
@ -859,6 +876,7 @@ sub enable_archiving
archive_mode = on
archive_command = '$copy_command'
));
return;
}
# Internal method
@ -885,6 +903,7 @@ sub _update_pid
# Complain if we expected to find a pidfile.
BAIL_OUT("postmaster.pid unexpectedly not present") if $is_running;
return;
}
=pod
@ -1014,7 +1033,7 @@ sub teardown_node
my $self = shift;
$self->stop('immediate');
return;
}
=pod
@ -1030,6 +1049,7 @@ sub clean_node
my $self = shift;
rmtree $self->{_basedir} unless defined $self->{_pid};
return;
}
=pod
@ -1351,6 +1371,7 @@ sub command_ok
local $ENV{PGPORT} = $self->port;
TestLib::command_ok(@_);
return;
}
=pod
@ -1368,6 +1389,7 @@ sub command_fails
local $ENV{PGPORT} = $self->port;
TestLib::command_fails(@_);
return;
}
=pod
@ -1385,6 +1407,7 @@ sub command_like
local $ENV{PGPORT} = $self->port;
TestLib::command_like(@_);
return;
}
=pod
@ -1402,6 +1425,7 @@ sub command_checks_all
local $ENV{PGPORT} = $self->port;
TestLib::command_checks_all(@_);
return;
}
=pod
@ -1427,6 +1451,7 @@ sub issues_sql_like
ok($result, "@$cmd exit code 0");
my $log = TestLib::slurp_file($self->logfile);
like($log, $expected_sql, "$test_name: SQL found in server log");
return;
}
=pod
@ -1445,6 +1470,7 @@ sub run_log
local $ENV{PGPORT} = $self->port;
TestLib::run_log(@_);
return;
}
=pod
@ -1548,6 +1574,7 @@ sub wait_for_catchup
$self->poll_query_until('postgres', $query)
or croak "timed out waiting for catchup";
print "done\n";
return;
}
=pod
@ -1590,6 +1617,7 @@ sub wait_for_slot_catchup
$self->poll_query_until('postgres', $query)
or croak "timed out waiting for catchup";
print "done\n";
return;
}
=pod

View File

@ -13,7 +13,7 @@ use strict;
sub TIEHANDLE
{
my $self = shift;
bless \@_, $self;
return bless \@_, $self;
}
sub PRINT

View File

@ -194,6 +194,7 @@ sub system_or_bail
{
BAIL_OUT("system $_[0] failed");
}
return;
}
sub run_log
@ -244,6 +245,7 @@ sub append_to_file
or die "could not write \"$filename\": $!";
print $fh $str;
close $fh;
return;
}
# Check that all file/dir modes in a directory match the expected values,
@ -338,6 +340,7 @@ sub chmod_recursive
}
},
$dir);
return;
}
# Check presence of a given regexp within pg_config.h for the installation
@ -366,6 +369,7 @@ sub command_ok
my ($cmd, $test_name) = @_;
my $result = run_log($cmd);
ok($result, $test_name);
return;
}
sub command_fails
@ -373,6 +377,7 @@ sub command_fails
my ($cmd, $test_name) = @_;
my $result = run_log($cmd);
ok(!$result, $test_name);
return;
}
sub command_exit_is
@ -394,6 +399,7 @@ sub command_exit_is
? ($h->full_results)[0]
: $h->result(0);
is($result, $expected, $test_name);
return;
}
sub program_help_ok
@ -406,6 +412,7 @@ sub program_help_ok
ok($result, "$cmd --help exit code 0");
isnt($stdout, '', "$cmd --help goes to stdout");
is($stderr, '', "$cmd --help nothing to stderr");
return;
}
sub program_version_ok
@ -418,6 +425,7 @@ sub program_version_ok
ok($result, "$cmd --version exit code 0");
isnt($stdout, '', "$cmd --version goes to stdout");
is($stderr, '', "$cmd --version nothing to stderr");
return;
}
sub program_options_handling_ok
@ -430,6 +438,7 @@ sub program_options_handling_ok
'2>', \$stderr;
ok(!$result, "$cmd with invalid option nonzero exit code");
isnt($stderr, '', "$cmd with invalid option prints error message");
return;
}
sub command_like
@ -441,6 +450,7 @@ sub command_like
ok($result, "$test_name: exit code 0");
is($stderr, '', "$test_name: no stderr");
like($stdout, $expected_stdout, "$test_name: matches");
return;
}
sub command_like_safe
@ -460,6 +470,7 @@ sub command_like_safe
ok($result, "$test_name: exit code 0");
is($stderr, '', "$test_name: no stderr");
like($stdout, $expected_stdout, "$test_name: matches");
return;
}
sub command_fails_like
@ -470,6 +481,7 @@ sub command_fails_like
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
ok(!$result, "$test_name: exit code not 0");
like($stderr, $expected_stderr, "$test_name: matches");
return;
}
# Run a command and check its status and outputs.
@ -509,6 +521,8 @@ sub command_checks_all
{
like($stderr, $re, "$test_name stderr /$re/");
}
return;
}
1;

View File

@ -97,6 +97,8 @@ sub test_target_session_attrs
1,
"connect to node $target_name if mode \"$mode\" and $node1_name,$node2_name listed"
);
return;
}
# Connect to master in "read-write" mode with master,standby1 list.
@ -195,6 +197,7 @@ sub replay_check
$node_standby_2->safe_psql('postgres',
qq[SELECT 1 FROM replayed WHERE val = $newval])
or die "standby_2 didn't replay standby_1 value $newval";
return;
}
replay_check();

View File

@ -41,6 +41,8 @@ sub test_recovery_standby
# Stop standby node
$node_standby->teardown_node;
return;
}
# Initialize master node

View File

@ -24,6 +24,7 @@ sub test_sync_state
}
ok($self->poll_query_until('postgres', $check_sql, $expected), $msg);
return;
}
# Initialize master node

View File

@ -20,6 +20,7 @@ sub configure_and_reload
));
$node->psql('postgres', "SELECT pg_reload_conf()", stdout => \$psql_out);
is($psql_out, 't', "reload node $name with $parameter");
return;
}
# Set up two nodes, which will alternately be master and replication standby.

View File

@ -47,6 +47,7 @@ sub test_connect_ok
];
command_ok($cmd, $test_name);
return;
}
sub test_connect_fails
@ -60,6 +61,7 @@ sub test_connect_fails
];
command_fails_like($cmd, $expected_stderr, $test_name);
return;
}
# Copy a set of files, taking into account wildcards
@ -75,6 +77,7 @@ sub copy_files
copy($orig_file, "$dest/$base_file")
or die "Could not copy $orig_file to $dest";
}
return;
}
sub configure_test_server_for_ssl
@ -130,6 +133,8 @@ sub configure_test_server_for_ssl
# Change pg_hba after restart because hostssl requires ssl=on
configure_hba_for_ssl($node, $serverhost, $authmethod);
return;
}
# Change the configuration to use given server cert file, and reload
@ -150,6 +155,7 @@ sub switch_server_cert
close $sslconf;
$node->restart;
return;
}
sub configure_hba_for_ssl
@ -173,4 +179,7 @@ sub configure_hba_for_ssl
print $hba
"hostssl certdb all ::1/128 cert\n";
close $hba;
return;
}
1;