Here is a patch series to move

pg_archivecleanup
pg_standby
pg_test_fsync
pg_test_timing
pg_upgrade
pg_xlogdump
pgbench

from contrib/ to src/bin/.

Move people didn't like moving oid2name and vacuumlo, which I
understand.  So I'll leave those for now.

I have also included a patch to move pg_upgrade_support into the
backend, as discussed.

Open issues/discussion points:

- no Windows build system support yet

- I didn't move the source of the man pages to .../sgml/ref.  This could
be done.

- I didn't rename to the SGML ids of the man pages to git the patter of
the other applications, because that would change the name of the HTML
pages.

- We have traditionally kept an individual author acknowledgement in the
man pages for contrib items.  Should those be removed now?

From 0a4b9a4eaf930b8e14b4b3e2077ca7706a65ab6a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sun, 14 Dec 2014 20:41:58 -0500
Subject: [PATCH 1/9] Sort SUBDIRS variable in src/bin/Makefile

The previous order appears to have been historically grown randomness.
---
 src/bin/Makefile | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/bin/Makefile b/src/bin/Makefile
index f03cc42..f0589f3 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -13,8 +13,16 @@ subdir = src/bin
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-SUBDIRS = initdb pg_ctl pg_dump \
-	psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup
+SUBDIRS = \
+	initdb \
+	pg_basebackup \
+	pg_config \
+	pg_controldata \
+	pg_ctl \
+	pg_dump \
+	pg_resetxlog \
+	psql \
+	scripts
 
 ifeq ($(PORTNAME), win32)
 SUBDIRS += pgevent
-- 
2.2.0

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

