aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/pgstatfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-02-19 21:36:50 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-02-19 21:36:50 -0500
commit2fb7a75f37d0beca80f45e15736ec8d50064228a (patch)
tree75b55578c09991a16f3714b928e3e5d8d717a8fd /src/backend/utils/adt/pgstatfuncs.c
parent634618ecd039cf99fb8212b0314ef8a3754ca9c2 (diff)
downloadpostgresql-2fb7a75f37d0beca80f45e15736ec8d50064228a.tar.gz
postgresql-2fb7a75f37d0beca80f45e15736ec8d50064228a.zip
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
Diffstat (limited to 'src/backend/utils/adt/pgstatfuncs.c')
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 389ea494dbb..9964c5e1032 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -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)