94 const char *relativeFilename);
155 pg_fatal(
"no output directory specified");
162 bool is_empty =
false;
174 while (errno = 0, (d =
readdir(dir)))
176 if (strcmp(d->
d_name,
".") != 0 && strcmp(d->
d_name,
"..") != 0)
184 pg_fatal(
"could not read directory \"%s\": %m",
188 pg_fatal(
"could not close directory \"%s\": %m",
194 pg_fatal(
"could not create directory \"%s\": %m",
206 pg_fatal(
"could not open input file \"%s\": %m", fname);
221 pg_fatal(
"could not close TOC file: %m");
238 if (strcmp(te->
desc,
"BLOBS") == 0)
331 if (ctx->dataFH->open_write_func(fname,
PG_BINARY_W, ctx->dataFH))
332 pg_fatal(
"could not open output file \"%s\": %m", fname);
351 if (dLen > 0 && CFH->write_func(
data, dLen, CFH) != dLen)
356 pg_fatal(
"could not write to output file: %s",
357 CFH->get_error_func(CFH));
374 pg_fatal(
"could not close data file: %m");
421 if (strcmp(te->
desc,
"BLOBS") == 0)
448 pg_fatal(
"could not open large object TOC file \"%s\" for input: %m",
452 while ((CFH->gets_func(line,
MAXPGPATH, CFH)) != NULL)
459 pg_fatal(
"invalid line in large object TOC file \"%s\": \"%s\"",
467 if (!CFH->eof_func(CFH))
468 pg_fatal(
"error reading large object TOC file \"%s\"",
472 pg_fatal(
"could not close large object TOC file \"%s\": %m",
489 unsigned char c = (
unsigned char)
i;
494 if (CFH->write_func(&
c, 1, CFH) != 1)
499 pg_fatal(
"could not write to output file: %s",
500 CFH->get_error_func(CFH));
537 pg_fatal(
"could not write to output file: %s",
538 CFH->get_error_func(CFH));
558 pg_fatal(
"could not read from input file: end of file");
593 pg_fatal(
"could not open output file \"%s\": %m", fname);
606 pg_fatal(
"could not close TOC file: %m");
657 if (ctx->LOsTocFH->open_write_func(fname,
"ab", ctx->LOsTocFH))
658 pg_fatal(
"could not open output file \"%s\": %m", fname);
676 pg_fatal(
"could not open output file \"%s\": %m", fname);
694 pg_fatal(
"could not close LO data file: %m");
699 if (CFH->write_func(
buf,
len, CFH) !=
len)
700 pg_fatal(
"could not write to LOs TOC file");
714 pg_fatal(
"could not close LOs TOC file: %m");
732 if (strlen(dname) + 1 + strlen(relativeFilename) + 1 >
MAXPGPATH)
733 pg_fatal(
"file name too long: \"%s\"", dname);
737 strcat(
buf, relativeFilename);
780 if (
stat(fname, &st) == 0)
785 strlcat(fname,
".gz",
sizeof(fname));
787 strlcat(fname,
".lz4",
sizeof(fname));
789 if (
stat(fname, &st) == 0)
800 if (strcmp(te->
desc,
"BLOBS") == 0)
void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate)
ParallelState * ParallelBackupStart(ArchiveHandle *AH)
int EndCompressFileHandle(CompressFileHandle *CFH)
CompressFileHandle * InitDiscoverCompressFileHandle(const char *path, const char *mode)
CompressFileHandle * InitCompressFileHandle(const pg_compress_specification compression_spec)
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 _LoadLOs(ArchiveHandle *AH)
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 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)
int(* getc_func)(CompressFileHandle *CFH)
size_t(* read_func)(void *ptr, size_t size, CompressFileHandle *CFH)
int(* open_write_func)(const char *path, const char *mode, CompressFileHandle *CFH)
DeClonePtrType DeClonePtr
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)