29#define READ_CHUNK_SIZE (128 * 1024)
38#define READ_ANY_WAL(privateInfo) ((privateInfo)->start_segno == 0)
78#define SH_PREFIX ArchivedWAL
79#define SH_ELEMENT_TYPE ArchivedWALFile
80#define SH_KEY_TYPE const char *
82#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
83#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
84#define SH_SCOPE static inline
85#define SH_RAW_ALLOCATOR pg_malloc0
185 while (entry ==
NULL)
188 pg_fatal(
"could not find WAL in archive \"%s\"",
206 "invalid WAL segment size in WAL file from archive \"%s\" (%d bytes)",
242 if (privateInfo->
timeline != timeline ||
305 size_t nbytes = count;
307 int segsize = privateInfo->
segsize;
367 pg_fatal(
"WAL segment \"%s\" in archive \"%s\" is too short: read %zu of %zu bytes",
369 (count - nbytes), count);
371 pg_fatal(
"unexpected end of archive \"%s\" while reading \"%s\": read %zu of %zu bytes",
373 (count - nbytes), count);
503 pg_fatal(
"could not close file \"%s/%s\": %m",
516 pg_fatal(
"could not find WAL \"%s\" in archive \"%s\"",
548 pg_fatal(
"could not read file \"%s\": %m",
590 template =
psprintf(
"%s/waldump_tmp-XXXXXX",
595 pg_fatal(
"could not create directory \"%s\": %m",
template);
626 pg_fatal(
"could not set permissions on file \"%s\": %m",
669 return &streamer->
base;
718 if (privateInfo->
timeline != timeline ||
743 pg_log_warning(
"ignoring duplicate WAL \"%s\" found in archive \"%s\"",
779 pg_fatal(
"unexpected state while parsing tar file");
853 const unsigned char *ss = (
const unsigned char *) s;
int read_archive_wal_page(XLogDumpPrivate *privateInfo, XLogRecPtr targetPagePtr, size_t count, char *readBuff)
static void astreamer_waldump_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
static astreamer * astreamer_waldump_new(XLogDumpPrivate *privateInfo)
#define READ_ANY_WAL(privateInfo)
static uint32 hash_string_pointer(const char *s)
static const astreamer_ops astreamer_waldump_ops
static void astreamer_waldump_free(astreamer *streamer)
static void perform_tmp_write(const char *fname, StringInfo buf, FILE *file)
void free_archive_reader(XLogDumpPrivate *privateInfo)
static void astreamer_waldump_finalize(astreamer *streamer)
static bool member_is_wal_file(astreamer_waldump *mystreamer, astreamer_member *member, char **fname)
static ArchivedWALFile * get_archive_wal_entry(const char *fname, XLogDumpPrivate *privateInfo)
static FILE * prepare_tmp_write(const char *fname, XLogDumpPrivate *privateInfo)
static bool read_archive_file(XLogDumpPrivate *privateInfo)
static void setup_tmpwal_dir(const char *waldir)
void free_archive_wal_entry(const char *fname, XLogDumpPrivate *privateInfo)
void init_archive_reader(XLogDumpPrivate *privateInfo, pg_compress_algorithm compression)
static void astreamer_free(astreamer *streamer)
static void astreamer_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
static void astreamer_finalize(astreamer *streamer)
astreamer_archive_context
@ ASTREAMER_MEMBER_HEADER
@ ASTREAMER_MEMBER_CONTENTS
@ ASTREAMER_MEMBER_TRAILER
@ ASTREAMER_ARCHIVE_TRAILER
astreamer * astreamer_gzip_decompressor_new(astreamer *next)
astreamer * astreamer_lz4_decompressor_new(astreamer *next)
astreamer * astreamer_tar_parser_new(astreamer *next)
astreamer * astreamer_zstd_decompressor_new(astreamer *next)
#define ngettext(s, p, n)
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void * pg_malloc(size_t size)
#define palloc0_object(type)
uint32 hash_bytes(const unsigned char *k, int keylen)
#define pg_log_error(...)
#define pg_log_error_detail(...)
#define pg_log_debug(...)
void pfree(void *pointer)
char * pnstrdup(const char *in, Size len)
static char buf[DEFAULT_XLOG_SEG_SIZE]
int open_file_in_directory(const char *directory, const char *fname)
#define pg_log_warning(...)
void canonicalize_path(char *path)
char * mkdtemp(char *path)
static int fd(const char *x, int i)
char * psprintf(const char *fmt,...)
void destroyStringInfo(StringInfo str)
StringInfo makeStringInfo(void)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
struct ArchivedWAL_hash * archive_wal_htab
astreamer * archive_streamer
struct ArchivedWALFile * cur_file
size_t archive_read_buf_size
void(* content)(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
XLogDumpPrivate * privateInfo
const astreamer_ops * bbs_ops
#define IsValidWalSegSize(size)
XLogLongPageHeaderData * XLogLongPageHeader
static bool IsXLogFileName(const char *fname)
static void XLogFromFileName(const char *fname, TimeLineID *tli, XLogSegNo *logSegNo, int wal_segsz_bytes)
#define XLogSegNoOffsetToRecPtr(segno, offset, wal_segsz_bytes, dest)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define XLogRecPtrIsInvalid(r)