From: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | pg_walfile_name uses XLByteToPrevSeg |
Date: | 2022-02-04 14:05:05 |
Message-ID: | CAExHW5uPqLh4627AXn6BD5TXsayEv2+xov66eGDtAuHVFuKD+Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi All,
pg_walfile_name() returns the WAL file name corresponding to the given
WAL location. Per
https://www.postgresql.org/docs/14/functions-admin.html
---
pg_walfile_name ( lsn pg_lsn ) → text
Converts a write-ahead log location to the name of the WAL file
holding that location.
---
The function uses XLByteToPrevSeg() which gives the name of previous
WAL file if the location falls on the boundary of WAL segment. I find
it misleading since the given LSN will fall into the segment provided
by XLByteToSeg() and not XLBytePrevSeg().
And it gives some surprising results as well
---
#select pg_walfile_name('0/0'::pg_lsn);
pg_walfile_name
--------------------------
00000001FFFFFFFF000000FF
(1 row)
----
Comment in the code says
---
/*
* Compute an xlog file name given a WAL location,
* such as is returned by pg_stop_backup() or pg_switch_wal().
*/
Datum
pg_walfile_name(PG_FUNCTION_ARGS)
---
XLByteToPrevSeg() may be inline with the comment but I don't think
that's what is conveyed by the documentation at least.
--
Best Wishes,
Ashutosh
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2022-02-04 14:10:42 | Re: Extensible Rmgr for Table AMs |
Previous Message | Robert Haas | 2022-02-04 13:46:39 | Re: make MaxBackends available in _PG_init |