From bb3a3ea9220aeed9be94ce6da826012f1ba5ed5e Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Sat, 28 Aug 2021 19:06:27 +0200 Subject: [PATCH 1/3] Replace call to pg_last_xlog_replay_location and pg_current_xlog_location by call to pg_last_wal_replay_location and pg_current_wal_location for version >= 10.0 --- pg_rep_test | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pg_rep_test b/pg_rep_test index bd8233c..513cacc 100755 --- a/pg_rep_test +++ b/pg_rep_test @@ -7,6 +7,8 @@ default_starting_port=5530 default_replication_structure='fan' minimum_max_connections=8 # The minimum number of max connections which will # increase by max_wal_senders. +xlog_last_function="pg_last_wal_replay_location" +xlog_current_function="pg_current_wal_location" # Run prerequisite checks prerequisite_commands="initdb psql pg_basebackup pg_ctl lsof getopts rmdir rm sync tput" @@ -811,6 +813,12 @@ function check_archive_dir_usage() function create_tool() { +if [ "$(version "$pg_version")" -ge "$(version "10.0.0")" ] +then + xlog_last_function="pg_last_xlog_replay_location" + xlog_current_function="pg_current_xlog_location" +fi + file_header=$(cat <<-TOOL_CONFIG #!/bin/bash @@ -923,10 +931,10 @@ file_body=$(cat <<-'TOOL_FILE' case ${standby:-$(in_recovery $port)} in true) - xlog_function='pg_last_xlog_replay_location' + xlog_function="${xlog_last_function}" ;; false) - xlog_function='pg_current_xlog_location' + xlog_function="${xlog_current_function}" ;; *) echo "N/A" From 249b82a2f0c92a35a58855b66643e07b18e4f222 Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Sat, 28 Aug 2021 19:14:12 +0200 Subject: [PATCH 2/3] Fix remaining call to recovery.conf instead of the variable --- pg_rep_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg_rep_test b/pg_rep_test index 513cacc..c52d964 100755 --- a/pg_rep_test +++ b/pg_rep_test @@ -953,7 +953,7 @@ file_body=$(cat <<-'TOOL_FILE' local standby_port=$1 local primary_port_query="\ WITH q AS (\ - SELECT "*" FROM regexp_split_to_table( pg_read_file('recovery.conf'), E'\\\\n') AS x\ + SELECT "*" FROM regexp_split_to_table( pg_read_file('${recovery_conf}'), E'\\\\n') AS x\ )\ SELECT regexp_replace(x, '.*port=([0-9]*).*', E'\\\\1')\ FROM q\ From a7c265b971104b150316d978592d7a1609d6daa7 Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Sat, 28 Aug 2021 19:20:34 +0200 Subject: [PATCH 3/3] Allow to extract PostgreSQL version from development version --- pg_rep_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg_rep_test b/pg_rep_test index c52d964..deede93 100755 --- a/pg_rep_test +++ b/pg_rep_test @@ -28,7 +28,7 @@ fi # Get the version details of the current PostgreSQL installation -read -r pg_version <<<"$(postgres -V | grep -Po '\d+(\.\d+)?(\.\d+)?')" +read -r pg_version <<<"$(postgres -V | sed 's/devel/.0/' | grep -Po '\d+(\.\d+)?(\.\d+)?')" function usage() {