pg_dump PublicationRelInfo objects need to be marked with owner

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: pg_dump PublicationRelInfo objects need to be marked with owner
Date: 2021-01-12 17:40:42
Message-ID: 1165710.1610473242@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Although pg_publication_rel entries don't have an owner per se,
it's still important for the ArchiveEntry created for one to be
marked with an appropriate owner, because that is what determines
which role will be used to run the ALTER PUBLICATION command when
doing a restore with --use-set-session-authorization. As the
code stands, the session's original role will be used to run
ALTER PUBLICATION. Admittedly, to have enough privileges to
create the publication, the original role probably has to be
superuser, so that generally this'd be moot. Still, in principle
it's wrong, and maybe there are edge cases where you'd get a
failure that you shouldn't.

Accordingly, I propose the attached patch to ensure that the ALTER
is done as the owner of the publication. While I was at it I rewrote
getPublicationTables to do just one query instead of one per table ---
the existing coding seems like it could be quite inefficient for lots
of tables.

Upon looking at the code, I notice that the ALTER PUBLICATION ref
page is lying about the permissions required. Yes, you do have to
own the publication, but you *also* have to own the table(s) you
are adding. So this raises the question of exactly which user
we should try to run the command as. I judged that the publication
owner is more likely to be the right thing.

Thoughts?

regards, tom lane

Attachment Content-Type Size
attach-ownership-to-PublicationRelInfo.patch text/x-diff 9.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-01-12 17:42:10 Re: WIP: BRIN multi-range indexes
Previous Message John Naylor 2021-01-12 17:28:52 Re: WIP: BRIN multi-range indexes