Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11b3e56

Browse files
committed
Now tested on 7.2->7.2 migration; still disabled. Need 7.1 testing now.
1 parent9be030f commit11b3e56

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

‎src/bin/pg_dump/pg_upgrade

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pg_upgrade: update a database without needing a full dump/reload cycle.
44
# CAUTION: Read the manual page before trying to use this!
55

6-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.31 2002/01/1301:22:27 momjian Exp $
6+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_upgrade,v 1.32 2002/01/1304:55:44 momjian Exp $
77
#
88
# NOTE: we must be sure to update the version-checking code a few dozen lines
99
# below for each new PostgreSQL release.
@@ -13,6 +13,16 @@
1313
# Set this to "Y" to enable this program
1414
ENABLE="N"
1515

16+
if ["$ENABLE"!="Y" ]
17+
then
18+
echo"Sorry,$0 cannot upgrade database
19+
version$SRC_VERSION to$DST_VERSION."1>&2
20+
echo"The on-disk structure of tables has changed."1>&2
21+
echo"You will need to dump and restore using pg_dumpall."1>&2
22+
exit 1
23+
fi
24+
25+
1626
# UPGRADE_VERSION is the expected old database version
1727
UPGRADE_VERSION="7.1"
1828
CUR_VERSION="7.2"
@@ -52,7 +62,7 @@ OLDDIR="$INFODIR/data"
5262
make_dbobjoidmap()
5363
{
5464
psql -d template1 -At -c"SELECT datname FROM pg_database"|
55-
grep -v'^template0$'|# template1 OK
65+
grep -v'^template0$'|
5666
whileread DB
5767
do
5868
QUERY="`echo\"SELECT relname, oid
@@ -78,7 +88,8 @@ make_dbobjoidmap()
7888
make_dboidmap()
7989
{
8090
psql -d template1 -At -F'' -c \
81-
'SELECT datname, oid FROM pg_database;'
91+
'SELECT datname, oid FROM pg_database;'|
92+
grep -v'^template0$'
8293
}
8394

8495

@@ -149,24 +160,10 @@ $0 aborted." 1>&2
149160
echo
150161
"However, your database is version$SRC_VERSION;
151162
$0 aborted."1>&2
152-
exit 1
153-
fi
154-
155-
# Check that input database is of a compatible version (anything with the same
156-
# physical layout of user tables and indexes should be OK). I did not write
157-
# something like "$SRC_VERSION -ge $UPGRADE_VERSION" because test(1) isn't bright
158-
# enough to compare dotted version strings properly. Using a case statement
159-
# looks uglier but is more flexible.
160-
if ["$ENABLE"!="Y" ]
161-
then
162-
echo"Sorry,$0 cannot upgrade database
163-
version$SRC_VERSION to$DST_VERSION."1>&2
164-
echo"The on-disk structure of tables has changed."1>&2
165163
echo"You will need to dump and restore using pg_dumpall."1>&2
166164
exit 1
167165
fi
168166

169-
170167
# Start server, if needed, so we can do some work.
171168
if! pg_ctl status| head -1| grep -q"is running"
172169
thenpg_ctl -w start
@@ -220,17 +217,18 @@ $0 aborted." 1>&2
220217
if ["$SRC_VERSION"="7.1" ]
221218
then
222219
psql -d template1 -At -c"SELECT datname FROM pg_database"|
223-
grep -v'^template0$'|# template1 OK
220+
grep -v'^template0$'|
224221
whileread DB
225-
do
226-
echo"\\connect$DB"
222+
do
223+
# We use awk as a portable way to output a backslash
224+
awk'BEGIN {print "\\connect'"$DB"'"}'
227225
psql -d"$DB" -At -c"
228226
SELECT relname
229227
FROM pg_class
230228
WHERE relkind = 'S';"|
231229
whileread SEQUENCE
232230
do
233-
VALUE=`psql -dtemplate1 -At -c"SELECT last_value
231+
VALUE=`psql -d"$DB" -At -c"SELECT last_value
234232
FROM\"$SEQUENCE\";"`
235233
echo"SELECT setval ('$SEQUENCE',$VALUE, true);"
236234
done
@@ -263,7 +261,8 @@ $0 aborted." 1>&2
263261
$0 aborted."1>&2
264262
exit 1
265263
fi
266-
echo"Plase 1 completed. Continue with the steps outlined in the$0 manual page."
264+
echo"Plase 1 completed.
265+
Continue with the steps outlined in the$0 manual page."
267266
exit 0
268267
fi
269268

@@ -520,6 +519,8 @@ $0 aborted." 1>&2
520519
fi
521520
fi
522521

522+
echo
523+
echo
523524
echo"You may remove the old database files with 'rm -r pg_upgrade'."
524525

525526
exit 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp