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
40 char *archive_read_buf; /* Reusable read buffer for archive I/O */
41
42#ifdef USE_ASSERT_CHECKING
44#endif
45
46 /* What the archive streamer is currently reading */
48
49 /*
50 * Hash table of WAL segments currently buffered from the archive,
51 * including any segment currently being streamed. Entries are removed
52 * once consumed, so this does not accumulate all segments ever read.
53 */
55
56 /*
57 * Pre-computed segment numbers derived from startptr and endptr. Caching
58 * them avoids repeated XLByteToSeg() calls when filtering each archive
59 * member against the requested WAL range. end_segno is initialized to
60 * UINT64_MAX when no end limit is requested.
61 */
65
66extern int open_file_in_directory(const char *directory, const char *fname);
67
68extern void init_archive_reader(XLogDumpPrivate *privateInfo,
69 pg_compress_algorithm compression);
70extern void free_archive_reader(XLogDumpPrivate *privateInfo);
71extern int read_archive_wal_page(XLogDumpPrivate *privateInfo,
73 Size count, char *readBuff);
74extern void free_archive_wal_entry(const char *fname,
75 XLogDumpPrivate *privateInfo);
76
77#endif /* PG_WALDUMP_H */
size_t Size
Definition c.h:691
pg_compress_algorithm
Definition compression.h:22
char * TmpWalSegDir
int open_file_in_directory(const char *directory, const char *fname)
Definition pg_waldump.c:180
int read_archive_wal_page(XLogDumpPrivate *privateInfo, XLogRecPtr targetPagePtr, Size count, char *readBuff)
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:62
struct ArchivedWAL_hash * archive_wal_htab
Definition pg_waldump.h:54
XLogRecPtr endptr
Definition pg_waldump.h:30
astreamer * archive_streamer
Definition pg_waldump.h:39
char * archive_read_buf
Definition pg_waldump.h:40
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:63
struct ArchivedWALFile * cur_file
Definition pg_waldump.h:47
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