Now tested on 7.2->7.2 migration; still disabled. Need 7.1 testing now.
This commit is contained in:
parent
9be030fbeb
commit
11b3e56223
@ -3,7 +3,7 @@
|
|||||||
# pg_upgrade: update a database without needing a full dump/reload cycle.
|
# pg_upgrade: update a database without needing a full dump/reload cycle.
|
||||||
# CAUTION: Read the manual page before trying to use this!
|
# CAUTION: Read the manual page before trying to use this!
|
||||||
|
|
||||||
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.31 2002/01/13 01:22:27 momjian Exp $
|
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.32 2002/01/13 04:55:44 momjian Exp $
|
||||||
#
|
#
|
||||||
# NOTE: we must be sure to update the version-checking code a few dozen lines
|
# NOTE: we must be sure to update the version-checking code a few dozen lines
|
||||||
# below for each new PostgreSQL release.
|
# below for each new PostgreSQL release.
|
||||||
@ -13,6 +13,16 @@
|
|||||||
# Set this to "Y" to enable this program
|
# Set this to "Y" to enable this program
|
||||||
ENABLE="N"
|
ENABLE="N"
|
||||||
|
|
||||||
|
if [ "$ENABLE" != "Y" ]
|
||||||
|
then
|
||||||
|
echo "Sorry, $0 cannot upgrade database
|
||||||
|
version $SRC_VERSION to $DST_VERSION." 1>&2
|
||||||
|
echo "The on-disk structure of tables has changed." 1>&2
|
||||||
|
echo "You will need to dump and restore using pg_dumpall." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# UPGRADE_VERSION is the expected old database version
|
# UPGRADE_VERSION is the expected old database version
|
||||||
UPGRADE_VERSION="7.1"
|
UPGRADE_VERSION="7.1"
|
||||||
CUR_VERSION="7.2"
|
CUR_VERSION="7.2"
|
||||||
@ -52,7 +62,7 @@ OLDDIR="$INFODIR/data"
|
|||||||
make_dbobjoidmap()
|
make_dbobjoidmap()
|
||||||
{
|
{
|
||||||
psql -d template1 -At -c "SELECT datname FROM pg_database" |
|
psql -d template1 -At -c "SELECT datname FROM pg_database" |
|
||||||
grep -v '^template0$' | # template1 OK
|
grep -v '^template0$' |
|
||||||
while read DB
|
while read DB
|
||||||
do
|
do
|
||||||
QUERY="`echo \" SELECT relname, oid
|
QUERY="`echo \" SELECT relname, oid
|
||||||
@ -78,7 +88,8 @@ make_dbobjoidmap()
|
|||||||
make_dboidmap()
|
make_dboidmap()
|
||||||
{
|
{
|
||||||
psql -d template1 -At -F' ' -c \
|
psql -d template1 -At -F' ' -c \
|
||||||
'SELECT datname, oid FROM pg_database;'
|
'SELECT datname, oid FROM pg_database;' |
|
||||||
|
grep -v '^template0$'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,24 +160,10 @@ $0 aborted." 1>&2
|
|||||||
echo
|
echo
|
||||||
"However, your database is version $SRC_VERSION;
|
"However, your database is version $SRC_VERSION;
|
||||||
$0 aborted." 1>&2
|
$0 aborted." 1>&2
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that input database is of a compatible version (anything with the same
|
|
||||||
# physical layout of user tables and indexes should be OK). I did not write
|
|
||||||
# something like "$SRC_VERSION -ge $UPGRADE_VERSION" because test(1) isn't bright
|
|
||||||
# enough to compare dotted version strings properly. Using a case statement
|
|
||||||
# looks uglier but is more flexible.
|
|
||||||
if [ "$ENABLE" != "Y" ]
|
|
||||||
then
|
|
||||||
echo "Sorry, $0 cannot upgrade database
|
|
||||||
version $SRC_VERSION to $DST_VERSION." 1>&2
|
|
||||||
echo "The on-disk structure of tables has changed." 1>&2
|
|
||||||
echo "You will need to dump and restore using pg_dumpall." 1>&2
|
echo "You will need to dump and restore using pg_dumpall." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Start server, if needed, so we can do some work.
|
# Start server, if needed, so we can do some work.
|
||||||
if ! pg_ctl status | head -1 | grep -q "is running"
|
if ! pg_ctl status | head -1 | grep -q "is running"
|
||||||
then pg_ctl -w start
|
then pg_ctl -w start
|
||||||
@ -220,17 +217,18 @@ $0 aborted." 1>&2
|
|||||||
if [ "$SRC_VERSION" = "7.1" ]
|
if [ "$SRC_VERSION" = "7.1" ]
|
||||||
then
|
then
|
||||||
psql -d template1 -At -c "SELECT datname FROM pg_database" |
|
psql -d template1 -At -c "SELECT datname FROM pg_database" |
|
||||||
grep -v '^template0$' | # template1 OK
|
grep -v '^template0$' |
|
||||||
while read DB
|
while read DB
|
||||||
do
|
do
|
||||||
echo "\\connect $DB"
|
# We use awk as a portable way to output a backslash
|
||||||
|
awk 'BEGIN {print "\\connect '"$DB"'"}'
|
||||||
psql -d "$DB" -At -c "
|
psql -d "$DB" -At -c "
|
||||||
SELECT relname
|
SELECT relname
|
||||||
FROM pg_class
|
FROM pg_class
|
||||||
WHERE relkind = 'S';" |
|
WHERE relkind = 'S';" |
|
||||||
while read SEQUENCE
|
while read SEQUENCE
|
||||||
do
|
do
|
||||||
VALUE=`psql -d template1 -At -c "SELECT last_value
|
VALUE=`psql -d "$DB" -At -c "SELECT last_value
|
||||||
FROM \"$SEQUENCE\";"`
|
FROM \"$SEQUENCE\";"`
|
||||||
echo "SELECT setval ('$SEQUENCE', $VALUE, true);"
|
echo "SELECT setval ('$SEQUENCE', $VALUE, true);"
|
||||||
done
|
done
|
||||||
@ -263,7 +261,8 @@ $0 aborted." 1>&2
|
|||||||
$0 aborted." 1>&2
|
$0 aborted." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Plase 1 completed. Continue with the steps outlined in the $0 manual page."
|
echo "Plase 1 completed.
|
||||||
|
Continue with the steps outlined in the $0 manual page."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -520,6 +519,8 @@ $0 aborted." 1>&2
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo
|
||||||
echo "You may remove the old database files with 'rm -r pg_upgrade'."
|
echo "You may remove the old database files with 'rm -r pg_upgrade'."
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user