2000-07-21 13:40:08 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pg_backup.h
|
|
|
|
*
|
|
|
|
* Public interface to the pg_dump archiver routines.
|
|
|
|
*
|
|
|
|
* See the headers to pg_restore for more details.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000, Philip Warner
|
2001-03-22 05:01:46 +01:00
|
|
|
* Rights are granted to use this software in any way so long
|
|
|
|
* as this notice is not removed.
|
2000-07-21 13:40:08 +02:00
|
|
|
*
|
|
|
|
* The author is not responsible for loss or damages that may
|
|
|
|
* result from it's use.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2002-08-20 19:54:45 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.22 2002/08/20 17:54:44 petere Exp $
|
2000-08-01 17:51:45 +02:00
|
|
|
*
|
2000-07-21 13:40:08 +02:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PG_BACKUP__
|
|
|
|
#define PG_BACKUP__
|
|
|
|
|
2001-02-10 03:31:31 +01:00
|
|
|
#include "postgres_fe.h"
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
#include "libpq-fe.h"
|
2002-08-18 11:36:26 +02:00
|
|
|
#include "pqexpbuffer.h"
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-04-01 07:42:51 +02:00
|
|
|
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
|
|
|
|
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
|
|
|
|
#define oideq(x,y) ( (x) == (y) )
|
2001-04-25 09:03:20 +02:00
|
|
|
#define oidle(x,y) ( (x) <= (y) )
|
|
|
|
#define oidge(x,y) ( (x) >= (y) )
|
|
|
|
#define oidzero(x) ( (x) == 0 )
|
2001-04-01 07:42:51 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef enum _archiveFormat
|
|
|
|
{
|
2001-10-28 07:26:15 +01:00
|
|
|
archUnknown = 0,
|
|
|
|
archCustom = 1,
|
|
|
|
archFiles = 2,
|
|
|
|
archTar = 3,
|
|
|
|
archNull = 4
|
2000-07-21 13:40:08 +02:00
|
|
|
} ArchiveFormat;
|
|
|
|
|
|
|
|
/*
|
2001-03-22 05:01:46 +01:00
|
|
|
* We may want to have so user-readbale data, but in the mean
|
|
|
|
* time this gives us some abstraction and type checking.
|
2000-07-21 13:40:08 +02:00
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef struct _Archive
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
int verbose;
|
|
|
|
int remoteVersion;
|
|
|
|
int minRemoteVersion;
|
|
|
|
int maxRemoteVersion;
|
2001-03-22 05:01:46 +01:00
|
|
|
/* The rest is private */
|
2000-07-21 13:40:08 +02:00
|
|
|
} Archive;
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef int (*DataDumperPtr) (Archive *AH, char *oid, void *userArg);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef struct _restoreOptions
|
|
|
|
{
|
2000-08-01 17:51:45 +02:00
|
|
|
int create; /* Issue commands to create the database */
|
2001-03-22 05:01:46 +01:00
|
|
|
int noOwner; /* Don't reconnect to database to match
|
|
|
|
* original object owner */
|
|
|
|
int noReconnect; /* Don't reconnect to database under any
|
|
|
|
* cirsumstances */
|
2001-10-25 07:50:21 +02:00
|
|
|
int use_setsessauth;/* use SET SESSSION AUTHORIZATION instead
|
|
|
|
* of \connect */
|
2002-05-11 00:36:27 +02:00
|
|
|
int disable_triggers;/* disable triggers during data-only restore */
|
2001-03-22 05:01:46 +01:00
|
|
|
char *superuser; /* Username to use as superuser */
|
2000-07-21 13:40:08 +02:00
|
|
|
int dataOnly;
|
|
|
|
int dropSchema;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *filename;
|
2000-07-21 13:40:08 +02:00
|
|
|
int schemaOnly;
|
|
|
|
int verbose;
|
|
|
|
int aclsSkip;
|
|
|
|
int tocSummary;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *tocFile;
|
2000-07-21 13:40:08 +02:00
|
|
|
int oidOrder;
|
|
|
|
int origOrder;
|
|
|
|
int rearrange;
|
|
|
|
int format;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *formatName;
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
int selTypes;
|
|
|
|
int selIndex;
|
|
|
|
int selFunction;
|
|
|
|
int selTrigger;
|
|
|
|
int selTable;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *indexNames;
|
|
|
|
char *functionNames;
|
|
|
|
char *tableNames;
|
|
|
|
char *triggerNames;
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
int useDB;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *dbname;
|
|
|
|
char *pgport;
|
|
|
|
char *pghost;
|
2001-05-17 23:12:49 +02:00
|
|
|
char *username;
|
2000-07-21 13:40:08 +02:00
|
|
|
int ignoreVersion;
|
|
|
|
int requirePassword;
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
int *idWanted;
|
2000-08-01 17:51:45 +02:00
|
|
|
int limitToList;
|
|
|
|
int compression;
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
int suppressDumpWarnings; /* Suppress output of WARNING
|
|
|
|
* entries to stderr */
|
2000-07-21 13:40:08 +02:00
|
|
|
} RestoreOptions;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main archiver interface.
|
|
|
|
*/
|
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
extern void
|
|
|
|
exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
|
|
|
|
__attribute__((format(printf, 3, 4)));
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2002-02-11 01:18:20 +01:00
|
|
|
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
|
2001-05-17 23:12:49 +02:00
|
|
|
|
2002-08-18 11:36:26 +02:00
|
|
|
extern const char *fmtId(const char *identifier);
|
|
|
|
extern void appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll);
|
|
|
|
|
2002-02-11 01:18:20 +01:00
|
|
|
|
|
|
|
/* Lets the archive know we have a DB connection to shutdown if it dies */
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
PGconn *ConnectDatabase(Archive *AH,
|
|
|
|
const char *dbname,
|
|
|
|
const char *pghost,
|
|
|
|
const char *pgport,
|
2001-05-17 23:12:49 +02:00
|
|
|
const char *username,
|
2001-03-22 05:01:46 +01:00
|
|
|
const int reqPwd,
|
|
|
|
const int ignoreVersion);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Called to add a TOC entry */
|
2002-07-04 17:35:07 +02:00
|
|
|
extern void ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
|
2002-05-11 00:36:27 +02:00
|
|
|
const char *namespace, const char *owner,
|
|
|
|
const char *desc, const char *((*deps)[]),
|
|
|
|
const char *defn, const char *dropStmt,
|
|
|
|
const char *copyStmt,
|
|
|
|
DataDumperPtr dumpFn, void *dumpArg);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
/* Called to write *data* to the archive */
|
2002-08-20 19:54:45 +02:00
|
|
|
extern size_t WriteData(Archive *AH, const void *data, size_t dLen);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
/*
|
|
|
|
extern int StartBlobs(Archive* AH);
|
2000-07-27 21:49:24 +02:00
|
|
|
extern int EndBlobs(Archive* AH);
|
|
|
|
*/
|
2001-04-01 07:42:51 +02:00
|
|
|
extern int StartBlob(Archive *AH, Oid oid);
|
|
|
|
extern int EndBlob(Archive *AH, Oid oid);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void CloseArchive(Archive *AH);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void RestoreArchive(Archive *AH, RestoreOptions *ropt);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
/* Open an existing archive */
|
2001-03-22 05:01:46 +01:00
|
|
|
extern Archive *OpenArchive(const char *FileSpec, const ArchiveFormat fmt);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
/* Create a new archive */
|
2001-03-22 05:01:46 +01:00
|
|
|
extern Archive *CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
|
|
|
|
const int compression);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
/* The --list option */
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
extern RestoreOptions *NewRestoreOptions(void);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
/* Rearrange TOC entries */
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void MoveToStart(Archive *AH, char *oType);
|
|
|
|
extern void MoveToEnd(Archive *AH, char *oType);
|
|
|
|
extern void SortTocByOID(Archive *AH);
|
|
|
|
extern void SortTocByID(Archive *AH);
|
|
|
|
extern void SortTocFromFile(Archive *AH, RestoreOptions *ropt);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
|
|
|
/* Convenience functions used only when writing DATA */
|
2001-03-22 05:01:46 +01:00
|
|
|
extern int archputs(const char *s, Archive *AH);
|
|
|
|
extern int archputc(const char c, Archive *AH);
|
2001-10-25 07:50:21 +02:00
|
|
|
extern int
|
|
|
|
archprintf(Archive *AH, const char *fmt,...)
|
2001-10-03 23:58:28 +02:00
|
|
|
/* This extension allows gcc to check the format string */
|
|
|
|
__attribute__((format(printf, 2, 3)));
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
#endif
|