From 86310e6cbc986a5f13e60fba129c10edd648d099 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sun, 14 Dec 2014 20:41:59 -0500
Subject: [PATCH 9/9] Move pg_upgrade from contrib/ to src/bin/

---
 contrib/Makefile                               |  1 -
 doc/src/sgml/contrib.sgml                      |  1 -
 doc/src/sgml/pgupgrade.sgml                    | 12 ++----------
 doc/src/sgml/reference.sgml                    |  1 +
 src/bin/Makefile                               |  1 +
 {contrib => src/bin}/pg_upgrade/.gitignore     |  0
 {contrib => src/bin}/pg_upgrade/IMPLEMENTATION |  2 --
 {contrib => src/bin}/pg_upgrade/Makefile       | 18 +++++++-----------
 {contrib => src/bin}/pg_upgrade/TESTING        |  2 --
 {contrib => src/bin}/pg_upgrade/check.c        |  2 +-
 {contrib => src/bin}/pg_upgrade/controldata.c  |  2 +-
 {contrib => src/bin}/pg_upgrade/dump.c         |  2 +-
 {contrib => src/bin}/pg_upgrade/exec.c         |  2 +-
 {contrib => src/bin}/pg_upgrade/file.c         |  2 +-
 {contrib => src/bin}/pg_upgrade/function.c     |  2 +-
 {contrib => src/bin}/pg_upgrade/info.c         |  2 +-
 {contrib => src/bin}/pg_upgrade/option.c       |  2 +-
 {contrib => src/bin}/pg_upgrade/page.c         |  2 +-
 {contrib => src/bin}/pg_upgrade/parallel.c     |  2 +-
 {contrib => src/bin}/pg_upgrade/pg_upgrade.c   |  2 +-
 {contrib => src/bin}/pg_upgrade/pg_upgrade.h   |  2 +-
 {contrib => src/bin}/pg_upgrade/relfilenode.c  |  2 +-
 {contrib => src/bin}/pg_upgrade/server.c       |  2 +-
 {contrib => src/bin}/pg_upgrade/tablespace.c   |  2 +-
 {contrib => src/bin}/pg_upgrade/test.sh        |  6 +++---
 {contrib => src/bin}/pg_upgrade/util.c         |  2 +-
 {contrib => src/bin}/pg_upgrade/version.c      |  2 +-
 27 files changed, 31 insertions(+), 47 deletions(-)
 rename {contrib => src/bin}/pg_upgrade/.gitignore (100%)
 rename {contrib => src/bin}/pg_upgrade/IMPLEMENTATION (99%)
 rename {contrib => src/bin}/pg_upgrade/Makefile (79%)
 rename {contrib => src/bin}/pg_upgrade/TESTING (99%)
 rename {contrib => src/bin}/pg_upgrade/check.c (99%)
 rename {contrib => src/bin}/pg_upgrade/controldata.c (99%)
 rename {contrib => src/bin}/pg_upgrade/dump.c (99%)
 rename {contrib => src/bin}/pg_upgrade/exec.c (99%)
 rename {contrib => src/bin}/pg_upgrade/file.c (99%)
 rename {contrib => src/bin}/pg_upgrade/function.c (99%)
 rename {contrib => src/bin}/pg_upgrade/info.c (99%)
 rename {contrib => src/bin}/pg_upgrade/option.c (99%)
 rename {contrib => src/bin}/pg_upgrade/page.c (99%)
 rename {contrib => src/bin}/pg_upgrade/parallel.c (99%)
 rename {contrib => src/bin}/pg_upgrade/pg_upgrade.c (99%)
 rename {contrib => src/bin}/pg_upgrade/pg_upgrade.h (99%)
 rename {contrib => src/bin}/pg_upgrade/relfilenode.c (99%)
 rename {contrib => src/bin}/pg_upgrade/server.c (99%)
 rename {contrib => src/bin}/pg_upgrade/tablespace.c (98%)
 rename {contrib => src/bin}/pg_upgrade/test.sh (98%)
 rename {contrib => src/bin}/pg_upgrade/util.c (99%)
 rename {contrib => src/bin}/pg_upgrade/version.c (99%)

