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 $< $@
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]*//' \
--- /dev/null
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+-- $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 <lr@pcorp.us>
+--
+-- 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 <lr@pcorp.us>
+--
+-- 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');