151 pg_fatal(
"could not open output file \"%s\": %m", AH->
fSpec);
157 pg_fatal(
"could not open output file: %m");
174 pg_fatal(
"could not open input file: %m");
290 if (tctx->dataPos >= 0)
318 cs->writeData(AH, cs,
data, dLen);
355 if (tctx->dataPos >= 0)
375 pg_fatal(
"invalid OID for large object");
440 pg_fatal(
"error during file seek: %m");
449 if (blkType == EOF ||
id == te->
dumpId)
472 othertctx->
dataPos = thisBlkPos;
475 else if (othertctx->
dataPos != thisBlkPos ||
496 pg_fatal(
"unrecognized data block type (%d) while searching archive",
505 if (
fseeko(AH->
FH, tctx->dataPos, SEEK_SET) != 0)
506 pg_fatal(
"error during file seek: %m");
518 pg_fatal(
"could not find block ID %d in archive -- "
519 "possibly due to out-of-order restore request, "
520 "which cannot be handled due to non-seekable input file",
523 pg_fatal(
"could not find block ID %d in archive -- "
524 "possibly corrupt archive",
530 pg_fatal(
"found unexpected block ID (%d) when reading data -- expected %d",
544 pg_fatal(
"unrecognized data block type %d while restoring archive",
634 if (
fseeko(AH->
FH, blkLen, SEEK_CUR) != 0)
635 pg_fatal(
"error during file seek: %m");
645 if (fread(
buf, 1, blkLen, AH->
FH) != blkLen)
648 pg_fatal(
"could not read from input file: end of file");
650 pg_fatal(
"could not read from input file: %m");
670 if (fputc(
i, AH->
FH) == EOF)
749 if (tpos < 0 && ctx->hasSeek)
750 pg_fatal(
"could not determine seek position in archive file: %m");
761 fseeko(AH->
FH, tpos, SEEK_SET) == 0)
765 if (fclose(AH->
FH) != 0)
766 pg_fatal(
"could not close archive file: %m");
789 pg_fatal(
"can only reopen input archives");
795 if (AH->
fSpec == NULL || strcmp(AH->
fSpec,
"") == 0)
796 pg_fatal(
"parallel restore from standard input is not supported");
798 pg_fatal(
"parallel restore from non-seekable file is not supported");
802 pg_fatal(
"could not determine seek position in archive file: %m");
805 if (fclose(AH->
FH) != 0)
806 pg_fatal(
"could not close archive file: %m");
813 if (
fseeko(AH->
FH, tpos, SEEK_SET) != 0)
814 pg_fatal(
"could not set seek position in archive file: %m");
855 if (tctx->
dataPos > prev_tctx->dataPos)
856 prev_te->dataLength = tctx->
dataPos - prev_tctx->dataPos;
868 if (
fseeko(AH->
FH, 0, SEEK_END) != 0)
869 pg_fatal(
"error during file seek: %m");
871 if (
endpos > prev_tctx->dataPos)
872 prev_te->dataLength =
endpos - prev_tctx->dataPos;
944 pg_fatal(
"could not determine seek position in archive file: %m");
1012 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_malloc(size_t size)
void * pg_malloc0(size_t size)
if(TABLE==NULL||TABLE_index==NULL)
void WriteHead(ArchiveHandle *AH)
size_t WriteInt(ArchiveHandle *AH, int i)
size_t WriteOffset(ArchiveHandle *AH, pgoff_t o, int wasSet)
void StartRestoreLOs(ArchiveHandle *AH)
TocEntry * getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
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)