Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa2d6b1

Browse files
committed
pg_verifybackup: Move some declarations to new pg_verifybackup.h
This is in preparation for adding a second source file to thisdirectory.Amul Sul, reviewed by Sravan Kumar and revised a bit by me.Discussion:http://postgr.es/m/CAAJ_b95mcGjkfAf1qduOR97CokW8-_i-dWLm3v6x1w2-OW9M+A@mail.gmail.com
1 parentaf99d44 commitaa2d6b1

File tree

2 files changed

+107
-85
lines changed

2 files changed

+107
-85
lines changed

‎src/bin/pg_verifybackup/pg_verifybackup.c

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
#include<sys/stat.h>
1919
#include<time.h>
2020

21-
#include"common/controldata_utils.h"
22-
#include"common/hashfn_unstable.h"
2321
#include"common/logging.h"
2422
#include"common/parse_manifest.h"
2523
#include"fe_utils/simple_list.h"
2624
#include"getopt_long.h"
25+
#include"pg_verifybackup.h"
2726
#include"pgtime.h"
2827

2928
/*
@@ -45,79 +44,6 @@
4544
*/
4645
#defineREAD_CHUNK_SIZE(128 * 1024)
4746

48-
/*
49-
* Each file described by the manifest file is parsed to produce an object
50-
* like this.
51-
*/
52-
typedefstructmanifest_file
53-
{
54-
uint32status;/* hash status */
55-
constchar*pathname;
56-
size_tsize;
57-
pg_checksum_typechecksum_type;
58-
intchecksum_length;
59-
uint8*checksum_payload;
60-
boolmatched;
61-
boolbad;
62-
}manifest_file;
63-
64-
#defineshould_verify_checksum(m) \
65-
(((m)->matched) && !((m)->bad) && (((m)->checksum_type) != CHECKSUM_TYPE_NONE))
66-
67-
/*
68-
* Define a hash table which we can use to store information about the files
69-
* mentioned in the backup manifest.
70-
*/
71-
#defineSH_PREFIXmanifest_files
72-
#defineSH_ELEMENT_TYPEmanifest_file
73-
#defineSH_KEY_TYPEconst char *
74-
#defineSH_KEYpathname
75-
#defineSH_HASH_KEY(tb,key)hash_string(key)
76-
#defineSH_EQUAL(tb,a,b)(strcmp(a, b) == 0)
77-
#defineSH_SCOPEstatic inline
78-
#defineSH_RAW_ALLOCATORpg_malloc0
79-
#defineSH_DECLARE
80-
#defineSH_DEFINE
81-
#include"lib/simplehash.h"
82-
83-
/*
84-
* Each WAL range described by the manifest file is parsed to produce an
85-
* object like this.
86-
*/
87-
typedefstructmanifest_wal_range
88-
{
89-
TimeLineIDtli;
90-
XLogRecPtrstart_lsn;
91-
XLogRecPtrend_lsn;
92-
structmanifest_wal_range*next;
93-
structmanifest_wal_range*prev;
94-
}manifest_wal_range;
95-
96-
/*
97-
* All the data parsed from a backup_manifest file.
98-
*/
99-
typedefstructmanifest_data
100-
{
101-
intversion;
102-
uint64system_identifier;
103-
manifest_files_hash*files;
104-
manifest_wal_range*first_wal_range;
105-
manifest_wal_range*last_wal_range;
106-
}manifest_data;
107-
108-
/*
109-
* All of the context information we need while checking a backup manifest.
110-
*/
111-
typedefstructverifier_context
112-
{
113-
manifest_data*manifest;
114-
char*backup_directory;
115-
SimpleStringListignore_list;
116-
boolskip_checksums;
117-
boolexit_on_error;
118-
boolsaw_any_error;
119-
}verifier_context;
120-
12147
staticmanifest_data*parse_manifest_file(char*manifest_path);
12248
staticvoidverifybackup_version_cb(JsonManifestParseContext*context,
12349
intmanifest_version);
@@ -151,13 +77,6 @@ static void parse_required_wal(verifier_context *context,
15177
char*pg_waldump_path,
15278
char*wal_directory);
15379

154-
staticvoidreport_backup_error(verifier_context*context,
155-
constchar*pg_restrictfmt,...)
156-
pg_attribute_printf(2,3);
157-
staticvoidreport_fatal_error(constchar*pg_restrictfmt,...)
158-
pg_attribute_printf(1,2)pg_attribute_noreturn();
159-
staticboolshould_ignore_relpath(verifier_context*context,constchar*relpath);
160-
16180
staticvoidprogress_report(boolfinished);
16281
staticvoidusage(void);
16382

