mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Add pg_stat_get_snapshot_timestamp() to show statistics snapshot timestamp.
Per discussion, this could be useful for purposes such as programmatically detecting a nonresponding stats collector. We already have the timestamp anyway, it's just a matter of providing a SQL-accessible function to fetch it. Matt Kelly, reviewed by Jim Nasby
This commit is contained in:
@ -115,6 +115,7 @@ extern Datum pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum pg_stat_get_snapshot_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_clear_snapshot(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_reset(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_reset_shared(PG_FUNCTION_ARGS);
|
||||
@ -1682,6 +1683,13 @@ pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
|
||||
/* Get the timestamp of the current statistics snapshot */
|
||||
Datum
|
||||
pg_stat_get_snapshot_timestamp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_TIMESTAMPTZ(pgstat_fetch_global()->stats_timestamp);
|
||||
}
|
||||
|
||||
/* Discard the active statistics snapshot */
|
||||
Datum
|
||||
pg_stat_clear_snapshot(PG_FUNCTION_ARGS)
|
||||
|
Reference in New Issue
Block a user