Issue - (#52): Create a function to return the build version.

Jira: PG-142
pull/55/head
Ibrar Ahmed 2020-10-12 17:54:44 +00:00
parent 6170d1f77c
commit b23df84af9
2 changed files with 22 additions and 4 deletions

View File

@ -9,17 +9,21 @@ RETURNS void
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE C PARALLEL SAFE; LANGUAGE C PARALLEL SAFE;
CREATE FUNCTION pg_stat_monitor_version()
RETURNS text
AS 'MODULE_PATHNAME'
LANGUAGE C PARALLEL SAFE;
CREATE FUNCTION pg_stat_monitor(IN showtext boolean, CREATE FUNCTION pg_stat_monitor(IN showtext boolean,
OUT bucket int, OUT bucket int,
OUT userid oid, OUT userid oid,
OUT dbid oid, OUT dbid oid,
OUT client_ip bigint, OUT client_ip bigint,
OUT queryid text, OUT queryid text,
OUT query text, OUT query text,
OUT bucket_start_time timestamptz, OUT bucket_start_time timestamptz,
OUT plan_calls int8, OUT plan_calls int8,
OUT plan_total_time float8, OUT plan_total_time float8,
OUT plan_min_time float8, OUT plan_min_time float8,
@ -27,7 +31,7 @@ CREATE FUNCTION pg_stat_monitor(IN showtext boolean,
OUT plan_mean_time float8, OUT plan_mean_time float8,
OUT plan_stddev_time float8, OUT plan_stddev_time float8,
OUT plan_rows int8, OUT plan_rows int8,
OUT total_calls int8, OUT total_calls int8,
OUT total_time float8, OUT total_time float8,
OUT min_time float8, OUT min_time float8,
@ -35,7 +39,7 @@ CREATE FUNCTION pg_stat_monitor(IN showtext boolean,
OUT mean_time float8, OUT mean_time float8,
OUT stddev_time float8, OUT stddev_time float8,
OUT affected_rows int8, OUT affected_rows int8,
OUT shared_blks_hit int8, OUT shared_blks_hit int8,
OUT shared_blks_read int8, OUT shared_blks_read int8,
OUT shared_blks_dirtied int8, OUT shared_blks_dirtied int8,

View File

@ -16,6 +16,8 @@
PG_MODULE_MAGIC; PG_MODULE_MAGIC;
#define BUILD_VERSION "0.6.0"
/*---- Initicalization Function Declarations ----*/ /*---- Initicalization Function Declarations ----*/
void _PG_init(void); void _PG_init(void);
void _PG_fini(void); void _PG_fini(void);
@ -45,6 +47,7 @@ static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
static ProcessUtility_hook_type prev_ProcessUtility = NULL; static ProcessUtility_hook_type prev_ProcessUtility = NULL;
PG_FUNCTION_INFO_V1(pg_stat_monitor_version);
PG_FUNCTION_INFO_V1(pg_stat_monitor_reset); PG_FUNCTION_INFO_V1(pg_stat_monitor_reset);
PG_FUNCTION_INFO_V1(pg_stat_monitor_1_2); PG_FUNCTION_INFO_V1(pg_stat_monitor_1_2);
PG_FUNCTION_INFO_V1(pg_stat_monitor_1_3); PG_FUNCTION_INFO_V1(pg_stat_monitor_1_3);
@ -194,6 +197,17 @@ _PG_fini(void)
hash_entry_reset(); hash_entry_reset();
} }
/*
* Select the version of pg_stat_monitor.
*/
Datum
pg_stat_monitor_version(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P(cstring_to_text(BUILD_VERSION));
}
#define PG_STAT_STATEMENTS_COLS 38 /* maximum of above */
/* /*
* Post-parse-analysis hook: mark query with a queryId * Post-parse-analysis hook: mark query with a queryId
*/ */