Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pg_rep_test
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -26,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()
{
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -945,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\
Expand Down