96 const char *relativeFilename);
153 pg_fatal(
"no output directory specified");
160 bool is_empty =
false;
172 while (errno = 0, (d =
readdir(dir)))
174 if (strcmp(d->
d_name,
".") != 0 && strcmp(d->
d_name,
"..") != 0)
182 pg_fatal(
"could not read directory \"%s\": %m",
186 pg_fatal(
"could not close directory \"%s\": %m",
192 pg_fatal(
"could not create directory \"%s\": %m",
204 pg_fatal(
"could not open input file \"%s\": %m", fname);
219 pg_fatal(
"could not close TOC file: %m");
236 if (strcmp(te->
desc,
"BLOBS") == 0)
332 if (!ctx->dataFH->open_write_func(fname,
PG_BINARY_W, ctx->dataFH))
333 pg_fatal(
"could not open output file \"%s\": %m", fname);
352 if (dLen > 0 && !CFH->write_func(
data, dLen, CFH))
357 pg_fatal(
"could not write to output file: %s",
358 CFH->get_error_func(CFH));
375 pg_fatal(
"could not close data file: %m");
401 while (CFH->
read_func(
buf, buflen, &cnt, CFH) && cnt > 0)
422 if (strcmp(te->
desc,
"BLOBS") == 0)
455 pg_fatal(
"could not open large object TOC file \"%s\" for input: %m",
466 pg_fatal(
"invalid line in large object TOC file \"%s\": \"%s\"",
475 pg_fatal(
"error reading large object TOC file \"%s\"",
479 pg_fatal(
"could not close large object TOC file \"%s\": %m",
496 unsigned char c = (
unsigned char)
i;
501 if (!CFH->write_func(&
c, 1, CFH))
506 pg_fatal(
"could not write to output file: %s",
507 CFH->get_error_func(CFH));
539 if (!CFH->write_func(
buf,
len, CFH))
544 pg_fatal(
"could not write to output file: %s",
545 CFH->get_error_func(CFH));
564 if (!CFH->read_func(
buf,
len, NULL, CFH))
565 pg_fatal(
"could not read from input file: end of file");
600 pg_fatal(
"could not open output file \"%s\": %m", fname);
613 pg_fatal(
"could not close TOC file: %m");
666 pg_fatal(
"could not open output file \"%s\": %m", fname);
684 pg_fatal(
"could not open output file \"%s\": %m", fname);
702 pg_fatal(
"could not close LO data file: %m");
707 if (!CFH->write_func(
buf,
len, CFH))
712 pg_fatal(
"could not write to LOs TOC file: %s",
713 CFH->get_error_func(CFH));
728 pg_fatal(
"could not close LOs TOC file: %m");
746 if (strlen(dname) + 1 + strlen(relativeFilename) + 1 >
MAXPGPATH)
747 pg_fatal(
"file name too long: \"%s\"", dname);
751 strcat(
buf, relativeFilename);
794 if (
stat(fname, &st) == 0)
799 strlcat(fname,
".gz",
sizeof(fname));
801 strlcat(fname,
".lz4",
sizeof(fname));
803 strlcat(fname,
".zst",
sizeof(fname));
805 if (
stat(fname, &st) == 0)
816 if (strcmp(te->
desc,
"BLOBS") == 0)
void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate)
ParallelState * ParallelBackupStart(ArchiveHandle *AH)
bool EndCompressFileHandle(CompressFileHandle *CFH)
CompressFileHandle * InitDiscoverCompressFileHandle(const char *path, const char *mode)
CompressFileHandle * InitCompressFileHandle(const pg_compress_specification compression_spec)
#define DEFAULT_IO_BUFFER_SIZE
struct dirent * readdir(DIR *)
DIR * opendir(const char *)
void * pg_malloc0(size_t size)
char * pg_strdup(const char *in)
void * pg_malloc(size_t size)
if(TABLE==NULL||TABLE_index==NULL)
void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
void WriteHead(ArchiveHandle *AH)
void StartRestoreLOs(ArchiveHandle *AH)
void WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
int ahprintf(ArchiveHandle *AH, const char *fmt,...)
char * ReadStr(ArchiveHandle *AH)
void ReadHead(ArchiveHandle *AH)
void ReadToc(ArchiveHandle *AH)
void EndRestoreLO(ArchiveHandle *AH, Oid oid)
void WriteToc(ArchiveHandle *AH)
void EndRestoreLOs(ArchiveHandle *AH)
void StartRestoreLO(ArchiveHandle *AH, Oid oid, bool drop)
int parallel_restore(ArchiveHandle *AH, TocEntry *te)
size_t WriteStr(ArchiveHandle *AH, const char *c)
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te)
static void _StartData(ArchiveHandle *AH, TocEntry *te)
static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
static void _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
static void _CloseArchive(ArchiveHandle *AH)
static void _DeClone(ArchiveHandle *AH)
static void _ReopenArchive(ArchiveHandle *AH)
static void _StartLOs(ArchiveHandle *AH, TocEntry *te)
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te)
static void _EndLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static void _EndLOs(ArchiveHandle *AH, TocEntry *te)
static int _WriteByte(ArchiveHandle *AH, const int i)
static void _PrepParallelRestore(ArchiveHandle *AH)
static void _StartLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static int _ReadByte(ArchiveHandle *AH)
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
static void _EndData(ArchiveHandle *AH, TocEntry *te)
static void _Clone(ArchiveHandle *AH)
static int _WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te)
void InitArchiveFmt_Directory(ArchiveHandle *AH)
static void _PrintFileData(ArchiveHandle *AH, char *filename)
static void setFilePath(ArchiveHandle *AH, char *buf, const char *relativeFilename)
static void _LoadLOs(ArchiveHandle *AH, TocEntry *te)
static int _WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te)
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
size_t strlcat(char *dst, const char *src, size_t siz)
bool(* open_write_func)(const char *path, const char *mode, CompressFileHandle *CFH)
int(* getc_func)(CompressFileHandle *CFH)
char *(* gets_func)(char *s, int size, CompressFileHandle *CFH)
bool(* eof_func)(CompressFileHandle *CFH)
bool(* read_func)(void *ptr, size_t size, size_t *rsize, CompressFileHandle *CFH)
DeClonePtrType DeClonePtr
DataDirSyncMethod sync_method
ReadExtraTocPtrType ReadExtraTocPtr
WorkerJobDumpPtrType WorkerJobDumpPtr
StartLOsPtrType StartLOsPtr
ArchiveEntryPtrType ArchiveEntryPtr
pg_compress_specification compression_spec
WriteDataPtrType WriteDataPtr
StartLOPtrType StartLOPtr
WriteBufPtrType WriteBufPtr
PrepParallelRestorePtrType PrepParallelRestorePtr
WriteExtraTocPtrType WriteExtraTocPtr
ReadBytePtrType ReadBytePtr
WorkerJobRestorePtrType WorkerJobRestorePtr
PrintTocDataPtrType PrintTocDataPtr
WriteBytePtrType WriteBytePtr
ReadBufPtrType ReadBufPtr
PrintExtraTocPtrType PrintExtraTocPtr
StartDataPtrType StartDataPtr
EndDataPtrType EndDataPtr
CompressFileHandle * LOsTocFH
CompressFileHandle * dataFH
pg_compress_algorithm algorithm
static void * fn(void *arg)