diff --git a/contrib/Makefile b/contrib/Makefile
index c20d4fe..a30eb5a 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -33,7 +33,6 @@ SUBDIRS = \
 		pg_prewarm	\
 		pg_stat_statements \
 		pg_trgm		\
-		pg_upgrade	\
 		pgcrypto	\
 		pgrowlocks	\
 		pgstattuple	\
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index aa47634..a8982db 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -201,6 +201,5 @@ <title>Server Applications</title>
    part of the core <productname>PostgreSQL</productname> distribution.
   </para>
 
- &pgupgrade;
  </sect1>
 </appendix>
diff --git a/doc/src/sgml/pgupgrade.sgml b/doc/src/sgml/pgupgrade.sgml
index 8d70727..bee62c4 100644
--- a/doc/src/sgml/pgupgrade.sgml
+++ b/doc/src/sgml/pgupgrade.sgml
@@ -240,7 +240,8 @@ <title>For source installs, build the new version</title>
     <title>Install the new PostgreSQL binaries</title>
 
     <para>
-     Install the new server's binaries and support files.
+     Install the new server's binaries and support
+     files.  <application>pg_upgrade</> is included in a default installation.
     </para>
 
     <para>
@@ -253,15 +254,6 @@ <title>Install the new PostgreSQL binaries</title>
    </step>
 
    <step>
-    <title>Install pg_upgrade</title>
-
-    <para>
-     Install the <application>pg_upgrade</> binary in the new PostgreSQL
-     installation.
-    </para>
-   </step>
-
-   <step>
     <title>Initialize the new PostgreSQL cluster</title>
 
     <para>
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index ac0ee62..a26ec9f 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -265,6 +265,7 @@ <title>PostgreSQL Server Applications</title>
    &pgstandby;
    &pgtestfsync;
    &pgtesttiming;
+   &pgupgrade;
    &pgxlogdump;
    &postgres;
    &postmaster;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 1e65f2e..1572521 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -25,6 +25,7 @@ SUBDIRS = \
 	pg_standby \
 	pg_test_fsync \
 	pg_test_timing \
+	pg_upgrade \
 	pg_xlogdump \
 	pgbench \
 	psql \
diff --git a/contrib/pg_upgrade/.gitignore b/src/bin/pg_upgrade/.gitignore
similarity index 100%
rename from contrib/pg_upgrade/.gitignore
rename to src/bin/pg_upgrade/.gitignore
diff --git a/contrib/pg_upgrade/IMPLEMENTATION b/src/bin/pg_upgrade/IMPLEMENTATION
similarity index 99%
rename from contrib/pg_upgrade/IMPLEMENTATION
rename to src/bin/pg_upgrade/IMPLEMENTATION
index a0cfcf1..9b5ff72 100644
--- a/contrib/pg_upgrade/IMPLEMENTATION
+++ b/src/bin/pg_upgrade/IMPLEMENTATION
@@ -1,5 +1,3 @@
-contrib/pg_upgrade/IMPLEMENTATION
-
 ------------------------------------------------------------------------------
 PG_UPGRADE: IN-PLACE UPGRADES FOR POSTGRESQL
 ------------------------------------------------------------------------------
diff --git a/contrib/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
similarity index 79%
rename from contrib/pg_upgrade/Makefile
rename to src/bin/pg_upgrade/Makefile
index 87da4b8..c22daa5 100644
--- a/contrib/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -1,8 +1,12 @@
-# contrib/pg_upgrade/Makefile
+# src/bin/pg_upgrade/Makefile
 
 PGFILEDESC = "pg_upgrade - an in-place binary upgrade utility"
 PGAPPICON = win32
 
+subdir = src/bin/pg_upgrade
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
 PROGRAM  = pg_upgrade
 OBJS = check.o controldata.o dump.o exec.o file.o function.o info.o \
        option.o page.o parallel.o pg_upgrade.o relfilenode.o server.o \
@@ -15,16 +19,8 @@ EXTRA_CLEAN = analyze_new_cluster.sh delete_old_cluster.sh log/ tmp_check/ \
               pg_upgrade_dump_globals.sql \
               pg_upgrade_dump_*.custom pg_upgrade_*.log
 
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_upgrade
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
 
 check: test.sh all
 	MAKE=$(MAKE) bindir=$(bindir) libdir=$(libdir) EXTRA_REGRESS_OPTS="$(EXTRA_REGRESS_OPTS)" $(SHELL) $< --install
