From 26b44326ee3c53945e59997e6e6bb03f5f9f3f25 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 8 May 2013 11:17:19 -0700 Subject: [PATCH] Add PC_Version function to read library version --- pgsql/expected/pointcloud.out | 6 ++++++ pgsql/pc_access.c | 11 +++++++++++ pgsql/pointcloud--1.0.sql | 5 +++++ pgsql/sql/pointcloud.sql | 2 ++ 4 files changed, 24 insertions(+) diff --git a/pgsql/expected/pointcloud.out b/pgsql/expected/pointcloud.out index 9286174..95534e4 100644 --- a/pgsql/expected/pointcloud.out +++ b/pgsql/expected/pointcloud.out @@ -1,4 +1,10 @@ CREATE EXTENSION pointcloud; +SELECT PC_Version(); + pc_version +------------ + 1.0 +(1 row) + INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 0, ' diff --git a/pgsql/pc_access.c b/pgsql/pc_access.c index 0cd23bb..2d9190b 100644 --- a/pgsql/pc_access.c +++ b/pgsql/pc_access.c @@ -23,6 +23,7 @@ Datum pcpatch_compression(PG_FUNCTION_ARGS); Datum pcpatch_intersects(PG_FUNCTION_ARGS); Datum pcpatch_size(PG_FUNCTION_ARGS); Datum pcpoint_size(PG_FUNCTION_ARGS); +Datum pc_version(PG_FUNCTION_ARGS); /* Generic aggregation functions */ Datum pointcloud_agg_transfn(PG_FUNCTION_ARGS); @@ -575,3 +576,13 @@ Datum pcpoint_size(PG_FUNCTION_ARGS) PG_RETURN_INT32(VARSIZE(serpt)); } +PG_FUNCTION_INFO_V1(pc_version); +Datum pc_version(PG_FUNCTION_ARGS) +{ + text *version_text; + char version[64]; + snprintf(version, 64, "%s", POINTCLOUD_VERSION); + version_text = cstring_to_text(version); + PG_RETURN_TEXT_P(version_text); +} + diff --git a/pgsql/pointcloud--1.0.sql b/pgsql/pointcloud--1.0.sql index c9a48b7..6459ece 100644 --- a/pgsql/pointcloud--1.0.sql +++ b/pgsql/pointcloud--1.0.sql @@ -46,6 +46,11 @@ CREATE OR REPLACE FUNCTION pc_typmod_pcid(typmod integer) RETURNS int4 AS 'MODULE_PATHNAME','pc_typmod_pcid' LANGUAGE 'c' IMMUTABLE STRICT; +-- Return the library version number +CREATE OR REPLACE FUNCTION pc_version() + RETURNS text AS 'MODULE_PATHNAME', 'pc_version' + LANGUAGE 'c' IMMUTABLE STRICT; + ------------------------------------------------------------------- -- PCPOINT ------------------------------------------------------------------- diff --git a/pgsql/sql/pointcloud.sql b/pgsql/sql/pointcloud.sql index f498cd5..7d129ec 100644 --- a/pgsql/sql/pointcloud.sql +++ b/pgsql/sql/pointcloud.sql @@ -1,5 +1,7 @@ CREATE EXTENSION pointcloud; +SELECT PC_Version(); + INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 0, '