diff --git a/pgsql/pc_access.c b/pgsql/pc_access.c index b926e39..f7b80df 100644 --- a/pgsql/pc_access.c +++ b/pgsql/pc_access.c @@ -41,6 +41,10 @@ Datum pcpatch_size(PG_FUNCTION_ARGS); Datum pcpoint_size(PG_FUNCTION_ARGS); Datum pcpoint_pcid(PG_FUNCTION_ARGS); Datum pc_version(PG_FUNCTION_ARGS); +Datum pc_pgsql_version(PG_FUNCTION_ARGS); +Datum pc_libxml2_version(PG_FUNCTION_ARGS); +Datum pc_libght_enable(PG_FUNCTION_ARGS); +Datum pc_lazperf_enable(PG_FUNCTION_ARGS); /* Generic aggregation functions */ Datum pointcloud_agg_transfn(PG_FUNCTION_ARGS); @@ -860,6 +864,46 @@ Datum pc_version(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(version_text); } +PG_FUNCTION_INFO_V1(pc_pgsql_version); +Datum pc_pgsql_version(PG_FUNCTION_ARGS) +{ + text *version_text; + char version[12]; + snprintf(version, 12, "%d", PGSQL_VERSION); + version_text = cstring_to_text(version); + PG_RETURN_TEXT_P(version_text); +} + +PG_FUNCTION_INFO_V1(pc_libxml2_version); +Datum pc_libxml2_version(PG_FUNCTION_ARGS) +{ + text *version_text; + char version[64]; + snprintf(version, 64, "%s", LIBXML2_VERSION); + version_text = cstring_to_text(version); + PG_RETURN_TEXT_P(version_text); +} + +PG_FUNCTION_INFO_V1(pc_libght_enabled); +Datum pc_libght_enabled(PG_FUNCTION_ARGS) +{ +#ifdef HAVE_LIBGHT + PG_RETURN_BOOL(TRUE); +#else + PG_RETURN_BOOL(FALSE); +#endif +} + +PG_FUNCTION_INFO_V1(pc_lazperf_enabled); +Datum pc_lazperf_enabled(PG_FUNCTION_ARGS) +{ +#ifdef HAVE_LAZPERF + PG_RETURN_BOOL(TRUE); +#else + PG_RETURN_BOOL(FALSE); +#endif +} + /** * Read a named dimension statistic from a PCPATCH * PC_PatchMax(patch pcpatch, dimname text) returns Numeric diff --git a/pgsql/pointcloud.sql.in b/pgsql/pointcloud.sql.in index a8c3d55..244af8e 100644 --- a/pgsql/pointcloud.sql.in +++ b/pgsql/pointcloud.sql.in @@ -56,6 +56,26 @@ CREATE OR REPLACE FUNCTION pc_lib_version() RETURNS text AS 'MODULE_PATHNAME', 'pc_version' LANGUAGE 'c' IMMUTABLE STRICT; +-- Return the pgsql version number +CREATE OR REPLACE FUNCTION pc_pgsql_version() + RETURNS text AS 'MODULE_PATHNAME', 'pc_pgsql_version' + LANGUAGE 'c' IMMUTABLE STRICT; + +-- Return the libxml2 version number +CREATE OR REPLACE FUNCTION pc_libxml2_version() + RETURNS text AS 'MODULE_PATHNAME', 'pc_libxml2_version' + LANGUAGE 'c' IMMUTABLE STRICT; + +-- Return whether libght is enabled +CREATE OR REPLACE FUNCTION pc_libght_enabled() + RETURNS boolean AS 'MODULE_PATHNAME', 'pc_libght_enabled' + LANGUAGE 'c' IMMUTABLE STRICT; + +-- Return whether lazperf is enabled +CREATE OR REPLACE FUNCTION pc_lazperf_enabled() + RETURNS boolean AS 'MODULE_PATHNAME', 'pc_lazperf_enabled' + LANGUAGE 'c' IMMUTABLE STRICT; + -- Return the extension version number and check sanity CREATE OR REPLACE FUNCTION pc_version() RETURNS text AS @@ -75,6 +95,27 @@ END; $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT; +CREATE OR REPLACE FUNCTION pc_full_version() + RETURNS text AS +$$ +DECLARE + pcver TEXT; + pgsqlver TEXT; + libxml2ver TEXT; + libghtenabled BOOLEAN; + lazperfenabled BOOLEAN; +BEGIN + pcver := pc_version(); + pgsqlver := pc_pgsql_version(); + libxml2ver := pc_libxml2_version(); + libghtenabled := pc_libght_enabled(); + lazperfenabled := pc_lazperf_enabled(); + RETURN 'POINTCLOUD="' || pcver || '" PGSQL="' || pgsqlver || '" LIBXML2="' || libxml2ver || + '" LIBGHT enabled=' || libghtenabled || ' LAZPERF enabled=' || lazperfenabled; +END; +$$ +LANGUAGE 'plpgsql' IMMUTABLE STRICT; + -- Upgrade pointcloud extension to latest (or specified) version. -- Takes care of in-development upgrades CREATE OR REPLACE FUNCTION pc_upgrade(to_version text DEFAULT NULL)