From 492b8e06a8ef4ae7f4be12c5adf694681fc8dbe0 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 12 Feb 2015 17:19:30 +0100 Subject: [PATCH] Strip aggregates, types and casts from upgrade scripts Closes #39 (again) --- pgsql/Makefile | 5 ++++- util/proc_upgrade.pl | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 util/proc_upgrade.pl diff --git a/pgsql/Makefile b/pgsql/Makefile index 15cccf3..c846c31 100644 --- a/pgsql/Makefile +++ b/pgsql/Makefile @@ -40,6 +40,9 @@ include $(PGXS) $(EXTENSION).control: $(EXTENSION).control.in Makefile $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@ -$(EXTENSION)--%.sql: $(EXTENSION).sql.in Makefile +$(EXTENSION)--$(EXTVERSION).sql: $(EXTENSION).sql.in Makefile cp $< $@ +# NOTE: relies on PERL being defined by PGXS +$(EXTENSION)--%--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql ../util/proc_upgrade.pl + cat $< | ../util/proc_upgrade.pl > $@ diff --git a/util/proc_upgrade.pl b/util/proc_upgrade.pl new file mode 100755 index 0000000..a2bfd3e --- /dev/null +++ b/util/proc_upgrade.pl @@ -0,0 +1,14 @@ +# Copyright (C) 2015 Boundless + +#!/usr/bin/perl -w + +eval "exec perl -w $0 $@" + if (0); + +local $/; +local $sql = ; +$sql =~ s/\nCREATE TYPE[^;]*;//gs; +$sql =~ s/\nCREATE AGGREGATE[^;]*;//gs; +$sql =~ s/\nCREATE CAST[^;]*;//gs; + +print $sql;