Skip to content

Instantly share code, notes, and snippets.

@schmiddy
Created October 17, 2012 04:53
Show Gist options
  • Save schmiddy/3903770 to your computer and use it in GitHub Desktop.
Save schmiddy/3903770 to your computer and use it in GitHub Desktop.
pg_reorg version checking in Makefile, and remove further unneeded macros in ./lib/reorg.c
diff --git a/Makefile b/Makefile
index 01e02e3..e9b251b 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.
+ifeq ($(shell echo $(VERSION) | grep -qE "7\.|8\.[012]" && echo yes || echo no),yes)
+$(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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment