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

Commitc419c22

Browse files
committed
Update pg_upgrade for 7.3.
1 parent7a48acb commitc419c22

File tree

1 file changed

+19
-85
lines changed

1 file changed

+19
-85
lines changed

‎contrib/pg_upgrade/pg_upgrade

Lines changed: 19 additions & 85 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/contrib/pg_upgrade/Attic/pg_upgrade,v 1.12 2002/02/11 15:19:33 momjian Exp $
6+
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.13 2002/04/09 18:07:24 momjian Exp $
77
#
88
# To migrate this to newer versions of PostgreSQL:
99
#1) Update the version numbers at the top of the file
@@ -14,8 +14,8 @@
1414
#set -x
1515

1616
# UPGRADE_VERSION is the expected old database version
17-
UPGRADE_VERSION="7.1"
18-
CUR_VERSION="7.2"
17+
UPGRADE_VERSION="7.2"
18+
CUR_VERSION="7.3"
1919

2020
# Set this to "Y" to enable this program
2121
ENABLE="Y"
@@ -75,6 +75,7 @@ fi
7575

7676
# Strip off the trailing directory name and store our data there
7777
# in the hope we are in the same filesystem so 'mv 'works.
78+
7879
INFODIR=`dirname"$PGDATA"`/pg_upgrade_info
7980
SAVEDATA="$INFODIR"/data
8081

@@ -88,14 +89,8 @@ make_dbobjoidmap()
8889
FROM pg_class
8990
WHERE relkind = 'r' OR
9091
relkind = 'i' OR
91-
relkind = 't'"
92-
# Don't move over 7.1 int4 sequences; use setval() file.
93-
# Sequence XIDs changed from 7.2beta4 to beta5; don't copy them.
94-
if ["$SRC_VERSION"!="7.1"-a \
95-
"$SRC_VERSION"!="7.2" ]
96-
thenQUERY="$QUERY OR relkind = 'S';";
97-
QUERY="$QUERY;"
98-
fi
92+
relkind = 'S' OR
93+
relkind = 't';"
9994

10095
psql -d"$DB" -At -F'' -c"$QUERY"|
10196
whileread RELNAME_OID
@@ -213,28 +208,7 @@ then
213208

214209

215210
# Dump schema
216-
pg_dumpall -s|
217-
awk -F' *''
218-
{
219-
# Modify sequences with int8 maximums if we are upgrading from 7.1.
220-
if ("'"$SRC_VERSION"'" == "7.1" &&
221-
$1 == "CREATE" &&
222-
$2 == "SEQUENCE" &&
223-
# handle OS rounding
224-
$9 >= 2147483646 &&
225-
$9 <= 2147483648)
226-
{
227-
for(i=1; i <= NF; i++)
228-
{
229-
if (i != 9)
230-
printf "%s ", $i;
231-
else
232-
printf "%s ", "9223372036854775807";
233-
}
234-
print "";
235-
}
236-
else print $0;
237-
}'>"$INFODIR"/schema
211+
pg_dumpall -s>"$INFODIR"/schema
238212
if [$?-ne 0 ]
239213
thenecho"Can not dump schema. Exiting."1>&2
240214
exit 1
@@ -244,32 +218,6 @@ then
244218
make_dboidmap>"$INFODIR"/dboidmap||exit"$?"
245219
make_dbobjoidmap>"$INFODIR"/dbobjoidmap||exit"$?"
246220

