15
15
*
16
16
*
17
17
* 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 $
19
19
*
20
20
*-------------------------------------------------------------------------
21
21
*/
@@ -49,7 +49,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
49
49
const int compression ,ArchiveMode mode );
50
50
static char * _getObjectFromDropStmt (const char * dropStmt ,const char * type );
51
51
static 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 );
53
53
54
54
55
55
static void fixPriorBlobRefs (ArchiveHandle * AH ,TocEntry * blobte ,
@@ -62,7 +62,7 @@ static void _becomeUser(ArchiveHandle *AH, const char *user);
62
62
static void _becomeOwner (ArchiveHandle * AH ,TocEntry * te );
63
63
static void _selectOutputSchema (ArchiveHandle * AH ,const char * schemaName );
64
64
65
- static teReqs _tocEntryRequired (TocEntry * te ,RestoreOptions * ropt ,bool ownerAndACL );
65
+ static teReqs _tocEntryRequired (TocEntry * te ,RestoreOptions * ropt ,bool acl_pass );
66
66
static void _disableTriggersIfNecessary (ArchiveHandle * AH ,TocEntry * te ,RestoreOptions * ropt );
67
67
static void _enableTriggersIfNecessary (ArchiveHandle * AH ,TocEntry * te ,RestoreOptions * ropt );
68
68
static TocEntry * getTocEntryByDumpId (ArchiveHandle * AH ,DumpId id );
@@ -1913,7 +1913,7 @@ ReadToc(ArchiveHandle *AH)
1913
1913
}
1914
1914
1915
1915
static teReqs
1916
- _tocEntryRequired (TocEntry * te ,RestoreOptions * ropt ,bool ownerAndACL )
1916
+ _tocEntryRequired (TocEntry * te ,RestoreOptions * ropt ,bool acl_pass )
1917
1917
{
1918
1918
teReqs res = 3 ;/* Schema = 1, Data = 2, Both = 3 */
1919
1919
@@ -1922,7 +1922,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool ownerAndACL)
1922
1922
return 0 ;
1923
1923
1924
1924
/* 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 )
1926
1926
return 0 ;
1927
1927
1928
1928
if (!ropt -> create && strcmp (te -> desc ,"DATABASE" )== 0 )
@@ -2338,39 +2338,20 @@ _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDa
2338
2338
}
2339
2339
2340
2340
static 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 )
2342
2342
{
2343
2343
/* Select schema as necessary */
2344
2344
_becomeOwner (AH ,te );
2345
2345
_selectOutputSchema (AH ,te -> namespace );
2346
- if (strcmp (te -> desc ,"TABLE" )== 0 && !ownerAndACL )
2346
+ if (strcmp (te -> desc ,"TABLE" )== 0 && !acl_pass )
2347
2347
_setWithOids (AH ,te );
2348
2348
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 )
2369
2350
{
2370
2351
_printTocHeader (AH ,te ,ropt ,isData );
2371
2352
ahprintf (AH ,"%s\n\n" ,te -> defn );
2372
2353
}
2373
- else if (!ownerAndACL && strlen (te -> defn )> 0 )
2354
+ else if (!acl_pass && strlen (te -> defn )> 0 )
2374
2355
{
2375
2356
_printTocHeader (AH ,te ,ropt ,isData );
2376
2357
@@ -2388,6 +2369,25 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
2388
2369
else
2389
2370
{
2390
2371
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
+ }
2391
2391
}
2392
2392
}
2393
2393
}