Skip to content

Commit 809314e

Browse files
committed
Merge branch 'PGPRO9_6' into PGPROEE9_6
2 parents 15ece8b + 3f62e63 commit 809314e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/pgpro-upgrade/pgpro_upgrade

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Utilities needed
33
# 1. sh
44
# 3. sed
5+
LC_MESSAGES=C
6+
export LC_MESSAGES
57
if [ -z "$PGDATA" ]; then
68
echo "PGDATA environment variable is not set. Stop." 1>&2
79
exit 2
@@ -30,22 +32,26 @@ esac
3032
# Check the catalog version
3133
CATALOG_VERSION_NO=2016081311
3234
MAJORVER=9.6
35+
if [ ! -f "${PGDATA}/global/pg_control" -a -f "${PGDATA}/postgresql.conf" ]; then
36+
# looks like we have Debian with separate directory for configs
37+
SAVE_PGDATA="$PGDATA"
38+
PGDATA=`sed -n "/data_directory/{s/^data_directory = '//
39+
s/'.*$//
40+
p}" ${PGDATA}/postgresql.conf`
41+
if [ -z "$PGDATA" -o ! -f "${PGDATA}/global/pg_control" ]; then
42+
echo "Cannot find valid database in $PGDATA" 1>&2;
43+
exit 1
44+
fi
45+
fi
3346
CATVER=`${PGBIN}pg_controldata|sed -n '/Catalog version number:/s/^.*: *//p'`
3447
if [ "$CATVER" != $CATALOG_VERSION_NO ]; then
35-
if [ ! -f "${PGDATA}/global/pg_control" ]; then
36-
# looks like we have Debian with separate directory for configs
37-
SAVE_PGDATA="$PGDATA"
38-
PGDATA=`sed -n "/data_directory/{s/^data_directory = '//
39-
s/'.*$//
40-
p}" /etc/postgresql/9.6/main/postgresql.conf`
41-
if [ -z "$PGDATA" -o ! -f "${PGDATA}/global/pg_control" ]; then
42-
echo "Cannot find valid database in $PGDATA" 1>&2;
43-
exit 1
44-
fi
45-
if [ -f "$PGDATA/postmaster.pid" ]; then
46-
echo "postmaster.pid exists. Is another backend running on $PGDATA" 1>&2;
47-
exit 1;
48-
fi
48+
if [ -n "$check" ]; then
49+
echo "Database needs upgrade"
50+
exit 1
51+
fi
52+
if [ -f "$PGDATA/postmaster.pid" ]; then
53+
echo "postmaster.pid exists. Is another backend running on $PGDATA" 1>&2;
54+
exit 1;
4955
fi
5056
# Fix pg_control file
5157
"${PGBIN}pg_controldata" -c
@@ -56,11 +62,11 @@ if [ "$CATVER" != $CATALOG_VERSION_NO ]; then
5662
(cd $i; mv PG_${MAJORVER}_$CATVER PG_${MAJORVER}_$CATALOG_VERSION_NO)
5763
done
5864
)
59-
if [ -n "$SAVE_PGDATA" ]; then
60-
PGDATA="$SAVE_PGDATA"
61-
fi
6265
fi
6366

67+
if [ -n "$SAVE_PGDATA" ]; then
68+
PGDATA="$SAVE_PGDATA"
69+
fi
6470

6571
for dir in "$PGSHARE" /usr/pgsql-9.6/share /usr/share/postgresql/9.6 /usr/pgsql/9.6/share /usr/share/pgsql /usr/share/postgrespro96 ; do
6672
if [ -d "$dir/pgpro-upgrade" ]; then

0 commit comments

Comments
 (0)