---
 contrib/Makefile                                       |  1 -
 contrib/pg_archivecleanup/Makefile                     | 18 ------------------
 doc/src/sgml/contrib.sgml                              |  1 -
 doc/src/sgml/reference.sgml                            |  1 +
 src/bin/Makefile                                       |  1 +
 {contrib => src/bin}/pg_archivecleanup/.gitignore      |  0
 src/bin/pg_archivecleanup/Makefile                     | 14 ++++++++++++++
 .../bin}/pg_archivecleanup/pg_archivecleanup.c         |  2 +-
 8 files changed, 17 insertions(+), 21 deletions(-)
 delete mode 100644 contrib/pg_archivecleanup/Makefile
 rename {contrib => src/bin}/pg_archivecleanup/.gitignore (100%)
 create mode 100644 src/bin/pg_archivecleanup/Makefile
 rename {contrib => src/bin}/pg_archivecleanup/pg_archivecleanup.c (99%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 195d447..c56050e 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -28,7 +28,6 @@ SUBDIRS = \
 		oid2name	\
 		pageinspect	\
 		passwordcheck	\
-		pg_archivecleanup \
 		pg_buffercache	\
 		pg_freespacemap \
 		pg_prewarm	\
diff --git a/contrib/pg_archivecleanup/Makefile b/contrib/pg_archivecleanup/Makefile
deleted file mode 100644
index ab52390..0000000
--- a/contrib/pg_archivecleanup/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# contrib/pg_archivecleanup/Makefile
-
-PGFILEDESC = "pg_archivecleanup - cleans archive when used with streaming replication"
-PGAPPICON = win32
-
-PROGRAM = pg_archivecleanup
-OBJS	= pg_archivecleanup.o $(WIN32RES)
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_archivecleanup
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index a698d0f..f21fa14 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -202,7 +202,6 @@ <title>Server Applications</title>
    part of the core <productname>PostgreSQL</productname> distribution.
   </para>
 
- &pgarchivecleanup;
  &pgstandby;
  &pgtestfsync;
  &pgtesttiming;
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index 10c9a6d..62267db 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -257,6 +257,7 @@ <title>PostgreSQL Server Applications</title>
   </partintro>
 
    &initdb;
+   &pgarchivecleanup;
    &pgControldata;
    &pgCtl;
    &pgResetxlog;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index f0589f3..0e7b183 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -15,6 +15,7 @@ include $(top_builddir)/src/Makefile.global
 
 SUBDIRS = \
 	initdb \
+	pg_archivecleanup \
 	pg_basebackup \
 	pg_config \
 	pg_controldata \
diff --git a/contrib/pg_archivecleanup/.gitignore b/src/bin/pg_archivecleanup/.gitignore
similarity index 100%
rename from contrib/pg_archivecleanup/.gitignore
rename to src/bin/pg_archivecleanup/.gitignore
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
new file mode 100644
index 0000000..5df86eb
--- /dev/null
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -0,0 +1,14 @@
+# src/bin/pg_archivecleanup/Makefile
+
+PGFILEDESC = "pg_archivecleanup - cleans archive when used with streaming replication"
+PGAPPICON = win32
+
+subdir = src/bin/pg_archivecleanup
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PROGRAM = pg_archivecleanup
+OBJS	= pg_archivecleanup.o $(WIN32RES)
+
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
diff --git a/contrib/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c
similarity index 99%
rename from contrib/pg_archivecleanup/pg_archivecleanup.c
rename to src/bin/pg_archivecleanup/pg_archivecleanup.c
index 97225a8..2ff2a27 100644
--- a/contrib/pg_archivecleanup/pg_archivecleanup.c
+++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c
@@ -1,5 +1,5 @@
 /*
- * contrib/pg_archivecleanup/pg_archivecleanup.c
+ * src/bin/pg_archivecleanup/pg_archivecleanup.c
  *
  * pg_archivecleanup.c
  *
-- 
2.2.0

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

---
 contrib/Makefile                             |  1 -
 contrib/pg_standby/Makefile                  | 18 ------------------
 doc/src/sgml/contrib.sgml                    |  1 -
 doc/src/sgml/reference.sgml                  |  1 +
 src/bin/Makefile                             |  1 +
 {contrib => src/bin}/pg_standby/.gitignore   |  0
 src/bin/pg_standby/Makefile                  | 14 ++++++++++++++
 {contrib => src/bin}/pg_standby/pg_standby.c |  2 +-
 8 files changed, 17 insertions(+), 21 deletions(-)
 delete mode 100644 contrib/pg_standby/Makefile
 rename {contrib => src/bin}/pg_standby/.gitignore (100%)
 create mode 100644 src/bin/pg_standby/Makefile
 rename {contrib => src/bin}/pg_standby/pg_standby.c (99%)

diff --git a/contrib/Makefile b/contrib/Makefile
index c56050e..1732443 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -31,7 +31,6 @@ SUBDIRS = \
 		pg_buffercache	\
 		pg_freespacemap \
 		pg_prewarm	\
-		pg_standby	\
 		pg_stat_statements \
 		pg_test_fsync	\
 		pg_test_timing	\
diff --git a/contrib/pg_standby/Makefile b/contrib/pg_standby/Makefile
deleted file mode 100644
index 0bca2f8..0000000
--- a/contrib/pg_standby/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# contrib/pg_standby/Makefile
-
-PGFILEDESC = "pg_standby - supports creation of a warm standby"
-PGAPPICON = win32
-
-PROGRAM = pg_standby
-OBJS	= pg_standby.o $(WIN32RES)
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_standby
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index f21fa14..087cd9f 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -202,7 +202,6 @@ <title>Server Applications</title>
    part of the core <productname>PostgreSQL</productname> distribution.
   </para>
 
- &pgstandby;
  &pgtestfsync;
  &pgtesttiming;
  &pgupgrade;
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index 62267db..d47272a 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -261,6 +261,7 @@ <title>PostgreSQL Server Applications</title>
    &pgControldata;
    &pgCtl;
    &pgResetxlog;
+   &pgstandby;
    &postgres;
    &postmaster;
 
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 0e7b183..6026b83 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -22,6 +22,7 @@ SUBDIRS = \
 	pg_ctl \
 	pg_dump \
 	pg_resetxlog \
+	pg_standby \
 	psql \
 	scripts
 
diff --git a/contrib/pg_standby/.gitignore b/src/bin/pg_standby/.gitignore
similarity index 100%
rename from contrib/pg_standby/.gitignore
rename to src/bin/pg_standby/.gitignore
diff --git a/src/bin/pg_standby/Makefile b/src/bin/pg_standby/Makefile
new file mode 100644
index 0000000..d45a47d
--- /dev/null
+++ b/src/bin/pg_standby/Makefile
@@ -0,0 +1,14 @@
+# src/bin/pg_standby/Makefile
+
+PGFILEDESC = "pg_standby - supports creation of a warm standby"
+PGAPPICON = win32
+
+subdir = src/bin/pg_standby
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PROGRAM = pg_standby
+OBJS	= pg_standby.o $(WIN32RES)
+
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
diff --git a/contrib/pg_standby/pg_standby.c b/src/bin/pg_standby/pg_standby.c
similarity index 99%
rename from contrib/pg_standby/pg_standby.c
rename to src/bin/pg_standby/pg_standby.c
index d6b1692..1d45cbf 100644
--- a/contrib/pg_standby/pg_standby.c
+++ b/src/bin/pg_standby/pg_standby.c
@@ -1,5 +1,5 @@
 /*
- * contrib/pg_standby/pg_standby.c
+ * src/bin/pg_standby/pg_standby.c
  *
  *
  * pg_standby.c
-- 
2.2.0

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

---
 contrib/Makefile                               |  1 -
 doc/src/sgml/contrib.sgml                      |  1 -
 doc/src/sgml/reference.sgml                    |  1 +
 src/bin/Makefile                               |  1 +
 {contrib => src/bin}/pg_xlogdump/.gitignore    |  0
 {contrib => src/bin}/pg_xlogdump/Makefile      | 19 ++++++++-----------
 {contrib => src/bin}/pg_xlogdump/compat.c      |  2 +-
 {contrib => src/bin}/pg_xlogdump/pg_xlogdump.c |  2 +-
 {contrib => src/bin}/pg_xlogdump/rmgrdesc.c    |  2 +-
 {contrib => src/bin}/pg_xlogdump/rmgrdesc.h    |  2 +-
 10 files changed, 14 insertions(+), 17 deletions(-)
 rename {contrib => src/bin}/pg_xlogdump/.gitignore (100%)
 rename {contrib => src/bin}/pg_xlogdump/Makefile (76%)
 rename {contrib => src/bin}/pg_xlogdump/compat.c (98%)
 rename {contrib => src/bin}/pg_xlogdump/pg_xlogdump.c (99%)
 rename {contrib => src/bin}/pg_xlogdump/rmgrdesc.c (96%)
 rename {contrib => src/bin}/pg_xlogdump/rmgrdesc.h (91%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 1732443..8f0d926 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -41,7 +41,6 @@ SUBDIRS = \
 		pgcrypto	\
 		pgrowlocks	\
 		pgstattuple	\
-		pg_xlogdump	\
 		postgres_fdw	\
 		seg		\
 		spi		\
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index 087cd9f..dbe9d0a 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -205,6 +205,5 @@ <title>Server Applications</title>
  &pgtestfsync;
  &pgtesttiming;
  &pgupgrade;
- &pgxlogdump;
  </sect1>
 </appendix>
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index d47272a..de2cdff 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -262,6 +262,7 @@ <title>PostgreSQL Server Applications</title>
    &pgCtl;
    &pgResetxlog;
    &pgstandby;
+   &pgxlogdump;
    &postgres;
    &postmaster;
 
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 6026b83..87f5c70 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -23,6 +23,7 @@ SUBDIRS = \
 	pg_dump \
 	pg_resetxlog \
 	pg_standby \
+	pg_xlogdump \
 	psql \
 	scripts
 
diff --git a/contrib/pg_xlogdump/.gitignore b/src/bin/pg_xlogdump/.gitignore
similarity index 100%
rename from contrib/pg_xlogdump/.gitignore
rename to src/bin/pg_xlogdump/.gitignore
diff --git a/contrib/pg_xlogdump/Makefile b/src/bin/pg_xlogdump/Makefile
similarity index 76%
rename from contrib/pg_xlogdump/Makefile
rename to src/bin/pg_xlogdump/Makefile
index 30a8706..ab8597b 100644
--- a/contrib/pg_xlogdump/Makefile
+++ b/src/bin/pg_xlogdump/Makefile
@@ -1,28 +1,25 @@
-# contrib/pg_xlogdump/Makefile
+# src/bin/pg_xlogdump/Makefile
 
 PGFILEDESC = "pg_xlogdump - decode and display WAL"
 PGAPPICON=win32
 
+subdir = src/bin/pg_xlogdump
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
 PROGRAM = pg_xlogdump
 OBJS = pg_xlogdump.o compat.o xlogreader.o rmgrdesc.o \
 	$(RMGRDESCOBJS) $(WIN32RES)
+override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
 
 RMGRDESCSOURCES = $(notdir $(wildcard $(top_srcdir)/src/backend/access/rmgrdesc/*desc.c))
 RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
 
 EXTRA_CLEAN = $(RMGRDESCSOURCES) xlogreader.c
 
-ifdef USE_PGXS
-$(error "pg_xlogdump cannot be built with PGXS")
-endif
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
 
-subdir = contrib/pg_xlogdump
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-
-
-override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
 
 xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
 	rm -f $@ && $(LN_S) $< .
diff --git a/contrib/pg_xlogdump/compat.c b/src/bin/pg_xlogdump/compat.c
similarity index 98%
rename from contrib/pg_xlogdump/compat.c
rename to src/bin/pg_xlogdump/compat.c
index 6ca7012..5c07e1e 100644
--- a/contrib/pg_xlogdump/compat.c
+++ b/src/bin/pg_xlogdump/compat.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 2013-2014, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *		contrib/pg_xlogdump/compat.c
+ *		src/bin/pg_xlogdump/compat.c
  *
  * This file contains client-side implementations for various backend
  * functions that the rm_desc functions in *desc.c files rely on.
diff --git a/contrib/pg_xlogdump/pg_xlogdump.c b/src/bin/pg_xlogdump/pg_xlogdump.c
similarity index 99%
rename from contrib/pg_xlogdump/pg_xlogdump.c
rename to src/bin/pg_xlogdump/pg_xlogdump.c
index 9f05e25..f767a97 100644
--- a/contrib/pg_xlogdump/pg_xlogdump.c
+++ b/src/bin/pg_xlogdump/pg_xlogdump.c
@@ -5,7 +5,7 @@
  * Copyright (c) 2013-2014, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *		  contrib/pg_xlogdump/pg_xlogdump.c
+ *		  src/bin/pg_xlogdump/pg_xlogdump.c
  *-------------------------------------------------------------------------
  */
 
diff --git a/contrib/pg_xlogdump/rmgrdesc.c b/src/bin/pg_xlogdump/rmgrdesc.c
similarity index 96%
rename from contrib/pg_xlogdump/rmgrdesc.c
rename to src/bin/pg_xlogdump/rmgrdesc.c
index 180818d..4fb0a00 100644
--- a/contrib/pg_xlogdump/rmgrdesc.c
+++ b/src/bin/pg_xlogdump/rmgrdesc.c
@@ -3,7 +3,7 @@
  *
  * pg_xlogdump resource managers definition
  *
- * contrib/pg_xlogdump/rmgrdesc.c
+ * src/bin/pg_xlogdump/rmgrdesc.c
  */
 #define FRONTEND 1
 #include "postgres.h"
diff --git a/contrib/pg_xlogdump/rmgrdesc.h b/src/bin/pg_xlogdump/rmgrdesc.h
similarity index 91%
rename from contrib/pg_xlogdump/rmgrdesc.h
rename to src/bin/pg_xlogdump/rmgrdesc.h
index aec4418..5440f94 100644
--- a/contrib/pg_xlogdump/rmgrdesc.h
+++ b/src/bin/pg_xlogdump/rmgrdesc.h
@@ -3,7 +3,7 @@
  *
  * pg_xlogdump resource managers declaration
  *
- * contrib/pg_xlogdump/rmgrdesc.h
+ * src/bin/pg_xlogdump/rmgrdesc.h
  */
 #ifndef RMGRDESC_H
 #define RMGRDESC_H
-- 
2.2.0

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

---
 contrib/Makefile                        |  1 -
 doc/src/sgml/contrib.sgml               |  1 -
 doc/src/sgml/reference.sgml             |  1 +
 src/bin/Makefile                        |  1 +
 {contrib => src/bin}/pgbench/.gitignore |  0
 {contrib => src/bin}/pgbench/Makefile   | 18 +++++++-----------
 {contrib => src/bin}/pgbench/pgbench.c  |  2 +-
 7 files changed, 10 insertions(+), 14 deletions(-)
 rename {contrib => src/bin}/pgbench/.gitignore (100%)
 rename {contrib => src/bin}/pgbench/Makefile (59%)
 rename {contrib => src/bin}/pgbench/pgbench.c (99%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 8f0d926..12c7500 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -37,7 +37,6 @@ SUBDIRS = \
 		pg_trgm		\
 		pg_upgrade	\
 		pg_upgrade_support \
-		pgbench		\
 		pgcrypto	\
 		pgrowlocks	\
 		pgstattuple	\
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index dbe9d0a..60c07ea 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -187,7 +187,6 @@ <title>Client Applications</title>
   </para>
 
  &oid2name;
- &pgbench;
  &vacuumlo;
  </sect1>
 
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index de2cdff..a839af7 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -230,6 +230,7 @@ <title>PostgreSQL Client Applications</title>
    &dropuser;
    &ecpgRef;
    &pgBasebackup;
+   &pgbench;
    &pgConfig;
    &pgDump;
    &pgDumpall;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 87f5c70..39d7e7d 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -24,6 +24,7 @@ SUBDIRS = \
 	pg_resetxlog \
 	pg_standby \
 	pg_xlogdump \
+	pgbench \
 	psql \
 	scripts
 
diff --git a/contrib/pgbench/.gitignore b/src/bin/pgbench/.gitignore
similarity index 100%
rename from contrib/pgbench/.gitignore
rename to src/bin/pgbench/.gitignore
diff --git a/contrib/pgbench/Makefile b/src/bin/pgbench/Makefile
similarity index 59%
rename from contrib/pgbench/Makefile
rename to src/bin/pgbench/Makefile
index b8e2fc8..de4863c 100644
--- a/contrib/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -1,24 +1,20 @@
-# contrib/pgbench/Makefile
+# src/bin/pgbench/Makefile
 
 PGFILEDESC = "pgbench - a simple program for running benchmark tests"
 PGAPPICON = win32
 
+subdir = src/bin/pgbench
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
 PROGRAM = pgbench
 OBJS	= pgbench.o $(WIN32RES)
 
 PG_CPPFLAGS = -I$(libpq_srcdir)
 PG_LIBS = $(libpq_pgport) $(PTHREAD_LIBS)
 
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pgbench
-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
 
 ifneq ($(PORTNAME), win32)
 override CFLAGS += $(PTHREAD_CFLAGS)
diff --git a/contrib/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
similarity index 99%
rename from contrib/pgbench/pgbench.c
rename to src/bin/pgbench/pgbench.c
index 3453a1f..616c986 100644
--- a/contrib/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -4,7 +4,7 @@
  * A simple benchmark program for PostgreSQL
  * Originally written by Tatsuo Ishii and enhanced by many contributors.
  *
- * contrib/pgbench/pgbench.c
+ * src/bin/pgbench/pgbench.c
  * Copyright (c) 2000-2014, PostgreSQL Global Development Group
  * ALL RIGHTS RESERVED;
  *
-- 
2.2.0

From 94101dd7ac2c93ea7958b6e6d29c5c039fb63fdb 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 6/9] Move pg_test_fsync from contrib/ to src/bin/

---
 contrib/Makefile                                   |  1 -
 contrib/pg_test_fsync/Makefile                     | 18 ------------------
 doc/src/sgml/contrib.sgml                          |  1 -
 doc/src/sgml/reference.sgml                        |  1 +
 src/bin/Makefile                                   |  1 +
 {contrib => src/bin}/pg_test_fsync/.gitignore      |  0
 src/bin/pg_test_fsync/Makefile                     | 14 ++++++++++++++
 {contrib => src/bin}/pg_test_fsync/pg_test_fsync.c |  0
 8 files changed, 16 insertions(+), 20 deletions(-)
 delete mode 100644 contrib/pg_test_fsync/Makefile
 rename {contrib => src/bin}/pg_test_fsync/.gitignore (100%)
 create mode 100644 src/bin/pg_test_fsync/Makefile
 rename {contrib => src/bin}/pg_test_fsync/pg_test_fsync.c (100%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 12c7500..6809ec8 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -32,7 +32,6 @@ SUBDIRS = \
 		pg_freespacemap \
 		pg_prewarm	\
 		pg_stat_statements \
-		pg_test_fsync	\
 		pg_test_timing	\
 		pg_trgm		\
 		pg_upgrade	\
diff --git a/contrib/pg_test_fsync/Makefile b/contrib/pg_test_fsync/Makefile
deleted file mode 100644
index 15afba7..0000000
--- a/contrib/pg_test_fsync/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# contrib/pg_test_fsync/Makefile
-
-PGFILEDESC = "pg_test_fsync - test various disk sync methods"
-PGAPPICON = win32
-
-PROGRAM  = pg_test_fsync
-OBJS = pg_test_fsync.o $(WIN32RES)
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_test_fsync
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index 60c07ea..57f4bbf 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -201,7 +201,6 @@ <title>Server Applications</title>
    part of the core <productname>PostgreSQL</productname> distribution.
   </para>
 
- &pgtestfsync;
  &pgtesttiming;
  &pgupgrade;
  </sect1>
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index a839af7..c766c7b 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -263,6 +263,7 @@ <title>PostgreSQL Server Applications</title>
    &pgCtl;
    &pgResetxlog;
    &pgstandby;
+   &pgtestfsync;
    &pgxlogdump;
    &postgres;
    &postmaster;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index 39d7e7d..e628a2c 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -23,6 +23,7 @@ SUBDIRS = \
 	pg_dump \
 	pg_resetxlog \
 	pg_standby \
+	pg_test_fsync \
 	pg_xlogdump \
 	pgbench \
 	psql \
diff --git a/contrib/pg_test_fsync/.gitignore b/src/bin/pg_test_fsync/.gitignore
similarity index 100%
rename from contrib/pg_test_fsync/.gitignore
rename to src/bin/pg_test_fsync/.gitignore
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
new file mode 100644
index 0000000..e8d1952
--- /dev/null
+++ b/src/bin/pg_test_fsync/Makefile
@@ -0,0 +1,14 @@
+# src/bin/pg_test_fsync/Makefile
+
+PGFILEDESC = "pg_test_fsync - test various disk sync methods"
+PGAPPICON = win32
+
+subdir = src/bin/pg_test_fsync
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PROGRAM  = pg_test_fsync
+OBJS = pg_test_fsync.o $(WIN32RES)
+
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
similarity index 100%
rename from contrib/pg_test_fsync/pg_test_fsync.c
rename to src/bin/pg_test_fsync/pg_test_fsync.c
-- 
2.2.0

From 01401e07f45dc51762080a0f09e2d6625b59233e 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 7/9] Move pg_test_timing from contrib/ to src/bin/

---
 contrib/Makefile                                     |  1 -
 contrib/pg_test_timing/Makefile                      | 18 ------------------
 doc/src/sgml/contrib.sgml                            |  1 -
 doc/src/sgml/reference.sgml                          |  1 +
 src/bin/Makefile                                     |  1 +
 {contrib => src/bin}/pg_test_timing/.gitignore       |  0
 src/bin/pg_test_timing/Makefile                      | 14 ++++++++++++++
 {contrib => src/bin}/pg_test_timing/pg_test_timing.c |  0
 8 files changed, 16 insertions(+), 20 deletions(-)
 delete mode 100644 contrib/pg_test_timing/Makefile
 rename {contrib => src/bin}/pg_test_timing/.gitignore (100%)
 create mode 100644 src/bin/pg_test_timing/Makefile
 rename {contrib => src/bin}/pg_test_timing/pg_test_timing.c (100%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 6809ec8..6ff409b 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -32,7 +32,6 @@ SUBDIRS = \
 		pg_freespacemap \
 		pg_prewarm	\
 		pg_stat_statements \
-		pg_test_timing	\
 		pg_trgm		\
 		pg_upgrade	\
 		pg_upgrade_support \
diff --git a/contrib/pg_test_timing/Makefile b/contrib/pg_test_timing/Makefile
deleted file mode 100644
index 8b37aa8..0000000
--- a/contrib/pg_test_timing/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# contrib/pg_test_timing/Makefile
-
-PGFILEDESC = "pg_test_timing - test timing overhead"
-PGAPPICON = win32
-
-PROGRAM  = pg_test_timing
-OBJS = pg_test_timing.o $(WIN32RES)
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_test_timing
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/doc/src/sgml/contrib.sgml b/doc/src/sgml/contrib.sgml
index 57f4bbf..aa47634 100644
--- a/doc/src/sgml/contrib.sgml
+++ b/doc/src/sgml/contrib.sgml
@@ -201,7 +201,6 @@ <title>Server Applications</title>
    part of the core <productname>PostgreSQL</productname> distribution.
   </para>
 
- &pgtesttiming;
  &pgupgrade;
  </sect1>
 </appendix>
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index c766c7b..ac0ee62 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -264,6 +264,7 @@ <title>PostgreSQL Server Applications</title>
    &pgResetxlog;
    &pgstandby;
    &pgtestfsync;
+   &pgtesttiming;
    &pgxlogdump;
    &postgres;
    &postmaster;
diff --git a/src/bin/Makefile b/src/bin/Makefile
index e628a2c..1e65f2e 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -24,6 +24,7 @@ SUBDIRS = \
 	pg_resetxlog \
 	pg_standby \
 	pg_test_fsync \
+	pg_test_timing \
 	pg_xlogdump \
 	pgbench \
 	psql \
diff --git a/contrib/pg_test_timing/.gitignore b/src/bin/pg_test_timing/.gitignore
similarity index 100%
rename from contrib/pg_test_timing/.gitignore
rename to src/bin/pg_test_timing/.gitignore
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
new file mode 100644
index 0000000..f96d2e9
--- /dev/null
+++ b/src/bin/pg_test_timing/Makefile
@@ -0,0 +1,14 @@
+# src/bin/pg_test_timing/Makefile
+
+PGFILEDESC = "pg_test_timing - test timing overhead"
+PGAPPICON = win32
+
+subdir = src/bin/pg_test_timing
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PROGRAM  = pg_test_timing
+OBJS = pg_test_timing.o $(WIN32RES)
+
+NO_PGXS = 1
+include $(top_srcdir)/src/makefiles/pgxs.mk
diff --git a/contrib/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c
similarity index 100%
rename from contrib/pg_test_timing/pg_test_timing.c
rename to src/bin/pg_test_timing/pg_test_timing.c
-- 
2.2.0

From 7062fabcb4a8fc4e01460c6377bf14cf45b66db3 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 8/9] Integrate pg_upgrade_support module into backend

Previously, these functions were created in a schema "binary_upgrade",
which was deleted after pg_upgrade was finished.  Because we don't want
to keep that schema around permanently, move them to pg_catalog but
rename them with a binary_upgrade_... prefix.

The provided functions are only small wrappers around global variables
that were added specifically for pg_upgrade use, so keeping the module
separate does not create any modularity.

The functions still check that they are only called in binary upgrade
mode, so it is not possible to call these during normal operation.
---
 contrib/Makefile                                   |   1 -
 contrib/pg_upgrade/dump.c                          |   2 +-
 contrib/pg_upgrade/function.c                      | 113 ---------------------
 contrib/pg_upgrade/pg_upgrade.c                    |  27 -----
 contrib/pg_upgrade/pg_upgrade.h                    |   2 -
 contrib/pg_upgrade/test.sh                         |   1 -
 contrib/pg_upgrade_support/Makefile                |  16 ---
 doc/src/sgml/pgupgrade.sgml                        |   5 +-
 src/backend/catalog/heap.c                         |   2 +-
 src/backend/catalog/index.c                        |   2 +-
 src/backend/catalog/pg_enum.c                      |   2 +-
 src/backend/catalog/pg_type.c                      |   2 +-
 src/backend/catalog/toasting.c                     |   2 +-
 src/backend/commands/typecmds.c                    |   2 +-
 src/backend/commands/user.c                        |   2 +-
 src/backend/utils/adt/Makefile                     |   2 +-
 .../backend/utils/adt}/pg_upgrade_support.c        |  45 ++++----
 src/bin/pg_dump/pg_dump.c                          |  18 ++--
 src/bin/pg_dump/pg_dumpall.c                       |   2 +-
 src/include/catalog/pg_proc.h                      |  20 ++++
 20 files changed, 60 insertions(+), 208 deletions(-)
 delete mode 100644 contrib/pg_upgrade_support/Makefile
 rename {contrib/pg_upgrade_support => src/backend/utils/adt}/pg_upgrade_support.c (73%)

