@@ -82,6 +82,7 @@ package PostgresNode;
8282use strict;
8383use warnings;
8484
85+ use Carp;
8586use Config;
8687use Cwd;
8788use Exporter' import' ;
@@ -359,7 +360,7 @@ sub set_replication_conf
359360my $pgdata =$self -> data_dir;
360361
361362$self -> hosteq $test_pghost
362- or die " set_replication_conf only works with the default host" ;
363+ or croak " set_replication_conf only works with the default host" ;
363364
364365open my $hba ,' >>' ," $pgdata /pg_hba.conf" ;
365366print $hba " \n # Allow replication (set up by PostgresNode.pm)\n " ;
@@ -624,7 +625,7 @@ sub init_from_backup
624625
625626print
626627" # Initializing node\" $node_name \" from backup\" $backup_name \" of node\" $root_name \"\n " ;
627- die " Backup\" $backup_name \" does not exist at$backup_path "
628+ croak " Backup\" $backup_name \" does not exist at$backup_path "
628629unless -d $backup_path ;
629630
630631mkdir $self -> backup_dir;
@@ -1445,7 +1446,7 @@ sub lsn
14451446' replay' => ' pg_last_wal_replay_lsn()' );
14461447
14471448$mode =' <undef>' if !defined ($mode );
1448- die " unknown mode for 'lsn': '$mode ', valid modes are"
1449+ croak " unknown mode for 'lsn': '$mode ', valid modes are"
14491450 .join (' ,' ,keys %modes )
14501451if !defined ($modes {$mode });
14511452
@@ -1490,7 +1491,7 @@ sub wait_for_catchup
14901491$mode =defined ($mode ) ?$mode :' replay' ;
14911492my %valid_modes =
14921493 (' sent' => 1,' write' => 1,' flush' => 1,' replay' => 1);
1493- die " unknown mode$mode for 'wait_for_catchup', valid modes are"
1494+ croak " unknown mode$mode for 'wait_for_catchup', valid modes are"
14941495 .join (' ,' ,keys (%valid_modes ))
14951496unless exists ($valid_modes {$mode });
14961497
@@ -1517,7 +1518,7 @@ sub wait_for_catchup
15171518my $query =
15181519qq[ SELECT$lsn_expr <=${mode} _lsn FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name ';] ;
15191520$self -> poll_query_until(' postgres' ,$query )
1520- or die " timed out waiting for catchup" ;
1521+ or croak " timed out waiting for catchup" ;
15211522print " done\n " ;
15221523}
15231524
@@ -1547,9 +1548,9 @@ sub wait_for_slot_catchup
15471548$mode =defined ($mode ) ?$mode :' restart' ;
15481549if (!($mode eq ' restart' ||$mode eq ' confirmed_flush' ))
15491550{
1550- die " valid modes are restart, confirmed_flush" ;
1551+ croak " valid modes are restart, confirmed_flush" ;
15511552}
1552- die ' target lsn must be specified' unless defined ($target_lsn );
1553+ croak ' target lsn must be specified' unless defined ($target_lsn );
15531554print " Waiting for replication slot"
15541555 .$slot_name ." 's"
15551556 .$mode
@@ -1559,7 +1560,7 @@ sub wait_for_slot_catchup
15591560my $query =
15601561qq[ SELECT '$target_lsn ' <=${mode} _lsn FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name ';] ;
15611562$self -> poll_query_until(' postgres' ,$query )
1562- or die " timed out waiting for catchup" ;
1563+ or croak " timed out waiting for catchup" ;
15631564print " done\n " ;
15641565}
15651566
@@ -1588,7 +1589,7 @@ null columns.
15881589sub query_hash
15891590{
15901591my ($self ,$dbname ,$query ,@columns ) =@_ ;
1591- die ' calls in array context for multi-row results not supported yet'
1592+ croak ' calls in array context for multi-row results not supported yet'
15921593if (wantarray );
15931594
15941595# Replace __COLUMNS__ if found
@@ -1663,8 +1664,8 @@ sub pg_recvlogical_upto
16631664
16641665my $timeout_exception =' pg_recvlogical timed out' ;
16651666
1666- die ' slot name must be specified' unless defined ($slot_name );
1667- die ' endpos must be specified' unless defined ($endpos );
1667+ croak ' slot name must be specified' unless defined ($slot_name );
1668+ croak ' endpos must be specified' unless defined ($endpos );
16681669
16691670my @cmd = (
16701671' pg_recvlogical' ,' -S' ,$slot_name ,' --dbname' ,
@@ -1674,7 +1675,7 @@ sub pg_recvlogical_upto
16741675
16751676while (my ($k ,$v ) =each %plugin_options )
16761677{
1677- die " = is not permitted to appear in replication option name"
1678+ croak " = is not permitted to appear in replication option name"
16781679if ($k =~qr / =/ );
16791680push @cmd ," -o" ," $k =$v " ;
16801681}