From 7ba6e4f0e08bd7bdf4d12974ac1e37fb0459c97c Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 9 Nov 2010 22:39:43 -0500 Subject: Add monitoring function pg_last_xact_replay_timestamp. Fujii Masao, with a little wordsmithing by me. --- src/backend/access/transam/xlog.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 786d0c696d1..7708b93fffb 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5604,6 +5604,24 @@ GetLatestXTime(void) return xtime; } +/* + * Returns timestamp of latest processed commit/abort record. + * + * When the server has been started normally without recovery the function + * returns NULL. + */ +Datum +pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS) +{ + TimestampTz xtime; + + xtime = GetLatestXTime(); + if (xtime == 0) + PG_RETURN_NULL(); + + PG_RETURN_TIMESTAMPTZ(xtime); +} + /* * Returns bool with current recovery mode, a global state. */ -- cgit v1.2.3