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",
75 manifest->manifest_size = UINT64CONST(0);
82 "{ \"PostgreSQL-Backup-Manifest-Version\": 1,\n"
101 const char *pathname,
size_t size,
pg_time_t mtime,
119 snprintf(pathbuf,
sizeof(pathbuf),
"pg_tblspc/%u/%s", spcoid,
145 pathlen = strlen(pathname);
184 elog(
ERROR,
"could not finalize checksum of file \"%s\"",
188 ", \"Checksum-Algorithm\": \"%s\", \"Checksum\": \"",
217 bool first_wal_range =
true;
218 bool found_start_timeline =
false;
232 foreach(lc, timelines)
251 if (first_wal_range && endtli != entry->
tli)
253 errmsg(
"expected end timeline %u but found timeline %u",
254 starttli, entry->
tli));
263 if (starttli == entry->
tli)
264 tl_beginptr = startptr;
267 tl_beginptr = entry->
begin;
277 errmsg(
"expected start timeline %u but found timeline %u",
278 starttli, entry->
tli));
282 "%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }",
283 first_wal_range ?
"" :
",\n",
288 if (starttli == entry->
tli)
290 found_start_timeline =
true;
294 endptr = entry->
begin;
295 first_wal_range =
false;
302 if (!found_start_timeline)
304 errmsg(
"start timeline %u not found in history of timeline %u",
319 size_t manifest_bytes_done = 0;
335 manifest->still_checksumming =
false;
337 sizeof(checksumbuf)) < 0)
338 elog(
ERROR,
"failed to finalize checksum of backup manifest: %s",
342 hex_encode((
char *) checksumbuf,
sizeof checksumbuf, checksumstringbuf);
355 errmsg(
"could not rewind temporary file")));
362 while (manifest_bytes_done < manifest->manifest_size)
364 size_t bytes_to_read;
367 manifest->manifest_size - manifest_bytes_done);
370 manifest_bytes_done += bytes_to_read;
390 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 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)
elog(ERROR, "%s: %s", p2, msg)
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(StringInfo buf, const char *str)
Assert(fmt[strlen(fmt) - 1] !='\n')
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
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)
#define LSN_FORMAT_ARGS(lsn)
#define XLogRecPtrIsInvalid(r)