PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_waldump.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_waldump.h - decode and display WAL
4 *
5 * Copyright (c) 2026, PostgreSQL Global Development Group
6 *
7 * IDENTIFICATION
8 * src/bin/pg_waldump/pg_waldump.h
9 *-------------------------------------------------------------------------
10 */
11#ifndef PG_WALDUMP_H
12#define PG_WALDUMP_H
13
14#include "access/xlogdefs.h"
15#include "fe_utils/astreamer.h"
16
17/* Forward declaration */
18struct ArchivedWALFile;
19struct ArchivedWAL_hash;
20
21/* Temporary directory for spilling out-of-order WAL segments from archives */
22extern char *TmpWalSegDir;
23
24/* Contains the necessary information to drive WAL decoding */
25typedef struct XLogDumpPrivate
26{
33
34 /* Fields required to read WAL from archive */
36 char *archive_name; /* Tar archive filename */
37 int archive_fd; /* File descriptor for the open tar file */
38 bool archive_fd_eof; /* Have we reached EOF on archive_fd? */
39
41 char *archive_read_buf; /* Reusable read buffer for archive I/O */
43
44 /*
45 * The buffer for the WAL file the archive streamer is currently reading,
46 * or NULL if none. It is quite risky to examine this anywhere except in
47 * astreamer_waldump_content(), since it can change multiple times during
48 * a single read_archive_file() call. However, it is safe to assume that
49 * if cur_file is different from a particular ArchivedWALFile of interest,
50 * then the archive streamer has finished reading that file.
51 */
53
54 /*
55 * Hash table of WAL segments currently buffered from the archive,
56 * including any segment currently being streamed. Entries are removed
57 * once consumed, so this does not accumulate all segments ever read.
58 */
60
61 /*
62 * Pre-computed segment numbers derived from startptr and endptr. Caching
63 * them avoids repeated XLByteToSeg() calls when filtering each archive
64 * member against the requested WAL range. end_segno is initialized to
65 * UINT64_MAX when no end limit is requested.
66 */
70
71extern int open_file_in_directory(const char *directory, const char *fname);
72
73extern void init_archive_reader(XLogDumpPrivate *privateInfo,
74 pg_compress_algorithm compression);
75extern void free_archive_reader(XLogDumpPrivate *privateInfo);
76extern int read_archive_wal_page(XLogDumpPrivate *privateInfo,
78 size_t count, char *readBuff);
79extern void free_archive_wal_entry(const char *fname,
80 XLogDumpPrivate *privateInfo);
81
82#endif /* PG_WALDUMP_H */
pg_compress_algorithm
Definition compression.h:22
int read_archive_wal_page(XLogDumpPrivate *privateInfo, XLogRecPtr targetPagePtr, size_t count, char *readBuff)
char * TmpWalSegDir
int open_file_in_directory(const char *directory, const char *fname)
Definition pg_waldump.c:182
void free_archive_reader(XLogDumpPrivate *privateInfo)
void free_archive_wal_entry(const char *fname, XLogDumpPrivate *privateInfo)
void init_archive_reader(XLogDumpPrivate *privateInfo, pg_compress_algorithm compression)
static int fb(int x)
XLogSegNo start_segno
Definition pg_waldump.h:67
struct ArchivedWAL_hash * archive_wal_htab
Definition pg_waldump.h:59
XLogRecPtr endptr
Definition pg_waldump.h:30
astreamer * archive_streamer
Definition pg_waldump.h:40
char * archive_read_buf
Definition pg_waldump.h:41
XLogRecPtr startptr
Definition pg_waldump.h:29
char * archive_name
Definition pg_waldump.h:36
TimeLineID timeline
Definition pg_waldump.h:27
char * archive_dir
Definition pg_waldump.h:35
XLogSegNo end_segno
Definition pg_waldump.h:68
struct ArchivedWALFile * cur_file
Definition pg_waldump.h:52
size_t archive_read_buf_size
Definition pg_waldump.h:42
bool decoding_started
Definition pg_waldump.h:32
uint64 XLogRecPtr
Definition xlogdefs.h:21
uint32 TimeLineID
Definition xlogdefs.h:63
uint64 XLogSegNo
Definition xlogdefs.h:52
static const char * directory
Definition zic.c:648