diff --git a/pg_stat_monitor--1.0--2.0.sql b/pg_stat_monitor--1.0--2.0.sql index c3302a7..21a1d41 100644 --- a/pg_stat_monitor--1.0--2.0.sql +++ b/pg_stat_monitor--1.0--2.0.sql @@ -72,7 +72,7 @@ CREATE FUNCTION pg_stat_monitor_internal( OUT toplevel BOOLEAN ) RETURNS SETOF record -AS 'MODULE_PATHNAME', 'pg_stat_monitor' +AS 'MODULE_PATHNAME', 'pg_stat_monitor_2_0' LANGUAGE C STRICT VOLATILE PARALLEL SAFE; -- Register a view on the function for ease of use. diff --git a/pg_stat_monitor--2.0.sql b/pg_stat_monitor--2.0.sql index bc0a0f9..2d6df69 100644 --- a/pg_stat_monitor--2.0.sql +++ b/pg_stat_monitor--2.0.sql @@ -168,7 +168,7 @@ CREATE FUNCTION pg_stat_monitor_internal( OUT toplevel BOOLEAN ) RETURNS SETOF record -AS 'MODULE_PATHNAME', 'pg_stat_monitor' +AS 'MODULE_PATHNAME', 'pg_stat_monitor_2_0' LANGUAGE C STRICT VOLATILE PARALLEL SAFE; -- Register a view on the function for ease of use. diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 41bcb4f..6fddf45 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -23,9 +23,19 @@ #include "commands/explain.h" #include "pg_stat_monitor.h" + /* + * Extension version number, for supporting older extension versions' objects + */ + typedef enum pgsmVersion + { + PGSM_V1_0 = 0, + PGSM_V2_0 + } pgsmVersion; + + PG_MODULE_MAGIC; -#define BUILD_VERSION "1.1.1" +#define BUILD_VERSION "2.0.0-dev" #define PG_STAT_STATEMENTS_COLS 52 /* maximum of above */ #define PGSM_TEXT_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat_monitor_query" @@ -107,6 +117,8 @@ static ExecutorCheckPerms_hook_type prev_ExecutorCheckPerms_hook = NULL; PG_FUNCTION_INFO_V1(pg_stat_monitor_version); PG_FUNCTION_INFO_V1(pg_stat_monitor_reset); +PG_FUNCTION_INFO_V1(pg_stat_monitor_1_0); +PG_FUNCTION_INFO_V1(pg_stat_monitor_2_0); PG_FUNCTION_INFO_V1(pg_stat_monitor); PG_FUNCTION_INFO_V1(pg_stat_monitor_settings); PG_FUNCTION_INFO_V1(get_histogram_timings); @@ -178,6 +190,7 @@ static void pgss_store(uint64 queryid, pgssStoreKind kind); static void pg_stat_monitor_internal(FunctionCallInfo fcinfo, + pgsmVersion api_version, bool showtext); #if PG_VERSION_NUM < 140000 @@ -1573,10 +1586,27 @@ pg_stat_monitor_reset(PG_FUNCTION_ARGS) PG_RETURN_VOID(); } +Datum +pg_stat_monitor_1_0(PG_FUNCTION_ARGS) +{ + pg_stat_monitor_internal(fcinfo, PGSM_V1_0, true); + return (Datum) 0; +} + +Datum +pg_stat_monitor_2_0(PG_FUNCTION_ARGS) +{ + pg_stat_monitor_internal(fcinfo, PGSM_V2_0, true); + return (Datum) 0; +} + +/* + * Legacy entry point for pg_stat_monitor() API versions 1.0 + */ Datum pg_stat_monitor(PG_FUNCTION_ARGS) { - pg_stat_monitor_internal(fcinfo, true); + pg_stat_monitor_internal(fcinfo, PGSM_V1_0, true); return (Datum) 0; } @@ -1603,6 +1633,7 @@ IsBucketValid(uint64 bucketid) /* Common code for all versions of pg_stat_statements() */ static void pg_stat_monitor_internal(FunctionCallInfo fcinfo, + pgsmVersion api_version, bool showtext) { ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;