152 pg_fatal(
"could not open output file \"%s\": %m", AH->
fSpec);
158 pg_fatal(
"could not open output file: %m");
175 pg_fatal(
"could not open input file: %m");
291 if (tctx->dataPos >= 0)
319 cs->writeData(AH, cs,
data, dLen);
356 if (tctx->dataPos >= 0)
376 pg_fatal(
"invalid OID for large object");
441 pg_fatal(
"error during file seek: %m");
450 if (blkType == EOF ||
id == te->
dumpId)
473 othertctx->
dataPos = thisBlkPos;
476 else if (othertctx->
dataPos != thisBlkPos ||
497 pg_fatal(
"unrecognized data block type (%d) while searching archive",
506 if (
fseeko(AH->
FH, tctx->dataPos, SEEK_SET) != 0)
507 pg_fatal(
"error during file seek: %m");
519 pg_fatal(
"could not find block ID %d in archive -- "
520 "possibly due to out-of-order restore request, "
521 "which cannot be handled due to non-seekable input file",
524 pg_fatal(
"could not find block ID %d in archive -- "
525 "possibly corrupt archive",
531 pg_fatal(
"found unexpected block ID (%d) when reading data -- expected %d",
545 pg_fatal(
"unrecognized data block type %d while restoring archive",
635 if (
fseeko(AH->
FH, blkLen, SEEK_CUR) != 0)
636 pg_fatal(
"error during file seek: %m");
646 if (fread(
buf, 1, blkLen, AH->
FH) != blkLen)
649 pg_fatal(
"could not read from input file: end of file");
651 pg_fatal(
"could not read from input file: %m");
671 if (fputc(
i, AH->
FH) == EOF)
750 if (tpos < 0 && ctx->hasSeek)
751 pg_fatal(
"could not determine seek position in archive file: %m");
762 fseeko(AH->
FH, tpos, SEEK_SET) == 0)
766 if (fclose(AH->
FH) != 0)
767 pg_fatal(
"could not close archive file: %m");
790 pg_fatal(
"can only reopen input archives");
796 if (AH->
fSpec == NULL || strcmp(AH->
fSpec,
"") == 0)
797 pg_fatal(
"parallel restore from standard input is not supported");
799 pg_fatal(
"parallel restore from non-seekable file is not supported");
803 pg_fatal(
"could not determine seek position in archive file: %m");
806 if (fclose(AH->
FH) != 0)
807 pg_fatal(
"could not close archive file: %m");
814 if (
fseeko(AH->
FH, tpos, SEEK_SET) != 0)
815 pg_fatal(
"could not set seek position in archive file: %m");
856 if (tctx->
dataPos > prev_tctx->dataPos)
857 prev_te->dataLength = tctx->
dataPos - prev_tctx->dataPos;
869 if (
fseeko(AH->
FH, 0, SEEK_END) != 0)
870 pg_fatal(
"error during file seek: %m");
872 if (
endpos > prev_tctx->dataPos)
873 prev_te->dataLength =
endpos - prev_tctx->dataPos;
945 pg_fatal(
"could not determine seek position in archive file: %m");
1013 if (blkLen > *buflen)
CompressorState * AllocateCompressor(const pg_compress_specification compression_spec, ReadFunc readF, WriteFunc writeF)
void EndCompressor(ArchiveHandle *AH, CompressorState *cs)
static void PGresult * res
void fsync_fname(const char *fname, bool isdir)
void * pg_malloc0(size_t size)
void * pg_malloc(size_t size)
if(TABLE==NULL||TABLE_index==NULL)
void WriteHead(ArchiveHandle *AH)
TocEntry * getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
size_t WriteInt(ArchiveHandle *AH, int i)
size_t WriteOffset(ArchiveHandle *AH, pgoff_t o, int wasSet)
void StartRestoreLOs(ArchiveHandle *AH)
void WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
int ahprintf(ArchiveHandle *AH, const char *fmt,...)
int ReadOffset(ArchiveHandle *AH, pgoff_t *o)
int ReadInt(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)
#define K_OFFSET_POS_NOT_SET
#define READ_ERROR_EXIT(fd)
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te)
static void _skipData(ArchiveHandle *AH)
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 _skipLOs(ArchiveHandle *AH)
static pgoff_t _getFilePos(ArchiveHandle *AH, lclContext *ctx)
static void _DeClone(ArchiveHandle *AH)
static void _ReopenArchive(ArchiveHandle *AH)
static void _StartLOs(ArchiveHandle *AH, TocEntry *te)
void InitArchiveFmt_Custom(ArchiveHandle *AH)
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te)
static void _EndLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static size_t _CustomReadFunc(ArchiveHandle *AH, char **buf, size_t *buflen)
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 _PrintData(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 _CustomWriteFunc(ArchiveHandle *AH, const char *buf, size_t len)
static int _WorkerJobRestoreCustom(ArchiveHandle *AH, TocEntry *te)
static void _Clone(ArchiveHandle *AH)
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id)
static void _LoadLOs(ArchiveHandle *AH, bool drop)
#define pg_log_warning(...)
void(* readData)(ArchiveHandle *AH, CompressorState *cs)
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
#define fseeko(stream, offset, origin)