[postgis-tickets] r16734 - Drop raster objects from postgis extension on upgrade
Sandro Santilli
strk at kbt.io
Tue Sep 11 02:18:48 PDT 2018
Author: strk
Date: 2018-09-11 02:18:48 -0700 (Tue, 11 Sep 2018)
New Revision: 16734
Added:
trunk/utils/create_extension_unpackage.pl
Modified:
trunk/extensions/postgis/Makefile.in
Log:
Drop raster objects from postgis extension on upgrade
Modified: trunk/extensions/postgis/Makefile.in
===================================================================
--- trunk/extensions/postgis/Makefile.in 2018-09-11 09:18:42 UTC (rev 16733)
+++ trunk/extensions/postgis/Makefile.in 2018-09-11 09:18:48 UTC (rev 16734)
@@ -32,7 +32,7 @@
# Scripts making up the extension file
# NOTE: order matters
EXTENSION_SCRIPTS = \
- sql/postgis.sql \
+ ../../postgis/postgis_for_extension.sql \
../../doc/postgis_comments.sql \
sql/spatial_ref_sys_config_dump.sql \
sql/spatial_ref_sys.sql
@@ -43,6 +43,7 @@
../postgis_extension_helper.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
@@ -50,6 +51,11 @@
EXTENSION_UNPACKAGED_UPGRADE_SCRIPTS = \
sql/postgis.sql
+RASTER_DROP_SCRIPTS = \
+ ../../raster/rt_pg/rtpostgis_upgrade_cleanup.sql \
+ ../../raster/rt_pg/rtpostgis_drop.sql \
+ ../../raster/rt_pg/uninstall_rtpostgis.sql
+
#DOCS = $(wildcard ../../doc/html/*.html)
PG_CONFIG = @PG_CONFIG@
@@ -71,6 +77,15 @@
| sed -e 's|@MODULEPATH@|$(MODULEPATH)|g' \
> $@
+$(RASTER_DROP_SCRIPTS):
+ $(MAKE) -C ../../raster
+
+sql/raster_unpackage.sql: $(RASTER_DROP_SCRIPTS) ../../utils/create_extension_unpackage.pl Makefile | sql
+ cat $(RASTER_DROP_SCRIPTS) \
+ | ../../utils/create_extension_unpackage.pl postgis > $@
+
+sql/raster_unpackage.sql: Makefile
+
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql | sql
cp $< $@
Added: trunk/utils/create_extension_unpackage.pl
===================================================================
--- trunk/utils/create_extension_unpackage.pl (rev 0)
+++ trunk/utils/create_extension_unpackage.pl 2018-09-11 09:18:48 UTC (rev 16734)
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+#
+# PostGIS - Spatial Types for PostgreSQL
+# http://postgis.net
+#
+# Copyright (C) 2017 Sandro Santilli <strk at kbt.io>
+#
+# This is free software; you can redistribute and/or modify it under
+# the terms of the GNU General Public Licence. See the COPYING file.
+#
+
+use warnings;
+use strict;
+use POSIX 'strftime';
+
+eval "exec perl -w $0 $@"
+ if (0);
+
+
+die "Usage: perl $0 <extname> [<sqlfile>]\n"
+ . " Prints SQL to drop objects dropped by given SQL file\n"
+ . " from extension with given name.\n"
+unless @ARGV;
+
+my $extname = shift(@ARGV);
+
+while(<>)
+{
+ /^DROP/i or next;
+ s/ IF EXISTS//i;
+ s/ CASCADE//i;
+ chop;
+ print 'DO $$ BEGIN ALTER EXTENSION ' . $extname
+ . ' ' . $_ . 'EXCEPTION '
+ . 'WHEN object_not_in_prerequisite_state OR undefined_function OR undefined_object THEN '
+ . " RAISE NOTICE '%', SQLERRM; "
+ . 'WHEN OTHERS THEN '
+ . " RAISE EXCEPTION 'Got % - %', SQLSTATE, SQLERRM; "
+ . 'END $$ LANGUAGE ' . "'plpgsql';\n";
+}
+
+1;
Property changes on: trunk/utils/create_extension_unpackage.pl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
More information about the postgis-tickets
mailing list