36 .
name =
"pg_walinspect",
52 bool *nulls,
uint32 ncols);
58 bool stats_per_record);
67 bool stats_per_record);
112 errmsg(
"could not read WAL at LSN %X/%08X",
127 errdetail(
"Failed while allocating a WAL reading processor.")));
136 errmsg(
"could not find a valid record after %X/%08X: %s",
140 errmsg(
"could not find a valid record after %X/%08X",
181 errmsg(
"could not read WAL at %X/%08X: %s",
186 errmsg(
"could not read WAL at %X/%08X",
203 bool *nulls,
uint32 ncols)
205 const char *record_type;
215 if (record_type ==
NULL)
265#define PG_GET_WAL_BLOCK_INFO_COLS 20
269 const char *record_type;
277 if (record_type ==
NULL)
278 record_type =
psprintf(
"UNKNOWN (%x)",
325 if (
blk->apply_image)
418#undef PG_GET_WAL_BLOCK_INFO_COLS
441 "pg_get_wal_block_info temporary cxt",
475#define PG_GET_WAL_RECORD_INFO_COLS 11
491 errmsg(
"WAL input LSN must be less than current LSN"),
492 errdetail(
"Current WAL LSN on the database system is at %X/%08X.",
497 elog(
ERROR,
"return type must be a row type");
504 errmsg(
"could not read WAL at %X/%08X",
516#undef PG_GET_WAL_RECORD_INFO_COLS
533 errmsg(
"WAL start LSN must be less than current LSN"),
534 errdetail(
"Current WAL LSN on the database system is at %X/%08X.",
537 if (start_lsn > *end_lsn)
540 errmsg(
"WAL start LSN must be less than end LSN")));
553#define PG_GET_WAL_RECORDS_INFO_COLS 11
559 Assert(start_lsn <= end_lsn);
566 "GetWALRecordsInfo temporary cxt",
595#undef PG_GET_WAL_RECORDS_INFO_COLS
665 bool stats_per_record)
691 "GetXLogSummaryStats temporary cxt",
710 if (stats_per_record)
758 total_len,
values, nulls, ncols);
777 bool stats_per_record)
779#define PG_GET_WAL_STATS_COLS 9
786 Assert(start_lsn <= end_lsn);
807#undef PG_GET_WAL_STATS_COLS
821 GetWalStats(fcinfo, start_lsn, end_lsn, stats_per_record);
836 if (start_lsn > end_lsn)
839 errmsg(
"WAL start LSN must be less than current LSN"),
840 errdetail(
"Current WAL LSN on the database system is at %X/%08X.",
855 if (start_lsn > end_lsn)
858 errmsg(
"WAL start LSN must be less than current LSN"),
859 errdetail(
"Current WAL LSN on the database system is at %X/%08X.",
862 GetWalStats(fcinfo, start_lsn, end_lsn, stats_per_record);
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
#define palloc0_array(type, count)
#define palloc0_object(type)
#define PG_MODULE_MAGIC_EXT(...)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static uint64 pg_popcount(const char *buf, int bytes)
static Datum LSNGetDatum(XLogRecPtr X)
static char buf[DEFAULT_XLOG_SEG_SIZE]
static void GetWALRecordInfo(XLogReaderState *record, Datum *values, bool *nulls, uint32 ncols)
#define PG_GET_WAL_STATS_COLS
Datum pg_get_wal_records_info(PG_FUNCTION_ARGS)
Datum pg_get_wal_stats(PG_FUNCTION_ARGS)
static void GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, XLogRecPtr end_lsn, bool stats_per_record)
#define PG_GET_WAL_RECORDS_INFO_COLS
#define PG_GET_WAL_RECORD_INFO_COLS
static void GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record, bool show_data)
Datum pg_get_wal_block_info(PG_FUNCTION_ARGS)
static void GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
Datum pg_get_wal_records_info_till_end_of_wal(PG_FUNCTION_ARGS)
#define PG_GET_WAL_BLOCK_INFO_COLS
static XLogRecord * ReadNextXLogRecord(XLogReaderState *xlogreader)
static XLogReaderState * InitXLogReaderState(XLogRecPtr lsn)
Datum pg_get_wal_stats_till_end_of_wal(PG_FUNCTION_ARGS)
static void GetXLogSummaryStats(XLogStats *stats, ReturnSetInfo *rsinfo, Datum *values, bool *nulls, uint32 ncols, bool stats_per_record)
static void FillXLogStatsRow(const char *name, uint64 n, uint64 total_count, uint64 rec_len, uint64 total_rec_len, uint64 fpi_len, uint64 total_fpi_len, uint64 tot_len, uint64 total_len, Datum *values, bool *nulls, uint32 ncols)
static void ValidateInputLSNs(XLogRecPtr start_lsn, XLogRecPtr *end_lsn)
Datum pg_get_wal_record_info(PG_FUNCTION_ARGS)
static XLogRecPtr GetCurrentLSN(void)
static Datum Int64GetDatum(int64 X)
static Datum PointerGetDatum(const void *X)
static Datum TransactionIdGetDatum(TransactionId X)
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
static Datum Float8GetDatum(float8 X)
static Datum UInt32GetDatum(uint32 X)
char * psprintf(const char *fmt,...)
#define RmgrIdIsValid(rmid)
void initStringInfo(StringInfo str)
const char *(* rm_identify)(uint8 info)
void(* rm_desc)(StringInfo buf, XLogReaderState *record)
XLogRecStats record_stats[RM_MAX_ID+1][MAX_XLINFO_TYPES]
XLogRecStats rmgr_stats[RM_MAX_ID+1]
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
static char * VARDATA(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)
bool RecoveryInProgress(void)
XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)
static RmgrData GetRmgr(RmgrId rmid)
static bool RmgrIdExists(RmgrId rmid)
#define XLogRecPtrIsValid(r)
#define LSN_FORMAT_ARGS(lsn)
void XLogRecGetBlockRefInfo(XLogReaderState *record, bool pretty, bool detailed_format, StringInfo buf, uint32 *fpi_len)
bool XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum, Buffer *prefetch_buffer)
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, XLogReaderRoutine *routine, void *private_data)
XLogRecord * XLogReadRecord(XLogReaderState *state, char **errormsg)
void XLogReaderFree(XLogReaderState *state)
XLogRecPtr XLogFindNextRecord(XLogReaderState *state, XLogRecPtr RecPtr, char **errormsg)
bool RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
#define XLogRecGetDataLen(decoder)
#define XLogRecGetInfo(decoder)
#define XLogRecGetRmid(decoder)
#define XLogRecGetTotalLen(decoder)
#define XLogRecGetXid(decoder)
#define XLogRecGetBlock(decoder, i)
#define XLogRecMaxBlockId(decoder)
#define XLogRecHasBlockRef(decoder, block_id)
#define XLogRecGetPrev(decoder)
#define XLogRecHasAnyBlockRefs(decoder)
#define BKPIMAGE_COMPRESS_ZSTD
#define BKPIMAGE_HAS_HOLE
#define BKPIMAGE_COMPRESS_LZ4
#define BKPIMAGE_COMPRESS_PGLZ
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
static XLogReaderState * xlogreader
void XLogRecStoreStats(XLogStats *stats, XLogReaderState *record)
void wal_segment_close(XLogReaderState *state)
void wal_segment_open(XLogReaderState *state, XLogSegNo nextSegNo, TimeLineID *tli_p)
int read_local_xlog_page_no_wait(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page)