summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup.h
blob: e84b4dd16cc4fbc24695280b7ccff024ce9da459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*-------------------------------------------------------------------------
 *
 * 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
 *      Rights are granted to use this software in any way so long
 *      as this notice is not removed.
 *
 *	The author is not responsible for loss or damages that may
 *	result from it's use.
 *
 *
 * IDENTIFICATION
 *
 * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
 *
 *	Initial version. 
 *
 *-------------------------------------------------------------------------
 */

#ifndef PG_BACKUP__

#include "config.h"
#include "c.h"

#define PG_BACKUP__

typedef enum _archiveFormat {
    archUnknown = 0,
    archCustom = 1,
    archFiles = 2,
    archTar = 3,
    archPlainText = 4
} ArchiveFormat;

/*
 *  We may want to have so user-readbale data, but in the mean
 *  time this gives us some abstraction and type checking.
 */
typedef struct _Archive {
    /* Nothing here */
} Archive;

typedef int     (*DataDumperPtr)(Archive* AH, char* oid, void* userArg);

typedef struct _restoreOptions {
	int			dataOnly;
	int			dropSchema;
	char		*filename;
	int			schemaOnly;
	int			verbose;
	int			aclsSkip;
	int			tocSummary;
	char		*tocFile;
	int			oidOrder;
	int			origOrder;
	int			rearrange;
	int			format;
	char		*formatName;

	int			selTypes;
	int		selIndex;
	int		selFunction;
	int		selTrigger;
	int		selTable;
	char		*indexNames;
	char		*functionNames;
	char		*tableNames;
	char		*triggerNames;

	int		*idWanted;
	int		limitToList;
	int		compression;

} RestoreOptions;

/*
 * Main archiver interface.
 */

/* Called to add a TOC entry */
extern void	ArchiveEntry(Archive* AH, const char* oid, const char* name,
			const char* desc, const char* (deps[]), const char* defn,
			const char* dropStmt, const char* owner, 
			DataDumperPtr dumpFn, void* dumpArg);

/* Called to write *data* to the archive */
extern int	WriteData(Archive* AH, const void* data, int dLen);

extern void	CloseArchive(Archive* AH);

extern void	RestoreArchive(Archive* AH, RestoreOptions *ropt);

/* Open an existing archive */
extern Archive* OpenArchive(const char* FileSpec, ArchiveFormat fmt);

/* Create a new archive */
extern Archive* CreateArchive(const char* FileSpec, ArchiveFormat fmt, int compression);

/* The --list option */
extern void	PrintTOCSummary(Archive* AH, RestoreOptions *ropt);

extern RestoreOptions*		NewRestoreOptions(void);

/* Rearrange TOC entries */
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);

/* Convenience functions used only when writing DATA */
extern int archputs(const char *s, Archive* AH);
extern int archputc(const char c, Archive* AH);
extern int archprintf(Archive* AH, const char *fmt, ...);

#endif