247-
# Generate setval() script for 7.1 because it has int4 sequences
248-
# Sequence XIDs changed from 7.2beta4 to beta5 so we have to recreate them too.
249-
# Not required for 7.2beta5 and later, but it can't hurt.
250-
if ["$SRC_VERSION"="7.1"-o \
251-
"$SRC_VERSION"="7.2" ]
252-
then
253-
psql -d template1 -At -c"SELECT datname FROM pg_database"|
254-
grep -v'^template0$'|
255-
whileread DB
256-
do
257-
# We use awk as a portable way to output a backslash
258-
awk'BEGIN {print "\\connect'"$DB"'"}'
259-
psql -d"$DB" -At -c"
260-
SELECT relname
261-
FROM pg_class
262-
WHERE relkind = 'S';"|
263-
whileread SEQUENCE
264-
do
265-
VALUE=`psql -d"$DB" -At -c"SELECT last_value
266-
FROM\"$SEQUENCE\";"`
267-
echo"SELECT setval ('$SEQUENCE',$VALUE, true);"
268-
done
269-
done>"$INFODIR"/setval
270-
elserm -f"$INFODIR"/setval
271-
fi
272-
273221
# Vacuum all databases to remove exipired rows.
274222
# We will lose our transaction log file during the upgrade so we
275223
# have to do this.
@@ -375,14 +323,7 @@ thenecho "Old version of pg_resetxlog found in path." 1>&2
375323
exit 1
376324
fi
377325

378-
# If the XID is > 2 billion, 7.1 database will have non-frozen XID's in
379-
# low numbers, and 7.2 will think they are in the future --- bad.
380-
381326
SRC_XID=`pg_resetxlog -n"$SAVEDATA"| grep"NextXID"| awk -F' *''{print $4}'`
382-
if ["$SRC_VERSION"="7.1"-a"$SRC_XID"-gt 2000000000 ]
383-
thenecho"XID too high for$BASENAME. Exiting."1>&2
384-
exit 1
385-
fi
386327
DST_XID=`pg_resetxlog -n"$PGDATA"| grep"NextXID"| awk -F' *''{print $4}'`
387328

388329
# compare locales to make sure they match
@@ -418,16 +359,6 @@ fi
418359

419360
echo"Input script completed, fixing row commit statuses..."
420361

421-
# XXX do we still need this?
422-
# Now vacuum each result database because our movement of transaction log
423-
# causes some committed transactions to appear as non-committed
424-
425-
vacuumdb -a
426-
if [$?-ne 0 ]
427-
thenecho"There were errors during VACUUM. Exiting."1>&2
428-
exit 1
429-
fi
430-
431362
# Generate mappings for new database
432363
make_dboidmap> /tmp/$$.dboidmap||exit"$?"
433364
make_dbobjoidmap> /tmp/$$.dbobjoidmap||exit"$?"
@@ -508,6 +439,11 @@ fi
508439
rm -r"$PGDATA"/pg_xlog
509440
mv -f"$SAVEDATA"/pg_xlog"$PGDATA"
510441

442+
# Move over old clog
443+
444+
rm -r"$PGDATA"/pg_clog
445+
mv -f"$SAVEDATA"/pg_clog"$PGDATA"
446+
511447
# Set last log file id and segment from old database
512448

513449
LOG_ID=`pg_resetxlog -n"$SAVEDATA"| grep"Current log file id:"|
@@ -539,16 +475,14 @@ thenecho "Unable to restart database server. Exiting." 1>&2
539475
exit 1
540476
fi
541477

542-
# Set sequence values for 7.1-version sequences, which were int4.
478+
# Now that we have moved the WAL/transaction log files, vacuum again to
479+
# mark install rows with fixed transaction ids to prevent problems on xid
480+
# wraparound.
543481

544-
if ["$SRC_VERSION"="7.1"-o \
545-
"$SRC_VERSION"="7.2" ]
546-
thenecho"Set sequence values..."
547-
psql -d template1 -At<"$INFODIR"/setval
548-
if [$?-ne 0 ]
549-
thenecho"There were errors during int4 sequence restoration. Exiting."1>&2
550-
exit 1
551-
fi
482+
vacuumdb -a
483+
if [$?-ne 0 ]
484+
thenecho"There were errors during VACUUM. Exiting."1>&2
485+
exit 1
552486
fi
553487

554488
echo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp