Improve debug mode about master SQL request

This commit is contained in:
Benjamin Renard 2019-03-15 16:30:20 +01:00
parent f883216050
commit 54b9b79023

View file

@ -120,6 +120,12 @@ function psql_get () {
echo "$sql"|su - $PG_USER -c "$PSQL_BIN -d "$PG_DB" -w -t -P format=unaligned"
}
function psql_master_get () {
sql="$1"
debug "Exec 'echo \"$sql\"|su - $PG_USER -c \"$PSQL_BIN -U $M_USER -h $M_HOST -w -p $M_PORT -d $PG_DB -t -P format=unaligned\""
echo "$sql"|su - $PG_USER -c "$PSQL_BIN -U $M_USER -h $M_HOST -w -p $M_PORT -d $PG_DB -t -P format=unaligned"
}
function debug() {
if [ $DEBUG -eq 1 ]
then
@ -211,7 +217,7 @@ then
fi
# Get current xlog file from master
M_CUR_XLOG="$( echo 'SELECT pg_current_xlog_location()'|su - $PG_USER -c "$PSQL_BIN -U $M_USER -h $M_HOST -p $M_PORT -d $PG_DB -t -P format=unaligned" )"
M_CUR_XLOG="$( psql_master_get 'SELECT pg_current_xlog_location()' )"
if [ ! -n "$M_CUR_XLOG" ]
then
echo "UNKNOWN : Can't retreive current xlog from master server"