15
15
*
16
16
*
17
17
* IDENTIFICATION
18
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.102 2005/01/23 00:03:54 tgl Exp $
18
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.103 2005/01/25 22:44:31 tgl Exp $
19
19
*
20
20
*-------------------------------------------------------------------------
21
21
*/
27
27
#include "dumputils.h"
28
28
29
29
#include <ctype.h>
30
- #include <errno.h>
31
30
#include <unistd.h>
32
31
33
32
#include "pqexpbuffer.h"
34
33
#include "libpq/libpq-fs.h"
35
34
36
35
37
- typedef enum _teReqs_
38
- {
39
- REQ_SCHEMA = 1 ,
40
- REQ_DATA = 2 ,
41
- REQ_ALL = REQ_SCHEMA + REQ_DATA
42
- } teReqs ;
43
-
44
36
const char * progname ;
37
+
45
38
static char * modulename = gettext_noop ("archiver" );
46
39
47
40
@@ -63,7 +56,7 @@ static void _becomeOwner(ArchiveHandle *AH, TocEntry *te);
63
56
static void _selectOutputSchema (ArchiveHandle * AH , const char * schemaName );
64
57
static void _selectTablespace (ArchiveHandle * AH , const char * tablespace );
65
58
66
- static teReqs _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool acl_pass );
59
+ static teReqs _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool include_acls );
67
60
static void _disableTriggersIfNecessary (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt );
68
61
static void _enableTriggersIfNecessary (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt );
69
62
static TocEntry * getTocEntryByDumpId (ArchiveHandle * AH , DumpId id );
@@ -135,7 +128,6 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
135
128
TocEntry * te = AH -> toc -> next ;
136
129
teReqs reqs ;
137
130
OutputContext sav ;
138
- int impliedDataOnly ;
139
131
bool defnDumped ;
140
132
141
133
AH -> ropt = ropt ;
@@ -188,17 +180,16 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
188
180
*/
189
181
if (!ropt -> dataOnly )
190
182
{
191
- te = AH -> toc -> next ;
192
- impliedDataOnly = 1 ;
193
- while (te != AH -> toc )
183
+ int impliedDataOnly = 1 ;
184
+
185
+ for (te = AH -> toc -> next ; te != AH -> toc ; te = te -> next )
194
186
{
195
- reqs = _tocEntryRequired (te , ropt , false );
187
+ reqs = _tocEntryRequired (te , ropt , true );
196
188
if ((reqs & REQ_SCHEMA ) != 0 )
197
189
{ /* It's schema, and it's wanted */
198
190
impliedDataOnly = 0 ;
199
191
break ;
200
192
}
201
- te = te -> next ;
202
193
}
203
194
if (impliedDataOnly )
204
195
{
@@ -232,7 +223,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
232
223
233
224
while (te != AH -> toc )
234
225
{
235
- reqs = _tocEntryRequired (te , ropt , false);
226
+ reqs = _tocEntryRequired (te , ropt , false /* needn't drop ACLs */ );
236
227
if (((reqs & REQ_SCHEMA ) != 0 ) && te -> dropStmt )
237
228
{
238
229
/* We want the schema */
@@ -248,7 +239,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
248
239
}
249
240
250
241
/*
251
- * Now process each TOC entry
242
+ * Now process each non-ACL TOC entry
252
243
*/
253
244
te = AH -> toc -> next ;
254
245
while (te != AH -> toc )
@@ -709,7 +700,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
709
700
710
701
while (te != AH -> toc )
711
702
{
712
- if (_tocEntryRequired (te , ropt , false ) != 0 )
703
+ if (_tocEntryRequired (te , ropt , true ) != 0 )
713
704
ahprintf (AH , "%d; %u %u %s %s %s %s\n" , te -> dumpId ,
714
705
te -> catalogId .tableoid , te -> catalogId .oid ,
715
706
te -> desc , te -> namespace ? te -> namespace : "-" ,
@@ -1341,15 +1332,15 @@ getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
1341
1332
return NULL ;
1342
1333
}
1343
1334
1344
- int
1335
+ teReqs
1345
1336
TocIDRequired (ArchiveHandle * AH , DumpId id , RestoreOptions * ropt )
1346
1337
{
1347
1338
TocEntry * te = getTocEntryByDumpId (AH , id );
1348
1339
1349
1340
if (!te )
1350
1341
return 0 ;
1351
1342
1352
- return _tocEntryRequired (te , ropt , false );
1343
+ return _tocEntryRequired (te , ropt , true );
1353
1344
}
1354
1345
1355
1346
size_t
@@ -1971,16 +1962,16 @@ ReadToc(ArchiveHandle *AH)
1971
1962
}
1972
1963
1973
1964
static teReqs
1974
- _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool acl_pass )
1965
+ _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool include_acls )
1975
1966
{
1976
- teReqs res = 3 ; /* Schema = 1, Data = 2, Both = 3 */
1967
+ teReqs res = REQ_ALL ;
1977
1968
1978
1969
/* ENCODING objects are dumped specially, so always reject here */
1979
1970
if (strcmp (te -> desc , "ENCODING" ) == 0 )
1980
1971
return 0 ;
1981
1972
1982
1973
/* If it's an ACL, maybe ignore it */
1983
- if ((!acl_pass || ropt -> aclsSkip ) && strcmp (te -> desc , "ACL" ) == 0 )
1974
+ if ((!include_acls || ropt -> aclsSkip ) && strcmp (te -> desc , "ACL" ) == 0 )
1984
1975
return 0 ;
1985
1976
1986
1977
if (!ropt -> create && strcmp (te -> desc , "DATABASE" ) == 0 )
0 commit comments