LP#1730721: future proof build-db.sh (followup)
authorBen Shum <ben@evergreener.net>
Tue, 7 Nov 2017 20:09:47 +0000 (15:09 -0500)
committerJason Stephenson <jason@sigio.com>
Tue, 7 Nov 2017 20:30:20 +0000 (15:30 -0500)
For PostgreSQL 10+, the versioning scheme has changed. We only want
the top number for those versions and up.

So, grab only the first two numbers for the variable...

9.6.5 = 96
10.0 = 10, etc.

Signed-off-by: Ben Shum <ben@evergreener.net>
Signed-off-by: Jason Stephenson <jason@sigio.com>

Open-ILS/src/sql/Pg/build-db.sh

index 4eb7be0..4b8df82 100755 (executable)
@@ -15,7 +15,7 @@ export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD
 # ---------------------------------------------------------------------------
 # Lookup the database version from the PostgreSQL server.
 # ---------------------------------------------------------------------------
-DB_VERSION=`psql -qtc 'show server_version;' | xargs | cut -d. -f 1,2 | tr -d '.'`
+DB_VERSION=`psql -qtc 'show server_version;' | xargs | cut -d. -f 1,2 | tr -d '.' | cut -c1,2`
 if [ -z "$DB_VERSION" ] || [ `echo $DB_VERSION | grep -c '[^0-9]'` != 0 ]; then
   cat <<EOM
 ********************************************************************************