diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 183b72cda48476db49867bd1eea364734052e627..1be9f90fe5ed4943ba92c5ff26f0dba9cef0a7e5 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -13551,6 +13551,9 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); <indexterm> <primary>pg_last_xlog_replay_location</primary> </indexterm> + <indexterm> + <primary>pg_last_xact_replay_timestamp</primary> + </indexterm> <para> The functions shown in <xref @@ -13605,6 +13608,22 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); the function returns NULL. </entry> </row> + <row> + <entry> + <literal><function>pg_last_xact_replay_timestamp()</function></literal> + </entry> + <entry><type>timestamp with time zone</type></entry> + <entry>Get timestamp of last transaction replayed during recovery. + This is the time at which the commit or abort WAL record for that + transaction was generated. + If no transactions have been replayed during recovery, this function + returns NULL. Otherwise, if recovery is still in progress this will + increase monotonically. If recovery has completed then this value will + remain static at the value of the last transaction applied during that + recovery. When the server has been started normally without recovery + the function returns NULL. + </entry> + </row> </tbody> </tgroup> </table> diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 786d0c696d1d595e3f7ae8dc0105c3b392e30460..7708b93fffbe1e60dd9b78f5c0111927be8ba8f3 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. */ diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 370c989ac056fea7fe1bc1219a86b545559d795a..29a50838fa40fb2497791e48ff82a359c355b6b6 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -271,6 +271,7 @@ extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS); extern Datum pg_current_xlog_insert_location(PG_FUNCTION_ARGS); extern Datum pg_last_xlog_receive_location(PG_FUNCTION_ARGS); extern Datum pg_last_xlog_replay_location(PG_FUNCTION_ARGS); +extern Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS); extern Datum pg_xlogfile_name_offset(PG_FUNCTION_ARGS); extern Datum pg_xlogfile_name(PG_FUNCTION_ARGS); extern Datum pg_is_in_recovery(PG_FUNCTION_ARGS); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 0c1abdbe89843a71c6ad699a72e0cf0ae7d87108..703cbea7d864ac37d5c356380c2364b1016e2e7a 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201010301 +#define CATALOG_VERSION_NO 201011091 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 12c640c3d00efe0f87bcaea3b716dad9790f66db..4f444aef8332004c0edaafc4ab9b3014e274e71b 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -3383,6 +3383,8 @@ DATA(insert OID = 3820 ( pg_last_xlog_receive_location PGNSP PGUID 12 1 0 0 f f DESCR("current xlog flush location"); DATA(insert OID = 3821 ( pg_last_xlog_replay_location PGNSP PGUID 12 1 0 0 f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_last_xlog_replay_location _null_ _null_ _null_ )); DESCR("last xlog replay location"); +DATA(insert OID = 3830 ( pg_last_xact_replay_timestamp PGNSP PGUID 12 1 0 0 f f f t f v 0 0 1184 "" _null_ _null_ _null_ _null_ pg_last_xact_replay_timestamp _null_ _null_ _null_ )); +DESCR("timestamp of last replay xact"); DATA(insert OID = 2621 ( pg_reload_conf PGNSP PGUID 12 1 0 0 f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pg_reload_conf _null_ _null_ _null_ )); DESCR("reload configuration files");