|
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 | | -#ifndefPG_BACKUP__ |
27 | | - |
28 | | -#include"config.h" |
29 | | -#include"c.h" |
30 | | - |
31 | | -#definePG_BACKUP__ |
32 | | - |
33 | | -typedefenum_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 | | -typedefstruct_Archive { |
46 | | -/* Nothing here */ |
47 | | -}Archive; |
48 | | - |
49 | | -typedefint (*DataDumperPtr)(Archive*AH,char*oid,void*userArg); |
50 | | - |
51 | | -typedefstruct_restoreOptions { |
52 | | -intdataOnly; |
53 | | -intdropSchema; |
54 | | -char*filename; |
55 | | -intschemaOnly; |
56 | | -intverbose; |
57 | | -intaclsSkip; |
58 | | -inttocSummary; |
59 | | -char*tocFile; |
60 | | -intoidOrder; |
61 | | -intorigOrder; |
62 | | -intrearrange; |
63 | | -intformat; |
64 | | -char*formatName; |
65 | | - |
66 | | -intselTypes; |
67 | | -intselIndex; |
68 | | -intselFunction; |
69 | | -intselTrigger; |
70 | | -intselTable; |
71 | | -char*indexNames; |
72 | | -char*functionNames; |
73 | | -char*tableNames; |
74 | | -char*triggerNames; |
75 | | - |
76 | | -int*idWanted; |
77 | | -intlimitToList; |
78 | | -intcompression; |
79 | | - |
80 | | -}RestoreOptions; |
81 | | - |
82 | | -/* |
83 | | - * Main archiver interface. |
84 | | - */ |
85 | | - |
86 | | -/* Called to add a TOC entry */ |
87 | | -externvoidArchiveEntry(Archive*AH,constchar*oid,constchar*name, |
88 | | -constchar*desc,constchar* (deps[]),constchar*defn, |
89 | | -constchar*dropStmt,constchar*owner, |
90 | | -DataDumperPtrdumpFn,void*dumpArg); |
91 | | - |
92 | | -/* Called to write *data* to the archive */ |
93 | | -externintWriteData(Archive*AH,constvoid*data,intdLen); |
94 | | - |
95 | | -externvoidCloseArchive(Archive*AH); |
96 | | - |
97 | | -externvoidRestoreArchive(Archive*AH,RestoreOptions*ropt); |
98 | | - |
99 | | -/* Open an existing archive */ |
100 | | -externArchive*OpenArchive(constchar*FileSpec,ArchiveFormatfmt); |
101 | | - |
102 | | -/* Create a new archive */ |
103 | | -externArchive*CreateArchive(constchar*FileSpec,ArchiveFormatfmt,intcompression); |
104 | | - |
105 | | -/* The --list option */ |
106 | | -externvoidPrintTOCSummary(Archive*AH,RestoreOptions*ropt); |
107 | | - |
108 | | -externRestoreOptions*NewRestoreOptions(void); |
109 | | - |
110 | | -/* Rearrange TOC entries */ |
111 | | -externvoidMoveToStart(Archive*AH,char*oType); |
112 | | -externvoidMoveToEnd(Archive*AH,char*oType); |
113 | | -externvoidSortTocByOID(Archive*AH); |
114 | | -externvoidSortTocByID(Archive*AH); |
115 | | -externvoidSortTocFromFile(Archive*AH,RestoreOptions*ropt); |
116 | | - |
117 | | -/* Convenience functions used only when writing DATA */ |
118 | | -externintarchputs(constchar*s,Archive*AH); |
119 | | -externintarchputc(constcharc,Archive*AH); |
120 | | -externintarchprintf(Archive*AH,constchar*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 | +#ifndefPG_BACKUP__ |
| 27 | + |
| 28 | +#include"config.h" |
| 29 | +#include"c.h" |
| 30 | + |
| 31 | +#definePG_BACKUP__ |
| 32 | + |
| 33 | +#include"postgres.h" |
| 34 | +#include"libpq-fe.h" |
| 35 | + |
| 36 | +typedefenum_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 | +typedefstruct_Archive { |
| 49 | +intverbose; |
| 50 | +/* The rest is private */ |
| 51 | +}Archive; |
| 52 | + |
| 53 | +typedefint (*DataDumperPtr)(Archive*AH,char*oid,void*userArg); |
| 54 | + |
| 55 | +typedefstruct_restoreOptions { |
| 56 | +intdataOnly; |
| 57 | +intdropSchema; |
| 58 | +char*filename; |
| 59 | +intschemaOnly; |
| 60 | +intverbose; |
| 61 | +intaclsSkip; |
| 62 | +inttocSummary; |
| 63 | +char*tocFile; |
| 64 | +intoidOrder; |
| 65 | +intorigOrder; |
| 66 | +intrearrange; |
| 67 | +intformat; |
| 68 | +char*formatName; |
| 69 | + |
| 70 | +intselTypes; |
| 71 | +intselIndex; |
| 72 | +intselFunction; |
| 73 | +intselTrigger; |
| 74 | +intselTable; |
| 75 | +char*indexNames; |
| 76 | +char*functionNames; |
| 77 | +char*tableNames; |
| 78 | +char*triggerNames; |
| 79 | + |
| 80 | +intuseDB; |
| 81 | +char*dbname; |
| 82 | +char*pgport; |
| 83 | +char*pghost; |
| 84 | +intignoreVersion; |
| 85 | +intrequirePassword; |
| 86 | + |
| 87 | +int*idWanted; |
| 88 | +intlimitToList; |
| 89 | +intcompression; |
| 90 | + |
| 91 | +}RestoreOptions; |
| 92 | + |
| 93 | +/* |
| 94 | + * Main archiver interface. |
| 95 | + */ |
| 96 | + |
| 97 | +externvoidexit_horribly(Archive*AH,constchar*fmt, ...); |
| 98 | + |
| 99 | +/* Lets the archibe know we have a DB connection to shutdown if it dies */ |
| 100 | + |
| 101 | +PGconn*ConnectDatabase(Archive*AH, |
| 102 | +constchar*dbname, |
| 103 | +constchar*pghost, |
| 104 | +constchar*pgport, |
| 105 | +constintreqPwd, |
| 106 | +constintignoreVersion); |
| 107 | + |
| 108 | + |
| 109 | +/* Called to add a TOC entry */ |
| 110 | +externvoidArchiveEntry(Archive*AH,constchar*oid,constchar*name, |
| 111 | +constchar*desc,constchar* (deps[]),constchar*defn, |
| 112 | +constchar*dropStmt,constchar*copyStmt,constchar*owner, |
| 113 | +DataDumperPtrdumpFn,void*dumpArg); |
| 114 | + |
| 115 | +/* Called to write *data* to the archive */ |
| 116 | +externintWriteData(Archive*AH,constvoid*data,intdLen); |
| 117 | + |
| 118 | +//extern int StartBlobs(Archive* AH); |
| 119 | +//extern intEndBlobs(Archive* AH); |
| 120 | +externintStartBlob(Archive*AH,intoid); |
| 121 | +externintEndBlob(Archive*AH,intoid); |
| 122 | + |
| 123 | +externvoidCloseArchive(Archive*AH); |
| 124 | + |
| 125 | +externvoidRestoreArchive(Archive*AH,RestoreOptions*ropt); |
| 126 | + |
| 127 | +/* Open an existing archive */ |
| 128 | +externArchive*OpenArchive(constchar*FileSpec,constArchiveFormatfmt); |
| 129 | + |
| 130 | +/* Create a new archive */ |
| 131 | +externArchive*CreateArchive(constchar*FileSpec,constArchiveFormatfmt, |
| 132 | +constintcompression); |
| 133 | + |
| 134 | +/* The --list option */ |
| 135 | +externvoidPrintTOCSummary(Archive*AH,RestoreOptions*ropt); |
| 136 | + |
| 137 | +externRestoreOptions*NewRestoreOptions(void); |
| 138 | + |
| 139 | +/* Rearrange TOC entries */ |
| 140 | +externvoidMoveToStart(Archive*AH,char*oType); |
| 141 | +externvoidMoveToEnd(Archive*AH,char*oType); |
| 142 | +externvoidSortTocByOID(Archive*AH); |
| 143 | +externvoidSortTocByID(Archive*AH); |
| 144 | +externvoidSortTocFromFile(Archive*AH,RestoreOptions*ropt); |
| 145 | + |
| 146 | +/* Convenience functions used only when writing DATA */ |
| 147 | +externintarchputs(constchar*s,Archive*AH); |
| 148 | +externintarchputc(constcharc,Archive*AH); |
| 149 | +externintarchprintf(Archive*AH,constchar*fmt, ...); |
| 150 | + |
| 151 | +#endif |
| 152 | + |
| 153 | + |
| 154 | + |