From 5c1b6628075a30b4eed6eb5835c2d2734254fa86 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 14 Mar 2023 20:13:02 +0900 Subject: Rework design of functions in pg_walinspect This commit reworks a bit the set-returning functions of pg_walinspect, making them more flexible regarding their end LSN: - pg_get_wal_records_info() - pg_get_wal_stats() - pg_get_wal_block_info() The end LSNs given to these functions is now handled so as a value higher than the current LSN of the cluster (insert LSN for a primary, or replay LSN for a standby) does not raise an error, giving more flexibility to monitoring queries. Instead, the functions return results up to the current LSN, as found at the beginning of each function call. As an effect of that, pg_get_wal_records_info_till_end_of_wal() and pg_get_wal_stats_till_end_of_wal() are now removed from 1.1, as the existing, equivalent functions are able to offer the same possibilities. Author: Bharath Rupireddy Discussion: https://postgr.es/m/CALj2ACU0_q-o4DSweyaW9NO1KBx-QkN6G_OzYQvpjf3CZVASkg@mail.gmail.com --- doc/src/sgml/pgwalinspect.sgml | 59 +++++++++++------------------------------- 1 file changed, 15 insertions(+), 44 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/pgwalinspect.sgml b/doc/src/sgml/pgwalinspect.sgml index 3b19863dce9..9a0241a8d67 100644 --- a/doc/src/sgml/pgwalinspect.sgml +++ b/doc/src/sgml/pgwalinspect.sgml @@ -94,9 +94,11 @@ block_ref | blkref #0: rel 1663/5/60221 fork main blk 2 Gets information of all the valid WAL records between start_lsn and end_lsn. - Returns one row per WAL record. If start_lsn - or end_lsn are not yet available, the - function will raise an error. For example: + Returns one row per WAL record. If a future + end_lsn (i.e. ahead of the current LSN of + the server) is specified, it returns information until the end of WAL. + The function raises an error if start_lsn + is not available. For example, usage of the function is as follows: postgres=# SELECT * FROM pg_get_wal_records_info('0/1E913618', '0/1E913740') LIMIT 1; -[ RECORD 1 ]----+-------------------------------------------------------------- @@ -116,23 +118,6 @@ block_ref | - - - - pg_get_wal_records_info_till_end_of_wal(start_lsn pg_lsn) - returns setof record - - - - - - This function is the same as pg_get_wal_records_info(), - except that it gets information of all the valid WAL records from - start_lsn till the end of WAL. - - - - @@ -148,10 +133,11 @@ block_ref | end_lsn. By default, it returns one row per resource_manager type. When per_record is set to true, - it returns one row per record_type. - If start_lsn - or end_lsn are not yet available, the - function will raise an error. For example: + it returns one row per record_type. If a + future end_lsn (i.e. ahead of the current + LSN of the server) is specified, it returns statistics until the end + of WAL. An error is raised if start_lsn is + not available. For example, usage of the function is as follows: postgres=# SELECT * FROM pg_get_wal_stats('0/1E847D00', '0/1E84F500') WHERE count > 0 LIMIT 1 AND @@ -171,23 +157,6 @@ combined_size_percentage | 2.8634072910530795 - - - - pg_get_wal_stats_till_end_of_wal(start_lsn pg_lsn, per_record boolean DEFAULT false) - returns setof record - - - - - - This function is the same as pg_get_wal_stats(), - except that it gets statistics of all the valid WAL records from - start_lsn till end of WAL. - - - - pg_get_wal_block_info(start_lsn pg_lsn, end_lsn pg_lsn) returns setof record @@ -202,9 +171,11 @@ combined_size_percentage | 2.8634072910530795 and their information associated with all the valid WAL records between start_lsn and end_lsn. Returns one row per block registered - in a WAL record. If start_lsn or - end_lsn are not yet available, the function - will raise an error. For example: + in a WAL record. If a future end_lsn (i.e. + ahead of the current LSN of the server) is specified, it returns + statistics until the end of WAL. An error is raised if + start_lsn is not available. For example, + usage of the function is as follows: postgres=# SELECT lsn, blockid, reltablespace, reldatabase, relfilenode, relblocknumber, forkname, -- cgit v1.2.3