mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Dump public schema ownership and security labels.
As a side effect, this corrects dumps of public schema ACLs in databases where the DBA dropped and recreated that schema. Reviewed by Asif Rehman. Discussion: https://postgr.es/m/20201229134924.GA1431748@rfd.leadboat.com
This commit is contained in:
@@ -3538,10 +3538,12 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
|
||||
* Actually print the definition.
|
||||
*
|
||||
* Really crude hack for suppressing AUTHORIZATION clause that old pg_dump
|
||||
* versions put into CREATE SCHEMA. We have to do this when --no-owner
|
||||
* mode is selected. This is ugly, but I see no other good way ...
|
||||
* versions put into CREATE SCHEMA. Don't mutate the variant for schema
|
||||
* "public" that is a comment. We have to do this when --no-owner mode is
|
||||
* selected. This is ugly, but I see no other good way ...
|
||||
*/
|
||||
if (ropt->noOwner && strcmp(te->desc, "SCHEMA") == 0)
|
||||
if (ropt->noOwner &&
|
||||
strcmp(te->desc, "SCHEMA") == 0 && strncmp(te->defn, "--", 2) != 0)
|
||||
{
|
||||
ahprintf(AH, "CREATE SCHEMA %s;\n\n\n", fmtId(te->tag));
|
||||
}
|
||||
@@ -3553,11 +3555,16 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
|
||||
|
||||
/*
|
||||
* If we aren't using SET SESSION AUTH to determine ownership, we must
|
||||
* instead issue an ALTER OWNER command. We assume that anything without
|
||||
* a DROP command is not a separately ownable object. All the categories
|
||||
* with DROP commands must appear in one list or the other.
|
||||
* instead issue an ALTER OWNER command. Schema "public" is special; when
|
||||
* a dump emits a comment in lieu of creating it, we use ALTER OWNER even
|
||||
* when using SET SESSION for all other objects. We assume that anything
|
||||
* without a DROP command is not a separately ownable object. All the
|
||||
* categories with DROP commands must appear in one list or the other.
|
||||
*/
|
||||
if (!ropt->noOwner && !ropt->use_setsessauth &&
|
||||
if (!ropt->noOwner &&
|
||||
(!ropt->use_setsessauth ||
|
||||
(strcmp(te->desc, "SCHEMA") == 0 &&
|
||||
strncmp(te->defn, "--", 2) == 0)) &&
|
||||
te->owner && strlen(te->owner) > 0 &&
|
||||
te->dropStmt && strlen(te->dropStmt) > 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user