mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
Add contrib/pg_walinspect.
Provides similar functionality to pg_waldump, but from a SQL interface rather than a separate utility. Author: Bharath Rupireddy Reviewed-by: Greg Stark, Kyotaro Horiguchi, Andres Freund, Ashutosh Sharma, Nitin Jadhav, RKN Sai Krishna Discussion: https://postgr.es/m/CALj2ACUGUYXsEQdKhEdsBzhGEyF3xggvLdD8C0VT72TNEfOiog%40mail.gmail.com
This commit is contained in:
@@ -80,6 +80,10 @@ typedef struct xl_invalid_page
|
||||
|
||||
static HTAB *invalid_page_tab = NULL;
|
||||
|
||||
static int
|
||||
read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
||||
int reqLen, XLogRecPtr targetRecPtr,
|
||||
char *cur_page, bool wait_for_wal);
|
||||
|
||||
/* Report a reference to an invalid page */
|
||||
static void
|
||||
@@ -870,6 +874,31 @@ wal_segment_close(XLogReaderState *state)
|
||||
int
|
||||
read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
||||
int reqLen, XLogRecPtr targetRecPtr, char *cur_page)
|
||||
{
|
||||
return read_local_xlog_page_guts(state, targetPagePtr, reqLen,
|
||||
targetRecPtr, cur_page, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as read_local_xlog_page except that it doesn't wait for future WAL
|
||||
* to be available.
|
||||
*/
|
||||
int
|
||||
read_local_xlog_page_no_wait(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
||||
int reqLen, XLogRecPtr targetRecPtr,
|
||||
char *cur_page)
|
||||
{
|
||||
return read_local_xlog_page_guts(state, targetPagePtr, reqLen,
|
||||
targetRecPtr, cur_page, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of read_local_xlog_page and its no wait version.
|
||||
*/
|
||||
static int
|
||||
read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
||||
int reqLen, XLogRecPtr targetRecPtr,
|
||||
char *cur_page, bool wait_for_wal)
|
||||
{
|
||||
XLogRecPtr read_upto,
|
||||
loc;
|
||||
@@ -925,6 +954,10 @@ read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
||||
if (loc <= read_upto)
|
||||
break;
|
||||
|
||||
/* If asked, let's not wait for future WAL. */
|
||||
if (!wait_for_wal)
|
||||
break;
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
pg_usleep(1000L);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user