@@ -111,6 +111,10 @@ use Scalar::Util qw(blessed);
111
111
our ($use_tcp , $test_localhost , $test_pghost , $last_host_assigned ,
112
112
$last_port_assigned , @all_nodes , $died );
113
113
114
+ # the minimum version we believe to be compatible with this package without
115
+ # subclassing.
116
+ our $min_compat = 12;
117
+
114
118
INIT
115
119
{
116
120
@@ -1063,7 +1067,7 @@ sub enable_streaming
1063
1067
1064
1068
print " ### Enabling streaming replication for node \" $name \"\n " ;
1065
1069
$self -> append_conf(
1066
- ' postgresql.conf ' , qq(
1070
+ $self -> _recovery_file , qq(
1067
1071
primary_conninfo='$root_connstr '
1068
1072
) );
1069
1073
$self -> set_standby_mode();
@@ -1092,7 +1096,7 @@ sub enable_restoring
1092
1096
: qq{ cp "$path /%f " "%p "} ;
1093
1097
1094
1098
$self -> append_conf(
1095
- ' postgresql.conf ' , qq(
1099
+ $self -> _recovery_file , qq(
1096
1100
restore_command = '$copy_command '
1097
1101
) );
1098
1102
if ($standby )
@@ -1106,6 +1110,8 @@ restore_command = '$copy_command'
1106
1110
return ;
1107
1111
}
1108
1112
1113
+ sub _recovery_file { return " postgresql.conf" ; }
1114
+
1109
1115
=pod
1110
1116
1111
1117
=item $node->set_recovery_mode()
@@ -1305,15 +1311,29 @@ sub new
1305
1311
1306
1312
$node -> dump_info;
1307
1313
1308
- # Add node to list of nodes
1309
- push (@all_nodes , $node );
1310
-
1311
1314
$node -> _set_pg_version;
1312
1315
1313
- my $v = $node -> {_pg_version };
1316
+ my $ver = $node -> {_pg_version };
1314
1317
1315
- carp(" PostgreSQL::Test::Cluster isn't fully compatible with version " . $v )
1316
- if $v < 12;
1318
+ # Use a subclass as defined below (or elsewhere) if this version
1319
+ # isn't fully compatible. Warn if the version is too old and thus we don't
1320
+ # have a subclass of this class.
1321
+ if (ref $ver && $ver < $min_compat )
1322
+ {
1323
+ my $maj = $ver -> major(separator => ' _' );
1324
+ my $subclass = $class . " ::V_$maj " ;
1325
+ if ($subclass -> isa($class ))
1326
+ {
1327
+ bless $node , $subclass ;
1328
+ }
1329
+ else
1330
+ {
1331
+ carp " PostgreSQL::Test::Cluster isn't fully compatible with version $ver " ;
1332
+ }
1333
+ }
1334
+
1335
+ # Add node to list of nodes
1336
+ push (@all_nodes , $node );
1317
1337
1318
1338
return $node ;
1319
1339
}
@@ -2602,8 +2622,12 @@ sub wait_for_catchup
2602
2622
. " _lsn to pass "
2603
2623
. $target_lsn . " on "
2604
2624
. $self -> name . " \n " ;
2625
+ # Before release 12 walreceiver just set the application name to
2626
+ # "walreceiver"
2605
2627
my $query =
2606
- qq[ SELECT '$target_lsn ' <= ${mode} _lsn AND state = 'streaming' FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name ';] ;
2628
+ qq[ SELECT '$target_lsn ' <= ${mode} _lsn AND state = 'streaming'
2629
+ FROM pg_catalog.pg_stat_replication
2630
+ WHERE application_name IN ('$standby_name ', 'walreceiver')] ;
2607
2631
$self -> poll_query_until(' postgres' , $query )
2608
2632
or croak " timed out waiting for catchup" ;
2609
2633
print " done\n " ;
@@ -2890,4 +2914,41 @@ sub corrupt_page_checksum
2890
2914
2891
2915
=cut
2892
2916
2917
+ # #########################################################################
2918
+
2919
+ package PostgreSQL::Test::Cluster::V_11 ; # # no critic (ProhibitMultiplePackages)
2920
+
2921
+ use parent -norequire, qw( PostgreSQL::Test::Cluster) ;
2922
+
2923
+ # https://www.postgresql.org/docs/11/release-11.html
2924
+
2925
+ # max_wal_senders + superuser_reserved_connections must be < max_connections
2926
+ # uses recovery.conf
2927
+
2928
+ sub _recovery_file { return " recovery.conf" ; }
2929
+
2930
+ sub set_standby_mode
2931
+ {
2932
+ my $self = shift ;
2933
+ $self -> append_conf(" recovery.conf" , " standby_mode = on\n " );
2934
+ }
2935
+
2936
+ sub init
2937
+ {
2938
+ my ($self , %params ) = @_ ;
2939
+ $self -> SUPER::init(%params );
2940
+ $self -> adjust_conf(' postgresql.conf' , ' max_wal_senders' ,
2941
+ $params {allows_streaming } ? 5 : 0);
2942
+ }
2943
+
2944
+ # #########################################################################
2945
+
2946
+ package PostgreSQL::Test::Cluster::V_10 ; # # no critic (ProhibitMultiplePackages)
2947
+
2948
+ use parent -norequire, qw( PostgreSQL::Test::Cluster::V_11) ;
2949
+
2950
+ # https://www.postgresql.org/docs/10/release-10.html
2951
+
2952
+ # #######################################################################
2953
+
2893
2954
1;
0 commit comments