42 #define AppendToManifest(manifest, ...) \
44 char *_manifest_s = psprintf(__VA_ARGS__); \
45 AppendStringToManifest(manifest, _manifest_s); \
62 manifest->checksum_type = manifest_checksum_type;
71 elog(
ERROR,
"failed to initialize checksum of backup manifest: %s",
82 "{ \"PostgreSQL-Backup-Manifest-Version\": 2,\n"
147 pathlen = strlen(pathname);
186 elog(
ERROR,
"could not finalize checksum of file \"%s\"",
190 ", \"Checksum-Algorithm\": \"%s\", \"Checksum\": \"",
219 bool first_wal_range =
true;
220 bool found_start_timeline =
false;
234 foreach(lc, timelines)
253 if (first_wal_range && endtli != entry->
tli)
255 errmsg(
"expected end timeline %u but found timeline %u",
256 starttli, entry->
tli));
265 if (starttli == entry->
tli)
266 tl_beginptr = startptr;
269 tl_beginptr = entry->
begin;
279 errmsg(
"expected start timeline %u but found timeline %u",
280 starttli, entry->
tli));
284 "%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }",
285 first_wal_range ?
"" :
",\n",
290 if (starttli == entry->
tli)
292 found_start_timeline =
true;
296 endptr = entry->
begin;
297 first_wal_range =
false;
304 if (!found_start_timeline)
306 errmsg(
"start timeline %u not found in history of timeline %u",
321 size_t manifest_bytes_done = 0;
337 manifest->still_checksumming =
false;
339 sizeof(checksumbuf)) < 0)
340 elog(
ERROR,
"failed to finalize checksum of backup manifest: %s",
344 hex_encode((
char *) checksumbuf,
sizeof checksumbuf, checksumstringbuf);
357 errmsg(
"could not rewind temporary file")));
364 while (manifest_bytes_done < manifest->manifest_size)
366 size_t bytes_to_read;
369 manifest->manifest_size - manifest_bytes_done);
372 manifest_bytes_done += bytes_to_read;
392 elog(
ERROR,
"failed to update checksum of backup manifest: %s",
List * readTimeLineHistory(TimeLineID targetTLI)
void InitializeBackupManifest(backup_manifest_info *manifest, backup_manifest_option want_manifest, pg_checksum_type manifest_checksum_type)
void AddFileToBackupManifest(backup_manifest_info *manifest, Oid spcoid, const char *pathname, size_t size, pg_time_t mtime, pg_checksum_context *checksum_ctx)
void AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr, TimeLineID starttli, XLogRecPtr endptr, TimeLineID endtli)
void SendBackupManifest(backup_manifest_info *manifest, bbsink *sink)
void FreeBackupManifest(backup_manifest_info *manifest)
#define AppendToManifest(manifest,...)
static void AppendStringToManifest(backup_manifest_info *manifest, const char *s)
static bool IsManifestEnabled(backup_manifest_info *manifest)
@ MANIFEST_OPTION_FORCE_ENCODE
enum manifest_option backup_manifest_option
static void bbsink_begin_manifest(bbsink *sink)
static void bbsink_end_manifest(bbsink *sink)
static void bbsink_manifest_contents(bbsink *sink, size_t len)
void BufFileReadExact(BufFile *file, void *ptr, size_t size)
BufFile * BufFileCreateTemp(bool interXact)
void BufFileWrite(BufFile *file, const void *ptr, size_t size)
int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
void BufFileClose(BufFile *file)
#define Assert(condition)
#define OidIsValid(objectId)
char * pg_checksum_type_name(pg_checksum_type type)
int pg_checksum_final(pg_checksum_context *context, uint8 *output)
#define PG_CHECKSUM_MAX_LENGTH
int pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)
int pg_cryptohash_init(pg_cryptohash_ctx *ctx)
void pg_cryptohash_free(pg_cryptohash_ctx *ctx)
pg_cryptohash_ctx * pg_cryptohash_create(pg_cryptohash_type type)
int pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len)
const char * pg_cryptohash_error(pg_cryptohash_ctx *ctx)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
uint64 hex_encode(const char *src, size_t len, char *dst)
void escape_json_with_len(StringInfo buf, const char *str, int len)
bool pg_verify_mbstr(int encoding, const char *mbstr, int len, bool noError)
void pfree(void *pointer)
struct pg_tm * pg_gmtime(const pg_time_t *timep)
size_t pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
#define PG_SHA256_DIGEST_LENGTH
#define PG_SHA256_DIGEST_STRING_LENGTH
static pg_noinline void Size size
void appendStringInfo(StringInfo str, const char *fmt,...)
void enlargeStringInfo(StringInfo str, int needed)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
uint64 GetSystemIdentifier(void)
#define LSN_FORMAT_ARGS(lsn)
#define XLogRecPtrIsInvalid(r)