Provide a single way to install pg_repack

Provide only CREATE EXTENSION support on PG >= 9.1 and only the sql script on
PG < 9.1.

Also dropped the /echo cruft in the extension script: it is broken on pg 9.1
and 9.1.1, and because the script is not installed on versions that don't
support CREATE EXTENSION it is just not terribly useful.
This commit is contained in:
Daniele Varrazzo 2012-11-12 00:59:04 +00:00
parent ac068cc69b
commit 532be6ea25
2 changed files with 23 additions and 10 deletions

View File

@ -306,12 +306,17 @@ packages for developer (postgresql-devel, etc.) and add ``pg_config`` to your
You can also use Microsoft Visual C++ 2010 to build the program on Windows.
There are project files in the ``msvc`` folder.
Start PostgreSQL and execute the script to register functions to your
database::
Install the pg_repack extension in the database you want to process. On
PostgreSQL 9.1 or following pg_repack is packaged as an extension::
$ pg_ctl start
$ psql -c "CREATE EXTENSION pg_repack" -d your_database
For previous PostgreSQL versions you should load the script ``pg_repack.sql``
that can be found in the ``contrib`` subdirectory of the directory reported by
``--pg_config sharedir``, e.g. ::
$ psql -f "$(pg_config --sharedir)/contrib/pg_repack.sql" -d your_database
Requirements
------------

View File

@ -5,10 +5,13 @@
# Portions Copyright (c) 2011, Itagaki Takahiro
# Portions Copyright (c) 2012, The Reorg Development Team
#
MODULE_big = pg_repack
OBJS = repack.o pgut/pgut-be.o pgut/pgut-spi.o
PG_CONFIG = pg_config
EXTENSION = pg_repack
MODULE_big = $(EXTENSION)
OBJS = repack.o pgut/pgut-be.o pgut/pgut-spi.o
# The version number of the program. It should be the same of the library.
REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
@ -22,12 +25,18 @@ EXTVER = $(shell grep -e '^default_version' $(EXTENSION).control \
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
#supports both EXTENSION (for >=9.1) and without_EXTENSION (for <PG 9.1)
DATA_built = pg_repack.sql pg_repack--$(EXTVER).sql
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
HAVE_EXTENSION = $(shell $(PG_CONFIG) --version \
| grep -qE " 8\.| 9\.0" && echo no || echo yes)
ifeq ($(HAVE_EXTENSION),yes)
DATA_built = pg_repack--$(EXTVER).sql
else
DATA_built = pg_repack.sql
DATA = uninstall_pg_repack.sql
endif
USE_PGXS = 1 # use pgxs if not in contrib directory
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
@ -42,5 +51,4 @@ pg_repack.sql: pg_repack.sql.in
echo "\nCOMMIT;" >> $@;
pg_repack--$(EXTVER).sql: pg_repack.sql.in
echo '\echo Use "CREATE EXTENSION pg_repack" to load this file. \quit' > $@; \
cat $< >> $@;
cat $< > $@;