diff --git a/contrib/Makefile b/contrib/Makefile
index 6ff409b..c20d4fe 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -34,7 +34,6 @@ SUBDIRS = \
 		pg_stat_statements \
 		pg_trgm		\
 		pg_upgrade	\
-		pg_upgrade_support \
 		pgcrypto	\
 		pgrowlocks	\
 		pgstattuple	\
diff --git a/contrib/pg_upgrade/dump.c b/contrib/pg_upgrade/dump.c
index e623a22..0dfce2b 100644
--- a/contrib/pg_upgrade/dump.c
+++ b/contrib/pg_upgrade/dump.c
@@ -121,7 +121,7 @@ optionally_create_toast_tables(void)
 		for (rowno = 0; rowno < ntups; rowno++)
 		{
 			/* enable auto-oid-numbered TOAST creation if needed */
-			PQclear(executeQueryOrDie(conn, "SELECT binary_upgrade.set_next_toast_pg_class_oid('%d'::pg_catalog.oid);",
+			PQclear(executeQueryOrDie(conn, "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%d'::pg_catalog.oid);",
 					OPTIONALLY_CREATE_TOAST_OID));
 
 			/* dummy command that also triggers check for required TOAST table */
diff --git a/contrib/pg_upgrade/function.c b/contrib/pg_upgrade/function.c
index a4dec6e..091119b 100644
--- a/contrib/pg_upgrade/function.c
+++ b/contrib/pg_upgrade/function.c
@@ -13,112 +13,6 @@
 
 #include "access/transam.h"
 
-#define PG_UPGRADE_SUPPORT	"$libdir/pg_upgrade_support"
-
-/*
- * install_support_functions_in_new_db()
- *
- * pg_upgrade requires some support functions that enable it to modify
- * backend behavior.
- */
-void
-install_support_functions_in_new_db(const char *db_name)
-{
-	PGconn	   *conn = connectToServer(&new_cluster, db_name);
-
-	/* suppress NOTICE of dropped objects */
-	PQclear(executeQueryOrDie(conn,
-							  "SET client_min_messages = warning;"));
-	PQclear(executeQueryOrDie(conn,
-						   "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;"));
-	PQclear(executeQueryOrDie(conn,
-							  "RESET client_min_messages;"));
-
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE SCHEMA binary_upgrade;"));
-
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							  "binary_upgrade.set_next_pg_type_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							"binary_upgrade.set_next_array_pg_type_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							"binary_upgrade.set_next_toast_pg_type_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							"binary_upgrade.set_next_heap_pg_class_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-						   "binary_upgrade.set_next_index_pg_class_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-						   "binary_upgrade.set_next_toast_pg_class_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							  "binary_upgrade.set_next_pg_enum_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							  "binary_upgrade.set_next_pg_authid_oid(OID) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C STRICT;"));
-	PQclear(executeQueryOrDie(conn,
-							  "CREATE OR REPLACE FUNCTION "
-							  "binary_upgrade.create_empty_extension(text, text, bool, text, oid[], text[], text[]) "
-							  "RETURNS VOID "
-							  "AS '$libdir/pg_upgrade_support' "
-							  "LANGUAGE C;"));
-	PQfinish(conn);
-}
-
-
-void
-uninstall_support_functions_from_new_cluster(void)
-{
-	int			dbnum;
-
-	prep_status("Removing support functions from new cluster");
-
-	for (dbnum = 0; dbnum < new_cluster.dbarr.ndbs; dbnum++)
-	{
-		DbInfo	   *new_db = &new_cluster.dbarr.dbs[dbnum];
-		PGconn	   *conn = connectToServer(&new_cluster, new_db->db_name);
-
-		/* suppress NOTICE of dropped objects */
-		PQclear(executeQueryOrDie(conn,
-								  "SET client_min_messages = warning;"));
-		PQclear(executeQueryOrDie(conn,
-								  "DROP SCHEMA binary_upgrade CASCADE;"));
-		PQclear(executeQueryOrDie(conn,
-								  "RESET client_min_messages;"));
-		PQfinish(conn);
-	}
-	check_ok();
-}
-
 
 /*
  * get_loadable_libraries()
@@ -218,8 +112,6 @@ get_loadable_libraries(void)
 	if (found_public_plpython_handler)
 		pg_fatal("Remove the problem functions from the old cluster to continue.\n");
 
-	totaltups++;				/* reserve for pg_upgrade_support */
-
 	/* Allocate what's certainly enough space */
 	os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
 
@@ -228,7 +120,6 @@ get_loadable_libraries(void)
 	 * there probably aren't enough entries to matter.
 	 */
 	totaltups = 0;
-	os_info.libraries[totaltups++] = pg_strdup(PG_UPGRADE_SUPPORT);
 
 	for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
 	{
@@ -321,10 +212,6 @@ check_loadable_libraries(void)
 		{
 			found = true;
 
-			/* exit and report missing support library with special message */
-			if (strcmp(lib, PG_UPGRADE_SUPPORT) == 0)
-				pg_fatal("The pg_upgrade_support module must be created and installed in the new cluster.\n");
-
 			if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
 				pg_fatal("Could not open file \"%s\": %s\n",
 						 output_path, getErrorText(errno));
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
index dd1113e..17c988e 100644
--- a/contrib/pg_upgrade/pg_upgrade.c
+++ b/contrib/pg_upgrade/pg_upgrade.c
@@ -276,14 +276,6 @@ prepare_new_databases(void)
 	prep_status("Restoring global objects in the new cluster");
 
 	/*
-	 * Install support functions in the global-object restore database to
-	 * preserve pg_authid.oid.  pg_dumpall uses 'template0' as its template
-	 * database so objects we add into 'template1' are not propogated.  They
-	 * are removed on pg_upgrade exit.
-	 */
-	install_support_functions_in_new_db("template1");
-
-	/*
 	 * We have to create the databases first so we can install support
 	 * functions in all the other databases.  Ideally we could create the
 	 * support functions in template1 but pg_dumpall creates database using
@@ -305,23 +297,6 @@ create_new_objects(void)
 {
 	int			dbnum;
 
-	prep_status("Adding support functions to new cluster");
-
-	/*
-	 * Technically, we only need to install these support functions in new
-	 * databases that also exist in the old cluster, but for completeness we
-	 * process all new databases.
-	 */
-	for (dbnum = 0; dbnum < new_cluster.dbarr.ndbs; dbnum++)
-	{
-		DbInfo	   *new_db = &new_cluster.dbarr.dbs[dbnum];
-
-		/* skip db we already installed */
-		if (strcmp(new_db->db_name, "template1") != 0)
-			install_support_functions_in_new_db(new_db->db_name);
-	}
-	check_ok();
-
 	prep_status("Restoring database schemas in the new cluster\n");
 
 	for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
@@ -365,8 +340,6 @@ create_new_objects(void)
 
 	/* regenerate now that we have objects in the databases */
 	get_db_and_rel_infos(&new_cluster);
-
-	uninstall_support_functions_from_new_cluster();
 }
 
 /*
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index c3b81e4..d20c1ef 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/contrib/pg_upgrade/pg_upgrade.h
@@ -406,8 +406,6 @@ FILE	   *fopen_priv(const char *path, const char *mode);
 
 /* function.c */
 
-void		install_support_functions_in_new_db(const char *db_name);
-void		uninstall_support_functions_from_new_cluster(void);
 void		get_loadable_libraries(void);
 void		check_loadable_libraries(void);
 
diff --git a/contrib/pg_upgrade/test.sh b/contrib/pg_upgrade/test.sh
index 7bbd2c7..81aae74 100644
--- a/contrib/pg_upgrade/test.sh
+++ b/contrib/pg_upgrade/test.sh
@@ -63,7 +63,6 @@ if [ "$1" = '--install' ]; then
 	libdir=$temp_install/$libdir
 
 	"$MAKE" -s -C ../.. install DESTDIR="$temp_install"
-	"$MAKE" -s -C ../pg_upgrade_support install DESTDIR="$temp_install"
 	"$MAKE" -s -C . install DESTDIR="$temp_install"
 
 	# platform-specific magic to find the shared libraries; see pg_regress.c
diff --git a/contrib/pg_upgrade_support/Makefile b/contrib/pg_upgrade_support/Makefile
deleted file mode 100644
index f7def16..0000000
--- a/contrib/pg_upgrade_support/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# contrib/pg_upgrade_support/Makefile
-
-PGFILEDESC = "pg_upgrade_support - server-side functions for pg_upgrade"
-
-MODULES = pg_upgrade_support
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_upgrade_support
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/doc/src/sgml/pgupgrade.sgml b/doc/src/sgml/pgupgrade.sgml
index e1cd260..8d70727 100644
--- a/doc/src/sgml/pgupgrade.sgml
+++ b/doc/src/sgml/pgupgrade.sgml
@@ -253,11 +253,10 @@ <title>Install the new PostgreSQL binaries</title>
    </step>
 
    <step>
-    <title>Install pg_upgrade and pg_upgrade_support</title>
+    <title>Install pg_upgrade</title>
 
     <para>
-     Install the <application>pg_upgrade</> binary and
-     <application>pg_upgrade_support</> library in the new PostgreSQL
+     Install the <application>pg_upgrade</> binary in the new PostgreSQL
      installation.
     </para>
    </step>
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index e523ee9..c7392e9 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -76,7 +76,7 @@
 #include "utils/tqual.h"
 
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_heap_pg_class_oid = InvalidOid;
 Oid			binary_upgrade_next_toast_pg_class_oid = InvalidOid;
 
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 844d413..f096fd5 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -69,7 +69,7 @@
 #include "utils/tqual.h"
 
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_index_pg_class_oid = InvalidOid;
 
 /* state info for validate_index bulkdelete callback */
diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c
index 086e80e..d1209a0 100644
--- a/src/backend/catalog/pg_enum.c
+++ b/src/backend/catalog/pg_enum.c
@@ -31,7 +31,7 @@
 #include "utils/tqual.h"
 
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_pg_enum_oid = InvalidOid;
 
 static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index f1329f8..1c84a71 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -36,7 +36,7 @@
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_pg_type_oid = InvalidOid;
 
 /* ----------------------------------------------------------------
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 5ef6dcc..2532154 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -32,7 +32,7 @@
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_toast_pg_type_oid = InvalidOid;
 
 static void CheckAndCreateToastTable(Oid relOid, Datum reloptions,
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index cbb65f8..c9fd191 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -87,7 +87,7 @@ typedef struct
 	/* atts[] is of allocated length RelationGetNumberOfAttributes(rel) */
 } RelToCheck;
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_array_pg_type_oid = InvalidOid;
 
 static void makeRangeConstructors(const char *name, Oid namespace,
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 1a73fd8..3f003d3 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -38,7 +38,7 @@
 #include "utils/timestamp.h"
 #include "utils/tqual.h"
 
-/* Potentially set by contrib/pg_upgrade_support functions */
+/* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_pg_authid_oid = InvalidOid;
 
 
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index 3ea9bf4..732974b 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -25,7 +25,7 @@ OBJS = acl.o arrayfuncs.o array_selfuncs.o array_typanalyze.o \
 	jsonfuncs.o like.o lockfuncs.o mac.o misc.o nabstime.o name.o \
 	network.o network_gist.o network_selfuncs.o \
 	numeric.o numutils.o oid.o oracle_compat.o \
-	orderedsetaggs.o pg_lzcompress.o pg_locale.o pg_lsn.o \
+	orderedsetaggs.o pg_lzcompress.o pg_locale.o pg_lsn.o pg_upgrade_support.o \
 	pgstatfuncs.o pseudotypes.o quote.o rangetypes.o rangetypes_gist.o \
 	rangetypes_selfuncs.o rangetypes_spgist.o rangetypes_typanalyze.o \
 	regexp.o regproc.o ri_triggers.o rowtypes.o ruleutils.o \
diff --git a/contrib/pg_upgrade_support/pg_upgrade_support.c b/src/backend/utils/adt/pg_upgrade_support.c
similarity index 73%
rename from contrib/pg_upgrade_support/pg_upgrade_support.c
rename to src/backend/utils/adt/pg_upgrade_support.c
index beaee76..89a104b 100644
--- a/contrib/pg_upgrade_support/pg_upgrade_support.c
+++ b/src/backend/utils/adt/pg_upgrade_support.c
@@ -6,7 +6,7 @@
  *	hacks needed for pg_upgrade.
  *
  *	Copyright (c) 2010-2014, PostgreSQL Global Development Group
- *	contrib/pg_upgrade_support/pg_upgrade_support.c
+ *	src/backend/utils/adt/pg_upgrade_support.c
  */
 
 #include "postgres.h"
@@ -19,24 +19,17 @@
 #include "utils/array.h"
 #include "utils/builtins.h"
 
-/* THIS IS USED ONLY FOR PG >= 9.0 */
 
-#ifdef PG_MODULE_MAGIC
-PG_MODULE_MAGIC;
-#endif
+Datum binary_upgrade_set_next_pg_type_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_array_pg_type_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_toast_pg_type_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_heap_pg_class_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_index_pg_class_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_toast_pg_class_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_pg_enum_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_set_next_pg_authid_oid(PG_FUNCTION_ARGS);
+Datum binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS);
 
-PG_FUNCTION_INFO_V1(set_next_pg_type_oid);
-PG_FUNCTION_INFO_V1(set_next_array_pg_type_oid);
-PG_FUNCTION_INFO_V1(set_next_toast_pg_type_oid);
-
-PG_FUNCTION_INFO_V1(set_next_heap_pg_class_oid);
-PG_FUNCTION_INFO_V1(set_next_index_pg_class_oid);
-PG_FUNCTION_INFO_V1(set_next_toast_pg_class_oid);
-
-PG_FUNCTION_INFO_V1(set_next_pg_enum_oid);
-PG_FUNCTION_INFO_V1(set_next_pg_authid_oid);
-
-PG_FUNCTION_INFO_V1(create_empty_extension);
 
 #define CHECK_IS_BINARY_UPGRADE 								\
 do { 															\
@@ -47,7 +40,7 @@ do { 															\
 } while (0)
 
 Datum
-set_next_pg_type_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_pg_type_oid(PG_FUNCTION_ARGS)
 {
 	Oid			typoid = PG_GETARG_OID(0);
 
@@ -58,7 +51,7 @@ set_next_pg_type_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_array_pg_type_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_array_pg_type_oid(PG_FUNCTION_ARGS)
 {
 	Oid			typoid = PG_GETARG_OID(0);
 
@@ -69,7 +62,7 @@ set_next_array_pg_type_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_toast_pg_type_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_toast_pg_type_oid(PG_FUNCTION_ARGS)
 {
 	Oid			typoid = PG_GETARG_OID(0);
 
@@ -80,7 +73,7 @@ set_next_toast_pg_type_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_heap_pg_class_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_heap_pg_class_oid(PG_FUNCTION_ARGS)
 {
 	Oid			reloid = PG_GETARG_OID(0);
 
@@ -91,7 +84,7 @@ set_next_heap_pg_class_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_index_pg_class_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_index_pg_class_oid(PG_FUNCTION_ARGS)
 {
 	Oid			reloid = PG_GETARG_OID(0);
 
@@ -102,7 +95,7 @@ set_next_index_pg_class_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_toast_pg_class_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_toast_pg_class_oid(PG_FUNCTION_ARGS)
 {
 	Oid			reloid = PG_GETARG_OID(0);
 
@@ -113,7 +106,7 @@ set_next_toast_pg_class_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_pg_enum_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_pg_enum_oid(PG_FUNCTION_ARGS)
 {
 	Oid			enumoid = PG_GETARG_OID(0);
 
@@ -124,7 +117,7 @@ set_next_pg_enum_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-set_next_pg_authid_oid(PG_FUNCTION_ARGS)
+binary_upgrade_set_next_pg_authid_oid(PG_FUNCTION_ARGS)
 {
 	Oid			authoid = PG_GETARG_OID(0);
 
@@ -134,7 +127,7 @@ set_next_pg_authid_oid(PG_FUNCTION_ARGS)
 }
 
 Datum
-create_empty_extension(PG_FUNCTION_ARGS)
+binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
 {
 	text	   *extName = PG_GETARG_TEXT_PP(0);
 	text	   *schemaName = PG_GETARG_TEXT_PP(1);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4175ddc..6c5261b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3014,7 +3014,7 @@ binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
 
 	appendPQExpBufferStr(upgrade_buffer, "\n-- For binary upgrade, must preserve pg_type oid\n");
 	appendPQExpBuffer(upgrade_buffer,
-	 "SELECT binary_upgrade.set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
+	 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
 					  pg_type_oid);
 
 	/* we only support old >= 8.3 for binary upgrades */
@@ -3033,7 +3033,7 @@ binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
 		appendPQExpBufferStr(upgrade_buffer,
 			   "\n-- For binary upgrade, must preserve pg_type array oid\n");
 		appendPQExpBuffer(upgrade_buffer,
-						  "SELECT binary_upgrade.set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
+						  "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
 						  pg_type_array_oid);
 	}
 
@@ -3075,7 +3075,7 @@ binary_upgrade_set_type_oids_by_rel_oid(Archive *fout,
 
 		appendPQExpBufferStr(upgrade_buffer, "\n-- For binary upgrade, must preserve pg_type toast oid\n");
 		appendPQExpBuffer(upgrade_buffer,
-						  "SELECT binary_upgrade.set_next_toast_pg_type_oid('%u'::pg_catalog.oid);\n\n",
+						  "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_type_oid('%u'::pg_catalog.oid);\n\n",
 						  pg_type_toast_oid);
 
 		toast_set = true;
@@ -3115,7 +3115,7 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
 	if (!is_index)
 	{
 		appendPQExpBuffer(upgrade_buffer,
-						  "SELECT binary_upgrade.set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
+						  "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
 						  pg_class_oid);
 		/* only tables have toast tables, not indexes */
 		if (OidIsValid(pg_class_reltoastrelid))
@@ -3130,18 +3130,18 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
 			 */
 
 			appendPQExpBuffer(upgrade_buffer,
-							  "SELECT binary_upgrade.set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
+							  "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
 							  pg_class_reltoastrelid);
 
 			/* every toast table has an index */
 			appendPQExpBuffer(upgrade_buffer,
-							  "SELECT binary_upgrade.set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
+							  "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
 							  pg_index_indexrelid);
 		}
 	}
 	else
 		appendPQExpBuffer(upgrade_buffer,
-						  "SELECT binary_upgrade.set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
+						  "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
 						  pg_class_oid);
 
 	appendPQExpBufferChar(upgrade_buffer, '\n');
@@ -8360,7 +8360,7 @@ dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
 		appendPQExpBuffer(q, "DROP EXTENSION IF EXISTS %s;\n", qextname);
 
 		appendPQExpBufferStr(q,
-							 "SELECT binary_upgrade.create_empty_extension(");
+							 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
 		appendStringLiteralAH(q, extinfo->dobj.name, fout);
 		appendPQExpBufferStr(q, ", ");
 		appendStringLiteralAH(q, extinfo->namespace, fout);
@@ -8538,7 +8538,7 @@ dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
 			if (i == 0)
 				appendPQExpBufferStr(q, "\n-- For binary upgrade, must preserve pg_enum oids\n");
 			appendPQExpBuffer(q,
-							  "SELECT binary_upgrade.set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
+							  "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
 							  enum_oid);
 			appendPQExpBuffer(q, "ALTER TYPE %s.",
 							  fmtId(tyinfo->dobj.namespace->dobj.name));
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index eb633bc..1955932 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -781,7 +781,7 @@ dumpRoles(PGconn *conn)
 		{
 			appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve pg_authid.oid\n");
 			appendPQExpBuffer(buf,
-							  "SELECT binary_upgrade.set_next_pg_authid_oid('%u'::pg_catalog.oid);\n\n",
+							  "SELECT pg_catalog.binary_upgrade_set_next_pg_authid_oid('%u'::pg_catalog.oid);\n\n",
 							  auth_oid);
 		}
 
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index e5912ea..6ab05de 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -5135,6 +5135,26 @@ DESCR("rank of hypothetical row without gaps");
 DATA(insert OID = 3993 ( dense_rank_final	PGNSP PGUID 12 1 0 2276 0 f f f f f f i 2 0 20 "2281 2276" "{2281,2276}" "{i,v}" _null_ _null_	hypothetical_dense_rank_final _null_ _null_ _null_ ));
 DESCR("aggregate final function");
 
+/* pg_upgrade support */
+DATA(insert OID = 3584 ( binary_upgrade_set_next_pg_type_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_pg_type_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3585 ( binary_upgrade_set_next_array_pg_type_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_array_pg_type_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3586 ( binary_upgrade_set_next_toast_pg_type_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_toast_pg_type_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3587 ( binary_upgrade_set_next_heap_pg_class_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_heap_pg_class_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3588 ( binary_upgrade_set_next_index_pg_class_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_index_pg_class_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3589 ( binary_upgrade_set_next_toast_pg_class_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_toast_pg_class_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3590 ( binary_upgrade_set_next_pg_enum_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_pg_enum_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3591 ( binary_upgrade_set_next_pg_authid_oid PGNSP PGUID  12 1 0 0 0 f f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ binary_upgrade_set_next_pg_authid_oid _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+DATA(insert OID = 3788 ( binary_upgrade_create_empty_extension PGNSP PGUID  12 1 0 0 0 f f f f t f v 7 0 2278 "25 25 16 25 1028 1009 1009" _null_ _null_ _null_ _null_ binary_upgrade_create_empty_extension _null_ _null_ _null_ ));
+DESCR("for use by pg_upgrade");
+
 
 /*
  * Symbolic values for provolatile column: these indicate whether the result
-- 
2.2.0

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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to