|
3 | 3 | # pg_upgrade: update a database without needing a full dump/reload cycle. |
4 | 4 | # CAUTION: read the manual page before trying to use this! |
5 | 5 |
|
6 | | -# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.12 1999/09/2816:02:28 momjian Exp $ |
| 6 | +# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.13 1999/09/2818:04:18 momjian Exp $ |
7 | 7 | # |
8 | 8 | # NOTE: we must be sure to update the version-checking code a few dozen lines |
9 | 9 | # below for each new PostgreSQL release. |
@@ -100,23 +100,24 @@ esac |
100 | 100 |
|
101 | 101 |
|
102 | 102 | # OK, ready to proceed. |
103 | | -# XXX Do I need to create a database? |
104 | 103 |
|
105 | | -# remove any COPY statements, except for the one that loads pg_shadow. |
106 | | -# there shouldn't be any others in there anyway... |
| 104 | +# Remove any COPY statements, except for the one that loads pg_shadow. |
| 105 | +# There shouldn't be any others in there anyway... |
| 106 | +# Also marks rows as committed because when pg_log is replaced with |
| 107 | +# the saved version, the transaction statuses may be wrong, so |
| 108 | +# vacuum sets the on-row status to the proper value. |
107 | 109 |
|
108 | 110 | cat$INPUT| awk'{ |
109 | 111 | if (toupper($1) == "COPY" && $2 != "pg_shadow") |
110 | 112 | while (getline $0 > 0 && $0 != "\\.") |
111 | 113 | ; |
| 114 | +else if (tolower($1) == "\\connect" && |
| 115 | + tolower($2) == "template1") |
| 116 | +printf "VACUUM;\n%s\n", $0; |
112 | 117 | elseprint $0; |
113 | 118 | }'>/tmp/$$ |
114 | 119 |
|
115 | | -# Add a VACUUM command to the end of the pg_dump script. With MVCC, |
116 | | -# this is necessary to ensure that all the rows in the new database's |
117 | | -# system tables will still be considered committed after we overwrite |
118 | | -# pg_log with the old database's commit log... |
119 | | - |
| 120 | +# We need to vacuum the last database too |
120 | 121 | echo"VACUUM;">>/tmp/$$ |
121 | 122 |
|
122 | 123 | # Create and vacuum empty tables/indexes |
|