29#define READ_CHUNK_SIZE (128 * 1024)
38#define READ_ANY_WAL(privateInfo) ((privateInfo)->start_segno == 0)
72#define SH_PREFIX ArchivedWAL
73#define SH_ELEMENT_TYPE ArchivedWALFile
74#define SH_KEY_TYPE const char *
76#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
77#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
78#define SH_SCOPE static inline
79#define SH_RAW_ALLOCATOR pg_malloc0
164#ifdef USE_ASSERT_CHECKING
182 pg_fatal(
"could not find WAL in archive \"%s\"",
194 "invalid WAL segment size in WAL file from archive \"%s\" (%d bytes)",
224 if (privateInfo->
timeline != timeline ||
287 int segsize = privateInfo->
segsize;
371 Assert((count - nbytes) > 0);
383 pg_fatal(
"WAL segment \"%s\" in archive \"%s\" is too short: read %lld of %lld bytes",
385 (
long long int) (count - nbytes),
386 (
long long int) count);
388 pg_fatal(
"unexpected end of archive \"%s\" while reading \"%s\": read %lld of %lld bytes",
390 (
long long int) (count - nbytes),
391 (
long long int) count);
536 pg_fatal(
"could not find WAL \"%s\" in archive \"%s\"",
550 Assert(privateInfo->archive_read_buf_size >= count);
554 pg_fatal(
"could not read file \"%s\": %m",
585 template =
psprintf(
"%s/waldump_tmp-XXXXXX",
590 pg_fatal(
"could not create directory \"%s\": %m",
template);
640 pg_fatal(
"could not set permissions on file \"%s\": %m",
683 return &streamer->
base;
729 if (privateInfo->
timeline != timeline ||
747 pg_log_warning(
"ignoring duplicate WAL \"%s\" found in archive \"%s\"",
783 pg_fatal(
"unexpected state while parsing tar file");
857 unsigned char *ss = (
unsigned char *) s;
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 cleanup_tmpwal_dir_atexit(void)
static void astreamer_waldump_free(astreamer *streamer)
int read_archive_wal_page(XLogDumpPrivate *privateInfo, XLogRecPtr targetPagePtr, Size count, char *readBuff)
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 int read_archive_file(XLogDumpPrivate *privateInfo, Size count)
static ArchivedWALFile * get_archive_wal_entry(const char *fname, XLogDumpPrivate *privateInfo)
static FILE * prepare_tmp_write(const char *fname, 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)
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)
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,...)
bool rmtree(const char *path, bool rmtopdir)
void destroyStringInfo(StringInfo str)
StringInfo makeStringInfo(void)
void resetStringInfo(StringInfo str)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
struct ArchivedWAL_hash * archive_wal_htab
astreamer * archive_streamer
struct ArchivedWALFile * cur_file
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)