1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Add min() and max() aggregates for pg_lsn

This is useful for monitoring, when it comes for example to calculations
of WAL retention with replication slots and delays with a set of
standbys.

Bump catalog version.

Author: Fabrízio de Royes Mello
Reviewed-by: Surafel Temesgen
Discussion: https://postgr.es/m/CAFcNs+oc8ZoHhowA4rR1GGCgG8QNgK_TOwPRVYQo5rYy8_PXzA@mail.gmail.com
This commit is contained in:
Michael Paquier
2019-07-05 12:21:11 +09:00
parent 8a810a177c
commit 313f87a171
7 changed files with 50 additions and 3 deletions

View File

@@ -171,6 +171,24 @@ pg_lsn_ge(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(lsn1 >= lsn2);
}
Datum
pg_lsn_larger(PG_FUNCTION_ARGS)
{
XLogRecPtr lsn1 = PG_GETARG_LSN(0);
XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_LSN((lsn1 > lsn2) ? lsn1 : lsn2);
}
Datum
pg_lsn_smaller(PG_FUNCTION_ARGS)
{
XLogRecPtr lsn1 = PG_GETARG_LSN(0);
XLogRecPtr lsn2 = PG_GETARG_LSN(1);
PG_RETURN_LSN((lsn1 < lsn2) ? lsn1 : lsn2);
}
/* btree index opclass support */
Datum
pg_lsn_cmp(PG_FUNCTION_ARGS)