mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
More improvements; still disabled. (Don't panic.)
This commit is contained in:
@ -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.20 2002/01/09 21:50:52 momjian Exp $
|
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.21 2002/01/10 03:05:48 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.
|
||||||
@ -164,7 +164,7 @@ fi
|
|||||||
|
|
||||||
# Now vacuum each result database in case our transaction increase
|
# Now vacuum each result database in case our transaction increase
|
||||||
# causes all the XID's to be marked with the frozen XID.
|
# causes all the XID's to be marked with the frozen XID.
|
||||||
psql -l | while read DB
|
psql -d template1 -At -c "SELECT datname FROM pg_database" | while read DB
|
||||||
do
|
do
|
||||||
echo "VACUUM;" | psql "$DB"
|
echo "VACUUM;" | psql "$DB"
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
@ -179,12 +179,16 @@ pg_dumpall -s > $TMPFILE 2>/dev/null
|
|||||||
|
|
||||||
# flush buffers to disk
|
# flush buffers to disk
|
||||||
pg_ctl stop
|
pg_ctl stop
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then echo "Unable to stop database server.; exiting" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Commit fixes complete, moving data files..."
|
echo "Commit fixes complete, moving data files..."
|
||||||
|
|
||||||
cat "$SCHEMA" | while read LINE
|
cat "$SCHEMA" | while read LINE
|
||||||
do
|
do
|
||||||
if /bin/echo "$LINE" | grep -q "^\\\\connect "
|
if /bin/echo "$LINE" | grep -q "^\\\\connect [^ ]*$"
|
||||||
then OLDDB="$DB"
|
then OLDDB="$DB"
|
||||||
DB="`/bin/echo \"$LINE\" | cut -d' ' -f2`"
|
DB="`/bin/echo \"$LINE\" | cut -d' ' -f2`"
|
||||||
if [ "$DB" = "-" ]
|
if [ "$DB" = "-" ]
|
||||||
@ -251,19 +255,37 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# set max transaction id, check < 2gig
|
|
||||||
|
|
||||||
# 7.1 has non-compressed log file format
|
# 7.1 has non-compressed log file format
|
||||||
if [ "$SRCVERSION" = "7.1" ]
|
if [ "$SRCVERSION" = "7.1" ]
|
||||||
# pg_log is oid 1269 in 7.1
|
then
|
||||||
LOGSIZE=`ls -l "$OLDDIR"/global/1269 "$OLDDIR"/global/1269.* 2>/dev/null |
|
# pg_log is oid 1269 in 7.1
|
||||||
awk -F' *' '
|
LOGSIZE=`ls -l "$OLDDIR"/global/1269 "$OLDDIR"/global/1269.* 2>/dev/null |
|
||||||
BEGIN {sum=0;}
|
awk -F' *' '
|
||||||
{sum += $5;}
|
BEGIN {sum=0;}
|
||||||
END {print sum;}'`
|
{sum += $5;}
|
||||||
|
END {print sum;}'`
|
||||||
|
|
||||||
|
# check < 2gig
|
||||||
|
|
||||||
|
# set max transaction id
|
||||||
|
|
||||||
|
else
|
||||||
|
# how to handle 7.2?
|
||||||
|
rm -r data/pg_clog &&
|
||||||
|
mv "$OLDDIR"/data/pg_clog data/pg_clog &&
|
||||||
|
mv "$OLDDIR"/data/global/pg_control data/global/pg_control
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then echo "Moving of transaction and control files failed.; exiting" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
pg_ctl start
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then echo "Unable to restart database server.; exiting" 1>&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "You must stop/start the postmaster before doing anything else."
|
|
||||||
echo "You may remove the $OLDDIR directory with 'rm -r $OLDDIR'."
|
echo "You may remove the $OLDDIR directory with 'rm -r $OLDDIR'."
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user