Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
2193121f
Commit
2193121f
authored
Aug 13, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix breakage with PUBLIC schema. Try to untwist the remarkably contorted
logic a little bit.
parent
bf08e655
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
64 deletions
+72
-64
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.c
+72
-64
No files found.
src/bin/pg_dump/pg_backup_archiver.c
View file @
2193121f
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.9
1 2004/08/04 17:13:03
tgl Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.9
2 2004/08/13 21:37:28
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -48,8 +48,7 @@ static char *modulename = gettext_noop("archiver");
...
@@ -48,8 +48,7 @@ static char *modulename = gettext_noop("archiver");
static
ArchiveHandle
*
_allocAH
(
const
char
*
FileSpec
,
const
ArchiveFormat
fmt
,
static
ArchiveHandle
*
_allocAH
(
const
char
*
FileSpec
,
const
ArchiveFormat
fmt
,
const
int
compression
,
ArchiveMode
mode
);
const
int
compression
,
ArchiveMode
mode
);
static
char
*
_getObjectFromDropStmt
(
const
char
*
dropStmt
,
const
char
*
type
);
static
char
*
_getObjectFromDropStmt
(
const
char
*
dropStmt
,
const
char
*
type
);
static
void
_printTocHeader
(
ArchiveHandle
*
AH
,
TocEntry
*
te
,
RestoreOptions
*
ropt
,
bool
isData
);
static
void
_printTocEntry
(
ArchiveHandle
*
AH
,
TocEntry
*
te
,
RestoreOptions
*
ropt
,
bool
isData
,
bool
acl_pass
);
static
int
_printTocEntry
(
ArchiveHandle
*
AH
,
TocEntry
*
te
,
RestoreOptions
*
ropt
,
bool
isData
,
bool
acl_pass
);
static
void
fixPriorBlobRefs
(
ArchiveHandle
*
AH
,
TocEntry
*
blobte
,
static
void
fixPriorBlobRefs
(
ArchiveHandle
*
AH
,
TocEntry
*
blobte
,
...
@@ -379,14 +378,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
...
@@ -379,14 +378,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/* Work out what, if anything, we want from this entry */
/* Work out what, if anything, we want from this entry */
reqs
=
_tocEntryRequired
(
te
,
ropt
,
true
);
reqs
=
_tocEntryRequired
(
te
,
ropt
,
true
);
defnDumped
=
false
;
if
((
reqs
&
REQ_SCHEMA
)
!=
0
)
/* We want the schema */
if
((
reqs
&
REQ_SCHEMA
)
!=
0
)
/* We want the schema */
{
{
ahlog
(
AH
,
1
,
"setting owner and acl for %s %s
\n
"
,
te
->
desc
,
te
->
tag
);
ahlog
(
AH
,
1
,
"setting owner and acl for %s %s
\n
"
,
te
->
desc
,
te
->
tag
);
_printTocEntry
(
AH
,
te
,
ropt
,
false
,
true
);
_printTocEntry
(
AH
,
te
,
ropt
,
false
,
true
);
defnDumped
=
true
;
}
}
te
=
te
->
next
;
te
=
te
->
next
;
...
@@ -2304,10 +2300,40 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
...
@@ -2304,10 +2300,40 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
}
}
static
void
static
void
_printToc
Header
(
ArchiveHandle
*
AH
,
TocEntry
*
te
,
RestoreOptions
*
ropt
,
bool
isData
)
_printToc
Entry
(
ArchiveHandle
*
AH
,
TocEntry
*
te
,
RestoreOptions
*
ropt
,
bool
isData
,
bool
acl_pass
)
{
{
const
char
*
pfx
;
const
char
*
pfx
;
/* ACLs are dumped only during acl pass */
if
(
acl_pass
)
{
if
(
strcmp
(
te
->
desc
,
"ACL"
)
!=
0
)
return
;
}
else
{
if
(
strcmp
(
te
->
desc
,
"ACL"
)
==
0
)
return
;
}
/*
* Avoid dumping the public schema, as it will already be created ...
* unless we are using --clean mode, in which case it's been deleted
* and we'd better recreate it.
*/
if
(
!
ropt
->
dropSchema
&&
strcmp
(
te
->
desc
,
"SCHEMA"
)
==
0
&&
strcmp
(
te
->
tag
,
"public"
)
==
0
)
return
;
/* Select owner and schema as necessary */
_becomeOwner
(
AH
,
te
);
_selectOutputSchema
(
AH
,
te
->
namespace
);
/* Set up OID mode too */
if
(
strcmp
(
te
->
desc
,
"TABLE"
)
==
0
)
_setWithOids
(
AH
,
te
);
/* Emit header comment for item */
if
(
isData
)
if
(
isData
)
pfx
=
"Data for "
;
pfx
=
"Data for "
;
else
else
...
@@ -2335,43 +2361,34 @@ _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDa
...
@@ -2335,43 +2361,34 @@ _printTocHeader(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDa
if
(
AH
->
PrintExtraTocPtr
!=
NULL
)
if
(
AH
->
PrintExtraTocPtr
!=
NULL
)
(
*
AH
->
PrintExtraTocPtr
)
(
AH
,
te
);
(
*
AH
->
PrintExtraTocPtr
)
(
AH
,
te
);
ahprintf
(
AH
,
"--
\n\n
"
);
ahprintf
(
AH
,
"--
\n\n
"
);
}
static
int
_printTocEntry
(
ArchiveHandle
*
AH
,
TocEntry
*
te
,
RestoreOptions
*
ropt
,
bool
isData
,
bool
acl_pass
)
{
/* Select schema as necessary */
_becomeOwner
(
AH
,
te
);
_selectOutputSchema
(
AH
,
te
->
namespace
);
if
(
strcmp
(
te
->
desc
,
"TABLE"
)
==
0
&&
!
acl_pass
)
_setWithOids
(
AH
,
te
);
if
(
acl_pass
&&
strcmp
(
te
->
desc
,
"ACL"
)
==
0
)
{
_printTocHeader
(
AH
,
te
,
ropt
,
isData
);
ahprintf
(
AH
,
"%s
\n\n
"
,
te
->
defn
);
}
else
if
(
!
acl_pass
&&
strlen
(
te
->
defn
)
>
0
)
{
_printTocHeader
(
AH
,
te
,
ropt
,
isData
);
/*
/*
* Actually print the definition.
*
* Really crude hack for suppressing AUTHORIZATION clause of CREATE SCHEMA
* Really crude hack for suppressing AUTHORIZATION clause of CREATE SCHEMA
* when --no-owner mode is selected. This is ugly, but I see no other
* when --no-owner mode is selected. This is ugly, but I see no other
* good way ... Also, avoid dumping the public schema as it will already be
* good way ...
* created.
*/
*/
if
(
strcmp
(
te
->
tag
,
"public"
)
!=
0
)
{
if
(
AH
->
ropt
&&
AH
->
ropt
->
noOwner
&&
strcmp
(
te
->
desc
,
"SCHEMA"
)
==
0
)
if
(
AH
->
ropt
&&
AH
->
ropt
->
noOwner
&&
strcmp
(
te
->
desc
,
"SCHEMA"
)
==
0
)
{
{
ahprintf
(
AH
,
"CREATE SCHEMA %s;
\n\n\n
"
,
te
->
tag
);
ahprintf
(
AH
,
"CREATE SCHEMA %s;
\n\n\n
"
,
te
->
tag
);
}
}
else
else
{
{
if
(
strlen
(
te
->
defn
)
>
0
)
ahprintf
(
AH
,
"%s
\n\n
"
,
te
->
defn
);
ahprintf
(
AH
,
"%s
\n\n
"
,
te
->
defn
);
}
if
(
!
ropt
->
noOwner
&&
!
ropt
->
use_setsessauth
&&
strlen
(
te
->
owner
)
>
0
&&
strlen
(
te
->
dropStmt
)
>
0
&&
(
/*
strcmp
(
te
->
desc
,
"AGGREGATE"
)
==
0
||
* If we aren't using SET SESSION AUTH to determine ownership, we must
* instead issue an ALTER OWNER command. Ugly, since we have to
* cons one up based on the dropStmt. We don't need this for schemas
* (since we use CREATE SCHEMA AUTHORIZATION instead), nor for some other
* object types.
*/
if
(
!
ropt
->
noOwner
&&
!
ropt
->
use_setsessauth
&&
strlen
(
te
->
owner
)
>
0
&&
strlen
(
te
->
dropStmt
)
>
0
&&
(
strcmp
(
te
->
desc
,
"AGGREGATE"
)
==
0
||
strcmp
(
te
->
desc
,
"CONVERSION"
)
==
0
||
strcmp
(
te
->
desc
,
"CONVERSION"
)
==
0
||
strcmp
(
te
->
desc
,
"DOMAIN"
)
==
0
||
strcmp
(
te
->
desc
,
"DOMAIN"
)
==
0
||
strcmp
(
te
->
desc
,
"FUNCTION"
)
==
0
||
strcmp
(
te
->
desc
,
"FUNCTION"
)
==
0
||
...
@@ -2380,19 +2397,12 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
...
@@ -2380,19 +2397,12 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
strcmp
(
te
->
desc
,
"TABLE"
)
==
0
||
strcmp
(
te
->
desc
,
"TABLE"
)
==
0
||
strcmp
(
te
->
desc
,
"TYPE"
)
==
0
||
strcmp
(
te
->
desc
,
"TYPE"
)
==
0
||
strcmp
(
te
->
desc
,
"VIEW"
)
==
0
||
strcmp
(
te
->
desc
,
"VIEW"
)
==
0
||
strcmp
(
te
->
desc
,
"SEQUENCE"
)
==
0
||
strcmp
(
te
->
desc
,
"SEQUENCE"
)
==
0
))
(
strcmp
(
te
->
desc
,
"SCHEMA"
)
==
0
&&
strcmp
(
te
->
tag
,
"public"
)
==
0
)
/* Only public schema */
))
{
{
char
*
temp
=
_getObjectFromDropStmt
(
te
->
dropStmt
,
te
->
desc
);
char
*
temp
=
_getObjectFromDropStmt
(
te
->
dropStmt
,
te
->
desc
);
ahprintf
(
AH
,
"ALTER %s OWNER TO %s;
\n\n
"
,
temp
,
fmtId
(
te
->
owner
));
ahprintf
(
AH
,
"ALTER %s OWNER TO %s;
\n\n
"
,
temp
,
fmtId
(
te
->
owner
));
free
(
temp
);
free
(
temp
);
}
}
}
}
else
if
(
isData
)
{
_printTocHeader
(
AH
,
te
,
ropt
,
isData
);
}
}
/*
/*
...
@@ -2405,8 +2415,6 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
...
@@ -2405,8 +2415,6 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
free
(
AH
->
currUser
);
free
(
AH
->
currUser
);
AH
->
currUser
=
NULL
;
AH
->
currUser
=
NULL
;
}
}
return
1
;
}
}
void
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment