From: Sandro Santilli Date: Wed, 18 Dec 2013 15:55:59 +0000 (+0000) Subject: Do not allow installing postgis twice in the same database (#2580) X-Git-Tag: 2.2.0rc1~1279 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4572ef795757df802519971a57ad75e09644bcb3;p=postgis Do not allow installing postgis twice in the same database (#2580) 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 --- diff --git a/NEWS b/NEWS index acf5cbf9f..277614bf2 100644 --- 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() diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in index a6eb88db2..b46f3136e 100644 --- a/postgis/postgis.sql.in +++ b/postgis/postgis.sql.in @@ -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