diff --git a/contrib/pg_upgrade/TESTING b/src/bin/pg_upgrade/TESTING
similarity index 99%
rename from contrib/pg_upgrade/TESTING
rename to src/bin/pg_upgrade/TESTING
index 359688c..4ecfc57 100644
--- a/contrib/pg_upgrade/TESTING
+++ b/src/bin/pg_upgrade/TESTING
@@ -1,5 +1,3 @@
-contrib/pg_upgrade/TESTING
-
 The most effective way to test pg_upgrade, aside from testing on user
 data, is by upgrading the PostgreSQL regression database.
 
diff --git a/contrib/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
similarity index 99%
rename from contrib/pg_upgrade/check.c
rename to src/bin/pg_upgrade/check.c
index 56db0dd..7dfa364 100644
--- a/contrib/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -4,7 +4,7 @@
  *	server checks and output routines
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/check.c
+ *	src/bin/pg_upgrade/check.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
similarity index 99%
rename from contrib/pg_upgrade/controldata.c
rename to src/bin/pg_upgrade/controldata.c
index 4e9d594..f7a87a3 100644
--- a/contrib/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -4,7 +4,7 @@
  *	controldata functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/controldata.c
+ *	src/bin/pg_upgrade/controldata.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
similarity index 99%
rename from contrib/pg_upgrade/dump.c
rename to src/bin/pg_upgrade/dump.c
index 0dfce2b..35954cc 100644
--- a/contrib/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -4,7 +4,7 @@
  *	dump functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/dump.c
+ *	src/bin/pg_upgrade/dump.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
similarity index 99%
rename from contrib/pg_upgrade/exec.c
rename to src/bin/pg_upgrade/exec.c
index c177288..fbc538a 100644
--- a/contrib/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -4,7 +4,7 @@
  *	execution functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/exec.c
+ *	src/bin/pg_upgrade/exec.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
similarity index 99%
rename from contrib/pg_upgrade/file.c
rename to src/bin/pg_upgrade/file.c
index ab9d1ed..a966506 100644
--- a/contrib/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -4,7 +4,7 @@
  *	file system operations
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/file.c
+ *	src/bin/pg_upgrade/file.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
similarity index 99%
rename from contrib/pg_upgrade/function.c
rename to src/bin/pg_upgrade/function.c
index 091119b..8789baf 100644
--- a/contrib/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -4,7 +4,7 @@
  *	server-side function support
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/function.c
+ *	src/bin/pg_upgrade/function.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
similarity index 99%
rename from contrib/pg_upgrade/info.c
rename to src/bin/pg_upgrade/info.c
index c347dfc..22cb3af 100644
--- a/contrib/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -4,7 +4,7 @@
  *	information support functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/info.c
+ *	src/bin/pg_upgrade/info.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c
similarity index 99%
rename from contrib/pg_upgrade/option.c
rename to src/bin/pg_upgrade/option.c
index cfc88ec..4e22ef1 100644
--- a/contrib/pg_upgrade/option.c
+++ b/src/bin/pg_upgrade/option.c
@@ -4,7 +4,7 @@
  *	options functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/option.c
