PostgreSQL Source Code  git master
pg_verifybackup.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_verifybackup.h
4  * Verify a backup against a backup manifest.
5  *
6  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/bin/pg_verifybackup/pg_verifybackup.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #ifndef PG_VERIFYBACKUP_H
15 #define PG_VERIFYBACKUP_H
16 
18 #include "common/hashfn_unstable.h"
19 #include "common/logging.h"
20 #include "common/parse_manifest.h"
21 #include "fe_utils/astreamer.h"
22 #include "fe_utils/simple_list.h"
23 
24 /*
25  * Each file described by the manifest file is parsed to produce an object
26  * like this.
27  */
28 typedef struct manifest_file
29 {
30  uint32 status; /* hash status */
31  const char *pathname;
32  uint64 size;
34  int checksum_length;
36  bool matched;
37  bool bad;
39 
40 #define should_verify_checksum(m) \
41  (((m)->matched) && !((m)->bad) && (((m)->checksum_type) != CHECKSUM_TYPE_NONE))
42 
43 /*
44  * Define a hash table which we can use to store information about the files
45  * mentioned in the backup manifest.
46  */
47 #define SH_PREFIX manifest_files
48 #define SH_ELEMENT_TYPE manifest_file
49 #define SH_KEY_TYPE const char *
50 #define SH_KEY pathname
51 #define SH_HASH_KEY(tb, key) hash_string(key)
52 #define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
53 #define SH_SCOPE static inline
54 #define SH_RAW_ALLOCATOR pg_malloc0
55 #define SH_DECLARE
56 #define SH_DEFINE
57 #include "lib/simplehash.h"
58 
59 /*
60  * Each WAL range described by the manifest file is parsed to produce an
61  * object like this.
62  */
63 typedef struct manifest_wal_range
64 {
68  struct manifest_wal_range *next;
69  struct manifest_wal_range *prev;
71 
72 /*
73  * All the data parsed from a backup_manifest file.
74  */
75 typedef struct manifest_data
76 {
77  int version;
78  uint64 system_identifier;
79  manifest_files_hash *files;
83 
84 /*
85  * All of the context information we need while checking a backup manifest.
86  */
87 typedef struct verifier_context
88 {
92  char format; /* backup format: p(lain)/t(ar) */
97 
99  const char *pg_restrict fmt,...)
100  pg_attribute_printf(2, 3);
101 extern void report_fatal_error(const char *pg_restrict fmt,...)
104  const char *relpath);
105 
108  char *archive_name,
109  Oid tblspc_oid);
110 
111 #endif /* PG_VERIFYBACKUP_H */
static int32 next
Definition: blutils.c:222
unsigned int uint32
Definition: c.h:506
#define pg_attribute_printf(f, a)
Definition: c.h:194
unsigned char uint8
Definition: c.h:504
pg_checksum_type
static void const char * fmt
struct verifier_context verifier_context
astreamer * astreamer_verify_content_new(astreamer *next, verifier_context *context, char *archive_name, Oid tblspc_oid)
bool should_ignore_relpath(verifier_context *context, const char *relpath)
struct manifest_wal_range manifest_wal_range
void void report_fatal_error(const char *pg_restrict fmt,...) pg_attribute_printf(1
struct manifest_file manifest_file
void report_backup_error(verifier_context *context, const char *pg_restrict fmt,...) pg_attribute_printf(2
void void pg_attribute_noreturn()
struct manifest_data manifest_data
unsigned int Oid
Definition: postgres_ext.h:31
tree context
Definition: radixtree.h:1835
#define relpath(rlocator, forknum)
Definition: relpath.h:102
manifest_wal_range * last_wal_range
Definition: load_manifest.h:61
manifest_wal_range * first_wal_range
Definition: load_manifest.h:60
uint64 system_identifier
Definition: load_manifest.h:58
manifest_files_hash * files
Definition: load_manifest.h:59
uint8 * checksum_payload
Definition: load_manifest.h:29
pg_checksum_type checksum_type
Definition: load_manifest.h:27
const char * pathname
Definition: load_manifest.h:25
XLogRecPtr end_lsn
Definition: load_manifest.h:48
struct manifest_wal_range * next
Definition: load_manifest.h:49
struct manifest_wal_range * prev
Definition: load_manifest.h:50
XLogRecPtr start_lsn
Definition: load_manifest.h:47
SimpleStringList ignore_list
manifest_data * manifest
uint64 XLogRecPtr
Definition: xlogdefs.h:21
uint32 TimeLineID
Definition: xlogdefs.h:59