From 0c342244cb505c7405702433ded1044e6591a83c Mon Sep 17 00:00:00 2001 From: Regina Obe Date: Mon, 14 Nov 2011 08:15:13 +0000 Subject: [PATCH] revise extension upgrade builder to use new remove functions from extension before attemtpting to readd them. Cool I can now upgrade my 2.0.0a3 to 2.0.0a.6 without any complaints. git-svn-id: http://svn.osgeo.org/postgis/trunk@8152 b70326c6-7e19-0410-871a-916f4a2858ee --- extensions/postgis/Makefile | 38 +++++++++---------- extensions/postgis/postgis.control | 2 +- .../sql_bits/remove_from_extension.sql.in | 20 ++++++++++ 3 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 extensions/postgis/sql_bits/remove_from_extension.sql.in diff --git a/extensions/postgis/Makefile b/extensions/postgis/Makefile index 4bb077da8..4b5dcf330 100644 --- a/extensions/postgis/Makefile +++ b/extensions/postgis/Makefile @@ -15,7 +15,7 @@ EXTRA_CLEAN += sql/$(EXTENSION).sql ${SQL_BITS} ifeq ($(PG91),yes) sql/$(EXTENSION).sql: sql_bits/postgis.sql sql_bits/postgis_comments.sql sql_bits/rtpostgis.sql sql_bits/raster_comments.sql sql_bits/spatial_ref_sys.sql cat $^ > $@ -all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--2.0.0a3--$(EXTVERSION).sql #sql/$(EXTENSION)--2.0.0a2--$(EXTVERSION).sql +all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--2.0.0a3--$(EXTVERSION).sql sql/$(EXTENSION)--2.0.0a4--$(EXTVERSION).sql sql/$(EXTENSION)--2.0.0a5--$(EXTVERSION).sql sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql cp $< $@ @@ -37,29 +37,29 @@ sql_bits/postgis_comments.sql: ../../doc/postgis_comments.sql sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis.sql sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' $< > $@ -sql_bits/raster_comments.sql: ../../doc/raster_comments.sql - cp $< $@ - -sql_bits/postgis_upgrade_minor.sql: sql_bits/postgis.sql - sed -e '/^\(CREATE\|ALTER\|DROP\) \(CAST\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\|OPERATOR\|AGGREGATE\|FUNCTION\).*;/d' \ - -e '/^\(CREATE\|ALTER\|DROP\) \(CAST\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\|OPERATOR\|AGGREGATE\|FUNCTION\)/,/\;/d' \ - $< > $@ - -sql_bits/postgis_drop_before.sql: ../../postgis/postgis_drop_before.sql.in.c - sed -e 's/^DROP \(FUNCTION\) [\(IF EXISTS\)]*\(.*\);/ALTER EXTENSION $(EXTENSION) DROP \1 \2;DROP \1 IF EXISTS \2 ;/' \ +#can't use the one built because can't drop the postgis_version function +#leave out all casts, operators, types, tables, schema, and aggregates +sql_bits/postgis_upgrade_minor.sql: ../../postgis/postgis.sql + sed -e '/^\(CREATE\|ALTER\) \(CAST\|OPERATOR\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\|AGGREGATE\).*;/d' \ + -e '/^\(CREATE\|ALTER\) \(CAST\|OPERATOR\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\|AGGREGATE\)/,/\;/d' \ + -e 's/BEGIN;//g' -e 's/COMMIT;//g' \ $< > $@ + -sql_bits/postgis_raster_upgrade_minor.sql: sql_bits/postgis_drop_before.sql sql_bits/postgis_upgrade_minor.sql ../../raster/rt_pg/rtpostgis_upgrade_20_minor.sql +sql_bits/raster_comments.sql: ../../doc/raster_comments.sql + cp $< $@ + +sql_bits/postgis_raster_upgrade_minor.sql: ../postgis_extension_helper.sql sql_bits/remove_from_extension.sql.in ../../postgis/postgis_drop_before.sql.in.c sql_bits/postgis_upgrade_minor.sql ../../raster/rt_pg/rtpostgis_upgrade_20_minor.sql ../../doc/raster_comments.sql ../../doc/postgis_comments.sql ../postgis_extension_helper_uninstall.sql cat $^ > $@ -# remove begin commits -# exclude type, cast, table creations -# we need to drop aggregates, casts, functions from the extension before we can drop them sql/$(EXTENSION)--2.0.0a3--$(EXTVERSION).sql: sql_bits/postgis_raster_upgrade_minor.sql - sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' -e '/^\(CREATE\|ALTER\) \(CAST\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\).*;/d' \ - -e '/^\(CREATE\|ALTER\|DROP\) \(CAST\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\)/,/\;/d' \ - -e 's/^DROP \(AGGREGATE\|OPERATOR\|FUNCTION\) [\(IF EXISTS\)]*\(.*\);/ALTER EXTENSION $(EXTENSION) DROP \1 \2;DROP \1 IF EXISTS \2 ;/' \ - $< > $@ + cp $< $@ + +sql/$(EXTENSION)--2.0.0a4--$(EXTVERSION).sql: sql_bits/postgis_raster_upgrade_minor.sql + cp $< $@ + +sql/$(EXTENSION)--2.0.0a5--$(EXTVERSION).sql: sql_bits/postgis_raster_upgrade_minor.sql + cp $< $@ # sql_bits/rtpostgis--unpackaged.sql: ../../raster/rt_pg/rtpostgis.sql # sed -e 's/^[\t]*//' \ diff --git a/extensions/postgis/postgis.control b/extensions/postgis/postgis.control index d5b3cc8bc..351187f86 100644 --- a/extensions/postgis/postgis.control +++ b/extensions/postgis/postgis.control @@ -1,5 +1,5 @@ # postgis extension comment = 'postgis geometry,geography, and raster spatial types and functions' -default_version = '2.0.0a5' +default_version = '2.0.0a6' module_pathname = '$libdir/postgis-2.0' relocatable = true diff --git a/extensions/postgis/sql_bits/remove_from_extension.sql.in b/extensions/postgis/sql_bits/remove_from_extension.sql.in new file mode 100644 index 000000000..cd710eb19 --- /dev/null +++ b/extensions/postgis/sql_bits/remove_from_extension.sql.in @@ -0,0 +1,20 @@ +-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +-- +-- $Id: postgis_extension_helper_uninstall.sql 7936 2011-11-12 14:33:23Z robe $ +---- +-- PostGIS - Spatial Types for PostgreSQL +-- http://www.postgis.org +-- +-- Copyright (C) 2011 Regina Obe +-- +-- This is free software; you can redistribute and/or modify it under +-- the terms of the GNU General Public Licence. See the COPYING file. +-- +-- Author: Regina Obe +-- +-- This drops extension helper functions +-- and should be called at the end of the extension upgrade file +-- removes all postgis_topology functions from postgis_topology extension since they will be readded +-- during upgrade +SELECT postgis_extension_remove_objects('postgis', 'FUNCTION'); +--SELECT postgis_extension_remove_objects('postgis', 'AGGREGATE'); -- 2.40.0