24 #ifndef __PG_BACKUP_ARCHIVE__
25 #define __PG_BACKUP_ARCHIVE__
33 #define LOBBUFSIZE 16384
40 #define MAKE_ARCHIVE_VERSION(major, minor, rev) (((major) * 256 + (minor)) * 256 + (rev))
42 #define ARCHIVE_MAJOR(version) (((version) >> 16) & 255)
43 #define ARCHIVE_MINOR(version) (((version) >> 8) & 255)
44 #define ARCHIVE_REV(version) (((version) ) & 255)
47 #define K_VERS_1_0 MAKE_ARCHIVE_VERSION(1, 0, 0)
48 #define K_VERS_1_2 MAKE_ARCHIVE_VERSION(1, 2, 0)
49 #define K_VERS_1_3 MAKE_ARCHIVE_VERSION(1, 3, 0)
50 #define K_VERS_1_4 MAKE_ARCHIVE_VERSION(1, 4, 0)
51 #define K_VERS_1_5 MAKE_ARCHIVE_VERSION(1, 5, 0)
52 #define K_VERS_1_6 MAKE_ARCHIVE_VERSION(1, 6, 0)
53 #define K_VERS_1_7 MAKE_ARCHIVE_VERSION(1, 7, 0)
55 #define K_VERS_1_8 MAKE_ARCHIVE_VERSION(1, 8, 0)
58 #define K_VERS_1_9 MAKE_ARCHIVE_VERSION(1, 9, 0)
60 #define K_VERS_1_10 MAKE_ARCHIVE_VERSION(1, 10, 0)
61 #define K_VERS_1_11 MAKE_ARCHIVE_VERSION(1, 11, 0)
63 #define K_VERS_1_12 MAKE_ARCHIVE_VERSION(1, 12, 0)
65 #define K_VERS_1_13 MAKE_ARCHIVE_VERSION(1, 13, 0)
67 #define K_VERS_1_14 MAKE_ARCHIVE_VERSION(1, 14, 0)
68 #define K_VERS_1_15 MAKE_ARCHIVE_VERSION(1, 15, 0)
71 #define K_VERS_1_16 MAKE_ARCHIVE_VERSION(1, 16, 0)
76 #define K_VERS_MAJOR 1
77 #define K_VERS_MINOR 16
79 #define K_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV)
82 #define K_VERS_MAX MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, 255)
86 #define K_OFFSET_POS_NOT_SET 1
87 #define K_OFFSET_POS_SET 2
88 #define K_OFFSET_NO_DATA 3
95 #define WORKER_CREATE_DONE 10
96 #define WORKER_INHIBIT_DATA 11
97 #define WORKER_IGNORED_ERRORS 12
103 #define READ_ERROR_EXIT(fd) \
106 pg_fatal("could not read from input file: end of file"); \
108 pg_fatal("could not read from input file: %m"); \
111 #define WRITE_ERROR_EXIT \
113 pg_fatal("could not write to output file: %m"); \
207 #define RESTORE_PASS_LAST RESTORE_PASS_POST_ACL
210 #define REQ_SCHEMA 0x01
211 #define REQ_DATA 0x02
212 #define REQ_SPECIAL 0x04
395 const char *
namespace;
402 const char *createStmt;
410 #define ARCHIVE_OPTS(...) &(ArchiveOpts){__VA_ARGS__}
428 #define appendStringLiteralAHX(buf,str,AH) \
429 appendStringLiteral(buf, str, (AH)->public.encoding, (AH)->public.std_strings)
431 #define appendByteaLiteralAHX(buf,str,len,AH) \
432 appendByteaLiteral(buf, str, len, (AH)->public.std_strings)
460 const char *cmdBegin,
const char *cmdEnd);
#define pg_attribute_printf(f, a)
static void const char * fmt
static AmcheckOptions opts
void(* SetupWorkerPtrType)(Archive *AH)
enum _archiveFormat ArchiveFormat
enum _teSection teSection
int(* DataDumperPtr)(Archive *AH, const void *userArg)
void DeCloneArchive(ArchiveHandle *AH)
int TocIDRequired(ArchiveHandle *AH, DumpId id)
void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
void InitArchiveFmt_Null(ArchiveHandle *AH)
void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
void(* EndLOPtrType)(ArchiveHandle *AH, TocEntry *te, Oid oid)
void WriteHead(ArchiveHandle *AH)
void(* ReadExtraTocPtrType)(ArchiveHandle *AH, TocEntry *te)
TocEntry * getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
size_t WriteInt(ArchiveHandle *AH, int i)
void IssueACLPerBlob(ArchiveHandle *AH, TocEntry *te)
void struct _archiveOpts ArchiveOpts
void(* PrintTocDataPtrType)(ArchiveHandle *AH, TocEntry *te)
int(* WorkerJobDumpPtrType)(ArchiveHandle *AH, TocEntry *te)
void(* EndDataPtrType)(ArchiveHandle *AH, TocEntry *te)
void(* StartDataPtrType)(ArchiveHandle *AH, TocEntry *te)
ArchiveHandle * CloneArchive(ArchiveHandle *AH)
int(* WorkerJobRestorePtrType)(ArchiveHandle *AH, TocEntry *te)
void InitArchiveFmt_Custom(ArchiveHandle *AH)
void InitArchiveFmt_Tar(ArchiveHandle *AH)
size_t WriteOffset(ArchiveHandle *, pgoff_t, int)
void DropLOIfExists(ArchiveHandle *AH, Oid oid)
void(* DeClonePtrType)(ArchiveHandle *AH)
void StartRestoreLOs(ArchiveHandle *AH)
void ReconnectToServer(ArchiveHandle *AH, const char *dbname)
int(* WriteBytePtrType)(ArchiveHandle *AH, const int i)
void(* WriteBufPtrType)(ArchiveHandle *AH, const void *c, size_t len)
void(* ClonePtrType)(ArchiveHandle *AH)
int ReadOffset(ArchiveHandle *, pgoff_t *)
void warn_or_exit_horribly(ArchiveHandle *AH, const char *fmt,...) pg_attribute_printf(2
void(* ClosePtrType)(ArchiveHandle *AH)
bool isValidTarHeader(char *header)
void(* PrintExtraTocPtrType)(ArchiveHandle *AH, TocEntry *te)
void(* WriteDataPtrType)(ArchiveHandle *AH, const void *data, size_t dLen)
void IssueCommandPerBlob(ArchiveHandle *AH, TocEntry *te, const char *cmdBegin, const char *cmdEnd)
char * ReadStr(ArchiveHandle *AH)
void(* EndLOsPtrType)(ArchiveHandle *AH, TocEntry *te)
int ReadInt(ArchiveHandle *AH)
void(* ArchiveEntryPtrType)(ArchiveHandle *AH, TocEntry *te)
void(* WriteExtraTocPtrType)(ArchiveHandle *AH, TocEntry *te)
void on_exit_close_archive(Archive *AHX)
TocEntry * ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, ArchiveOpts *opts)
void WriteDataChunks(ArchiveHandle *AH, struct ParallelState *pstate)
void ReadHead(ArchiveHandle *AH)
void(* StartLOsPtrType)(ArchiveHandle *AH, TocEntry *te)
void ReadToc(ArchiveHandle *AH)
void EndRestoreLO(ArchiveHandle *AH, Oid oid)
int ahprintf(ArchiveHandle *AH, const char *fmt,...) pg_attribute_printf(2
int(* ReadBytePtrType)(ArchiveHandle *AH)
size_t(* CustomOutPtrType)(ArchiveHandle *AH, const void *buf, size_t len)
void WriteToc(ArchiveHandle *AH)
void InitArchiveFmt_Directory(ArchiveHandle *AH)
void(* ReadBufPtrType)(ArchiveHandle *AH, void *buf, size_t len)
void(* StartLOPtrType)(ArchiveHandle *AH, TocEntry *te, Oid oid)
void(* ReopenPtrType)(ArchiveHandle *AH)
void EndRestoreLOs(ArchiveHandle *AH)
void StartRestoreLO(ArchiveHandle *AH, Oid oid, bool drop)
int parallel_restore(ArchiveHandle *AH, TocEntry *te)
void(* PrepParallelRestorePtrType)(ArchiveHandle *AH)
size_t WriteStr(ArchiveHandle *AH, const char *c)
static pg_noinline void Size size
DeClonePtrType DeClonePtr
DataDirSyncMethod sync_method
struct _tocEntry * lastErrorTE
ReadExtraTocPtrType ReadExtraTocPtr
char * archiveDumpVersion
struct _tocEntry * currentTE
CustomOutPtrType CustomOutPtr
WorkerJobDumpPtrType WorkerJobDumpPtr
PGcancel *volatile connCancel
StartLOsPtrType StartLOsPtr
ArchiveEntryPtrType ArchiveEntryPtr
pg_compress_specification compression_spec
WriteDataPtrType WriteDataPtr
StartLOPtrType StartLOPtr
struct _tocEntry ** tocsByDumpId
WriteBufPtrType WriteBufPtr
PrepParallelRestorePtrType PrepParallelRestorePtr
WriteExtraTocPtrType WriteExtraTocPtr
ReadBytePtrType ReadBytePtr
WorkerJobRestorePtrType WorkerJobRestorePtr
PrintTocDataPtrType PrintTocDataPtr
struct _tocEntry * currToc
WriteBytePtrType WriteBytePtr
ReadBufPtrType ReadBufPtr
PrintExtraTocPtrType PrintExtraTocPtr
ArchiverStage lastErrorStage
StartDataPtrType StartDataPtr
ArchiverOutput outputKind
EndDataPtrType EndDataPtr
char * archiveRemoteVersion
SetupWorkerPtrType SetupWorkerPtr
struct _tocEntry * pending_next
struct _tocEntry * pending_prev
const void * dataDumperArg