]> granicus.if.org Git - postgis/commitdiff
Check unpackaged version for topology too
authorSandro Santilli <strk@kbt.io>
Sun, 22 Oct 2017 19:06:49 +0000 (19:06 +0000)
committerSandro Santilli <strk@kbt.io>
Sun, 22 Oct 2017 19:06:49 +0000 (19:06 +0000)
See #3892

git-svn-id: http://svn.osgeo.org/postgis/trunk@16049 b70326c6-7e19-0410-871a-916f4a2858ee

extensions/postgis_topology/Makefile.in
extensions/postgis_topology/unpackaged_check.sql.in [new file with mode: 0644]

index 881d1f2bd128c5d4a495e1f656689036b6e0057e..2402118309133684627f6ca2ffd54e86444511cb 100644 (file)
@@ -55,9 +55,16 @@ sql_bits/topology.sql: ../../topology/topology.sql
 sql_bits/topology_comments.sql: ../../doc/topology_comments.sql
        cp $< $@
 
-sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../topology/topology.sql ../../utils/create_unpackaged.pl
+sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../topology/topology.sql ../../utils/create_unpackaged.pl unpackaged_check.sql Makefile
        mkdir -p sql
-       cat $< | $(PERL) ../../utils/create_unpackaged.pl postgis_topology > $@
+       # Ensure version is correct
+       cat unpackaged_check.sql > $@
+       cat $< | $(PERL) ../../utils/create_unpackaged.pl postgis_topology >> $@
+
+unpackaged_check.sql: unpackaged_check.sql.in Makefile
+       cat $< \
+               | sed -e 's|@EXTVERSION@|$(EXTVERSION)|g' \
+               > $@
 
 #upgrade script should have everything but table, schema, type creation/alter
 #NOTE: we assume all object definitions end in ;
diff --git a/extensions/postgis_topology/unpackaged_check.sql.in b/extensions/postgis_topology/unpackaged_check.sql.in
new file mode 100644 (file)
index 0000000..8b89498
--- /dev/null
@@ -0,0 +1,14 @@
+DO $$
+DECLARE
+       ver TEXT;
+BEGIN
+       ver := split_part(postgis_topology_scripts_installed(), ' ', 1);
+       IF ver != '@EXTVERSION@' THEN
+               RAISE EXCEPTION 'Installed PostGIS Topology version is %', ver
+               USING HINT = 'Try `CREATE EXTENSION postgis_topology VERSION '''
+                       || ver || ''' from unpackaged`,'
+                       ' or source topology_upgrade.sql`';
+       END IF;
+END;
+$$ LANGUAGE 'plpgsql';
+