Skip to content

Commit 532be6e

Browse files
committed
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.
1 parent ac068cc commit 532be6e

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

doc/pg_repack.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,17 @@ packages for developer (postgresql-devel, etc.) and add ``pg_config`` to your
306306
You can also use Microsoft Visual C++ 2010 to build the program on Windows.
307307
There are project files in the ``msvc`` folder.
308308

309-
Start PostgreSQL and execute the script to register functions to your
310-
database::
309+
Install the pg_repack extension in the database you want to process. On
310+
PostgreSQL 9.1 or following pg_repack is packaged as an extension::
311311

312-
$ pg_ctl start
313312
$ psql -c "CREATE EXTENSION pg_repack" -d your_database
314313

314+
For previous PostgreSQL versions you should load the script ``pg_repack.sql``
315+
that can be found in the ``contrib`` subdirectory of the directory reported by
316+
``--pg_config sharedir``, e.g. ::
317+
318+
$ psql -f "$(pg_config --sharedir)/contrib/pg_repack.sql" -d your_database
319+
315320

316321
Requirements
317322
------------

lib/Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
# Portions Copyright (c) 2011, Itagaki Takahiro
66
# Portions Copyright (c) 2012, The Reorg Development Team
77
#
8-
MODULE_big = pg_repack
9-
OBJS = repack.o pgut/pgut-be.o pgut/pgut-spi.o
8+
9+
PG_CONFIG = pg_config
1010

1111
EXTENSION = pg_repack
12+
MODULE_big = $(EXTENSION)
13+
14+
OBJS = repack.o pgut/pgut-be.o pgut/pgut-spi.o
1215

1316
# The version number of the program. It should be the same of the library.
1417
REPACK_VERSION = $(shell grep '"version":' ../META.json | head -1 \
@@ -22,12 +25,18 @@ EXTVER = $(shell grep -e '^default_version' $(EXTENSION).control \
2225

2326
PG_CPPFLAGS = -DREPACK_VERSION=$(REPACK_VERSION)
2427

25-
#supports both EXTENSION (for >=9.1) and without_EXTENSION (for <PG 9.1)
26-
DATA_built = pg_repack.sql pg_repack--$(EXTVER).sql
28+
# Support CREATE EXTENSION for PG >= 9.1 and a simple sql script for PG < 9.1
29+
HAVE_EXTENSION = $(shell $(PG_CONFIG) --version \
30+
| grep -qE " 8\.| 9\.0" && echo no || echo yes)
31+
32+
ifeq ($(HAVE_EXTENSION),yes)
33+
DATA_built = pg_repack--$(EXTVER).sql
34+
else
35+
DATA_built = pg_repack.sql
2736
DATA = uninstall_pg_repack.sql
37+
endif
2838

2939
USE_PGXS = 1 # use pgxs if not in contrib directory
30-
PG_CONFIG = pg_config
3140
PGXS := $(shell $(PG_CONFIG) --pgxs)
3241
include $(PGXS)
3342

@@ -42,5 +51,4 @@ pg_repack.sql: pg_repack.sql.in
4251
echo "\nCOMMIT;" >> $@;
4352

4453
pg_repack--$(EXTVER).sql: pg_repack.sql.in
45-
echo '\echo Use "CREATE EXTENSION pg_repack" to load this file. \quit' > $@; \
46-
cat $< >> $@;
54+
cat $< > $@;

0 commit comments

Comments
 (0)