1515 *
1616 *
1717 * 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 $
1919 *
2020 *-------------------------------------------------------------------------
2121 */
2727#include "dumputils.h"
2828
2929#include <ctype.h>
30- #include <errno.h>
3130#include <unistd.h>
3231
3332#include "pqexpbuffer.h"
3433#include "libpq/libpq-fs.h"
3534
3635
37- typedef enum _teReqs_
38- {
39- REQ_SCHEMA = 1 ,
40- REQ_DATA = 2 ,
41- REQ_ALL = REQ_SCHEMA + REQ_DATA
42- } teReqs ;
43-
4436const char * progname ;
37+
4538static char * modulename = gettext_noop ("archiver" );
4639
4740
@@ -63,7 +56,7 @@ static void _becomeOwner(ArchiveHandle *AH, TocEntry *te);
6356static void _selectOutputSchema (ArchiveHandle * AH , const char * schemaName );
6457static void _selectTablespace (ArchiveHandle * AH , const char * tablespace );
6558
66- static teReqs _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool acl_pass );
59+ static teReqs _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool include_acls );
6760static void _disableTriggersIfNecessary (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt );
6861static void _enableTriggersIfNecessary (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt );
6962static TocEntry * getTocEntryByDumpId (ArchiveHandle * AH , DumpId id );
@@ -135,7 +128,6 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
135128 TocEntry * te = AH -> toc -> next ;
136129 teReqs reqs ;
137130 OutputContext sav ;
138- int impliedDataOnly ;
139131 bool defnDumped ;
140132
141133 AH -> ropt = ropt ;
@@ -188,17 +180,16 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
188180 */
189181 if (!ropt -> dataOnly )
190182 {
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 )
194186 {
195- reqs = _tocEntryRequired (te , ropt , false );
187+ reqs = _tocEntryRequired (te , ropt , true );
196188 if ((reqs & REQ_SCHEMA ) != 0 )
197189 { /* It's schema, and it's wanted */
198190 impliedDataOnly = 0 ;
199191 break ;
200192 }
201- te = te -> next ;
202193 }
203194 if (impliedDataOnly )
204195 {
@@ -232,7 +223,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
232223
233224 while (te != AH -> toc )
234225 {
235- reqs = _tocEntryRequired (te , ropt , false);
226+ reqs = _tocEntryRequired (te , ropt , false /* needn't drop ACLs */ );
236227 if (((reqs & REQ_SCHEMA ) != 0 ) && te -> dropStmt )
237228 {
238229 /* We want the schema */
@@ -248,7 +239,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
248239 }
249240
250241 /*
251- * Now process each TOC entry
242+ * Now process each non-ACL TOC entry
252243 */
253244 te = AH -> toc -> next ;
254245 while (te != AH -> toc )
@@ -709,7 +700,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
709700
710701 while (te != AH -> toc )
711702 {
712- if (_tocEntryRequired (te , ropt , false ) != 0 )
703+ if (_tocEntryRequired (te , ropt , true ) != 0 )
713704 ahprintf (AH , "%d; %u %u %s %s %s %s\n" , te -> dumpId ,
714705 te -> catalogId .tableoid , te -> catalogId .oid ,
715706 te -> desc , te -> namespace ? te -> namespace : "-" ,
@@ -1341,15 +1332,15 @@ getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
13411332 return NULL ;
13421333}
13431334
1344- int
1335+ teReqs
13451336TocIDRequired (ArchiveHandle * AH , DumpId id , RestoreOptions * ropt )
13461337{
13471338 TocEntry * te = getTocEntryByDumpId (AH , id );
13481339
13491340 if (!te )
13501341 return 0 ;
13511342
1352- return _tocEntryRequired (te , ropt , false );
1343+ return _tocEntryRequired (te , ropt , true );
13531344}
13541345
13551346size_t
@@ -1971,16 +1962,16 @@ ReadToc(ArchiveHandle *AH)
19711962}
19721963
19731964static teReqs
1974- _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool acl_pass )
1965+ _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool include_acls )
19751966{
1976- teReqs res = 3 ; /* Schema = 1, Data = 2, Both = 3 */
1967+ teReqs res = REQ_ALL ;
19771968
19781969 /* ENCODING objects are dumped specially, so always reject here */
19791970 if (strcmp (te -> desc , "ENCODING" ) == 0 )
19801971 return 0 ;
19811972
19821973 /* 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 )
19841975 return 0 ;
19851976
19861977 if (!ropt -> create && strcmp (te -> desc , "DATABASE" ) == 0 )
0 commit comments