Skip to content

Commit

Permalink
cats scripts: psql: suppress hints when doing database operations
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Jan 24, 2020
1 parent 1f62685 commit 9a73822
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions core/src/cats/create_bareos_database.in
Expand Up @@ -95,7 +95,7 @@ case ${db_type} in
#
# use SQL_ASCII to be able to put any filename into
# the database even those created with unusual character sets
PSQLVERSION=`psql -d template1 -c 'SELECT version()' $* 2>/dev/null | \
PSQLVERSION=`PGOPTIONS='--client-min-messages=warning' psql -d template1 -c 'SELECT version()' $* 2>/dev/null | \
awk '/PostgreSQL/ { print $2 }' | \
cut -d '.' -f 1,2`

Expand All @@ -120,14 +120,14 @@ case ${db_type} in
;;
esac

psql -f - -d template1 $* << END-OF-DATA
PGOPTIONS='--client-min-messages=warning' psql -f - -d template1 $* << END-OF-DATA
\set ON_ERROR_STOP on
CREATE DATABASE ${db_name} $ENCODING TEMPLATE template0;
ALTER DATABASE ${db_name} SET datestyle TO 'ISO, YMD';
END-OF-DATA
retval=$?

if psql -l ${dbname} $* | grep " ${db_name}.*SQL_ASCII" >/dev/null; then
if PGOPTIONS='--client-min-messages=warning' psql -l ${dbname} $* | grep " ${db_name}.*SQL_ASCII" >/dev/null; then
echo "Database encoding OK"
else
echo " "
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/drop_bareos_tables.in
Expand Up @@ -123,7 +123,7 @@ case ${db_type} in
fi
;;
postgresql)
psql -f ${temp_sql_schema} -d ${db_name} $*
PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_schema} -d ${db_name} $*

retval=$?
if test $retval = 0; then
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/grant_bareos_privileges.in
Expand Up @@ -99,7 +99,7 @@ case ${db_type} in
retval=$?
;;
postgresql)
psql -f ${temp_sql_grants} -d ${db_name} $*
PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_grants} -d ${db_name} $*

retval=$?
;;
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/make_bareos_tables.in
Expand Up @@ -124,7 +124,7 @@ case ${db_type} in
fi
;;
postgresql)
psql -f ${temp_sql_schema} -d ${db_name} $*
PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_schema} -d ${db_name} $*
retval=$?
if test $retval = 0; then
echo "Creation of Bareos PostgreSQL tables succeeded."
Expand Down
8 changes: 4 additions & 4 deletions core/src/cats/update_bareos_tables.in
Expand Up @@ -94,7 +94,7 @@ do
sed -n -e 's/^.*VersionId.*: \(.*\)$/\1/p'`
;;
postgresql)
DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "SELECT MAX(VersionId) FROM Version;" $*`
DBVERSION=`PGOPTIONS='--client-min-messages=warning' psql -d ${db_name} -t --pset format=unaligned -c "SELECT MAX(VersionId) FROM Version;" $*`
;;
*)
echo "Unknown database type ${db_type}"
Expand Down Expand Up @@ -168,15 +168,15 @@ do
retval=$?
;;
postgresql)
psql -f ${temp_sql_schema} -d ${db_name} $*
PGOPTIONS='--client-min-messages=warning' -f ${temp_sql_schema} -d ${db_name} $*
retval=$?
if [ $retval -eq 0 ] && [ ${end_version} -eq 2192 ]; then
PGSQLVERSION=`psql -d template1 -c 'SELECT version()' $* 2>/dev/null | \
PGSQLVERSION=`PGOPTIONS='--client-min-messages=warning' -d template1 -c 'SELECT version()' $* 2>/dev/null | \
awk '/PostgreSQL/ { print $2 }' | \
cut -d '.' -f 1,2`
case ${PGSQLVERSION} in
10.*|11.*|12.*)
psql -d ${db_name} -c 'ALTER SEQUENCE basefiles_baseid_seq AS BIGINT'
PGOPTIONS='--client-min-messages=warning' -d ${db_name} -c 'ALTER SEQUENCE basefiles_baseid_seq AS BIGINT'
result=$?
if [ $result -ne 0 ]; then
echo "WARNING: Failed to update sequence basefiles_baseid_seq"
Expand Down

0 comments on commit 9a73822

Please sign in to comment.