/* Current archive version number (the format we can output) */ #define K_VERS_MAJOR 1 #define K_VERS_MINOR 16 #define K_VERS_REV 0 #define K_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV)
/* Newest format we can read */ #define K_VERS_MAX MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, 255)
/* Flags to indicate disposition of offsets stored in files */ #define K_OFFSET_POS_NOT_SET 1 #define K_OFFSET_POS_SET 2 #define K_OFFSET_NO_DATA 3
#define READ_ERROR_EXIT(fd) \ do { \ if (feof(fd)) \
pg_fatal("could not read from input file: end of file"); \ else \
pg_fatal("could not read from input file: %m"); \
} while (0)
#define WRITE_ERROR_EXIT \ do { \
pg_fatal("could not write to output file: %m"); \
} while (0)
typedefstruct
{
sqlparseState state; /* see above */ bool backSlash; /* next char is backslash quoted? */
PQExpBuffer curCmd; /* incomplete line (NULL if not created) */
} sqlparseInfo;
#define REQ_SCHEMA 0x01 /* want schema */ #define REQ_DATA 0x02 /* want data */ #define REQ_STATS 0x04 #define REQ_SPECIAL 0x08 /* for special TOC entries */
struct _archiveHandle
{
Archive public; /* Public part of archive */ int version; /* Version of file */
char *archiveRemoteVersion; /* When reading an archive, the
* version of the dumped DB */ char *archiveDumpVersion; /* When reading an archive, the version of
* the dumper */
size_t intSize; /* Size of an integer in the archive */
size_t offSize; /* Size of a file offset in the archive -
* Added V1.7 */
ArchiveFormat format; /* Archive format */
sqlparseInfo sqlparse; /* state for parsing INSERT data */
time_t createDate; /* Date archive created */
/* *Fieldsusedwhendiscoveringarchiveformat.Fortarformat,weload *thefirstblockintothelookaheadbuffer,andverifythatitlooks *likeatarheader.Thetarmodulemustthenconsumebytesfromthe *lookaheadbufferbeforereadinganymorefromthefile.Forcustom *format,weloadonlythe"PGDMP"markerintothebuffer,andthenset *readHeaderafterconfirmingitmatches.Thebufferisvestigialin *thiscase,asthesubsequentcodejustchecksreadHeaderanddoesn't *examinethebuffer.
*/ int readHeader; /* Set if we already read "PGDMP" marker */ char *lookahead; /* Buffer used when reading header to discover
* format */
size_t lookaheadSize; /* Allocated size of buffer */
size_t lookaheadLen; /* Length of valid data in lookahead */
size_t lookaheadPos; /* Current read position in lookahead buffer */
ArchiveEntryPtrType ArchiveEntryPtr; /* Called for each metadata object */
StartDataPtrType StartDataPtr; /* Called when table data is about to be
* dumped */
WriteDataPtrType WriteDataPtr; /* Called to send some table data to the
* archive */
EndDataPtrType EndDataPtr; /* Called when table data dump is finished */
WriteBytePtrType WriteBytePtr; /* Write a byte to output */
ReadBytePtrType ReadBytePtr; /* Read a byte from an archive */
WriteBufPtrType WriteBufPtr; /* Write a buffer of output to the archive */
ReadBufPtrType ReadBufPtr; /* Read a buffer of input from the archive */
ClosePtrType ClosePtr; /* Close the archive */
ReopenPtrType ReopenPtr; /* Reopen the archive */
WriteExtraTocPtrType WriteExtraTocPtr; /* Write extra TOC entry data *associatedwiththecurrent
* archive format */
ReadExtraTocPtrType ReadExtraTocPtr; /* Read extra info associated with
* archive format */
PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */
PrintTocDataPtrType PrintTocDataPtr;
CustomOutPtrType CustomOutPtr; /* Alternative script output routine */
/* Stuff for direct DB connection */ char *archdbname; /* DB name *read* from archive */ char *savedPassword; /* password for ropt->username, if known */ char *use_role;
PGconn *connection; /* If connCancel isn't NULL, SIGINT handler will send a cancel */
PGcancel *volatile connCancel;
int connectToDB; /* Flag to indicate if direct DB connection is
* required */
ArchiverOutput outputKind; /* Flag for what we're currently writing */ bool pgCopyIn; /* Currently in libpq 'COPY IN' mode. */
int loFd; bool writingLO; int loCount; /* # of LOs restored */
struct _tocEntry *toc; /* Header of circular list of TOC entries */ int tocCount; /* Number of TOC entries */
DumpId maxDumpId; /* largest DumpId among all TOC entries */
/* arrays created after the TOC list is complete: */ struct _tocEntry **tocsByDumpId; /* TOCs indexed by dumpId */
DumpId *tableDataId; /* TABLE DATA ids, indexed by table dumpId */
struct _tocEntry *currToc; /* Used when dumping data */
pg_compress_specification compression_spec; /* Requested specification for
* compression */ bool dosync; /* data requested to be synced on sight */
DataDirSyncMethod sync_method;
ArchiveMode mode; /* File mode - r or w */ void *formatData; /* Header data specific to file format */
/* these vars track state to avoid sending redundant SET commands */ char *currUser; /* current username, or NULL if unknown */ char *currSchema; /* current schema, or NULL */ char *currTablespace; /* current tablespace, or NULL */ char *currTableAm; /* current table access method, or NULL */
/* in --transaction-size mode, this counts objects emitted in cur xact */ int txnCount;
struct _tocEntry
{ struct _tocEntry *prev; struct _tocEntry *next;
CatalogId catalogId;
DumpId dumpId;
teSection section; bool hadDumper; /* Archiver was passed a dumper routine (used
* in restore) */ char *tag; /* index tag */ char *namespace; /* null or empty string if not in a schema */ char *tablespace; /* null if not in a tablespace; empty string
* means use database default */ char *tableam; /* table access method, only for TABLE tags */ char relkind; /* relation kind, only for TABLE tags */ char *owner; char *desc; char *defn; char *dropStmt; char *copyStmt;
DumpId *dependencies; /* dumpIds of objects this one depends on */ int nDeps; /* number of dependencies */
DataDumperPtr dataDumper; /* Routine to dump data for object */ constvoid *dataDumperArg; /* Arg for above routine */ void *formatData; /* TOC Entry data specific to file format */
DefnDumperPtr defnDumper; /* routine to dump definition statement */ constvoid *defnDumperArg; /* arg for above routine */
size_t defnLen; /* length of dumped definition */
/* working state while dumping/restoring */
pgoff_t dataLength; /* item's data size; 0 if none or unknown */ int reqs; /* do we need schema and/or data of object
* (REQ_* bit mask) */ bool created; /* set for DATA member if TABLE was created */
/* working state (needed only for parallel restore) */ struct _tocEntry *pending_prev; /* list links for pending-items list; */ struct _tocEntry *pending_next; /* NULL if not in that list */ int depCount; /* number of dependencies not yet restored */
DumpId *revDeps; /* dumpIds of objects depending on this one */ int nRevDeps; /* number of such dependencies */
DumpId *lockDeps; /* dumpIds of objects this one needs lock on */ int nLockDeps; /* number of such dependencies */
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.