Change deprecation warning to raise a WARNING after 2 version deprecation time
authorSandro Santilli <strk@keybit.net>
Fri, 27 Sep 2013 16:34:21 +0000 (16:34 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 27 Sep 2013 16:34:21 +0000 (16:34 +0000)
I kept the DEBUG for the first deprecating version to keep changes
small (no need to change testsuite again) but I really think
it should be at least a NOTICE in that case, or nobody would notice.

See #2440

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

postgis/postgis.sql.in
postgis/sqldefines.h.in

index ed96878e38f00d14272190bfc8009d83ecd28fa6..e2f304ac4f29a9404b0b863166ec85ebf49f9788 100644 (file)
@@ -27,11 +27,26 @@ SET client_min_messages TO warning;
 
 BEGIN;
 
+-- 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
 $$
+DECLARE
+  curver_text text;
 BEGIN
-    RAISE DEBUG '% signature was deprecated in %. Please use %', oldname, version, newname;
+  --
+  -- Raises a NOTICE if it was deprecated in this version,
+  -- a WARNING if in a previous version (only up to minor version checked)
+  --
+    curver_text := POSTGIS_LIB_VERSION;
+    IF split_part(curver_text,'.',1)::int > split_part(version,'.',1)::int OR
+       ( split_part(curver_text,'.',1) = split_part(version,'.',1) AND
+         split_part(curver_text,'.',2) != split_part(version,'.',2) )
+    THEN
+      RAISE WARNING '% signature was deprecated in %. Please use %', oldname, version, newname;
+    ELSE
+      RAISE DEBUG '% signature was deprecated in %. Please use %', oldname, version, newname;
+    END IF;
 END;
 $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
 
index 9cb18108f3a026aa86b432092e8d37f8c8d39b36..1235af6bc3e27bae54e92ae88abaf230008d22fd 100644 (file)
@@ -9,7 +9,7 @@
 #define POSTGIS_PGSQL_VERSION @POSTGIS_PGSQL_VERSION@
 #define POSTGIS_GEOS_VERSION @POSTGIS_GEOS_VERSION@
 #define POSTGIS_PROJ_VERSION @POSTGIS_PROJ_VERSION@
-#define POSTGIS_LIB_VERSION @POSTGIS_LIB_VERSION@
+#define POSTGIS_LIB_VERSION '@POSTGIS_LIB_VERSION@'
 #define POSTGIS_LIBXML2_VERSION @POSTGIS_LIBXML2_VERSION@
 
 /*