Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9eabfe3

Browse files
committed
pg_dump: label INDEX ATTACH ArchiveEntries with an owner.
Although a partitioned index's attachment to its parent doesn't have separate ownership, the ArchiveEntry for it needs to be marked with an owner anyway, to ensure that the ALTER command is run by the appropriate role when restoring with --use-set-session-authorization. Without this, the ALTER will be run by the role that started the restore session, which will usually work but it's formally the wrong thing. Back-patch to v11 where this type of ArchiveEntry was added. In HEAD, add equivalent commentary to the just-added TABLE ATTACH case, which I'd made do the right thing already. Discussion: https://postgr.es/m/1094034.1610418498@sss.pgh.pa.us
1 parent cc865c0 commit 9eabfe3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/bin/pg_dump/pg_dump.c

+15
Original file line numberDiff line numberDiff line change
@@ -16404,6 +16404,13 @@ dumpTableAttach(Archive *fout, TableAttachInfo *attachinfo)
1640416404
fmtQualifiedDumpable(attachinfo->partitionTbl),
1640516405
attachinfo->partitionTbl->partbound);
1640616406

16407+
/*
16408+
* There is no point in creating a drop query as the drop is done by table
16409+
* drop. (If you think to change this, see also _printTocEntry().)
16410+
* Although this object doesn't really have ownership as such, set the
16411+
* owner field anyway to ensure that the command is run by the correct
16412+
* role at restore time.
16413+
*/
1640716414
ArchiveEntry(fout, attachinfo->dobj.catId, attachinfo->dobj.dumpId,
1640816415
ARCHIVE_OPTS(.tag = attachinfo->dobj.name,
1640916416
.namespace = attachinfo->dobj.namespace->dobj.name,
@@ -16685,9 +16692,17 @@ dumpIndexAttach(Archive *fout, IndexAttachInfo *attachinfo)
1668516692
appendPQExpBuffer(q, "ATTACH PARTITION %s;\n",
1668616693
fmtQualifiedDumpable(attachinfo->partitionIdx));
1668716694

16695+
/*
16696+
* There is no point in creating a drop query as the drop is done by
16697+
* index drop. (If you think to change this, see also
16698+
* _printTocEntry().) Although this object doesn't really have
16699+
* ownership as such, set the owner field anyway to ensure that the
16700+
* command is run by the correct role at restore time.
16701+
*/
1668816702
ArchiveEntry(fout, attachinfo->dobj.catId, attachinfo->dobj.dumpId,
1668916703
ARCHIVE_OPTS(.tag = attachinfo->dobj.name,
1669016704
.namespace = attachinfo->dobj.namespace->dobj.name,
16705+
.owner = attachinfo->parentIdx->indextable->rolname,
1669116706
.description = "INDEX ATTACH",
1669216707
.section = SECTION_POST_DATA,
1669316708
.createStmt = q->data));

0 commit comments

Comments
 (0)