|
1 | | -/*------------------------------------------------------------------------- |
2 | | - * |
3 | | - * pg_backup.h |
4 | | - * |
5 | | - * Public interface to the pg_dump archiver routines. |
6 | | - * |
7 | | - * See the headers to pg_restore for more details. |
8 | | - * |
9 | | - * Copyright (c) 2000, Philip Warner |
10 | | - * Rights are granted to use this software in any way so long |
11 | | - * as this notice is not removed. |
12 | | - * |
13 | | - * The author is not responsible for loss or damages that may |
14 | | - * result from it's use. |
15 | | - * |
16 | | - * |
17 | | - * IDENTIFICATION |
18 | | - * |
19 | | - * Modifications - 28-Jun-2000 - pjw@rhyme.com.au |
20 | | - * |
21 | | - * Initial version. |
22 | | - * |
23 | | - *------------------------------------------------------------------------- |
24 | | - */ |
25 | | - |
26 | | -#ifndef PG_BACKUP__ |
27 | | - |
28 | | -#include "config.h" |
29 | | -#include "c.h" |
30 | | - |
31 | | -#define PG_BACKUP__ |
32 | | - |
33 | | -typedef enum _archiveFormat { |
34 | | - archUnknown = 0, |
35 | | - archCustom = 1, |
36 | | - archFiles = 2, |
37 | | - archTar = 3, |
38 | | - archPlainText = 4 |
39 | | -} ArchiveFormat; |
40 | | - |
41 | | -/* |
42 | | - * We may want to have so user-readbale data, but in the mean |
43 | | - * time this gives us some abstraction and type checking. |
44 | | - */ |
45 | | -typedef struct _Archive { |
46 | | - /* Nothing here */ |
47 | | -} Archive; |
48 | | - |
49 | | -typedef int (*DataDumperPtr)(Archive* AH, char* oid, void* userArg); |
50 | | - |
51 | | -typedef struct _restoreOptions { |
52 | | - int dataOnly; |
53 | | - int dropSchema; |
54 | | - char *filename; |
55 | | - int schemaOnly; |
56 | | - int verbose; |
57 | | - int aclsSkip; |
58 | | - int tocSummary; |
59 | | - char *tocFile; |
60 | | - int oidOrder; |
61 | | - int origOrder; |
62 | | - int rearrange; |
63 | | - int format; |
64 | | - char *formatName; |
65 | | - |
66 | | - int selTypes; |
67 | | - int selIndex; |
68 | | - int selFunction; |
69 | | - int selTrigger; |
70 | | - int selTable; |
71 | | - char *indexNames; |
72 | | - char *functionNames; |
73 | | - char *tableNames; |
74 | | - char *triggerNames; |
75 | | - |
76 | | - int *idWanted; |
77 | | - int limitToList; |
78 | | - int compression; |
79 | | - |
80 | | -} RestoreOptions; |
81 | | - |
82 | | -/* |
83 | | - * Main archiver interface. |
84 | | - */ |
85 | | - |
86 | | -/* Called to add a TOC entry */ |
87 | | -extern void ArchiveEntry(Archive* AH, const char* oid, const char* name, |
88 | | - const char* desc, const char* (deps[]), const char* defn, |
89 | | - const char* dropStmt, const char* owner, |
90 | | - DataDumperPtr dumpFn, void* dumpArg); |
91 | | - |
92 | | -/* Called to write *data* to the archive */ |
93 | | -extern int WriteData(Archive* AH, const void* data, int dLen); |
94 | | - |
95 | | -extern void CloseArchive(Archive* AH); |
96 | | - |
97 | | -extern void RestoreArchive(Archive* AH, RestoreOptions *ropt); |
98 | | - |
99 | | -/* Open an existing archive */ |
100 | | -extern Archive* OpenArchive(const char* FileSpec, ArchiveFormat fmt); |
101 | | - |
102 | | -/* Create a new archive */ |
103 | | -extern Archive* CreateArchive(const char* FileSpec, ArchiveFormat fmt, int compression); |
104 | | - |
105 | | -/* The --list option */ |
106 | | -extern void PrintTOCSummary(Archive* AH, RestoreOptions *ropt); |
107 | | - |
108 | | -extern RestoreOptions* NewRestoreOptions(void); |
109 | | - |
110 | | -/* Rearrange TOC entries */ |
111 | | -extern void MoveToStart(Archive* AH, char *oType); |
112 | | -extern void MoveToEnd(Archive* AH, char *oType); |
113 | | -extern void SortTocByOID(Archive* AH); |
114 | | -extern void SortTocByID(Archive* AH); |
115 | | -extern void SortTocFromFile(Archive* AH, RestoreOptions *ropt); |
116 | | - |
117 | | -/* Convenience functions used only when writing DATA */ |
118 | | -extern int archputs(const char *s, Archive* AH); |
119 | | -extern int archputc(const char c, Archive* AH); |
120 | | -extern int archprintf(Archive* AH, const char *fmt, ...); |
121 | | - |
122 | | -#endif |
123 | | - |
124 | | - |
125 | | - |
| 1 | +/*------------------------------------------------------------------------- |
| 2 | + * |
| 3 | + * pg_backup.h |
| 4 | + * |
| 5 | + * Public interface to the pg_dump archiver routines. |
| 6 | + * |
| 7 | + * See the headers to pg_restore for more details. |
| 8 | + * |
| 9 | + * Copyright (c) 2000, Philip Warner |
| 10 | + * Rights are granted to use this software in any way so long |
| 11 | + * as this notice is not removed. |
| 12 | + * |
| 13 | + * The author is not responsible for loss or damages that may |
| 14 | + * result from it's use. |
| 15 | + * |
| 16 | + * |
| 17 | + * IDENTIFICATION |
| 18 | + * |
| 19 | + * Modifications - 28-Jun-2000 - pjw@rhyme.com.au |
| 20 | + * |
| 21 | + * Initial version. |
| 22 | + * |
| 23 | + *------------------------------------------------------------------------- |
| 24 | + */ |
| 25 | + |
| 26 | +#ifndef PG_BACKUP__ |
| 27 | + |
| 28 | +#include "config.h" |
| 29 | +#include "c.h" |
| 30 | + |
| 31 | +#define PG_BACKUP__ |
| 32 | + |
| 33 | +#include "postgres.h" |
| 34 | +#include "libpq-fe.h" |
| 35 | + |
| 36 | +typedef enum _archiveFormat { |
| 37 | + archUnknown = 0, |
| 38 | + archCustom = 1, |
| 39 | + archFiles = 2, |
| 40 | + archTar = 3, |
| 41 | + archNull = 4 |
| 42 | +} ArchiveFormat; |
| 43 | + |
| 44 | +/* |
| 45 | + * We may want to have so user-readbale data, but in the mean |
| 46 | + * time this gives us some abstraction and type checking. |
| 47 | + */ |
| 48 | +typedef struct _Archive { |
| 49 | + int verbose; |
| 50 | + /* The rest is private */ |
| 51 | +} Archive; |
| 52 | + |
| 53 | +typedef int (*DataDumperPtr)(Archive* AH, char* oid, void* userArg); |
| 54 | + |
| 55 | +typedef struct _restoreOptions { |
| 56 | + int dataOnly; |
| 57 | + int dropSchema; |
| 58 | + char *filename; |
| 59 | + int schemaOnly; |
| 60 | + int verbose; |
| 61 | + int aclsSkip; |
| 62 | + int tocSummary; |
| 63 | + char *tocFile; |
| 64 | + int oidOrder; |
| 65 | + int origOrder; |
| 66 | + int rearrange; |
| 67 | + int format; |
| 68 | + char *formatName; |
| 69 | + |
| 70 | + int selTypes; |
| 71 | + int selIndex; |
| 72 | + int selFunction; |
| 73 | + int selTrigger; |
| 74 | + int selTable; |
| 75 | + char *indexNames; |
| 76 | + char *functionNames; |
| 77 | + char *tableNames; |
| 78 | + char *triggerNames; |
| 79 | + |
| 80 | + int useDB; |
| 81 | + char *dbname; |
| 82 | + char *pgport; |
| 83 | + char *pghost; |
| 84 | + int ignoreVersion; |
| 85 | + int requirePassword; |
| 86 | + |
| 87 | + int *idWanted; |
| 88 | + int limitToList; |
| 89 | + int compression; |
| 90 | + |
| 91 | +} RestoreOptions; |
| 92 | + |
| 93 | +/* |
| 94 | + * Main archiver interface. |
| 95 | + */ |
| 96 | + |
| 97 | +extern void exit_horribly(Archive *AH, const char *fmt, ...); |
| 98 | + |
| 99 | +/* Lets the archibe know we have a DB connection to shutdown if it dies */ |
| 100 | + |
| 101 | +PGconn* ConnectDatabase(Archive *AH, |
| 102 | + const char* dbname, |
| 103 | + const char* pghost, |
| 104 | + const char* pgport, |
| 105 | + const int reqPwd, |
| 106 | + const int ignoreVersion); |
| 107 | + |
| 108 | + |
| 109 | +/* Called to add a TOC entry */ |
| 110 | +extern void ArchiveEntry(Archive* AH, const char* oid, const char* name, |
| 111 | + const char* desc, const char* (deps[]), const char* defn, |
| 112 | + const char* dropStmt, const char* copyStmt, const char* owner, |
| 113 | + DataDumperPtr dumpFn, void* dumpArg); |
| 114 | + |
| 115 | +/* Called to write *data* to the archive */ |
| 116 | +extern int WriteData(Archive* AH, const void* data, int dLen); |
| 117 | + |
| 118 | +//extern int StartBlobs(Archive* AH); |
| 119 | +//extern int EndBlobs(Archive* AH); |
| 120 | +extern int StartBlob(Archive* AH, int oid); |
| 121 | +extern int EndBlob(Archive* AH, int oid); |
| 122 | + |
| 123 | +extern void CloseArchive(Archive* AH); |
| 124 | + |
| 125 | +extern void RestoreArchive(Archive* AH, RestoreOptions *ropt); |
| 126 | + |
| 127 | +/* Open an existing archive */ |
| 128 | +extern Archive* OpenArchive(const char* FileSpec, const ArchiveFormat fmt); |
| 129 | + |
| 130 | +/* Create a new archive */ |
| 131 | +extern Archive* CreateArchive(const char* FileSpec, const ArchiveFormat fmt, |
| 132 | + const int compression); |
| 133 | + |
| 134 | +/* The --list option */ |
| 135 | +extern void PrintTOCSummary(Archive* AH, RestoreOptions *ropt); |
| 136 | + |
| 137 | +extern RestoreOptions* NewRestoreOptions(void); |
| 138 | + |
| 139 | +/* Rearrange TOC entries */ |
| 140 | +extern void MoveToStart(Archive* AH, char *oType); |
| 141 | +extern void MoveToEnd(Archive* AH, char *oType); |
| 142 | +extern void SortTocByOID(Archive* AH); |
| 143 | +extern void SortTocByID(Archive* AH); |
| 144 | +extern void SortTocFromFile(Archive* AH, RestoreOptions *ropt); |
| 145 | + |
| 146 | +/* Convenience functions used only when writing DATA */ |
| 147 | +extern int archputs(const char *s, Archive* AH); |
| 148 | +extern int archputc(const char c, Archive* AH); |
| 149 | +extern int archprintf(Archive* AH, const char *fmt, ...); |
| 150 | + |
| 151 | +#endif |
| 152 | + |
| 153 | + |
| 154 | + |
0 commit comments