156 pg_fatal(
"could not open output file \"%s\": %m", AH->
fSpec);
162 pg_fatal(
"could not open output file: %m");
179 pg_fatal(
"could not open input file: %m");
295 if (tctx->dataPos >= 0)
356 if (tctx->dataPos >= 0)
376 pg_fatal(
"invalid OID for large object");
439 pg_fatal(
"error during file seek: %m");
448 if (blkType == EOF ||
id == te->
dumpId)
471 othertctx->
dataPos = thisBlkPos;
474 else if (othertctx->
dataPos != thisBlkPos ||
495 pg_fatal(
"unrecognized data block type (%d) while searching archive",
504 if (
fseeko(AH->
FH, tctx->dataPos, SEEK_SET) != 0)
505 pg_fatal(
"error during file seek: %m");
517 pg_fatal(
"could not find block ID %d in archive -- "
518 "possibly due to out-of-order restore request, "
519 "which cannot be handled due to non-seekable input file",
522 pg_fatal(
"could not find block ID %d in archive -- "
523 "possibly corrupt archive",
529 pg_fatal(
"found unexpected block ID (%d) when reading data -- expected %d",
543 pg_fatal(
"unrecognized data block type %d while restoring archive",
628 if (
fseeko(AH->
FH, blkLen, SEEK_CUR) != 0)
629 pg_fatal(
"error during file seek: %m");
640 if (fread(
buf, 1, blkLen, AH->
FH) != blkLen)
643 pg_fatal(
"could not read from input file: end of file");
645 pg_fatal(
"could not read from input file: %m");
666 if (fputc(
i, AH->
FH) == EOF)
745 if (tpos < 0 && ctx->hasSeek)
746 pg_fatal(
"could not determine seek position in archive file: %m");
757 fseeko(AH->
FH, tpos, SEEK_SET) == 0)
761 if (fclose(AH->
FH) != 0)
762 pg_fatal(
"could not close archive file: %m");
785 pg_fatal(
"can only reopen input archives");
791 if (AH->
fSpec == NULL || strcmp(AH->
fSpec,
"") == 0)
792 pg_fatal(
"parallel restore from standard input is not supported");
794 pg_fatal(
"parallel restore from non-seekable file is not supported");
798 pg_fatal(
"could not determine seek position in archive file: %m");
801 if (fclose(AH->
FH) != 0)
802 pg_fatal(
"could not close archive file: %m");
809 if (
fseeko(AH->
FH, tpos, SEEK_SET) != 0)
810 pg_fatal(
"could not set seek position in archive file: %m");
851 if (tctx->
dataPos > prev_tctx->dataPos)
852 prev_te->dataLength = tctx->
dataPos - prev_tctx->dataPos;
864 if (
fseeko(AH->
FH, 0, SEEK_END) != 0)
865 pg_fatal(
"error during file seek: %m");
867 if (
endpos > prev_tctx->dataPos)
868 prev_te->dataLength =
endpos - prev_tctx->dataPos;
943 pg_fatal(
"could not determine seek position in archive file: %m");
1011 if (blkLen > *buflen)
CompressorState * AllocateCompressor(int compression, WriteFunc writeF)
void WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs, const void *data, size_t dLen)
void ReadDataFromArchive(ArchiveHandle *AH, int compression, ReadFunc readF)
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)
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 StartRestoreBlob(ArchiveHandle *AH, Oid oid, bool drop)
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 StartRestoreBlobs(ArchiveHandle *AH)
void ReadHead(ArchiveHandle *AH)
void ReadToc(ArchiveHandle *AH)
void WriteToc(ArchiveHandle *AH)
void EndRestoreBlob(ArchiveHandle *AH, Oid oid)
void EndRestoreBlobs(ArchiveHandle *AH)
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 _StartBlobs(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 _skipBlobs(ArchiveHandle *AH)
static pgoff_t _getFilePos(ArchiveHandle *AH, lclContext *ctx)
static void _DeClone(ArchiveHandle *AH)
static void _ReopenArchive(ArchiveHandle *AH)
void InitArchiveFmt_Custom(ArchiveHandle *AH)
static void _LoadBlobs(ArchiveHandle *AH, bool drop)
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te)
static size_t _CustomReadFunc(ArchiveHandle *AH, char **buf, size_t *buflen)
static int _WriteByte(ArchiveHandle *AH, const int i)
static void _PrepParallelRestore(ArchiveHandle *AH)
static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
static void _PrintData(ArchiveHandle *AH)
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
static void _EndData(ArchiveHandle *AH, TocEntry *te)
static void _EndBlobs(ArchiveHandle *AH, TocEntry *te)
static void _CustomWriteFunc(ArchiveHandle *AH, const char *buf, size_t len)
static int _WorkerJobRestoreCustom(ArchiveHandle *AH, TocEntry *te)
static int _ReadByte(ArchiveHandle *)
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)
#define pg_log_warning(...)
DeClonePtrType DeClonePtr
ReadExtraTocPtrType ReadExtraTocPtr
WorkerJobDumpPtrType WorkerJobDumpPtr
EndBlobPtrType EndBlobPtr
ArchiveEntryPtrType ArchiveEntryPtr
WriteDataPtrType WriteDataPtr
StartBlobsPtrType StartBlobsPtr
WriteBufPtrType WriteBufPtr
PrepParallelRestorePtrType PrepParallelRestorePtr
StartBlobPtrType StartBlobPtr
WriteExtraTocPtrType WriteExtraTocPtr
ReadBytePtrType ReadBytePtr
WorkerJobRestorePtrType WorkerJobRestorePtr
PrintTocDataPtrType PrintTocDataPtr
WriteBytePtrType WriteBytePtr
ReadBufPtrType ReadBufPtr
PrintExtraTocPtrType PrintExtraTocPtr
EndBlobsPtrType EndBlobsPtr
StartDataPtrType StartDataPtr
EndDataPtrType EndDataPtr
#define fseeko(stream, offset, origin)