diff --git a/doc/src/sgml/ref/pg_upgrade.sgml b/doc/src/sgml/ref/pg_upgrade.sgml
index a7c0a502a5..b90412ec5d 100644
--- a/doc/src/sgml/ref/pg_upgrade.sgml
+++ b/doc/src/sgml/ref/pg_upgrade.sgml
@@ -1,5 +1,5 @@
@@ -24,7 +24,7 @@ PostgreSQL documentation
1999-07-31
-pg_upgrade -s filename [ -d filename ] old_data_dir
+pg_upgrade -s filenameold_data_dir
@@ -50,10 +50,14 @@ pg_upgrade -s filename [ -d
Back up your existing data directory, preferably by making a
- complete dump with pg_dumpall. Those upgrading from 7.1 are
- required to supply this dump filename to pg_upgrade with the
- option. Other releases should not use the
- option.
+ complete dump with pg_dumpall.
+
+
+
+
+
+ VACUUM your entire database using
+ vacuumdb -a
@@ -111,7 +115,7 @@ $ make install
Change your working directory to the
pgsql main directory, and type:
-$ pg_upgrade -s schema.out -d data.out data.old
+$ pg_upgrade -s schema.out data.old
The program will do some checking to make sure everything is properly
configured, and will run your db.out script to recreate all the databases
@@ -130,12 +134,6 @@ $ pg_upgrade -s schema.out -d data.out data.old
-
-
- Stop and restart the postmaster.
-
-
-
Carefully examine the contents of the upgraded
@@ -154,6 +152,11 @@ $ pg_upgrade -s schema.out -d data.out data.old
+
+
+ pg_upgrade does not migrate large objects.
+
+
diff --git a/src/bin/pg_dump/pg_upgrade b/src/bin/pg_dump/pg_upgrade
index 63af1ceac1..9fdd11a68d 100755
--- a/src/bin/pg_dump/pg_upgrade
+++ b/src/bin/pg_dump/pg_upgrade
@@ -3,7 +3,7 @@
# pg_upgrade: update a database without needing a full dump/reload cycle.
# CAUTION: read the manual page before trying to use this!
-# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.23 2002/01/11 00:27:42 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.24 2002/01/11 04:39:19 momjian Exp $
#
# NOTE: we must be sure to update the version-checking code a few dozen lines
# below for each new PostgreSQL release.
@@ -13,7 +13,6 @@ TMPFILE="/tmp/pgupgrade.$$"
trap "rm -f $TMPFILE" 0 1 2 3 15
SCHEMA=""
-DATA=""
while [ "$#" -gt 1 ]
do
if [ "X$1" = "X-s" ]
@@ -23,20 +22,13 @@ do
exit 1
fi
shift 2
- elif [ "X$1" = "X-d" ]
- then DATA="$2"
- if [ ! -s "$DATA" ]
- then echo "$DATA does not exist" 1>&2
- exit 1
- fi
- shift 2
- else echo "Usage: $0 -s schema_dump [ -d data_dump ] old_data_dir" 1>&2
+ else echo "Usage: $0 -s schema_dump old_data_dir" 1>&2
exit 1
fi
done
if [ "$#" -ne 1 -o ! "$SCHEMA" ]
-then echo "Usage: $0 -s schema_dump [ -d data_dump ] old_data_dir" 1>&2
+then echo "Usage: $0 -s schema_dump old_data_dir" 1>&2
exit 1
fi
@@ -86,21 +78,6 @@ SRC_VERSION=`cat ./$OLDDIR/PG_VERSION`
# UPGRADE_VERSION is the expected output database version
UPGRADE_VERSION="7.1"
-if [ "$SRC_VERSION" = "7.1" -a ! "$DATA" ]
-then echo "$0 requires a full data dump file to upgrade from version $SRC_VERSION." 1>&2
- echo "Use the '-d' parameter to specify the data dump file" 1>&2
- echo "If you don't have enough disk space to keep a dump file, grep out the '\\connect' and" 1>&2
- echo "'SELECT setval' lines from the dump file and pass that file to $0, e.g:" 1>&2
- echo 1>&2
- echo " pg_dumpall | egrep '^(\\connect)|SELECT setval \()[^ ]*$' > data.out" 1>&2
- exit 1
-fi
-
-if [ "$SRC_VERSION" != "7.1" -a "$DATA" ]
-then echo "$0 does not require the -d option for this version." 1>&2
- exit 1
-fi
-
if [ "$DEST_VERSION" != "$UPGRADE_VERSION" -a "$DEST_VERSION" != "$SRC_VERSION" ]
then echo "`basename $0` is for PostgreSQL version $UPGRADE_VERSION, but ./data/PG_VERSION contains $DEST_VERSION." 1>&2
echo "Did you run initdb for version $UPGRADE_VERSION?" 1>&2
@@ -134,8 +111,8 @@ Install a newer version from pgsql/contrib/pg_resetxlog and continue.; exiting"
exit 1
fi
-# We need a high XID number so there is 1 gig gap in XID numbers so the
-# moved-over rows can be frozen on next VACUUM.
+# If the XID is > 2 billion, 7.1 database will have non-frozen XID's in
+# low numbers, and 7.2 will think they are in the future --- bad.
XID=`pg_resetxlog -n "$OLDDIR" | grep "NextXID" | awk -F' *' '{print $4}'`
if [ "$SRC_VERSION" = "7.1" -a "$XID" -gt 2000000000 ]
@@ -171,26 +148,11 @@ $0 aborted." 1>&2
exit 1
fi
-# Set sequence values for 7.1-version sequences, which are int4.
-if [ "$SRC_VERSION" != "7.1" ]
-then echo "Input script $SCHEMA complete, fixing row commit statuses..."
-else echo "Input script $SCHEMA complete, setting int8 sequences..."
+echo "Input script $SCHEMA complete, fixing row commit statuses..."
- # Set all the sequence counters because they are not brought over
- # in the schema dump.
- cat $DATA | egrep '^(\\connect)|SELECT setval \()[^ ]*$' |
- psql "template1"
- if [ $? -ne 0 ]
- then echo "There were errors in setting the sequence values.
-$0 aborted." 1>&2
- exit 1
- fi
-
- echo "Int8 sequences set, fixing row commit statuses..."
-fi
-
-# Now vacuum each result database in case our transaction increase
-# causes all the XID's to be marked with the frozen XID.
+# XXX do we still need this?
+# Now vacuum each result database because our movement of transaction log
+# causes some committed transactions to appear as non-committed
psql -d template1 -At -c "SELECT datname FROM pg_database" | while read DB
do
@@ -337,6 +299,82 @@ then echo "Unable to restart database server.; exiting" 1>&2
exit 1
fi
+# Set sequence values for 7.1-version sequences, which were int4.
+if [ "$SRC_VERSION" = "7.1" ]
+else echo "Set int8 sequence values from 7.1..."
+
+ psql -d template1 -At -c "SELECT datname FROM pg_database" |
+ while read DB
+ do
+ echo "$DB"
+ # XXX is concurrency a problem here?
+ psql -d "$DB" -At -c "SELECT relname FROM pg_class where relkind = 'S';" |
+ while read SEQUENCE
+ do
+ psql -d "$DB" -At <&2
+ exit 1
+ done
+ done
+fi
+
echo "You may remove the $OLDDIR directory with 'rm -r $OLDDIR'."
exit 0