From 6c8c532701962607f29a3b4807f7ad2b3d595422 Mon Sep 17 00:00:00 2001 From: Josh Kupershmidt Date: Wed, 17 Oct 2012 08:00:47 -0700 Subject: [PATCH] Enforce version restriction (8.3+) in the Makefile, and further macro pruning. Per Issue #12, have the Makefile bail out if the user is trying to build on an unsupported Postgres version. Also, some further removal of macros purportedly handling older PG versions which are no longer needed, and were missed in 370e572. --- Makefile | 9 +++++++++ lib/reorg.c | 17 +++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 01e02e3..c053398 100755 --- a/Makefile +++ b/Makefile @@ -24,6 +24,15 @@ endif SUBDIRS = bin lib +# Pull out the version number from pg_config +VERSION = $(shell $(PG_CONFIG) --version | awk '{print $$2}') + +# We support PostgreSQL 8.3 and later. +ifneq ($(shell echo $(VERSION) | grep -E "^7\.|^8\.[012]"),) +$(error pg_reorg requires PostgreSQL 8.3 or later. This is $(VERSION)) +endif + + all install installdirs uninstall distprep clean distclean maintainer-clean debug: @for dir in $(SUBDIRS); do \ $(MAKE) -C $$dir $@ || exit; \ diff --git a/lib/reorg.c b/lib/reorg.c index 22aa5c7..1dacce1 100755 --- a/lib/reorg.c +++ b/lib/reorg.c @@ -520,16 +520,13 @@ reorg_get_index_keys(PG_FUNCTION_ARGS) Oid opclass; Oid oprid; int16 strategy = BTLessStrategyNumber; -#if PG_VERSION_NUM >= 80300 Oid opcintype; Oid opfamily; HeapTuple tp; Form_pg_opclass opclassTup; -#endif opclass = OpclassnameGetOpcid(BTREE_AM_OID, opcname); -#if PG_VERSION_NUM >= 80300 /* Retrieve operator information. */ tp = SearchSysCache(CLAOID, ObjectIdGetDatum(opclass), 0, 0, 0); if (!HeapTupleIsValid(tp)) @@ -551,13 +548,9 @@ reorg_get_index_keys(PG_FUNCTION_ARGS) if (!OidIsValid(oprid)) elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", strategy, opcintype, opcintype, opfamily); -#else - oprid = get_opclass_member(opclass, 0, strategy); - if (!OidIsValid(oprid)) - elog(ERROR, "missing operator %d for %s", strategy, opcname); -#endif - opcname[-1] = '\0'; + + opcname[-1] = '\0'; appendStringInfo(&str, "%s USING %s", token, get_opname(oprid)); } else @@ -1096,11 +1089,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, Oid namespaceId) allowSystemTableMods = true; PG_TRY(); { - renamerel(myrelid, newrelname -#if PG_VERSION_NUM >= 80300 - , OBJECT_TABLE -#endif - ); + renamerel(myrelid, newrelname, OBJECT_TABLE); allowSystemTableMods = save_allowSystemTableMods; } PG_CATCH();