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

Commit5bab198

Browse files
committed
Fix bit-rot in pg_upgrade's test.sh, and improve documentation.
Doing a cross-version upgrade test with test.sh evidently hasn't beentested since circa 9.2, because the script lacked case branches forold-version servers newer than 9.1. Future-proof that a bit, andclean up breakage induced by our recent drop of V0 function callprotocol (namely that oldstyle_length() isn't in the regressionsuite anymore).(This isn't enough to make the test work perfectly cleanly acrossversions, but at least it finishes and provides dump files thatyou can diff manually. One issue I didn't touch is that we mightwant to execute the "reindex_hash.sql" file in the new DB beforedumping it, so that the hash indexes don't vanish from the dump.)Improve the TESTING doc file: put the tl;dr version at the top notthe bottom, and bring its explanation of how to run a cross-versiontest up to speed, since the installcheck target isn't there and won'tbe resurrected. Improve the comment in the Makefile about why not.In passing, teach .gitignore and "make clean" about a couple morejunk output files.Discussion:https://postgr.es/m/14058.1496892482@sss.pgh.pa.us
1 parente3df8f8 commit5bab198

File tree

4 files changed

+53
-29
lines changed

4 files changed

+53
-29
lines changed

‎src/bin/pg_upgrade/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
/delete_old_cluster.sh
55
/analyze_new_cluster.bat
66
/delete_old_cluster.bat
7+
/reindex_hash.sql
8+
/loadable_libraries.txt
79
/log/
810
/tmp_check/

‎src/bin/pg_upgrade/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ uninstall:
3232
cleandistcleanmaintainer-clean:
3333
rm -f pg_upgrade$(X)$(OBJS)
3434
rm -rf analyze_new_cluster.sh delete_old_cluster.sh log/ tmp_check/\
35+
loadable_libraries.txt reindex_hash.sql\
3536
pg_upgrade_dump_globals.sql\
3637
pg_upgrade_dump_*.custom pg_upgrade_*.log
3738

3839
check: test.sh all
3940
MAKE=$(MAKE) bindir=$(bindir) libdir=$(libdir) EXTRA_REGRESS_OPTS="$(EXTRA_REGRESS_OPTS)"$(SHELL)$< --install
4041

41-
# disabled because it upsets the build farm
42-
#installcheck: test.sh
43-
#MAKE=$(MAKE) bindir=$(bindir) libdir=$(libdir) $(SHELL) $<
42+
# installcheck is not supported because there's no meaningful way to test
43+
# pg_upgrade against a single already-running server

‎src/bin/pg_upgrade/TESTING

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
THE SHORT VERSION
2+
-----------------
3+
4+
On non-Windows machines, you can execute the testing process
5+
described below by running
6+
make check
7+
in this directory. This will run the shell script test.sh, performing
8+
an upgrade from the version in this source tree to a new instance of
9+
the same version.
10+
11+
To test an upgrade from a different version, you must have a built
12+
source tree for the old version as well as this version, and you
13+
must have done "make install" for both versions. Then do:
14+
15+
export oldsrc=...somewhere/postgresql(old version's source tree)
16+
export oldbindir=...otherversion/bin(old version's installed bin dir)
17+
export bindir=...thisversion/bin(this version's installed bin dir)
18+
export libdir=...thisversion/lib(this version's installed lib dir)
19+
sh test.sh
20+
21+
In this case, you will have to manually eyeball the resulting dump
22+
diff for version-specific differences, as explained below.
23+
24+
25+
DETAILS
26+
-------
27+
128
The most effective way to test pg_upgrade, aside from testing on user
229
data, is by upgrading the PostgreSQL regression database.
330

@@ -7,7 +34,7 @@ specific to each major version of Postgres.
734

835
Here are the steps needed to create a regression database dump file:
936

10-
1) Create and populate the regression database in the old cluster
37+
1) Create and populate the regression database in the old cluster.
1138
This database can be created by running 'make installcheck' from
1239
src/test/regression.
1340

@@ -60,22 +87,3 @@ steps:
6087

6188
7) Diff the regression database dump file with the regression dump
6289
file loaded into the old server.
63-
64-
The shell script test.sh in this directory performs more or less this
65-
procedure. You can invoke it by running
66-
67-
make check
68-
69-
or by running
70-
71-
make installcheck
72-
73-
if "make install" (or "make install-world") were done beforehand.
74-
When invoked without arguments, it will run an upgrade from the
75-
version in this source tree to a new instance of the same version. To
76-
test an upgrade from a different version, invoke it like this:
77-
78-
make installcheck oldbindir=...otherversion/bin oldsrc=...somewhere/postgresql
79-
80-
In this case, you will have to manually eyeball the resulting dump
81-
diff for version-specific differences, as explained above.

‎src/bin/pg_upgrade/test.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,32 @@ createdb "$dbname2" || createdb_status=$?
170170
createdb"$dbname3"|| createdb_status=$?
171171

172172
if"$MAKE" -C"$oldsrc" installcheck;then
173-
pg_dumpall --no-sync -f"$temp_root"/dump1.sql|| pg_dumpall1_status=$?
173+
oldpgversion=`psql -X -A -t -d regression -c"SHOW server_version_num"`
174+
175+
# before dumping, get rid of objects not existing in later versions
174176
if ["$newsrc"!="$oldsrc" ];then
175-
oldpgversion=`psql -X -A -t -d regression -c"SHOW server_version_num"`
176177
fix_sql=""
177178
case$oldpgversionin
178179
804??)
179-
fix_sql="UPDATE pg_proc SET probin = replace(probin::text, '$oldsrc', '$newsrc')::bytea WHERE probin LIKE '$oldsrc%'; DROP FUNCTION public.myfunc(integer);"
180+
fix_sql="DROP FUNCTION public.myfunc(integer); DROP FUNCTION public.oldstyle_length(integer, text);"
180181
;;
181-
900??)
182-
fix_sql="SET bytea_output TO escape; UPDATE pg_proc SET probin = replace(probin::text, '$oldsrc', '$newsrc')::bytea WHERE probin LIKE '$oldsrc%';"
182+
*)
183+
fix_sql="DROP FUNCTION public.oldstyle_length(integer, text);"
184+
;;
185+
esac
186+
psql -X -d regression -c"$fix_sql;"|| psql_fix_sql_status=$?
187+
fi
188+
189+
pg_dumpall --no-sync -f"$temp_root"/dump1.sql|| pg_dumpall1_status=$?
190+
191+
if ["$newsrc"!="$oldsrc" ];then
192+
# update references to old source tree's regress.so etc
193+
fix_sql=""
194+
case$oldpgversionin
195+
804??)
196+
fix_sql="UPDATE pg_proc SET probin = replace(probin::text, '$oldsrc', '$newsrc')::bytea WHERE probin LIKE '$oldsrc%';"
183197
;;
184-
901??)
198+
*)
185199
fix_sql="UPDATE pg_proc SET probin = replace(probin, '$oldsrc', '$newsrc') WHERE probin LIKE '$oldsrc%';"
186200
;;
187201
esac

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp