]> granicus.if.org Git - postgis/commitdiff
Only unpackage raster when needed, and hint about restoring it
authorSandro Santilli <strk@kbt.io>
Tue, 11 Sep 2018 09:19:09 +0000 (09:19 +0000)
committerSandro Santilli <strk@kbt.io>
Tue, 11 Sep 2018 09:19:09 +0000 (09:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@16738 b70326c6-7e19-0410-871a-916f4a2858ee

extensions/postgis/Makefile.in
extensions/postgis/unpackage_raster_if_needed.sql [new file with mode: 0644]

index 7b2865c5e2784a3267a17099eccc4e294f7997c3..03fbbb9bfbb6451d0baadb23a239d39640d43854 100644 (file)
@@ -41,9 +41,9 @@ EXTENSION_SCRIPTS = \
 # 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
@@ -80,11 +80,16 @@ $(EXTENSION).control: $(EXTENSION).control.in Makefile
 $(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 $< $@
diff --git a/extensions/postgis/unpackage_raster_if_needed.sql b/extensions/postgis/unpackage_raster_if_needed.sql
new file mode 100644 (file)
index 0000000..68ac0a1
--- /dev/null
@@ -0,0 +1,18 @@
+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';
+