# NOTE: order matters
EXTENSION_UPGRADE_SCRIPTS = \
../postgis_extension_helper.sql \
+ sql/raster_unpackage.sql \
sql/postgis_upgrade.sql \
../../doc/postgis_comments.sql \
- sql/raster_unpackage.sql \
../postgis_extension_helper_uninstall.sql
# Scripts making up the extension upgrade-from-unpackaged file
$(RASTER_DROP_SCRIPTS):
$(MAKE) -C ../../raster
-sql/raster_unpackage.sql: $(RASTER_DROP_SCRIPTS) ../../utils/create_extension_unpackage.pl Makefile | sql
+sql/raster_unpackage.sql: ../../utils/create_extension_unpackage.pl Makefile
+sql/raster_unpackage.sql: $(RASTER_DROP_SCRIPTS) | sql
+
+ sed '/UNPACKAGE_CODE/q' unpackage_raster_if_needed.sql > $@
+
cat $(RASTER_DROP_SCRIPTS) \
- | ../../utils/create_extension_unpackage.pl postgis > $@
+ | ../../utils/create_extension_unpackage.pl postgis >> $@
-sql/raster_unpackage.sql: Makefile
+ sed -ne '/UNPACKAGE_CODE/{s///; :a' -e 'n;p;ba' -e '}' \
+ unpackage_raster_if_needed.sql >> $@
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql | sql
cp $< $@
--- /dev/null
+DO $unpackage_if_needed$
+BEGIN
+ IF EXISTS (
+ select t.typname from pg_depend d, pg_extension e, pg_type t where
+ e.extname = 'postgis' and d.refclassid =
+ 'pg_catalog.pg_extension'::pg_catalog.regclass and d.refobjid = e.oid
+ and d.classid = 'pg_type'::regclass and d.objid = t.oid
+ and t.typname = 'raster'
+ ) THEN
+
+ -- UNPACKAGE_CODE --
+
+ RAISE WARNING 'PostGIS Raster functionality have been unpackaged'
+ USING HINT = 'type `CREATE EXTENSION postgis_raster FROM unpackaged` to re-package';
+ END IF;
+END
+$unpackage_if_needed$ LANGUAGE 'plpgsql';
+