@@ -980,7 +899,7 @@ parse_required_wal(verifier_context *context, char *pg_waldump_path,
980899
* Update the context to indicate that we saw an error, and exit if the
981900
* context says we should.
982901
*/
983-
staticvoid
902+
void
984903
report_backup_error(verifier_context*context,constchar*pg_restrictfmt,...)
985904
{
986905
va_listap;
@@ -997,7 +916,7 @@ report_backup_error(verifier_context *context, const char *pg_restrict fmt,...)
997916
/*
998917
* Report a fatal error and exit
999918
*/
1000-
staticvoid
919+
void
1001920
report_fatal_error(constchar*pg_restrictfmt,...)
1002921
{
1003922
va_listap;
@@ -1016,7 +935,7 @@ report_fatal_error(const char *pg_restrict fmt,...)
1016935
* Note that by "prefix" we mean a parent directory; for this purpose,
1017936
* "aa/bb" is not a prefix of "aa/bbb", but it is a prefix of "aa/bb/cc".
1018937
*/
1019-
staticbool
938+
bool
1020939
should_ignore_relpath(verifier_context*context,constchar*relpath)
1021940
{
1022941
SimpleStringListCell*cell;
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
#ifndefPG_VERIFYBACKUP_H
15+
#definePG_VERIFYBACKUP_H
16+
17+
#include"common/controldata_utils.h"
18+
#include"common/hashfn_unstable.h"
19+
#include"common/parse_manifest.h"
20+
#include"fe_utils/simple_list.h"
21+
22+
/*
23+
* Each file described by the manifest file is parsed to produce an object
24+
* like this.
25+
*/
26+
typedefstructmanifest_file
27+
{
28+
uint32status;/* hash status */
29+
constchar*pathname;
30+
size_tsize;
31+
pg_checksum_typechecksum_type;
32+
intchecksum_length;
33+
uint8*checksum_payload;
34+
boolmatched;
35+
boolbad;
36+
}manifest_file;
37+
38+
#defineshould_verify_checksum(m) \
39+
(((m)->matched) && !((m)->bad) && (((m)->checksum_type) != CHECKSUM_TYPE_NONE))
40+
41+
/*
42+
* Define a hash table which we can use to store information about the files
43+
* mentioned in the backup manifest.
44+
*/
45+
#defineSH_PREFIXmanifest_files
46+
#defineSH_ELEMENT_TYPEmanifest_file
47+
#defineSH_KEY_TYPEconst char *
48+
#defineSH_KEYpathname
49+
#defineSH_HASH_KEY(tb,key)hash_string(key)
50+
#defineSH_EQUAL(tb,a,b)(strcmp(a, b) == 0)
51+
#defineSH_SCOPEstatic inline
52+
#defineSH_RAW_ALLOCATORpg_malloc0
53+
#defineSH_DECLARE
54+
#defineSH_DEFINE
55+
#include"lib/simplehash.h"
56+
57+
/*
58+
* Each WAL range described by the manifest file is parsed to produce an
59+
* object like this.
60+
*/
61+
typedefstructmanifest_wal_range
62+
{
63+
TimeLineIDtli;
64+
XLogRecPtrstart_lsn;
65+
XLogRecPtrend_lsn;
66+
structmanifest_wal_range*next;
67+
structmanifest_wal_range*prev;
68+
}manifest_wal_range;
69+
70+
/*
71+
* All the data parsed from a backup_manifest file.
72+
*/
73+
typedefstructmanifest_data
74+
{
75+
intversion;
76+
uint64system_identifier;
77+
manifest_files_hash*files;
78+
manifest_wal_range*first_wal_range;
79+
manifest_wal_range*last_wal_range;
80+
}manifest_data;
81+
82+
/*
83+
* All of the context information we need while checking a backup manifest.
84+
*/
85+
typedefstructverifier_context
86+
{
87+
manifest_data*manifest;
88+
char*backup_directory;
89+
SimpleStringListignore_list;
90+
boolskip_checksums;
91+
boolexit_on_error;
92+
boolsaw_any_error;
93+
}verifier_context;
94+
95+
externvoidreport_backup_error(verifier_context*context,
96+
constchar*pg_restrictfmt,...)
97+
pg_attribute_printf(2,3);
98+
externvoidreport_fatal_error(constchar*pg_restrictfmt,...)
99+
pg_attribute_printf(1,2)pg_attribute_noreturn();
100+
externboolshould_ignore_relpath(verifier_context*context,
101+
constchar*relpath);
102+
103+
#endif/* PG_VERIFYBACKUP_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp