use strict;
use warnings;
+use Carp;
use Config;
use Cwd;
use Exporter 'import';
my $pgdata = $self->data_dir;
$self->host eq $test_pghost
- or die "set_replication_conf only works with the default host";
+ or croak "set_replication_conf only works with the default host";
open my $hba, '>>', "$pgdata/pg_hba.conf";
print $hba "\n# Allow replication (set up by PostgresNode.pm)\n";
print
"# Initializing node \"$node_name\" from backup \"$backup_name\" of node \"$root_name\"\n";
- die "Backup \"$backup_name\" does not exist at $backup_path"
+ croak "Backup \"$backup_name\" does not exist at $backup_path"
unless -d $backup_path;
mkdir $self->backup_dir;
'replay' => 'pg_last_wal_replay_lsn()');
$mode = '<undef>' if !defined($mode);
- die "unknown mode for 'lsn': '$mode', valid modes are "
+ croak "unknown mode for 'lsn': '$mode', valid modes are "
. join(', ', keys %modes)
if !defined($modes{$mode});
$mode = defined($mode) ? $mode : 'replay';
my %valid_modes =
('sent' => 1, 'write' => 1, 'flush' => 1, 'replay' => 1);
- die "unknown mode $mode for 'wait_for_catchup', valid modes are "
+ croak "unknown mode $mode for 'wait_for_catchup', valid modes are "
. join(', ', keys(%valid_modes))
unless exists($valid_modes{$mode});
my $query =
qq[SELECT $lsn_expr <= ${mode}_lsn FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';];
$self->poll_query_until('postgres', $query)
- or die "timed out waiting for catchup";
+ or croak "timed out waiting for catchup";
print "done\n";
}
$mode = defined($mode) ? $mode : 'restart';
if (!($mode eq 'restart' || $mode eq 'confirmed_flush'))
{
- die "valid modes are restart, confirmed_flush";
+ croak "valid modes are restart, confirmed_flush";
}
- die 'target lsn must be specified' unless defined($target_lsn);
+ croak 'target lsn must be specified' unless defined($target_lsn);
print "Waiting for replication slot "
. $slot_name . "'s "
. $mode
my $query =
qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name';];
$self->poll_query_until('postgres', $query)
- or die "timed out waiting for catchup";
+ or croak "timed out waiting for catchup";
print "done\n";
}
sub query_hash
{
my ($self, $dbname, $query, @columns) = @_;
- die 'calls in array context for multi-row results not supported yet'
+ croak 'calls in array context for multi-row results not supported yet'
if (wantarray);
# Replace __COLUMNS__ if found
my $timeout_exception = 'pg_recvlogical timed out';
- die 'slot name must be specified' unless defined($slot_name);
- die 'endpos must be specified' unless defined($endpos);
+ croak 'slot name must be specified' unless defined($slot_name);
+ croak 'endpos must be specified' unless defined($endpos);
my @cmd = (
'pg_recvlogical', '-S', $slot_name, '--dbname',
while (my ($k, $v) = each %plugin_options)
{
- die "= is not permitted to appear in replication option name"
+ croak "= is not permitted to appear in replication option name"
if ($k =~ qr/=/);
push @cmd, "-o", "$k=$v";
}
use strict;
use warnings;
+use Carp;
use File::Basename;
use File::Copy;
if (defined $params{filterfn})
{
- die "if specified, filterfn must be a subroutine reference"
+ croak "if specified, filterfn must be a subroutine reference"
unless defined(ref $params{filterfn})
and (ref $params{filterfn} eq 'CODE');
}
# Complain if original path is bogus, because _copypath_recurse won't.
- die "\"$base_src_dir\" does not exist" if !-e $base_src_dir;
+ croak "\"$base_src_dir\" does not exist" if !-e $base_src_dir;
# Start recursive copy from current directory
return _copypath_recurse($base_src_dir, $base_dest_dir, "", $filterfn);
# Check for symlink -- needed only on source dir
# (note: this will fall through quietly if file is already gone)
- die "Cannot operate on symlink \"$srcpath\"" if -l $srcpath;
+ croak "Cannot operate on symlink \"$srcpath\"" if -l $srcpath;
# Abort if destination path already exists. Should we allow directories
# to exist already?
- die "Destination path \"$destpath\" already exists" if -e $destpath;
+ croak "Destination path \"$destpath\" already exists" if -e $destpath;
# If this source path is a file, simply copy it to destination with the
# same name and we're done.
return 1 if !-e $srcpath;
# Else it's some weird file type; complain.
- die "Source path \"$srcpath\" is not a regular file or directory";
+ croak "Source path \"$srcpath\" is not a regular file or directory";
}
1;