$OpenBSD: patch-src_cats_create_postgresql_database_in,v 1.4 2019/02/16 22:49:48 sthen Exp $

Index: src/cats/create_postgresql_database.in
--- src/cats/create_postgresql_database.in.orig
+++ src/cats/create_postgresql_database.in
@@ -13,7 +13,11 @@ db_name=${db_name:-@db_name@}
 # 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()' $* | awk '/PostgreSQL/ {print $2}' | cut -d '.' -f 1,2`
+echo "- checking version"
+if ! PSQLVERSION=`psql -d template1 -c 'show server_version' $*`; then
+   echo failed
+   exit 1
+fi
 
 #
 # Note, LC_COLLATE and LC_TYPE are needed on 8.4 and beyond, but are
@@ -38,6 +42,7 @@ esac
 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 #
 #
+echo "- creating database"
 if psql -f - -d template1 $* <<END-OF-DATA
 \set ON_ERROR_STOP on
 CREATE DATABASE ${db_name} $ENCODING TEMPLATE template0;
@@ -52,6 +57,7 @@ else
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    exit 1
 fi
+echo "- checking encoding"
 if psql -l $* | grep " ${db_name}.*SQL_ASCII" >/dev/null; then 
    echo "Database encoding OK"
 else
