]> granicus.if.org Git - postgis/commitdiff
Changed all version functions to return text.
authorSandro Santilli <strk@keybit.net>
Wed, 28 Jul 2004 16:10:59 +0000 (16:10 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 28 Jul 2004 16:10:59 +0000 (16:10 +0000)
Renamed postgis_scripts_version() to postgis_scripts_installed()
Added postgis_scripts_released().
Added postgis_full_version().

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

doc/postgis.xml
postgis.sql.in
postgis_fn.c
postgis_geos.c
postgis_transform.c

index e43ed3960a591c0a180358ffe741793b76472fca..1299a6b51bb51100b85f5729267d7f77d3983cf6 100644 (file)
@@ -2719,6 +2719,20 @@ FROM geometry_table;</literallayout>
                                                </para>
                                        </listitem>
                                </varlistentry>
+                               <varlistentry>
+                                       <term>postgis_scripts_installed()</term>
+                                       <listitem>
+                                               <para>Returns the version number of the postgis.sql script installed in this database. 
+                                               </para>
+                                       </listitem>
+                               </varlistentry>
+                               <varlistentry>
+                                       <term>postgis_scripts_released()</term>
+                                       <listitem>
+                                               <para>Returns the version number of the postgis.sql script released with the installed postgis lib.
+                                               </para>
+                                       </listitem>
+                               </varlistentry>
                                <varlistentry>
                                        <term>postgis_geos_version()</term>
                                        <listitem>
index bbac49182da86f666db0e8fc6c426907c68cb796..d0b047cad36e89d314f6829a873d41fef744814d 100644 (file)
@@ -295,26 +295,78 @@ CREATE TABLE geometry_columns (
 -----------------------------------------------------------------------
 -- POSTGIS_VERSION()
 -----------------------------------------------------------------------
-CREATEFUNCTION postgis_lib_version() RETURNS cstring
+
+CREATEFUNCTION postgis_version() RETURNS text
+AS 'SELECT \'@POSTGIS_VERSION@\'::text AS version'
+LANGUAGE 'sql';
+
+CREATEFUNCTION postgis_lib_version() RETURNS text
        AS '@MODULE_FILENAME@'
        LANGUAGE 'C';
 
-CREATEFUNCTION postgis_geos_version() RETURNS cstring
+CREATEFUNCTION postgis_geos_version() RETURNS text
        AS '@MODULE_FILENAME@'
        LANGUAGE 'C';
 
-CREATEFUNCTION postgis_proj_version() RETURNS cstring
+CREATEFUNCTION postgis_proj_version() RETURNS text
        AS '@MODULE_FILENAME@'
        LANGUAGE 'C';
 
-CREATEFUNCTION postgis_version() RETURNS text
-AS 'SELECT \'@POSTGIS_VERSION@\'::text AS version'
-LANGUAGE 'sql';
-
-CREATEFUNCTION postgis_scripts_version() RETURNS text
+CREATEFUNCTION postgis_scripts_installed() RETURNS text
 AS 'SELECT \'@POSTGIS_SCRIPTS_VERSION@\'::text AS version'
 LANGUAGE 'sql';
 
+CREATEFUNCTION postgis_scripts_released() RETURNS text
+       AS '@MODULE_FILENAME@'
+       LANGUAGE 'C';
+
+CREATEFUNCTION postgis_uses_stats() RETURNS bool
+       AS '@MODULE_FILENAME@'
+       LANGUAGE 'C';
+
+CREATEFUNCTION postgis_full_version() RETURNS text
+AS '
+DECLARE
+       libver text;
+       projver text;
+       geosver text;
+       usestats bool;
+       dbproc text;
+       relproc text;
+       fullver text;
+BEGIN
+       SELECT postgis_lib_version() INTO libver;
+       SELECT postgis_proj_version() INTO projver;
+       SELECT postgis_geos_version() INTO geosver;
+       SELECT postgis_uses_stats() INTO usestats;
+       SELECT postgis_scripts_installed() INTO dbproc;
+       SELECT postgis_scripts_released() INTO relproc;
+
+       fullver = \'POSTGIS="\' || libver || \'"\';
+
+       IF  geosver IS NOT NULL THEN
+               fullver = fullver || \' GEOS="\' || geosver || \'"\';
+       END IF;
+
+       IF  projver IS NOT NULL THEN
+               fullver = fullver || \' PROJ="\' || geosver || \'"\';
+       END IF;
+
+       IF usestats THEN
+               fullver = fullver || \' USE_STATS\';
+       END IF;
+
+       fullver = fullver || \' DBPROC="\' || dbproc || \'"\';
+       fullver = fullver || \' RELPROC="\' || relproc || \'"\';
+
+       IF dbproc != relproc THEN
+               fullver = fullver || \' (needs proc upgrade)\';
+       END IF;
+
+       RETURN fullver;
+END
+' LANGUAGE 'plpgsql';
+
 -----------------------------------------------------------------------
 -- FIND_SRID( <schema>, <table>, <geom col> )
 -----------------------------------------------------------------------
index ad882806caca793ba1ffd602b876bb2a65e0dbe3..acb7e204ee92413689c18954c13a0597ecd068d2 100644 (file)
  *
  **********************************************************************
  * $Log$
+ * Revision 1.39  2004/07/28 16:10:59  strk
+ * Changed all version functions to return text.
+ * Renamed postgis_scripts_version() to postgis_scripts_installed()
+ * Added postgis_scripts_released().
+ * Added postgis_full_version().
+ *
  * Revision 1.38  2004/07/28 13:37:43  strk
  * Added postgis_uses_stats and postgis_scripts_version.
  * Experimented with PIP short-circuit in within/contains functions.
@@ -3173,8 +3179,23 @@ Datum fluffType(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(postgis_lib_version);
 Datum postgis_lib_version(PG_FUNCTION_ARGS)
 {
-       char *result = pstrdup(POSTGIS_LIB_VERSION);
-       PG_RETURN_CSTRING(result);
+       char *ver = POSTGIS_LIB_VERSION;
+       text *result;
+       result = (text *) palloc(VARHDRSZ  + strlen(ver));
+       VARATT_SIZEP(result) = VARHDRSZ + strlen(ver) ;
+       memcpy(VARDATA(result), ver, strlen(ver));
+       PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(postgis_scripts_released);
+Datum postgis_scripts_released(PG_FUNCTION_ARGS)
+{
+       char *ver = POSTGIS_SCRIPTS_VERSION;
+       text *result;
+       result = (text *) palloc(VARHDRSZ  + strlen(ver));
+       VARATT_SIZEP(result) = VARHDRSZ + strlen(ver) ;
+       memcpy(VARDATA(result), ver, strlen(ver));
+       PG_RETURN_POINTER(result);
 }
 
 PG_FUNCTION_INFO_V1(postgis_uses_stats);
index a12a4c0b9b2669913374bab685ae153fa2459249..90c61083c3429a9d33eaf944b37666d809cac660 100644 (file)
  *
  **********************************************************************
  * $Log$
+ * Revision 1.38  2004/07/28 16:10:59  strk
+ * Changed all version functions to return text.
+ * Renamed postgis_scripts_version() to postgis_scripts_installed()
+ * Added postgis_scripts_released().
+ * Added postgis_full_version().
+ *
  * Revision 1.37  2004/07/28 13:37:43  strk
  * Added postgis_uses_stats and postgis_scripts_version.
  * Experimented with PIP short-circuit in within/contains functions.
@@ -1927,9 +1933,12 @@ PG_FUNCTION_INFO_V1(postgis_geos_version);
 Datum postgis_geos_version(PG_FUNCTION_ARGS)
 {
        char *ver = GEOSversion();
-       char *result = pstrdup(ver);
+       text *result;
+       result = (text *) palloc(VARHDRSZ  + strlen(ver));
+       VARATT_SIZEP(result) = VARHDRSZ + strlen(ver) ;
+       memcpy(VARDATA(result), ver, strlen(ver));
        free(ver);
-       PG_RETURN_CSTRING(result);
+       PG_RETURN_POINTER(result);
 }
 
 //----------------------------------------------------------------------------
index e372635c220adbc2109d9ef3923b682d18ae6b0c..3ad455305dfcd5c9daaec7392ed15d0958cdfcc6 100644 (file)
  *
  **********************************************************************
  * $Log$
+ * Revision 1.19  2004/07/28 16:10:59  strk
+ * Changed all version functions to return text.
+ * Renamed postgis_scripts_version() to postgis_scripts_installed()
+ * Added postgis_scripts_released().
+ * Added postgis_full_version().
+ *
  * Revision 1.18  2004/07/23 21:24:33  strk
  * Added postgis_proj_version()
  *
@@ -464,8 +470,12 @@ Datum transform_geom(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(postgis_proj_version);
 Datum postgis_proj_version(PG_FUNCTION_ARGS)
 {
-       char *result = pstrdup(pj_get_release());
-       PG_RETURN_CSTRING(result);
+       const char *ver = pj_get_release();
+       text *result;
+       result = (text *) palloc(VARHDRSZ  + strlen(ver));
+       VARATT_SIZEP(result) = VARHDRSZ + strlen(ver) ;
+       memcpy(VARDATA(result), ver, strlen(ver));
+       PG_RETURN_POINTER(result);
 }