1515 *
1616 *
1717 * IDENTIFICATION
18- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.90 2004/07/19 21:39:47 momjian Exp $
18+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.91 2004/08/04 17:13:03 tgl Exp $
1919 *
2020 *-------------------------------------------------------------------------
2121 */
@@ -49,7 +49,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
4949 const int compression , ArchiveMode mode );
5050static char * _getObjectFromDropStmt (const char * dropStmt , const char * type );
5151static void _printTocHeader (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt , bool isData );
52- static int _printTocEntry (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt , bool isData , bool ownerAndACL );
52+ static int _printTocEntry (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt , bool isData , bool acl_pass );
5353
5454
5555static void fixPriorBlobRefs (ArchiveHandle * AH , TocEntry * blobte ,
@@ -62,7 +62,7 @@ static void _becomeUser(ArchiveHandle *AH, const char *user);
6262static void _becomeOwner (ArchiveHandle * AH , TocEntry * te );
6363static void _selectOutputSchema (ArchiveHandle * AH , const char * schemaName );
6464
65- static teReqs _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool ownerAndACL );
65+ static teReqs _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool acl_pass );
6666static void _disableTriggersIfNecessary (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt );
6767static void _enableTriggersIfNecessary (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt );
6868static TocEntry * getTocEntryByDumpId (ArchiveHandle * AH , DumpId id );
@@ -1913,7 +1913,7 @@ ReadToc(ArchiveHandle *AH)
19131913}
19141914
19151915static teReqs
1916- _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool ownerAndACL )
1916+ _tocEntryRequired (TocEntry * te , RestoreOptions * ropt , bool acl_pass )
19171917{
19181918 teReqs res = 3 ; /* Schema = 1, Data = 2, Both = 3 */
19191919
@@ -1922,7 +1922,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool ownerAndACL)
19221922 return 0 ;
19231923
19241924 /* If it's an ACL, maybe ignore it */
1925- if ((!ownerAndACL || ropt -> aclsSkip ) && strcmp (te -> desc , "ACL" ) == 0 )
1925+ if ((!acl_pass || ropt -> aclsSkip ) && strcmp (te -> desc , "ACL" ) == 0 )
19261926 return 0 ;
19271927
19281928 if (!ropt -> create && strcmp (te -> desc , "DATABASE" ) == 0 )
@@ -2338,39 +2338,20 @@ _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDa
23382338}
23392339
23402340static int
2341- _printTocEntry (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt , bool isData , bool ownerAndACL )
2341+ _printTocEntry (ArchiveHandle * AH , TocEntry * te , RestoreOptions * ropt , bool isData , bool acl_pass )
23422342{
23432343 /* Select schema as necessary */
23442344 _becomeOwner (AH , te );
23452345 _selectOutputSchema (AH , te -> namespace );
2346- if (strcmp (te -> desc , "TABLE" ) == 0 && !ownerAndACL )
2346+ if (strcmp (te -> desc , "TABLE" ) == 0 && !acl_pass )
23472347 _setWithOids (AH , te );
23482348
2349- if (!ropt -> noOwner && !ropt -> use_setsessauth && ownerAndACL && strlen (te -> owner ) > 0 && strlen (te -> dropStmt ) > 0 && (
2350- strcmp (te -> desc , "AGGREGATE" ) == 0 ||
2351- strcmp (te -> desc , "CONVERSION" ) == 0 ||
2352- strcmp (te -> desc , "DOMAIN" ) == 0 ||
2353- strcmp (te -> desc , "FUNCTION" ) == 0 ||
2354- strcmp (te -> desc , "OPERATOR" ) == 0 ||
2355- strcmp (te -> desc , "OPERATOR CLASS" ) == 0 ||
2356- strcmp (te -> desc , "TABLE" ) == 0 ||
2357- strcmp (te -> desc , "TYPE" ) == 0 ||
2358- strcmp (te -> desc , "VIEW" ) == 0 ||
2359- strcmp (te -> desc , "SEQUENCE" ) == 0 ||
2360- (strcmp (te -> desc , "SCHEMA" ) == 0 && strcmp (te -> tag , "public" ) == 0 ) /* Only public schema */
2361- ))
2362- {
2363- char * temp = _getObjectFromDropStmt (te -> dropStmt , te -> desc );
2364- _printTocHeader (AH , te , ropt , isData );
2365- ahprintf (AH , "ALTER %s OWNER TO %s;\n\n" , temp , fmtId (te -> owner ));
2366- free (temp );
2367- }
2368- else if (ownerAndACL && strcmp (te -> desc , "ACL" ) == 0 )
2349+ if (acl_pass && strcmp (te -> desc , "ACL" ) == 0 )
23692350 {
23702351 _printTocHeader (AH , te , ropt , isData );
23712352 ahprintf (AH , "%s\n\n" , te -> defn );
23722353 }
2373- else if (!ownerAndACL && strlen (te -> defn ) > 0 )
2354+ else if (!acl_pass && strlen (te -> defn ) > 0 )
23742355 {
23752356 _printTocHeader (AH , te , ropt , isData );
23762357
@@ -2388,6 +2369,25 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
23882369 else
23892370 {
23902371 ahprintf (AH , "%s\n\n" , te -> defn );
2372+
2373+ if (!ropt -> noOwner && !ropt -> use_setsessauth && strlen (te -> owner ) > 0 && strlen (te -> dropStmt ) > 0 && (
2374+ strcmp (te -> desc , "AGGREGATE" ) == 0 ||
2375+ strcmp (te -> desc , "CONVERSION" ) == 0 ||
2376+ strcmp (te -> desc , "DOMAIN" ) == 0 ||
2377+ strcmp (te -> desc , "FUNCTION" ) == 0 ||
2378+ strcmp (te -> desc , "OPERATOR" ) == 0 ||
2379+ strcmp (te -> desc , "OPERATOR CLASS" ) == 0 ||
2380+ strcmp (te -> desc , "TABLE" ) == 0 ||
2381+ strcmp (te -> desc , "TYPE" ) == 0 ||
2382+ strcmp (te -> desc , "VIEW" ) == 0 ||
2383+ strcmp (te -> desc , "SEQUENCE" ) == 0 ||
2384+ (strcmp (te -> desc , "SCHEMA" ) == 0 && strcmp (te -> tag , "public" ) == 0 ) /* Only public schema */
2385+ ))
2386+ {
2387+ char * temp = _getObjectFromDropStmt (te -> dropStmt , te -> desc );
2388+ ahprintf (AH , "ALTER %s OWNER TO %s;\n\n" , temp , fmtId (te -> owner ));
2389+ free (temp );
2390+ }
23912391 }
23922392 }
23932393 }
0 commit comments