+ *	src/bin/pg_upgrade/option.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/page.c b/src/bin/pg_upgrade/page.c
similarity index 99%
rename from contrib/pg_upgrade/page.c
rename to src/bin/pg_upgrade/page.c
index 6354cec..9a486c5 100644
--- a/contrib/pg_upgrade/page.c
+++ b/src/bin/pg_upgrade/page.c
@@ -4,7 +4,7 @@
  *	per-page conversion operations
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/page.c
+ *	src/bin/pg_upgrade/page.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/parallel.c b/src/bin/pg_upgrade/parallel.c
similarity index 99%
rename from contrib/pg_upgrade/parallel.c
rename to src/bin/pg_upgrade/parallel.c
index 5d2565d..55f73cd 100644
--- a/contrib/pg_upgrade/parallel.c
+++ b/src/bin/pg_upgrade/parallel.c
@@ -4,7 +4,7 @@
  *	multi-process support
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/parallel.c
+ *	src/bin/pg_upgrade/parallel.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
similarity index 99%
rename from contrib/pg_upgrade/pg_upgrade.c
rename to src/bin/pg_upgrade/pg_upgrade.c
index 17c988e..bbc72c2 100644
--- a/contrib/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -4,7 +4,7 @@
  *	main source file
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/pg_upgrade.c
+ *	src/bin/pg_upgrade/pg_upgrade.c
  */
 
 /*
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
similarity index 99%
rename from contrib/pg_upgrade/pg_upgrade.h
rename to src/bin/pg_upgrade/pg_upgrade.h
index d20c1ef..0c473b3 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -2,7 +2,7 @@
  *	pg_upgrade.h
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/pg_upgrade.h
+ *	src/bin/pg_upgrade/pg_upgrade.h
  */
 
 #include <unistd.h>
diff --git a/contrib/pg_upgrade/relfilenode.c b/src/bin/pg_upgrade/relfilenode.c
similarity index 99%
rename from contrib/pg_upgrade/relfilenode.c
rename to src/bin/pg_upgrade/relfilenode.c
index aa6aafd..0ac6185 100644
--- a/contrib/pg_upgrade/relfilenode.c
+++ b/src/bin/pg_upgrade/relfilenode.c
@@ -4,7 +4,7 @@
  *	relfilenode functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/relfilenode.c
+ *	src/bin/pg_upgrade/relfilenode.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
similarity index 99%
rename from contrib/pg_upgrade/server.c
rename to src/bin/pg_upgrade/server.c
index fc0d22e..6353ee1 100644
--- a/contrib/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -4,7 +4,7 @@
  *	database server functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/server.c
+ *	src/bin/pg_upgrade/server.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/tablespace.c b/src/bin/pg_upgrade/tablespace.c
similarity index 98%
rename from contrib/pg_upgrade/tablespace.c
rename to src/bin/pg_upgrade/tablespace.c
index 68e9cb2..f335b84 100644
--- a/contrib/pg_upgrade/tablespace.c
+++ b/src/bin/pg_upgrade/tablespace.c
@@ -4,7 +4,7 @@
  *	tablespace functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/tablespace.c
+ *	src/bin/pg_upgrade/tablespace.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh
similarity index 98%
rename from contrib/pg_upgrade/test.sh
rename to src/bin/pg_upgrade/test.sh
index 81aae74..d6c5f97 100644
--- a/contrib/pg_upgrade/test.sh
+++ b/src/bin/pg_upgrade/test.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# contrib/pg_upgrade/test.sh
+# src/bin/pg_upgrade/test.sh
 #
 # Test driver for pg_upgrade.  Initializes a new database cluster,
 # runs the regression tests (to put in some data), runs pg_dumpall,
@@ -85,9 +85,9 @@ fi
 
 : ${oldbindir=$bindir}
 
-: ${oldsrc=../..}
+: ${oldsrc=../../..}
 oldsrc=`cd "$oldsrc" && pwd`
-newsrc=`cd ../.. && pwd`
+newsrc=`cd ../../.. && pwd`
 
 PATH=$bindir:$PATH
 export PATH
diff --git a/contrib/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c
similarity index 99%
rename from contrib/pg_upgrade/util.c
rename to src/bin/pg_upgrade/util.c
index 79da8d7..4b710fd 100644
--- a/contrib/pg_upgrade/util.c
+++ b/src/bin/pg_upgrade/util.c
@@ -4,7 +4,7 @@
  *	utility functions
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/util.c
+ *	src/bin/pg_upgrade/util.c
  */
 
 #include "postgres_fe.h"
diff --git a/contrib/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
similarity index 99%
rename from contrib/pg_upgrade/version.c
rename to src/bin/pg_upgrade/version.c
index 0f9dc07..e1bebaa 100644
--- a/contrib/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -4,7 +4,7 @@
  *	Postgres-version-specific routines
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade/version.c
+ *	src/bin/pg_upgrade/version.c
  */
 
 #include "postgres_fe.h"
-- 
2.2.0

