pg_last_xact_replay_timestamp_v1.patch
application/octet-stream
Filename: pg_last_xact_replay_timestamp_v1.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
Series: patch v1
| File | + | − |
|---|---|---|
| doc/src/sgml/func.sgml | 18 | 0 |
| src/backend/access/transam/xlog.c | 18 | 0 |
| src/include/access/xlog_internal.h | 1 | 0 |
| src/include/catalog/pg_proc.h | 2 | 0 |
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
***************
*** 13551,13556 **** postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
--- 13551,13559 ----
<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,13610 **** postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
--- 13608,13628 ----
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 replayed transaction during recovery.
+ This timestamp indicates the time when the commit or abort record
+ of that transaction was generated.
+ 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>
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 5605,5610 **** GetLatestXTime(void)
--- 5605,5628 ----
}
/*
+ * 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.
*/
Datum
*** a/src/include/access/xlog_internal.h
--- b/src/include/access/xlog_internal.h
***************
*** 271,276 **** extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
--- 271,277 ----
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);
*** a/src/include/catalog/pg_proc.h
--- b/src/include/catalog/pg_proc.h
***************
*** 3383,3388 **** DATA(insert OID = 3820 ( pg_last_xlog_receive_location PGNSP PGUID 12 1 0 0 f f
--- 3383,3390 ----
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");