/* contrib/pg_stat_logmsg/pg_stat_logmsg--1.0.sql */

-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_stat_logmsg" to load this file. \quit

-- Register functions.
CREATE FUNCTION pg_stat_logmsg_reset()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C PARALLEL SAFE;

CREATE FUNCTION pg_stat_logmsg(
    OUT filename text,
    OUT lineno int,
    OUT elevel text,
    OUT funcname text,
    OUT sqlerrcode text,
    OUT message text,
    OUT count bigint
)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'pg_stat_logmsg'
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;

-- Register a view on the function for ease of use.
CREATE VIEW pg_stat_logmsg AS
  SELECT * FROM pg_stat_logmsg();

GRANT SELECT ON pg_stat_logmsg TO PUBLIC;

-- Don't want this to be available to non-superusers.
REVOKE ALL ON FUNCTION pg_stat_logmsg_reset() FROM PUBLIC;

--- Define pg_stat_logmsg_info
CREATE FUNCTION pg_stat_logmsg_info(
    OUT dealloc bigint,
    OUT stats_reset timestamp with time zone
)
RETURNS record
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;

CREATE VIEW pg_stat_logmsg_info AS
  SELECT * FROM pg_stat_logmsg_info();

GRANT SELECT ON pg_stat_logmsg_info TO PUBLIC;

