]> granicus.if.org Git - postgis/commitdiff
Do not allow installing postgis twice in the same database (#2580)
authorSandro Santilli <strk@keybit.net>
Wed, 18 Dec 2013 15:55:59 +0000 (15:55 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 18 Dec 2013 15:55:59 +0000 (15:55 +0000)
Checks for the presence of a "postgis_version" function,
and if found raises an exception with a message with
the schema containing it.

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

NEWS
postgis/postgis.sql.in

diff --git a/NEWS b/NEWS
index acf5cbf9ff495d3600f07173460d450e9b55d38b..277614bf2b8da0ee2b263ae5228add7d17c02ec0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
 PostGIS 2.2.0
 2014/MM/DD
 
- * Important / Breaking Changes  *
+ * Important / Breaking Changes *
 
   - #2565, ST_SummaryStats(tablename, rastercolumn, ...) uses
            ST_SummaryStatsAgg()
index a6eb88db27c7b34d029cd05718327ed636a47850..b46f3136ec0a49cf4a517092962a145e63f4cbcd 100644 (file)
@@ -27,6 +27,22 @@ SET client_min_messages TO warning;
 
 BEGIN;
 
+-- Check that no other postgis is installed
+DO $$
+DECLARE
+  rec RECORD;
+BEGIN
+  FOR rec IN
+    SELECT n.nspname, p.proname FROM pg_proc p, pg_namespace n
+    WHERE p.proname = 'postgis_version'
+    AND p.pronamespace = n.oid
+  LOOP
+    RAISE EXCEPTION 'PostGIS is already installed in schema ''%'', uninstall it first', rec.nspname;
+  END LOOP;
+END
+$$ LANGUAGE 'plpgsql';
+
+
 -- Let the user know about a deprecated signature and its new name, if any
 CREATE OR REPLACE FUNCTION _postgis_deprecate(oldname text, newname text, version text)
 RETURNS void AS